コード例 #1
0
        public void SuperColumnFamily()
        {
            // arrange
            double         value      = Math.PI;
            DateTimeOffset timestamp  = DateTimeOffset.UtcNow;
            int            timeToLive = 1;

            // act
            _superFamily.InsertColumn(_testKey, _testSuperName, _testName, value, timestamp, timeToLive);

            // assert
        }
コード例 #2
0
        public void SuperColumnFamily()
        {
            // arrange
            double         value      = Math.PI;
            DateTimeOffset timestamp  = DateTimeOffset.UtcNow;
            int            timeToLive = 1;

            // act
            _superFamily.InsertColumn(_testKey, _testSuperName, _testName, value, timestamp, timeToLive);
            var column = _family.Get(_testKey).Execute();
            var actual = column.FirstOrDefault().Columns.FirstOrDefault();

            // assert
            Assert.Equal(_testName, (string)actual.ColumnName);
            Assert.Equal(value, (double)actual.ColumnValue);
        }
コード例 #3
0
        public void ResetSuperFamily(CassandraSuperColumnFamily superFamily = null)
        {
            superFamily = superFamily ?? SuperFamily;

            superFamily.RemoveAllRows();

            superFamily.InsertColumn(TestKey1, TestSuperName, "Test1", Math.PI);
            superFamily.InsertColumn(TestKey1, TestSuperName, "Test2", Math.PI);
            superFamily.InsertColumn(TestKey1, TestSuperName, "Test3", Math.PI);

            superFamily.InsertColumn(TestKey2, TestSuperName, "Test1", Math.PI);
            superFamily.InsertColumn(TestKey2, TestSuperName, "Test2", Math.PI);
            superFamily.InsertColumn(TestKey2, TestSuperName, "Test3", Math.PI);
        }
コード例 #4
0
        public _CassandraSetup()
        {
            var keyspaceName = "Testing";
            var server = new Server("localhost");

            if (CassandraSession.KeyspaceExists(server, keyspaceName))
                CassandraSession.DropKeyspace(server, keyspaceName);

            var keyspace = new CassandraKeyspace(keyspaceName);
            keyspace.TryCreateSelf(server);
            keyspace.TryCreateColumnFamily<AsciiType>(server, "Standard");
            keyspace.TryCreateColumnFamily<AsciiType, AsciiType>(server, "Super");
            keyspace.TryCreateColumnFamily<AsciiType>(server, "StandardAsciiType");
            keyspace.TryCreateColumnFamily<BytesType>(server, "StandardBytesType");
            keyspace.TryCreateColumnFamily<IntegerType>(server, "StandardIntegerType");
            keyspace.TryCreateColumnFamily<LexicalUUIDType>(server, "StandardLexicalUUIDType");
            keyspace.TryCreateColumnFamily<LongType>(server, "StandardLongType");
            keyspace.TryCreateColumnFamily<TimeUUIDType>(server, "StandardTimeUUIDType");
            keyspace.TryCreateColumnFamily<UTF8Type>(server, "StandardUTF8Type");
            keyspace.TryCreateColumnFamily<UUIDType>(server, "StandardUUIDType");
            keyspace.TryCreateColumnFamily<CompositeType<LongType, UTF8Type>>(server, "StandardCompositeType");
            keyspace.TryCreateColumnFamily<DynamicCompositeType>(server, "StandardDynamicCompositeType");

            DB = new CassandraContext(keyspaceName, server);
            DB.ThrowErrors = true;

            Family = DB.GetColumnFamily<AsciiType>("Standard");
            SuperFamily = DB.GetColumnFamily<AsciiType, AsciiType>("Super");

            Family.RemoveAllRows();
            SuperFamily.RemoveAllRows();

            Family.InsertColumn(TestKey1, "Test1", Math.PI);
            Family.InsertColumn(TestKey1, "Test2", Math.PI);
            Family.InsertColumn(TestKey1, "Test3", Math.PI);

            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test1", Math.PI);
            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test2", Math.PI);
            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test3", Math.PI);

            Family.InsertColumn(TestKey2, "Test1", Math.PI);
            Family.InsertColumn(TestKey2, "Test2", Math.PI);
            Family.InsertColumn(TestKey2, "Test3", Math.PI);

            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test1", Math.PI);
            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test2", Math.PI);
            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test3", Math.PI);
        }
コード例 #5
0
		public void ResetSuperFamily(CassandraSuperColumnFamily superFamily = null)
		{
			superFamily = superFamily ?? SuperFamily;

			superFamily.RemoveAllRows();

			superFamily.InsertColumn(TestKey1, TestSuperName, "Test1", Math.PI);
			superFamily.InsertColumn(TestKey1, TestSuperName, "Test2", Math.PI);
			superFamily.InsertColumn(TestKey1, TestSuperName, "Test3", Math.PI);

			superFamily.InsertColumn(TestKey2, TestSuperName, "Test1", Math.PI);
			superFamily.InsertColumn(TestKey2, TestSuperName, "Test2", Math.PI);
			superFamily.InsertColumn(TestKey2, TestSuperName, "Test3", Math.PI);
		}
コード例 #6
0
        public CassandraDatabaseSetup(bool volitile = false)
        {
            var keyspaceName = "Testing";
            var server = new Server("localhost");

            DB = new CassandraContext(keyspaceName, server);
            DB.ThrowErrors = true;

            var exists = DB.KeyspaceExists(keyspaceName);
            Users = new[] {
                new User { Id = 1, Name = "Darren Gemmell", Email = "*****@*****.**", Age = 32 },
                new User { Id = 2, Name = "Fernando Laubscher", Email = "*****@*****.**", Age = 23 },
                new User { Id = 3, Name = "Cody Millhouse", Email = "*****@*****.**", Age = 56 },
                new User { Id = 4, Name = "Emilia Thibert", Email = "*****@*****.**", Age = 67 },
                new User { Id = 5, Name = "Allyson Schurr", Email = "*****@*****.**", Age = 21 }
            };

            Family = DB.GetColumnFamily<AsciiType>("Standard");
            SuperFamily = DB.GetColumnFamily<AsciiType, AsciiType>("Super");
            UserFamily = DB.GetColumnFamily("Users");

            if (exists && !volitile)
                return;

            using (var session = DB.OpenSession())
            {
                if (exists)
                    DB.DropKeyspace(keyspaceName);

                var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema { Name = keyspaceName, Strategy = CassandraKeyspaceSchema.ReplicaPlacementStrategySimple, ReplicationFactor = 1 }, 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<CompositeType<LongType, UTF8Type>>("StandardCompositeType");
                keyspace.TryCreateColumnFamily<DynamicCompositeType>("StandardDynamicCompositeType");

                Family = DB.GetColumnFamily<AsciiType>("Standard");
                SuperFamily = DB.GetColumnFamily<AsciiType, AsciiType>("Super");

                Family.InsertColumn(TestKey1, "Test1", Math.PI);
                Family.InsertColumn(TestKey1, "Test2", Math.PI);
                Family.InsertColumn(TestKey1, "Test3", Math.PI);

                SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test1", Math.PI);
                SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test2", Math.PI);
                SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test3", Math.PI);

                Family.InsertColumn(TestKey2, "Test1", Math.PI);
                Family.InsertColumn(TestKey2, "Test2", Math.PI);
                Family.InsertColumn(TestKey2, "Test3", Math.PI);

                SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test1", Math.PI);
                SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test2", Math.PI);
                SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test3", Math.PI);

                DB.ExecuteNonQuery(@"
            CREATE COLUMNFAMILY Users (
            KEY int PRIMARY KEY,
            Name ascii,
            Email ascii,
            Age int
            );");
                DB.ExecuteNonQuery(@"CREATE INDEX User_Age ON Users (Age);");
                DB.Keyspace.ClearCachedKeyspaceSchema();
                UserFamily = DB.GetColumnFamily("Users");

                foreach (var user in Users)
                {
                    dynamic record = UserFamily.CreateRecord(user.Id);
                    record.Name = user.Name;
                    record.Email = user.Email;
                    record.Age = user.Age;

                    DB.Attach(record);
                }
                DB.SaveChanges();
            }
        }
コード例 #7
0
        public _CassandraSetup()
        {
            var keyspaceName = "Testing";
            var server = new Server("localhost");

            if (!CassandraSession.KeyspaceExists(server, keyspaceName))
                CassandraSession.AddKeyspace(server, new KsDef {
                    Name = "Testing",
                    Replication_factor = 1,
                    Strategy_class = "org.apache.cassandra.locator.SimpleStrategy",
                    Cf_defs = new List<CfDef>()
                });

            var keyspace = new CassandraKeyspace(keyspaceName);

            if (!keyspace.ColumnFamilyExists(server, "Standard"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "Standard",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "AsciiType",
                    Comment = "Used for testing Standard family."
                });

            if (!keyspace.ColumnFamilyExists(server, "StandardAsciiType"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "StandardAsciiType",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "AsciiType",
                    Comment = "Used for testing Standard family."
                });

            if (!keyspace.ColumnFamilyExists(server, "StandardBytesType"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "StandardBytesType",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "BytesType",
                    Comment = "Used for testing BytesType family."
                });

            if (!keyspace.ColumnFamilyExists(server, "StandardIntegerType"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "StandardIntegerType",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "IntegerType",
                    Comment = "Used for testing IntegerType family."
                });

            if (!keyspace.ColumnFamilyExists(server, "StandardLexicalUUIDType"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "StandardLexicalUUIDType",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "LexicalUUIDType",
                    Comment = "Used for testing LexicalUUIDType family."
                });

            if (!keyspace.ColumnFamilyExists(server, "StandardLongType"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "StandardLongType",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "LongType",
                    Comment = "Used for testing LongType family."
                });

            if (!keyspace.ColumnFamilyExists(server, "StandardTimeUUIDType"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "StandardTimeUUIDType",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "TimeUUIDType",
                    Comment = "Used for testing TimeUUIDType family."
                });

            if (!keyspace.ColumnFamilyExists(server, "StandardUTF8Type"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "StandardUTF8Type",
                    Keyspace = "Testing",
                    Column_type = "Standard",
                    Comparator_type = "UTF8Type",
                    Comment = "Used for testing UTF8Type family."
                });

            if (!keyspace.ColumnFamilyExists(server, "Super"))
                keyspace.AddColumnFamily(server, new CfDef {
                    Name = "Super",
                    Keyspace = "Testing",
                    Column_type = "Super",
                    Comparator_type = "AsciiType",
                    Subcomparator_type = "AsciiType",
                    Comment = "Used for testing Super family."
                });

            DB = new CassandraContext(keyspaceName, server);
            DB.ThrowErrors = true;

            Family = DB.GetColumnFamily<AsciiType>("Standard");
            SuperFamily = DB.GetColumnFamily<AsciiType, AsciiType>("Super");

            Family.RemoveAllRows();
            SuperFamily.RemoveAllRows();

            Family.InsertColumn(TestKey1, "Test1", Math.PI);
            Family.InsertColumn(TestKey1, "Test2", Math.PI);
            Family.InsertColumn(TestKey1, "Test3", Math.PI);

            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test1", Math.PI);
            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test2", Math.PI);
            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test3", Math.PI);

            Family.InsertColumn(TestKey2, "Test1", Math.PI);
            Family.InsertColumn(TestKey2, "Test2", Math.PI);
            Family.InsertColumn(TestKey2, "Test3", Math.PI);

            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test1", Math.PI);
            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test2", Math.PI);
            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test3", Math.PI);
        }
コード例 #8
0
        public _CassandraSetup()
        {
            var keyspaceName = "Testing";
            var server       = new Server("localhost");

            if (!CassandraSession.KeyspaceExists(server, keyspaceName))
            {
                CassandraSession.AddKeyspace(server, new KsDef {
                    Name = "Testing",
                    Replication_factor = 1,
                    Strategy_class     = "org.apache.cassandra.locator.SimpleStrategy",
                    Cf_defs            = new List <CfDef>()
                });
            }

            var keyspace = new CassandraKeyspace(keyspaceName);

            if (!keyspace.ColumnFamilyExists(server, "Standard"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "Standard",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "AsciiType",
                    Comment         = "Used for testing Standard family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "StandardAsciiType"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "StandardAsciiType",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "AsciiType",
                    Comment         = "Used for testing Standard family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "StandardBytesType"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "StandardBytesType",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "BytesType",
                    Comment         = "Used for testing BytesType family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "StandardIntegerType"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "StandardIntegerType",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "IntegerType",
                    Comment         = "Used for testing IntegerType family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "StandardLexicalUUIDType"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "StandardLexicalUUIDType",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "LexicalUUIDType",
                    Comment         = "Used for testing LexicalUUIDType family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "StandardLongType"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "StandardLongType",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "LongType",
                    Comment         = "Used for testing LongType family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "StandardTimeUUIDType"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "StandardTimeUUIDType",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "TimeUUIDType",
                    Comment         = "Used for testing TimeUUIDType family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "StandardUTF8Type"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name            = "StandardUTF8Type",
                    Keyspace        = "Testing",
                    Column_type     = "Standard",
                    Comparator_type = "UTF8Type",
                    Comment         = "Used for testing UTF8Type family."
                });
            }

            if (!keyspace.ColumnFamilyExists(server, "Super"))
            {
                keyspace.AddColumnFamily(server, new CfDef {
                    Name               = "Super",
                    Keyspace           = "Testing",
                    Column_type        = "Super",
                    Comparator_type    = "AsciiType",
                    Subcomparator_type = "AsciiType",
                    Comment            = "Used for testing Super family."
                });
            }

            DB             = new CassandraContext(keyspaceName, server);
            DB.ThrowErrors = true;

            Family      = DB.GetColumnFamily <AsciiType>("Standard");
            SuperFamily = DB.GetColumnFamily <AsciiType, AsciiType>("Super");

            Family.RemoveAllRows();
            SuperFamily.RemoveAllRows();

            Family.InsertColumn(TestKey1, "Test1", Math.PI);
            Family.InsertColumn(TestKey1, "Test2", Math.PI);
            Family.InsertColumn(TestKey1, "Test3", Math.PI);

            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test1", Math.PI);
            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test2", Math.PI);
            SuperFamily.InsertColumn(TestKey1, TestSuperName, "Test3", Math.PI);

            Family.InsertColumn(TestKey2, "Test1", Math.PI);
            Family.InsertColumn(TestKey2, "Test2", Math.PI);
            Family.InsertColumn(TestKey2, "Test3", Math.PI);

            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test1", Math.PI);
            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test2", Math.PI);
            SuperFamily.InsertColumn(TestKey2, TestSuperName, "Test3", Math.PI);
        }