public static void RemoveColumn <CompareWith>(this CassandraColumnFamily <CompareWith> family, BytesType key, FluentColumnPath path)
            where CompareWith : CassandraType
        {
            var columnName = (CompareWith)path.Column.ColumnName;

            RemoveColumn <CompareWith>(family, key, columnName);
        }
        public static void RemoveColumn <CompareWith>(this CassandraColumnFamily <CompareWith> family, BytesType key, CompareWith columnName)
            where CompareWith : CassandraType
        {
            var op = new RemoveColumn(key, columnName);

            family.ExecuteOperation(op);
        }
        public static IFluentColumn <CompareWith> GetColumn <CompareWith>(this CassandraColumnFamily <CompareWith> family, BytesType key, FluentColumnPath path)
            where CompareWith : CassandraType
        {
            var columnName = (CompareWith)path.Column.ColumnName;

            return(GetColumn <CompareWith>(family, key, columnName));
        }
Beispiel #4
0
        public void ResetUsersFamily(CassandraColumnFamily userFamily = null)
        {
            userFamily = userFamily ?? UserFamily;

            var db = userFamily.Context;

            userFamily.RemoveAllRows();

            foreach (var user in Users)
            {
                dynamic record = userFamily.CreateRecord(user.Id);
                if (toLower2)
                {
                    record.name  = user.Name;
                    record.email = user.Email;
                    record.age   = user.Age;
                }
                else
                {
                    record.Name  = user.Name;
                    record.Email = user.Email;
                    record.Age   = user.Age;
                }

                db.Attach(record);
            }

            db.SaveChanges();
        }
Beispiel #5
0
        public void SetFixture(CassandraDatabaseSetupFixture data)
        {
            var setup = data.DatabaseSetup();

            _db     = setup.DB;
            _family = setup.Family;
        }
        public static void InsertColumn <CompareWith>(this CassandraColumnFamily <CompareWith> family, BytesType key, CompareWith columnName, BytesType columnValue, DateTimeOffset timestamp, int timeToLive)
            where CompareWith : CassandraType
        {
            var op = new InsertColumn(key, columnName, columnValue, timestamp, timeToLive);

            family.ExecuteOperation(op);
        }
        public static IEnumerable <ICqlRow <CompareWith> > Cql <CompareWith>(this CassandraColumnFamily <CompareWith> family, UTF8Type cqlQuery)
            where CompareWith : CassandraType
        {
            var op = new ExecuteCqlQuery <CompareWith>(cqlQuery);

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

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

            return(family.ExecuteOperation(op));
        }
Beispiel #10
0
        public void TestInit()
        {
            var setup = new _CassandraSetup();

            _db     = setup.DB;
            _family = setup.Family;
        }
        public static IFluentColumn <CompareWith> GetColumn <CompareWith>(this CassandraColumnFamily <CompareWith> family, BytesType key, CompareWith columnName)
            where CompareWith : CassandraType
        {
            var op = new GetColumn <CompareWith>(key, columnName);

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

            family.ExecuteOperation(op);
        }
        public static void InsertColumn(this CassandraColumnFamily family, CassandraObject key, FluentColumnPath path)
        {
            var columnName  = path.Column.ColumnName;
            var columnValue = path.Column.ColumnValue;
            var timestamp   = path.Column.ColumnTimestamp;
            var timeToLive  = path.Column.ColumnSecondsUntilDeleted;

            var op = new InsertColumn(key, columnName, columnValue, timestamp, timeToLive);

            family.ExecuteOperation(op);
        }
        public static void InsertColumn <CompareWith>(this CassandraColumnFamily <CompareWith> family, BytesType key, FluentColumnPath path)
            where CompareWith : CassandraType
        {
            var columnName  = path.Column.ColumnName;
            var columnValue = path.Column.ColumnValue;
            var timestamp   = path.Column.ColumnTimestamp;
            var timeToLive  = path.Column.ColumnTimeToLive;

            var op = new InsertColumn(key, columnName, columnValue, timestamp, timeToLive);

            family.ExecuteOperation(op);
        }
Beispiel #15
0
        public void ResetCounterColumnFamily(CassandraColumnFamily counterFamily = null)
        {
            counterFamily = counterFamily ?? CounterFamily;

            counterFamily.RemoveAllRows();

            counterFamily.InsertCounterColumn(TestKey1, "Test1", 1);
            counterFamily.InsertCounterColumn(TestKey1, "Test2", 2);
            counterFamily.InsertCounterColumn(TestKey1, "Test3", 3);

            counterFamily.InsertCounterColumn(TestKey2, "Test1", 2);
            counterFamily.InsertCounterColumn(TestKey2, "Test2", 4);
            counterFamily.InsertCounterColumn(TestKey2, "Test3", 6);
        }
Beispiel #16
0
        public void ResetFamily(CassandraColumnFamily family = null)
        {
            family = family ?? Family;

            family.RemoveAllRows();

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

            family.InsertColumn(TestKey2, "Test1", Math.PI);
            family.InsertColumn(TestKey2, "Test2", Math.PI);
            family.InsertColumn(TestKey2, "Test3", Math.PI);
        }
Beispiel #17
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();
        }
Beispiel #18
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();
        }
        public static int ColumnCount(this CassandraColumnFamily family, CassandraObject key, IEnumerable <CassandraObject> columnNames)
        {
            var op = new ColumnCount(key, new CassandraColumnSlicePredicate(columnNames));

            return(family.ExecuteOperation(op));
        }
        public static void RemoveColumn(this CassandraColumnFamily family, CassandraObject key, CassandraObject columnName)
        {
            var op = new Remove(key, columnName);

            family.ExecuteOperation(op);
        }
        public static void RemoveColumn(this CassandraColumnFamily family, CassandraObject key, FluentColumnPath path)
        {
            var columnName = path.Column.ColumnName;

            RemoveColumn(family, key, columnName);
        }
        public static FluentColumn GetColumn(this CassandraColumnFamily family, CassandraObject key, FluentColumnPath path)
        {
            var columnName = path.Column.ColumnName;

            return(GetColumn(family, key, columnName));
        }
        public static FluentColumn GetColumn(this CassandraColumnFamily family, CassandraObject key, CassandraObject columnName)
        {
            var op = new GetColumn(key, columnName);

            return(family.ExecuteOperation(op));
        }
        public static void InsertColumn(this CassandraColumnFamily family, CassandraObject key, CassandraObject columnName, BytesType columnValue, DateTimeOffset timestamp, int?timeToLive)
        {
            var op = new InsertColumn(key, columnName, columnValue, timestamp, timeToLive);

            family.ExecuteOperation(op);
        }
        public static FluentColumnFamily GetSingle(this CassandraColumnFamily family, CassandraObject key, IEnumerable <CassandraObject> columnNames)
        {
            var op = new GetColumnFamilySlice(key, new CassandraColumnSlicePredicate(columnNames));

            return(family.ExecuteOperation(op));
        }
 public static void InsertColumn(this CassandraColumnFamily family, CassandraObject key, CassandraObject columnName, BytesType columnValue)
 {
     InsertColumn(family, key, columnName, columnValue, TimestampHelper.UtcNow(), null);
 }
        // queryable

        public static CassandraSlicePredicateQuery <FluentColumnFamily> Get(this CassandraColumnFamily family)
        {
            return(family.CreateCassandraSlicePredicateQuery <FluentColumnFamily>(null));
        }
 public static void InsertColumn(this CassandraColumnFamily family, CassandraObject key, FluentColumn column)
 {
     InsertColumn(family, key, column.GetPath());
 }
        public static int ColumnCount(this CassandraColumnFamily family, CassandraObject key, CassandraObject columnStart, CassandraObject columnEnd, bool reversed = false, int count = 100)
        {
            var op = new ColumnCount(key, new CassandraRangeSlicePredicate(columnStart, columnEnd, reversed, count));

            return(family.ExecuteOperation(op));
        }
 public static CassandraSlicePredicateQuery <FluentColumnFamily> Get(this CassandraColumnFamily family, params CassandraObject[] keys)
 {
     return(Get(family).FetchKeys(keys));
 }