コード例 #1
0
        public string DropColumnFamily(Server server, string columnFamily)
        {
            _cachedKeyspaceDescription = null;

            using (var session = new CassandraSession(new ConnectionBuilder(KeyspaceName, server.Host, server.Port)))
                return(session.GetClient().system_drop_column_family(columnFamily));
        }
コード例 #2
0
        public string AddColumnFamily(Server server, CfDef definition)
        {
            _cachedKeyspaceDescription = null;

            using (var session = new CassandraSession(new ConnectionBuilder(KeyspaceName, server.Host, server.Port)))
                return session.GetClient().system_add_column_family(definition);
        }
コード例 #3
0
        /// <summary>
        /// Execute the column family operation against the connection to the server.
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="action"></param>
        /// <param name="throwOnError"></param>
        /// <returns></returns>
        public TResult ExecuteOperation <TResult>(Operation <TResult> action, bool?throwOnError = null)
        {
            if (WasDisposed)
            {
                throw new ObjectDisposedException(GetType().FullName);
            }

            var localSession = _session == null;
            var session      = _session;

            if (session == null)
            {
                session = new CassandraSession(ConnectionBuilder);
            }

            action.Context = this;

            try
            {
                var result = session.ExecuteOperation(action, throwOnError ?? ThrowErrors);
                LastError = session.LastError;

                return(result);
            }
            finally
            {
                if (localSession && session != null)
                {
                    session.Dispose();
                }
            }
        }
コード例 #4
0
        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();

                    db.ExecuteNonQuery(@"
CREATE TABLE users (
	id int ,
	name ascii,
	email ascii,
	age int,
    PRIMARY KEY(id, email)
);");

                    ResetUsersFamily(db);
                }
        }
コード例 #5
0
        public string UpdateColumnFamily(Server server, CfDef definition)
        {
            _cachedKeyspaceDescription = null;

            using (var session = new CassandraSession(new ConnectionBuilder(KeyspaceName, server.Host, server.Port)))
                return(session.GetClient().system_update_column_family(definition));
        }
コード例 #6
0
        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();

                db.ExecuteNonQuery(@"
            CREATE TABLE users (
            id int ,
            name ascii,
            email ascii,
            age int,
            PRIMARY KEY(id, email)
            );");

                ResetUsersFamily(db);
            }
        }
コード例 #7
0
        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     = "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(string.Format(@"
CREATE TABLE {0} (
	id int ,
	name ascii,
	email ascii,
	age int,
    PRIMARY KEY(id)
);", toLowerIf(toLower, "Users")));

                    //db.ExecuteNonQuery(@"CREATE INDEX User_Age ON users (Age);");
                    db.Keyspace.ClearCachedKeyspaceSchema();

                    var family      = db.GetColumnFamily <AsciiType>("Standard");
                    var superFamily = db.GetColumnFamily <AsciiType, AsciiType>("Super");
                    var userFamily  = db.GetColumnFamily(toLowerIf(toLower, "Users"));

                    ResetFamily(family);
                    ResetSuperFamily(superFamily);
                    ResetUsersFamily(userFamily);
                }
        }
コード例 #8
0
 public static string DescribePartitioner(Server server)
 {
     using (var session = new CassandraSession(new ConnectionBuilder(null, server.Host, server.Port)))
     {
         string response = session.GetClient(setKeyspace: false).describe_partitioner();
         return(response);
     }
 }
コード例 #9
0
 public static Dictionary <string, List <string> > DescribeSchemaVersions(Server server)
 {
     using (var session = new CassandraSession(new ConnectionBuilder(null, server.Host, server.Port)))
     {
         var response = session.GetClient(setKeyspace: false).describe_schema_versions();
         return(response);
     }
 }
コード例 #10
0
        public KsDef Describe(Server server)
        {
            if (_cachedKeyspaceDescription == null)
            {
                _cachedKeyspaceDescription = CassandraSession.GetKeyspace(server, KeyspaceName);
            }

            return(_cachedKeyspaceDescription);
        }
コード例 #11
0
        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 = "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(string.Format(@"
            CREATE TABLE {0} (
            id int ,
            name ascii,
            email ascii,
            age int,
            PRIMARY KEY(id)
            );", toLowerIf(toLower, "Users")));

                //db.ExecuteNonQuery(@"CREATE INDEX User_Age ON users (Age);");
                db.Keyspace.ClearCachedKeyspaceSchema();

                var family = db.GetColumnFamily<AsciiType>("Standard");
                var superFamily = db.GetColumnFamily<AsciiType, AsciiType>("Super");
                var userFamily = db.GetColumnFamily(toLowerIf(toLower, "Users"));

                ResetFamily(family);
                ResetSuperFamily(superFamily);
                ResetUsersFamily(userFamily);
            }
        }
コード例 #12
0
        /// <summary>
        /// The dispose.
        /// </summary>
        /// <param name="disposing">
        /// The disposing.
        /// </param>
        protected virtual void Dispose(bool disposing)
        {
            if (!WasDisposed && !_isOutsideSession && disposing && _session != null)
            {
                _session.Dispose();
                _session = null;
            }

            WasDisposed = true;
        }
コード例 #13
0
        public IEnumerable<CassandraTokenRange> DescribeRing(Server server)
        {
            using (var session = new CassandraSession(new ConnectionBuilder(KeyspaceName, server.Host, server.Port)))
            {
                var tokenRanges = session.GetClient(setKeyspace: false).describe_ring(KeyspaceName);

                foreach (var tokenRange in tokenRanges)
                    yield return new CassandraTokenRange(tokenRange.Start_token, tokenRange.End_token, tokenRange.Endpoints);
            }
        }
コード例 #14
0
        public void ResetDatabase()
        {
            using (var session = new CassandraSession(ConnectionBuilder))
            using (var db = new CassandraContext(session))
            {
                db.ThrowErrors = true;

                try { db.DropKeyspace(Keyspace); }
                catch (Exception exc) { Console.WriteLine(exc); }

                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 = "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 (
            KEY int PRIMARY KEY,
            Name ascii,
            Email ascii,
            Age int
            );");
                db.ExecuteNonQuery(@"CREATE INDEX User_Age ON Users (Age);");
                db.Keyspace.ClearCachedKeyspaceSchema();

                var family = db.GetColumnFamily<AsciiType>("Standard");
                var superFamily = db.GetColumnFamily<AsciiType, AsciiType>("Super");
                var userFamily = db.GetColumnFamily("Users");

                ResetFamily(family);
                ResetSuperFamily(superFamily);
                ResetUsersFamily(userFamily);
            }
        }
コード例 #15
0
        public IEnumerable <CassandraTokenRange> DescribeRing(Server server)
        {
            using (var session = new CassandraSession(new ConnectionBuilder(KeyspaceName, server.Host, server.Port)))
            {
                var tokenRanges = session.GetClient(setKeyspace: false).describe_ring(KeyspaceName);

                foreach (var tokenRange in tokenRanges)
                {
                    yield return(new CassandraTokenRange(tokenRange.Start_token, tokenRange.End_token, tokenRange.Endpoints));
                }
            }
        }
コード例 #16
0
        public static IEnumerable <CassandraKeyspace> DescribeKeyspaces(Server server)
        {
            using (var session = new CassandraSession(new ConnectionBuilder(null, server.Host, server.Port)))
            {
                IEnumerable <KsDef> keyspaces = session.GetClient(setKeyspace: false).describe_keyspaces();

                foreach (var keyspace in keyspaces)
                {
                    yield return(new CassandraKeyspace(keyspace));
                }
            }
        }
コード例 #17
0
        public CassandraSession(IConnectionProvider connectionProvider, ConsistencyLevel read, ConsistencyLevel write)
        {
            if (Current != null)
            {
                throw new CassandraException("Cannot create a new session while there is one already active.");
            }

            ConnectionProvider = connectionProvider;
            ReadConsistency    = read;
            WriteConsistency   = write;
            Keyspace           = new CassandraKeyspace(connectionProvider.Builder.Keyspace);

            Current = this;
        }
コード例 #18
0
        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();
                }
        }
コード例 #19
0
        public void TryCreateSelf(Server server)
        {
            if (CassandraSession.KeyspaceExists(server, KeyspaceName))
            {
                Debug.WriteLine(KeyspaceName + " already exists", "keyspace");
                return;
            }

            string result = CassandraSession.AddKeyspace(server, new KsDef {
                Name               = KeyspaceName,
                Strategy_class     = "org.apache.cassandra.locator.SimpleStrategy",
                Replication_factor = 1,
                Cf_defs            = new List <CfDef>(0)
            });

            Debug.WriteLine(result, "keyspace setup");
        }
コード例 #20
0
        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();

            }
        }
コード例 #21
0
        /// <summary>
        /// Execute the column family operation against the connection to the server.
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="action"></param>
        /// <param name="throwOnError"></param>
        /// <returns></returns>
        public TResult ExecuteOperation <TResult>(Operation <TResult> action, bool?throwOnError = null)
        {
            if (!throwOnError.HasValue)
            {
                throwOnError = ThrowErrors;
            }

            CassandraSession _localSession = null;

            if (CassandraSession.Current == null)
            {
                _localSession = new CassandraSession();
            }

            try
            {
                LastError = null;

                TResult result;
                bool    success = action.TryExecute(out result);

                if (!success)
                {
                    LastError = action.Error;
                }

                if (!success && (throwOnError ?? ThrowErrors))
                {
                    throw action.Error;
                }

                return(result);
            }
            finally
            {
                if (_localSession != null)
                {
                    _localSession.Dispose();
                }
            }
        }
コード例 #22
0
 public static string UpdateKeyspace(Server server, KsDef definition)
 {
     using (var session = new CassandraSession(new ConnectionBuilder(null, server.Host, server.Port)))
         return session.GetClient(setKeyspace: false).system_update_keyspace(definition);
 }
コード例 #23
0
 public static KsDef GetKeyspace(Server server, string keyspace)
 {
     using (var session = new CassandraSession(new ConnectionBuilder(keyspace, server.Host, server.Port)))
         return session.GetClient().describe_keyspace(keyspace);
 }
コード例 #24
0
 public static string DropKeyspace(Server server, string keyspace)
 {
     using (var session = new CassandraSession(new ConnectionBuilder(null, server.Host, server.Port)))
         return session.GetClient(setKeyspace: false).system_drop_keyspace(keyspace);
 }
コード例 #25
0
 public static string DescribeVersion(Server server)
 {
     using (var session = new CassandraSession(new ConnectionBuilder(null, server.Host, server.Port)))
     {
         string response = session.GetClient(setKeyspace: false).describe_version();
         return response;
     }
 }
コード例 #26
0
 public static Dictionary<string, List<string>> DescribeSchemaVersions(Server server)
 {
     using (var session = new CassandraSession(new ConnectionBuilder(null, server.Host, server.Port)))
     {
         var response = session.GetClient(setKeyspace: false).describe_schema_versions();
         return response;
     }
 }
コード例 #27
0
        public static IEnumerable<CassandraKeyspace> DescribeKeyspaces(Server server)
        {
            using (var session = new CassandraSession(new ConnectionBuilder(null, server.Host, server.Port)))
            {
                IEnumerable<KsDef> keyspaces = session.GetClient(setKeyspace: false).describe_keyspaces();

                foreach (var keyspace in keyspaces)
                    yield return new CassandraKeyspace(keyspace);
            }
        }
コード例 #28
0
        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);
                }
        }
コード例 #29
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="session"></param>
 public CassandraContext(CassandraSession session)
     : this(session.ConnectionBuilder)
 {
     _session          = session;
     _isOutsideSession = true;
 }
コード例 #30
0
 public static IEnumerable<CassandraKeyspace> DescribeKeyspaces(Server server)
 {
     using (var session = new CassandraSession(new ConnectionBuilder(null, server.Host, server.Port)))
     {
         IEnumerable<KsDef> keyspaces = session.GetClient(setKeyspace: false).describe_keyspaces();
         return keyspaces.Select(keyspace => new CassandraKeyspace(keyspace)).ToList();
     }
 }
コード例 #31
0
        public _CassandraSetup()
        {
            var keyspaceName = "Testing";
            var server       = new Server("localhost");

            if (!CassandraSession.KeyspaceExists(server, keyspaceName))
            {
                CassandraSession.AddKeyspace(server, new KsDef {
                    Name = keyspaceName,
                    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);
        }
コード例 #32
0
        public string DropColumnFamily(Server server, string columnFamily)
        {
            _cachedKeyspaceDescription = null;

            using (var session = new CassandraSession(new ConnectionBuilder(KeyspaceName, server.Host, server.Port)))
                return session.GetClient().system_drop_column_family(columnFamily);
        }
コード例 #33
0
 public static KsDef GetKeyspace(Server server, string keyspace)
 {
     using (var session = new CassandraSession(new ConnectionBuilder(keyspace, server.Host, server.Port)))
         return(session.GetClient().describe_keyspace(keyspace));
 }
コード例 #34
0
 public static string DropKeyspace(Server server, string keyspace)
 {
     using (var session = new CassandraSession(new ConnectionBuilder(null, server.Host, server.Port)))
         return(session.GetClient(setKeyspace: false).system_drop_keyspace(keyspace));
 }
コード例 #35
0
 public static string UpdateKeyspace(Server server, KsDef definition)
 {
     using (var session = new CassandraSession(new ConnectionBuilder(null, server.Host, server.Port)))
         return(session.GetClient(setKeyspace: false).system_update_keyspace(definition));
 }