Skip to content

Instantly share code, notes, and snippets.

@ponkin
Last active December 16, 2017 21:44
Show Gist options
  • Select an option

  • Save ponkin/40db34dde4477f84e711 to your computer and use it in GitHub Desktop.

Select an option

Save ponkin/40db34dde4477f84e711 to your computer and use it in GitHub Desktop.

Revisions

  1. ponkin revised this gist Oct 29, 2015. 1 changed file with 12 additions and 10 deletions.
    22 changes: 12 additions & 10 deletions CassandraEmbeded.scala
    Original file line number Diff line number Diff line change
    @@ -20,16 +20,18 @@ class CasandraSpec extends FunSuite
    |'class': 'SimpleStrategy',
    |'replication_factor':1}
    |""".stripMargin)
    session.execute(
    s"""CREATE TABLE $testKeyspace.$testTable(
    | partitionKey text,
    | clusterKey text,
    | someValue int,
    | PRIMARY KEY (partitionKey, clusterKey))
    | WITH
    | compaction = { 'class' : 'SizeTieredCompactionStrategy'} AND
    | compression = { 'sstable_compression' : 'SnappyCompressor' }
    | """.stripMargin)
    session.execute(s"""CREATE TABLE $testKeyspace.$testTable(
    | partitionKey text,
    | clusterKey text,
    | someValue int,
    | PRIMARY KEY (partitionKey, clusterKey))
    | WITH
    | compaction = { 'class' : 'SizeTieredCompactionStrategy'} AND
    | compression = { 'sstable_compression' : 'SnappyCompressor' }
    | """.stripMargin)
    }
    }

    override def clearCache: Unit = Unit

    }
  2. ponkin created this gist Oct 29, 2015.
    35 changes: 35 additions & 0 deletions CassandraEmbeded.scala
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    class CasandraSpec extends FunSuite
    with Eventually
    with BeforeAndAfterAll
    with LocalSparkContext
    with EmbeddedCassandra
    with Logging{

    val testKeyspace = "test1"
    val testTable = "table1"
    var conn: CassandraConnector = _


    override def beforeAll(): Unit = {
    useCassandraConfig(Seq("cassandra-default.yaml.template"))
    conn = CassandraConnector(Set(EmbeddedCassandra.getHost(0)))
    conn.withSessionDo { session =>
    session.execute( s"""DROP KEYSPACE IF EXISTS $testKeyspace""")
    session.execute( s"""CREATE KEYSPACE $testKeyspace
    |WITH replication = {
    |'class': 'SimpleStrategy',
    |'replication_factor':1}
    |""".stripMargin)
    session.execute(
    s"""CREATE TABLE $testKeyspace.$testTable(
    | partitionKey text,
    | clusterKey text,
    | someValue int,
    | PRIMARY KEY (partitionKey, clusterKey))
    | WITH
    | compaction = { 'class' : 'SizeTieredCompactionStrategy'} AND
    | compression = { 'sstable_compression' : 'SnappyCompressor' }
    | """.stripMargin)
    }
    }
    }