SetSchemaForSlicePredicate() public static method

public static SetSchemaForSlicePredicate ( CassandraSlicePredicate predicate, CassandraColumnFamilySchema schema, bool forSuperColumn = false ) : CassandraSlicePredicate
predicate CassandraSlicePredicate
schema CassandraColumnFamilySchema
forSuperColumn bool
return CassandraSlicePredicate
        private IEnumerable <FluentColumn> GetColumns(BaseCassandraColumnFamily columnFamily)
        {
            var schema = ColumnFamily.GetSchema();
            var list   = new List <FluentColumn>();

            var parent = new CassandraColumnParent {
                ColumnFamily = columnFamily.FamilyName,
                SuperColumn  = SuperColumnName
            };

            SlicePredicate = Helper.SetSchemaForSlicePredicate(SlicePredicate, schema, SuperColumnName == null);

            var output = Session.GetClient().get_slice(
                Key,
                parent,
                SlicePredicate,
                Session.ReadConsistency
                );

            foreach (var result in output)
            {
                var r = Helper.ConvertColumnToFluentColumn(result.Column, schema);
                list.Add(r);
            }

            return(list);
        }
        public override IDictionary <CassandraObject, int> Execute()
        {
            var schema = ColumnFamily.GetSchema();

            var parent = new CassandraColumnParent {
                ColumnFamily = ColumnFamily.FamilyName
            };

            if (SuperColumnName != null)
            {
                parent.SuperColumn = SuperColumnName;
            }

            SlicePredicate = Helper.SetSchemaForSlicePredicate(SlicePredicate, schema, SuperColumnName == null);

            var output = Session.GetClient().multiget_count(
                Keys,
                parent,
                SlicePredicate,
                Session.ReadConsistency
                );

            var results = new Dictionary <CassandraObject, int>();

            foreach (var result in output)
            {
                results.Add(result.Key, result.Value);
            }

            return(results);
        }
Esempio n. 3
0
        private IEnumerable <FluentSuperColumn> GetColumns(BaseCassandraColumnFamily columnFamily)
        {
            var schema = ColumnFamily.GetSchema();

            var parent = new CassandraColumnParent {
                ColumnFamily = columnFamily.FamilyName
            };

            SlicePredicate = Helper.SetSchemaForSlicePredicate(SlicePredicate, schema);

            var output = Session.GetClient().get_slice(
                Key,
                parent,
                SlicePredicate,
                Session.ReadConsistency
                );

            foreach (var result in output)
            {
                var r = Helper.ConvertSuperColumnToFluentSuperColumn(result.Super_column, schema);
                columnFamily.Context.Attach(r);
                r.MutationTracker.Clear();

                yield return(r);
            }
        }
        public override IEnumerable <FluentColumnFamily> Execute()
        {
            var schema = ColumnFamily.GetSchema();
            var list   = new List <FluentColumnFamily>();

            var parent = new CassandraColumnParent
            {
                ColumnFamily = ColumnFamily.FamilyName
            };

            SlicePredicate = Helper.SetSchemaForSlicePredicate(SlicePredicate, schema);

            var output = Session.GetClient().get_indexed_slices(
                parent,
                IndexClause,
                SlicePredicate,
                Session.ReadConsistency
                );

            foreach (var result in output)
            {
                var key = CassandraObject.GetCassandraObjectFromDatabaseByteArray(result.Key, schema.KeyValueType);

                var r = new FluentColumnFamily(key, ColumnFamily.FamilyName, schema, result.Columns.Select(col =>
                {
                    return(Helper.ConvertColumnToFluentColumn(col.Column, schema));
                }));
                ColumnFamily.Context.Attach(r);
                r.MutationTracker.Clear();

                list.Add(r);
            }

            return(list);
        }
        private IEnumerable <FluentColumnFamily> GetFamilies(BaseCassandraColumnFamily columnFamily)
        {
            var schema = ColumnFamily.GetSchema();

            var parent = new CassandraColumnParent {
                ColumnFamily = columnFamily.FamilyName
            };

            SlicePredicate = Helper.SetSchemaForSlicePredicate(SlicePredicate, schema);

            var output = Session.GetClient().get_range_slices(
                parent,
                SlicePredicate,
                KeyRange,
                Session.ReadConsistency
                );

            foreach (var result in output)
            {
                var r = new FluentColumnFamily(result.Key, columnFamily.FamilyName, columnFamily.GetSchema(), result.Columns.Select(col => {
                    return(Helper.ConvertColumnToFluentColumn(col.Column, schema));
                }));
                columnFamily.Context.Attach(r);
                r.MutationTracker.Clear();

                yield return(r);
            }
        }
Esempio n. 6
0
        public override IEnumerable <FluentSuperColumnFamily> Execute()
        {
            var schema = ColumnFamily.GetSchema();

            var parent = new CassandraColumnParent {
                ColumnFamily = ColumnFamily.FamilyName
            };

            SlicePredicate = Helper.SetSchemaForSlicePredicate(SlicePredicate, schema);

            var output = Session.GetClient().get_indexed_slices(
                parent,
                IndexClause,
                SlicePredicate,
                Session.ReadConsistency
                );

            foreach (var result in output)
            {
                var r = new FluentSuperColumnFamily(result.Key, ColumnFamily.FamilyName, ColumnFamily.GetSchema(), result.Columns.Select(col => {
                    var superCol = Helper.ConvertSuperColumnToFluentSuperColumn(col.Super_column, schema);
                    ColumnFamily.Context.Attach(superCol);
                    superCol.MutationTracker.Clear();

                    return(superCol);
                }));
                ColumnFamily.Context.Attach(r);
                r.MutationTracker.Clear();

                yield return(r);
            }
        }
        public override IEnumerable <FluentSuperColumnFamily> Execute()
        {
            var schema = ColumnFamily.GetSchema();

            var parent = new CassandraColumnParent {
                ColumnFamily = ColumnFamily.FamilyName
            };

            SlicePredicate = Helper.SetSchemaForSlicePredicate(SlicePredicate, schema, SuperColumnName == null);

            var output = Session.GetClient().get_range_slices(
                parent,
                SlicePredicate,
                KeyRange,
                Session.ReadConsistency
                );

            foreach (var result in output)
            {
                var key = CassandraObject.GetCassandraObjectFromDatabaseByteArray(result.Key, schema.KeyValueType);

                var r = new FluentSuperColumnFamily(key, ColumnFamily.FamilyName, schema, result.Columns.Select(col => {
                    var superCol = Helper.ConvertSuperColumnToFluentSuperColumn(col.Super_column, schema);
                    ColumnFamily.Context.Attach(superCol);
                    superCol.MutationTracker.Clear();

                    return(superCol);
                }));
                ColumnFamily.Context.Attach(r);
                r.MutationTracker.Clear();

                yield return(r);
            }
        }
        public override IEnumerable <FluentSuperColumnFamily> Execute()
        {
            var schema = ColumnFamily.GetSchema();

            var parent = new CassandraColumnParent {
                ColumnFamily = ColumnFamily.FamilyName
            };

            if (SuperColumnName != null)
            {
                parent.SuperColumn = SuperColumnName;
            }

            SlicePredicate = Helper.SetSchemaForSlicePredicate(SlicePredicate, schema, SuperColumnName == null);

            var output = Session.GetClient().multiget_slice(
                Keys,
                parent,
                SlicePredicate,
                Session.ReadConsistency
                );

            foreach (var result in output)
            {
                var key = CassandraObject.GetCassandraObjectFromDatabaseByteArray(result.Key, schema.KeyValueType);

                var superColumns = (IEnumerable <FluentSuperColumn>)null;

                if (SuperColumnName != null)
                {
                    var superColSchema = new CassandraColumnSchema {
                        NameType  = schema.SuperColumnNameType,
                        Name      = SuperColumnName,
                        ValueType = schema.ColumnNameType
                    };

                    var superCol = new FluentSuperColumn(superColSchema, result.Value.Select(col => Helper.ConvertColumnToFluentColumn(col.Column, schema)));
                    ColumnFamily.Context.Attach(superCol);

                    superColumns = new[] { superCol };
                }
                else
                {
                    superColumns = result.Value.Select(col => Helper.ConvertSuperColumnToFluentSuperColumn(col.Super_column, schema));
                }

                var familyName = ColumnFamily.FamilyName;
                var r          = new FluentSuperColumnFamily(key, familyName, schema, superColumns);
                ColumnFamily.Context.Attach(r);

                yield return(r);
            }
        }