Skip to content

Instantly share code, notes, and snippets.

View adutra's full-sized avatar
🏳️‍🌈

Alexandre Dutra adutra

🏳️‍🌈
View GitHub Profile
@adutra
adutra / keybase.md
Created August 7, 2023 08:57
keybase.md

Keybase proof

I hereby claim:

  • I am adutra on github.
  • I am alexdut (https://keybase.io/alexdut) on keybase.
  • I have a public key ASBFlSfWiOiYkSGDel1lvqrMg9vu4ooklta73Ss64pAKcgo

To claim this, I am signing this object:

@adutra
adutra / SpliteratorBenchmark.java
Created June 22, 2019 16:14
SpliteratorBenchmark.java
public static class SpliteratorBenchmark {
static double sink;
public static void main(String[] args) throws IOException {
final Path inputPath = createInput();
for (int i = 0; i < 3; i++) {
System.out.println("Start processing JDK stream");
measureProcessing(Files.lines(inputPath));
System.out.println("Start processing fixed-batch stream");
measureProcessing(withBatchSize(Files.lines(inputPath), 500));
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
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.DefaultBatchType;
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
import com.datastax.oss.driver.api.core.cql.ResultSet;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
import com.datastax.oss.driver.shaded.guava.common.base.Strings;
@adutra
adutra / SimpleReactiveClient.java
Last active May 6, 2019 13:30
Examples of reactive style programming with OSS DataStax Java driver 3.x and Reactor
package com.datastax.test;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.Session;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
@adutra
adutra / FluxExamples.java
Created September 20, 2018 10:47
Driver examples with Reactor
package com.datastax.driver.dse;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.ResultSetFuture;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.Session;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
@adutra
adutra / IntBlobCodec.java
Created May 31, 2016 08:20
IntBlobCodec.java
package com.datastax.driver.extras.codecs.blobs;
import com.datastax.driver.core.DataType;
import com.datastax.driver.core.ProtocolVersion;
import com.datastax.driver.core.TypeCodec;
import java.nio.ByteBuffer;
public class IntBlobCodec extends TypeCodec.PrimitiveIntCodec {
@adutra
adutra / SSHPortForwardingAddressTranslator.java
Last active January 22, 2016 17:17
Connecting to a cluster with SSH port forwardings
import com.datastax.driver.core.policies.AddressTranslator;
import java.net.InetSocketAddress;
import java.util.Map;
public class SSHPortForwardingAddressTranslator implements AddressTranslator {
private final Map<InetSocketAddress, InetSocketAddress> portForwardings;
public SSHPortForwardingAddressTranslator(Map<InetSocketAddress, InetSocketAddress> portForwardings) {
@adutra
adutra / DevCenter 1.2.0 Change list
Last active August 29, 2015 14:07
DevCenter 1.2.0 Change list
# New Features / Improvements
- Query tracing view
- Cassandra 2.1 support
- Upgrade to Java Driver 2.1
- Add support for Tuples
- Add support for UDTs
- Add UDTs to the Schema view
- Add content assist for UDTs
- Add scoping and validation for UDTs
@adutra
adutra / NestedShutdownHooks.java
Created September 13, 2012 11:53
Nested Shutdown Hooks
public class NestedShutdownHooks {
public static void main(String[] args) {
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
System.out.println("foo");
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
System.out.println("bar");
}
});
@adutra
adutra / EmbeddedMongo.java
Created June 11, 2012 17:35
Using custom StreamProcessors with Embedmongo / How to redirect mongo output to SLF4J
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.mongodb.Mongo;
import com.mongodb.MongoException;
import com.mongodb.WriteConcern;
import de.flapdoodle.embedmongo.MongoDBRuntime;