Skip to content

Instantly share code, notes, and snippets.

#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include "cassandra.h"
#define NUM_CONCURRENT_REQUESTS 5000
package org.apache.cassandra.triggers;
import java.nio.ByteBuffer;
import java.util.Collection;
import org.apache.cassandra.db.ColumnFamily;
import org.apache.cassandra.db.Mutation;
import org.apache.cassandra.db.Cell;
public class FWWTrigger implements ITrigger {
public Collection<Mutation> augment(ByteBuffer partitionKey, ColumnFamily update) {
import java.util.*;
import java.lang.*;
import java.math.BigInteger;
import com.datastax.driver.core.*;
import com.datastax.driver.core.policies.*;
class CassReadMT {
class ThreadExecute extends Thread {
private Cluster cluster;
@brianmhess
brianmhess / Xyz.java
Created March 25, 2015 21:28
Solution for OSS Cassandra Bootcamp
package org.apache.cassandra.db.compaction;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.HashSet;
import java.util.List;
import java.util.ArrayList;
sc.textFile("/mnt/disk2/data/data_99-rand.csv").map(x => x.split(",")).map(x => (x(0).toLong, x(1).toLong, x(2).toLong, x(3).toLong, x(4).toLong, x(5).toLong, x(6).toLong, x(7).toLong, x(8).toLong, x(9).toLong)).saveToCassandra("test", "test10", SomeColumns("pkey", "ccol", "col1", "col2", "col3", "col4", "col5", "col6", "col7", "col8"))
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#

Setup

First we need to create the Cassandra table and populate with simple data.

In CQLSH:

CREATE KEYSPACE sparktest WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3};
CREATE TABLE sparktest.test(pkey INT, ccol INT, x INT, y INT, PRIMARY KEY ((pkey), ccol));
INSERT INTO sparktest.test(pkey,ccol,x,y) VALUES (1,1,1,1);
INSERT INTO sparktest.test(pkey,ccol,x,y) VALUES (2,2,2,2);
INSERT INTO sparktest.test(pkey,ccol,x,y) VALUES (3,3,3,3);
mkdir -p /tmp/opt/connector
cd /tmp/opt/connector
rm *.jar
curl -o ivy-2.3.0.jar \
'http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.3.0/ivy-2.3.0.jar'
curl -o spark-cassandra-connector_2.10-1.0.0-beta1.jar \
'http://search.maven.org/remotecontent?filepath=com/datastax/spark/spark-cassandra-connector_2.10/1.0.0-beta1/spark-cassandra-connector_2.10-1.0.0-beta1.jar'
## If you did not install in the default directory, replace '/opt/datastax/cassandraodbc'
## with the correct location.
[ODBC]
Trace=no
[ODBC Data Sources]
cassandra64=DataStax Cassandra ODBC Driver 64-bit
spark64=Simba Spark ODBC Driver 64-bit
spark64old=Simba Spark ODBC Driver 64-bit
package com.datastax.loader;
import java.util.Map;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.CloseFuture;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.ResultSetFuture;
import com.datastax.driver.core.Statement;