Skip to content

Instantly share code, notes, and snippets.

Avatar

Olivier Michallat olim7t

  • DataStax
  • San Jose, CA
View GitHub Profile
@olim7t
olim7t / AliasExample.java
Last active Jan 29, 2021
Multiple selections of the same field with different arguments, under different aliases
View AliasExample.java
import graphql.GraphQL;
import graphql.Scalars;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import graphql.schema.GraphQLSchema;
import static graphql.schema.FieldCoordinates.coordinates;
import static graphql.schema.GraphQLArgument.newArgument;
import static graphql.schema.GraphQLCodeRegistry.newCodeRegistry;
import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition;
@olim7t
olim7t / Hello.scala
Created Jul 26, 2019
Test project to reproduce JAVA-1252, and check if JAVA-2365 will cause the same issue
View Hello.scala
// (in src/main/scala/example/)
package example
import com.datastax.oss.driver.api.core.cql.BatchType
import com.datastax.driver.dse.DseCluster
object Hello extends App {
// Test if JAVA-2365 creates a problem:
println(BatchType.LOGGED)
View BatchExample.java
package com.datastax.oss.driver.mapper;
import static com.datastax.oss.driver.api.querybuilder.QueryBuilder.bindMarker;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.cql.BatchStatement;
import com.datastax.oss.driver.api.core.cql.BatchStatementBuilder;
import com.datastax.oss.driver.api.core.cql.BoundStatementBuilder;
import com.datastax.oss.driver.api.core.cql.DefaultBatchType;
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
@olim7t
olim7t / Read2MbBlobs.java
Last active Apr 5, 2016
Test program to debug blob reading issue
View Read2MbBlobs.java
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.PreparedStatement;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.Session;
import java.nio.ByteBuffer;
import java.util.concurrent.TimeUnit;
public class Read2MbBlobs {
public static void main(String[] args) {
@olim7t
olim7t / IntToDateDemo.java
Last active Jan 21, 2016
Custom codec to handle CQL `date` columns as Java ints
View IntToDateDemo.java
import com.datastax.driver.core.*;
import com.datastax.driver.core.exceptions.InvalidTypeException;
import java.nio.ByteBuffer;
public class LongToDateDemo {
public static class LongToDateCodec extends TypeCodec<Integer> {
// Piggyback on the default codecs' implementation
@olim7t
olim7t / GatherAllListenAddresses.java
Created Jan 7, 2016
Use custom LBP to query system.local on each host
View GatherAllListenAddresses.java
import com.datastax.driver.core.*;
import com.datastax.driver.core.policies.Policies;
import java.net.InetAddress;
public class GatherAllListenAddresses {
public static void main(String[] args) {
Cluster cluster = null;
try {
cluster = Cluster.builder()
@olim7t
olim7t / DriverDemo.java
Created Nov 13, 2015
Standalone program that can be used as a template to reproduce Java driver issues
View DriverDemo.java
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session;
import com.datastax.driver.mapping.Mapper;
import com.datastax.driver.mapping.MappingManager;
import com.datastax.driver.mapping.annotations.Frozen;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
import com.datastax.driver.mapping.annotations.UDT;
public class DriverDemo {
@olim7t
olim7t / SwingClient.java
Last active Aug 29, 2015
Swing client to expose Cassandra java driver internals in tests
View SwingClient.java
package com.datastax.driver.core;
import java.awt.Component;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Iterator;
import java.util.Set;
import javax.swing.*;
@olim7t
olim7t / gist:e53ca1a25e25dd1551be
Created Dec 11, 2014
Java driver test using SCassandra.
View gist:e53ca1a25e25dd1551be
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import com.codahale.metrics.ConsoleReporter;
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.MoreExecutors;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.scassandra.http.client.PrimingClient;
@olim7t
olim7t / gist:08026acfff09e475390d
Created Dec 8, 2014
Monitor inFlight queries of DataStax Java driver
View gist:08026acfff09e475390d
static void reportInFlightQueries(Session session) {
Session.State state = session.getState();
System.out.printf("State of %s:%n", session);
for (Host host : state.getConnectedHosts()) {
int connections = state.getOpenConnections(host);
int inFlight = state.getInFlightQueries(host);
System.out.printf("\t%s:\tconnections=%2s\tinFlight=%4s\tmean=%4s%n",
host,
connections,
inFlight,