Esempio n. 1
0
        public static void RemoveColumn(this CassandraSuperColumnFamily family, CassandraObject key, FluentColumnPath path)
        {
            var columnName      = path.Column.ColumnName;
            var superColumnName = path.SuperColumn.ColumnName;

            RemoveColumn(family, key, superColumnName, columnName);
        }
Esempio n. 2
0
        public static FluentColumn GetColumn(this CassandraSuperColumnFamily family, CassandraObject key, FluentColumnPath path)
        {
            var columnName      = path.Column.ColumnName;
            var superColumnName = path.SuperColumn.ColumnName;

            return(GetColumn(family, key, superColumnName, columnName));
        }
        public static void RemoveKey <CompareWith, CompareSubcolumnWith>(this CassandraSuperColumnFamily <CompareWith, CompareSubcolumnWith> family, BytesType key)
            where CompareWith : CassandraType
            where CompareSubcolumnWith : CassandraType
        {
            var op = new RemoveKey(key);

            family.ExecuteOperation(op);
        }
        public static void InsertColumn <CompareWith, CompareSubcolumnWith>(this CassandraSuperColumnFamily <CompareWith, CompareSubcolumnWith> family, BytesType key, CompareWith superColumnName, CompareSubcolumnWith name, BytesType value, DateTimeOffset timestamp, int timeToLive)
            where CompareWith : CassandraType
            where CompareSubcolumnWith : CassandraType
        {
            var op = new InsertColumn(key, superColumnName, name, value, timestamp, timeToLive);

            family.ExecuteOperation(op);
        }
        public static int SuperColumnCount <CompareWith, CompareSubcolumnWith>(this CassandraSuperColumnFamily <CompareWith, CompareSubcolumnWith> family, BytesType key, CompareWith superColumnName, CompareWith columnStart, CompareWith columnEnd, bool reversed = false, int count = 100)
            where CompareWith : CassandraType
            where CompareSubcolumnWith : CassandraType
        {
            var op = new ColumnCount(key, superColumnName, new RangeSlicePredicate(columnStart, columnEnd, reversed, count));

            return(family.ExecuteOperation(op));
        }
        public static int SuperColumnCount <CompareWith, CompareSubcolumnWith>(this CassandraSuperColumnFamily <CompareWith, CompareSubcolumnWith> family, BytesType key, CompareWith superColumnName, IEnumerable <CompareWith> columnNames)
            where CompareWith : CassandraType
            where CompareSubcolumnWith : CassandraType
        {
            var op = new ColumnCount(key, superColumnName, new ColumnSlicePredicate(columnNames));

            return(family.ExecuteOperation(op));
        }
        public static void RemoveSuperColumn <CompareWith, CompareSubcolumnWith>(this CassandraSuperColumnFamily <CompareWith, CompareSubcolumnWith> family, BytesType key, FluentColumnParent parent)
            where CompareWith : CassandraType
            where CompareSubcolumnWith : CassandraType
        {
            var superColumnName = (CompareWith)parent.SuperColumn.ColumnName;

            RemoveSuperColumn <CompareWith, CompareSubcolumnWith>(family, key, superColumnName);
        }
Esempio n. 8
0
        public static void InsertColumn(this CassandraSuperColumnFamily family, CassandraObject key, FluentColumnPath path)
        {
            var superColumnName = path.SuperColumn.ColumnName;
            var name            = path.Column.ColumnName;
            var value           = path.Column.ColumnValue;
            var timestamp       = path.Column.ColumnTimestamp;
            var timeToLive      = path.Column.ColumnSecondsUntilDeleted;

            var op = new InsertColumn(key, superColumnName, name, value, timestamp, timeToLive);

            family.ExecuteOperation(op);
        }
        public static void InsertColumn <CompareWith, CompareSubcolumnWith>(this CassandraSuperColumnFamily <CompareWith, CompareSubcolumnWith> family, BytesType key, FluentColumnPath path)
            where CompareWith : CassandraType
            where CompareSubcolumnWith : CassandraType
        {
            var superColumnName = path.SuperColumn.ColumnName;
            var name            = path.Column.ColumnName;
            var value           = path.Column.ColumnValue;
            var timestamp       = path.Column.ColumnTimestamp;
            var timeToLive      = path.Column.ColumnTimeToLive;

            var op = new InsertColumn(key, superColumnName, name, value, timestamp, timeToLive);

            family.ExecuteOperation(op);
        }
Esempio n. 10
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);
        }
Esempio n. 11
0
        public CassandraDatabaseSetup(bool reset = false)
        {
            ConnectionBuilder = new ConnectionBuilder(keyspace: Keyspace, server: Server);
            DB = new CassandraContext(ConnectionBuilder);

            var exists = DB.KeyspaceExists(Keyspace);

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

            if (exists && !reset)
            {
                return;
            }

            ResetDatabase();
        }
Esempio n. 12
0
        public CompatibilityCassandraDatabaseSetup(bool reset = false, bool toLower = false, bool toLower2 = false)
        {
            this.toLower  = toLower;
            this.toLower2 = toLower2;

            ConnectionBuilder = new ConnectionBuilder(keyspace: Keyspace, server: Server, cqlVersion: CqlVersion.Cql3);
            DB = new CassandraContext(ConnectionBuilder);

            if (DB.KeyspaceExists(Keyspace))
            {
                DB.DropKeyspace(Keyspace);
            }

            var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema
            {
                Name = Keyspace,
            }, DB);

            var exists = DB.KeyspaceExists(Keyspace);

            if (!exists)
            {
                keyspace.TryCreateSelf();
            }

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

            if (exists && !reset)
            {
                return;
            }

            ResetDatabase();
        }
Esempio n. 13
0
        public static FluentColumn GetColumn(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName, CassandraObject columnName)
        {
            var op = new GetColumn(key, superColumnName, columnName);

            return(family.ExecuteOperation(op));
        }
Esempio n. 14
0
        public static void InsertCounterColumn(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName, CassandraObject columnName, long columnValue)
        {
            var op = new AddColumn(key, superColumnName, columnName, columnValue);

            family.ExecuteOperation(op);
        }
 public static void InsertColumn <CompareWith, CompareSubcolumnWith>(this CassandraSuperColumnFamily <CompareWith, CompareSubcolumnWith> family, BytesType key, CompareWith superColumnName, CompareSubcolumnWith name, BytesType value)
     where CompareWith : CassandraType
     where CompareSubcolumnWith : CassandraType
 {
     InsertColumn <CompareWith, CompareSubcolumnWith>(family, key, superColumnName, name, value, DateTimeOffset.UtcNow, 1);
 }
Esempio n. 16
0
 public static void InsertColumn(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName, CassandraObject name, BytesType value)
 {
     InsertColumn(family, key, superColumnName, name, value, DateTimePrecise.UtcNow, null);
 }
Esempio n. 17
0
        public static void InsertColumn(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName, CassandraObject name, BytesType value, DateTimeOffset timestamp, int?timeToLive)
        {
            var op = new InsertColumn(key, superColumnName, name, value, timestamp, timeToLive);

            family.ExecuteOperation(op);
        }
Esempio n. 18
0
 public static void RemoveColumn(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName)
 {
     RemoveColumn(family, key, superColumnName, null);
 }
        public static IFluentColumn <CompareSubcolumnWith> GetColumn <CompareWith, CompareSubcolumnWith>(this CassandraSuperColumnFamily <CompareWith, CompareSubcolumnWith> family, BytesType key, FluentColumnPath path)
            where CompareWith : CassandraType
            where CompareSubcolumnWith : CassandraType
        {
            var columnName      = (CompareSubcolumnWith)path.Column.ColumnName;
            var superColumnName = (CompareWith)path.SuperColumn.ColumnName;

            return(GetColumn <CompareWith, CompareSubcolumnWith>(family, key, superColumnName, columnName));
        }
Esempio n. 20
0
        public static int SuperColumnCount(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName, IEnumerable <CassandraObject> columnNames)
        {
            var op = new ColumnCount(key, superColumnName, new CassandraColumnSlicePredicate(columnNames));

            return(family.ExecuteOperation(op));
        }
Esempio n. 21
0
        public static int SuperColumnCount(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName, CassandraObject columnStart, CassandraObject columnEnd, bool reversed = false, int count = 100)
        {
            var op = new ColumnCount(key, superColumnName, new CassandraRangeSlicePredicate(columnStart, columnEnd, reversed, count));

            return(family.ExecuteOperation(op));
        }
Esempio n. 22
0
        // queryable

        public static CassandraSlicePredicateQuery <FluentSuperColumnFamily> Get(this CassandraSuperColumnFamily family)
        {
            return(family.CreateCassandraSlicePredicateQuery <FluentSuperColumnFamily>(null));
        }
Esempio n. 23
0
 public static CassandraSlicePredicateQuery <FluentSuperColumnFamily> Get(this CassandraSuperColumnFamily family, params CassandraObject[] keys)
 {
     return(Get(family).FetchKeys(keys));
 }
Esempio n. 24
0
        public static FluentSuperColumnFamily GetSingle(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject columnStart, CassandraObject columnEnd, bool reversed = false, int count = 100)
        {
            var op = new GetSuperColumnFamilySlice(key, new CassandraRangeSlicePredicate(columnStart, columnEnd, reversed, count));

            return(family.ExecuteOperation(op));
        }
        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);
        }
Esempio n. 26
0
        public static void RemoveColumn(this CassandraSuperColumnFamily family, CassandraObject key, CassandraObject superColumnName, CassandraObject columnName)
        {
            var op = new Remove(key, superColumnName, columnName);

            family.ExecuteOperation(op);
        }
 public static void InsertColumn <CompareWith, CompareSubcolumnWith>(this CassandraSuperColumnFamily <CompareWith, CompareSubcolumnWith> family, BytesType key, IFluentColumn <CompareSubcolumnWith> column)
     where CompareWith : CassandraType
     where CompareSubcolumnWith : CassandraType
 {
     InsertColumn <CompareWith, CompareSubcolumnWith>(family, key, column.GetPath());
 }
Esempio n. 28
0
 public static void InsertColumn(this CassandraSuperColumnFamily family, CassandraObject key, FluentColumn column)
 {
     InsertColumn(family, key, column.GetPath());
 }
Esempio n. 29
0
        public static FluentSuperColumnFamily GetSingle(this CassandraSuperColumnFamily family, CassandraObject key, IEnumerable <CassandraObject> columnNames)
        {
            var op = new GetSuperColumnFamilySlice(key, new CassandraColumnSlicePredicate(columnNames));

            return(family.ExecuteOperation(op));
        }
Esempio n. 30
0
        public static FluentSuperColumn GetSuperColumn(this CassandraSuperColumnFamily family, CassandraObject key, FluentColumnParent parent)
        {
            var superColumnName = parent.SuperColumn.ColumnName;

            return(GetSuperColumn(family, key, superColumnName));
        }