private static void SetupKeyspace() { if (CassandraSession.KeyspaceExists(server, keyspaceName)) { CassandraSession.DropKeyspace(server, keyspaceName); } var keyspace = new CassandraKeyspace(keyspaceName); keyspace.TryCreateSelf(server); keyspace.TryCreateColumnFamily <UTF8Type>(server, "Posts"); keyspace.TryCreateColumnFamily <LongType>(server, "Tags"); keyspace.TryCreateColumnFamily <TimeUUIDType, UTF8Type>(server, "Comments"); }
private static void SetupKeyspace() { using (var db = new CassandraContext(keyspace: KeyspaceName, server: Server)) { if (db.KeyspaceExists(KeyspaceName)) { db.DropKeyspace(KeyspaceName); } var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema { Name = KeyspaceName, }, db); keyspace.TryCreateSelf(); // create super column family using API keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema { FamilyName = "razgovor", FamilyType = ColumnType.Super, KeyValueType = CassandraType.AsciiType, SuperColumnNameType = CassandraType.AsciiType, ColumnNameType = CassandraType.UTF8Type, DefaultColumnValueType = CassandraType.UTF8Type }); db.ExecuteNonQuery(@"CREATE TABLE poraka( naslov text, sodrzina text, PRIMARY KEY(naslov) );"); } }
private static void SetupKeyspace() { using (var db = new CassandraContext(keyspace: KeyspaceName, server: Server)) { if (db.KeyspaceExists(KeyspaceName)) { db.DropKeyspace(KeyspaceName); } var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema { Name = KeyspaceName, }, db); keyspace.TryCreateSelf(); // create column family using CQL db.ExecuteNonQuery(@" CREATE COLUMNFAMILY Posts ( KEY ascii PRIMARY KEY, Title text, Body text, Author text, PostedOn timestamp );" ); // create column family using API keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema { FamilyName = "Tags", KeyValueType = CassandraType.AsciiType, ColumnNameType = CassandraType.Int32Type, DefaultColumnValueType = CassandraType.UTF8Type }); // create super column family using API keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema { FamilyName = "Comments", FamilyType = ColumnType.Super, KeyValueType = CassandraType.AsciiType, SuperColumnNameType = CassandraType.DateType, ColumnNameType = CassandraType.UTF8Type, DefaultColumnValueType = CassandraType.UTF8Type }); } }
private static void SetupKeyspace() { using (var db = new CassandraContext(keyspace: KeyspaceName, server: Server)) { if (db.KeyspaceExists(KeyspaceName)) db.DropKeyspace(KeyspaceName); var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema { Name = KeyspaceName, }, db); keyspace.TryCreateSelf(); // create column family using CQL db.ExecuteNonQuery(@" CREATE COLUMNFAMILY Posts ( KEY ascii PRIMARY KEY, Title text, Body text, Author text, PostedOn timestamp );"); // create column family using API keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema { FamilyName = "Tags", KeyValueType = CassandraType.AsciiType, ColumnNameType = CassandraType.Int32Type, DefaultColumnValueType = CassandraType.UTF8Type }); // create super column family using API keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema { FamilyName = "Comments", FamilyType = ColumnType.Super, KeyValueType = CassandraType.AsciiType, SuperColumnNameType = CassandraType.DateType, ColumnNameType = CassandraType.UTF8Type, DefaultColumnValueType = CassandraType.UTF8Type }); } }
public void ResetDatabase() { using (var session = new CassandraSession(ConnectionBuilder)) using (var db = new CassandraContext(session)) { db.ThrowErrors = true; db.TryDropKeyspace(Keyspace); var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema { Name = Keyspace }, db); db.Keyspace = keyspace; keyspace.TryCreateSelf(); keyspace.TryCreateColumnFamily<AsciiType>("Standard"); keyspace.TryCreateColumnFamily<AsciiType, AsciiType>("Super"); keyspace.TryCreateColumnFamily<AsciiType>("StandardAsciiType"); keyspace.TryCreateColumnFamily<BytesType>("StandardBytesType"); keyspace.TryCreateColumnFamily<IntegerType>("StandardIntegerType"); keyspace.TryCreateColumnFamily<LexicalUUIDType>("StandardLexicalUUIDType"); keyspace.TryCreateColumnFamily<LongType>("StandardLongType"); keyspace.TryCreateColumnFamily<TimeUUIDType>("StandardTimeUUIDType"); keyspace.TryCreateColumnFamily<UTF8Type>("StandardUTF8Type"); keyspace.TryCreateColumnFamily<UUIDType>("StandardUUIDType"); keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema() { FamilyName = "Counters", ColumnNameType = CassandraType.AsciiType, DefaultColumnValueType = CassandraType.CounterColumnType }); keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema { FamilyName = "StandardDecimalType", ColumnNameType = CassandraType.DecimalType }); keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema { FamilyName = "StandardCompositeType", ColumnNameType = CassandraType.CompositeType(new[] { CassandraType.AsciiType, CassandraType.DoubleType }) }); keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema { FamilyName = "StandardDynamicCompositeType", ColumnNameType = CassandraType.DynamicCompositeType(new Dictionary<char, CassandraType> { { 'a', CassandraType.AsciiType }, { 'd', CassandraType.DoubleType } }) }); db.ExecuteNonQuery(@" CREATE COLUMNFAMILY Users ( Id int PRIMARY KEY, Name ascii, Email ascii, Age int );", CqlVersion.Cql); db.ExecuteNonQuery(@"CREATE INDEX User_Age ON Users (Age);", CqlVersion.Cql); db.Keyspace.ClearCachedKeyspaceSchema(); var family = db.GetColumnFamily<AsciiType>("Standard"); var superFamily = db.GetColumnFamily<AsciiType, AsciiType>("Super"); var userFamily = db.GetColumnFamily("Users"); var counterFamily = db.GetColumnFamily("Counters"); ResetFamily(family); ResetSuperFamily(superFamily); ResetUsersFamily(userFamily); ResetCounterColumnFamily(counterFamily); } }
private static void SetupKeyspace() { if (CassandraSession.KeyspaceExists(server, keyspaceName)) CassandraSession.DropKeyspace(server, keyspaceName); var keyspace = new CassandraKeyspace(keyspaceName); keyspace.TryCreateSelf(server); keyspace.TryCreateColumnFamily<UTF8Type>(server, "Posts"); keyspace.TryCreateColumnFamily<LongType>(server, "Tags"); keyspace.TryCreateColumnFamily<TimeUUIDType, UTF8Type>(server, "Comments"); }
public void ResetDatabase() { using (var session = new CassandraSession(ConnectionBuilder)) using (var db = new CassandraContext(session)) { db.ThrowErrors = true; db.TryDropKeyspace(Keyspace); var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema { Name = Keyspace }, db); db.Keyspace = keyspace; keyspace.TryCreateSelf(); keyspace.TryCreateColumnFamily <AsciiType>("Standard"); keyspace.TryCreateColumnFamily <AsciiType, AsciiType>("Super"); keyspace.TryCreateColumnFamily <AsciiType>("StandardAsciiType"); keyspace.TryCreateColumnFamily <BytesType>("StandardBytesType"); keyspace.TryCreateColumnFamily <IntegerType>("StandardIntegerType"); keyspace.TryCreateColumnFamily <LexicalUUIDType>("StandardLexicalUUIDType"); keyspace.TryCreateColumnFamily <LongType>("StandardLongType"); keyspace.TryCreateColumnFamily <TimeUUIDType>("StandardTimeUUIDType"); keyspace.TryCreateColumnFamily <UTF8Type>("StandardUTF8Type"); keyspace.TryCreateColumnFamily <UUIDType>("StandardUUIDType"); keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema() { FamilyName = "Counters", ColumnNameType = CassandraType.AsciiType, DefaultColumnValueType = CassandraType.CounterColumnType }); keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema(type: ColumnType.Super) { FamilyName = "SuperCounters", SuperColumnNameType = CassandraType.AsciiType, ColumnNameType = CassandraType.AsciiType, DefaultColumnValueType = CassandraType.CounterColumnType }); keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema { FamilyName = "StandardDecimalType", ColumnNameType = CassandraType.DecimalType }); keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema { FamilyName = "StandardCompositeType", ColumnNameType = CassandraType.CompositeType(new[] { CassandraType.AsciiType, CassandraType.DoubleType }) }); keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema { FamilyName = "StandardDynamicCompositeType", ColumnNameType = CassandraType.DynamicCompositeType(new Dictionary <char, CassandraType> { { 'a', CassandraType.AsciiType }, { 'd', CassandraType.DoubleType } }) }); db.ExecuteNonQuery(@" CREATE COLUMNFAMILY ""Users"" ( Id int PRIMARY KEY, Name ascii, Email ascii, Age int );"); db.ExecuteNonQuery(@"CREATE INDEX User_Age ON ""Users"" (Age);"); db.ExecuteNonQuery(@" CREATE COLUMNFAMILY Cql3List ( Id int PRIMARY KEY, TagList list<text> --list of strings );"); db.ExecuteNonQuery(@" CREATE COLUMNFAMILY Cql3Set ( Id int PRIMARY KEY, TagSet set<uuid> --set of Guids );"); db.ExecuteNonQuery(@" CREATE COLUMNFAMILY Cql3Map ( Id int PRIMARY KEY, TagMap map<bigint,uuid> --map of long integers and Guids );"); db.Keyspace.ClearCachedKeyspaceSchema(); var family = db.GetColumnFamily <AsciiType>("Standard"); var superFamily = db.GetColumnFamily <AsciiType, AsciiType>("Super"); var userFamily = db.GetColumnFamily("Users"); var counterFamily = db.GetColumnFamily("Counters"); ResetFamily(family); ResetSuperFamily(superFamily); ResetUsersFamily(userFamily); ResetCounterColumnFamily(counterFamily); } }