Ejemplo n.º 1
0
        public IDictionary <string, IList <Column> > GetRangeSlice(ColumnParent columnParent, SlicePredicate predicate, string start, string finish, int count)
        {
            var op = new Operation <IDictionary <string, IList <Column> > >(ClientCounter.READ_FAIL,
                                                                            client =>
            {
                var result = new Dictionary <string, IList <Column> >();

                var keySlices = client.get_range_slice(Name, columnParent.ToThrift(), predicate.ToThrift(), start, finish, count, ConsistencyLevel.ToThrift());

                if (keySlices == null || keySlices.Count == 0)
                {
                    return(result);
                }

                foreach (var entry in keySlices.Transform(entry => new { entry.Key, Columns = GetColumnList(entry.Columns) }))
                {
                    result.Add(entry.Key, entry.Columns);
                }

                return(result);
            });

            OperateWithFailover(op);
            return(op.Result);
        }
Ejemplo n.º 2
0
        public IDictionary <string, SuperColumn> MultigetSuperColumn(IList <string> keys, ColumnPath columnPath, bool reversed, int size)
        {
            AssertSuperColumnPath(columnPath);

            var result = new Dictionary <string, SuperColumn>();

            // only can get supercolumn by multigetSuperSlice
            var clp    = new ColumnParent(columnPath.ColumnFamily, columnPath.SuperColumn);
            var sr     = new SliceRange(reversed, size);
            var sp     = new SlicePredicate(sr);
            var sclist = MultigetSuperSlice(keys, clp, sp);

            if (sclist == null || sclist.Count == 0)
            {
                return(result);
            }

            foreach (var sc in sclist)
            {
                if (sc.Value.Count > 0)
                {
                    result.Add(sc.Key, sc.Value[0]);
                }
            }

            return(result);
        }
Ejemplo n.º 3
0
        public int GetCount(string key, ColumnParent columnParent)
        {
            var op = new Operation <int>(ClientCounter.READ_FAIL,
                                         client =>
            {
                return(client.get_count(Name, key, columnParent.ToThrift(), ConsistencyLevel.ToThrift()));
            });

            OperateWithFailover(op);
            return(op.Result);
        }
Ejemplo n.º 4
0
        public IEnumerable <SuperColumn> GetSuperSlice(string key, ColumnParent columnParent, SlicePredicate predicate)
        {
            var op = new Operation <IEnumerable <SuperColumn> >(ClientCounter.READ_FAIL,
                                                                client =>
            {
                return(client.get_slice(Name, key, columnParent.ToThrift(), predicate.ToThrift(), ConsistencyLevel.ToThrift())
                       .Transform(c => c.Super_column.ToModel()));
            });

            OperateWithFailover(op);
            return(op.Result);
        }
Ejemplo n.º 5
0
 public static Apache.Cassandra.ColumnParent ToThrift(this ColumnParent parent)
 {
     return(new Apache.Cassandra.ColumnParent(parent.ColumnFamily, parent.SuperColumn));
 }
Ejemplo n.º 6
0
        public IDictionary <string, IList <SuperColumn> > MultigetSuperSlice(IList <string> keys, ColumnParent columnParent, SlicePredicate predicate)
        {
            var op = new Operation <IDictionary <string, IList <SuperColumn> > >(ClientCounter.READ_FAIL,
                                                                                 client =>
            {
                var result = new Dictionary <string, IList <SuperColumn> >();
                var cfmap  = client.multiget_slice(Name, new List <string>(keys), columnParent.ToThrift(), predicate.ToThrift(), ConsistencyLevel.ToThrift());

                if (string.IsNullOrEmpty(columnParent.SuperColumn))
                {
                    foreach (var entry in cfmap.Transform(m => new { m.Key, List = GetSuperColumnList(m.Value) }))
                    {
                        result.Add(entry.Key, entry.List);
                    }
                }
                else
                {
                    foreach (var entry in cfmap.Transform(m =>
                                                          new
                    {
                        m.Key,
                        List = new List <SuperColumn>
                        {
                            new SuperColumn(columnParent.SuperColumn, GetColumnList(m.Value))
                        }
                    }))
                    {
                        result.Add(entry.Key, entry.List);
                    }
                }
                return(result);
            }
                                                                                 );

            OperateWithFailover(op);
            return(op.Result);
        }
Ejemplo n.º 7
0
        public int GetCount(string key, ColumnParent columnParent)
        {
            var op = new Operation<int>(ClientCounter.READ_FAIL,
                client =>
                {
                    return client.get_count(Name, key, columnParent.ToThrift(), ConsistencyLevel.ToThrift());
                });

            OperateWithFailover(op);
            return op.Result;
        }
Ejemplo n.º 8
0
        public IDictionary<string, IList<SuperColumn>> MultigetSuperSlice(IList<string> keys, ColumnParent columnParent, SlicePredicate predicate)
        {
            var op = new Operation<IDictionary<string, IList<SuperColumn>>>(ClientCounter.READ_FAIL,
                client =>
                {
                    var result = new Dictionary<string, IList<SuperColumn>>();
                    var cfmap = client.multiget_slice(Name, new List<string>(keys), columnParent.ToThrift(), predicate.ToThrift(), ConsistencyLevel.ToThrift());

                    if (string.IsNullOrEmpty(columnParent.SuperColumn))
                    {
                        foreach (var entry in cfmap.Transform(m => new { m.Key, List = GetSuperColumnList(m.Value) }))
                            result.Add(entry.Key, entry.List);
                    }
                    else
                    {
                        foreach (var entry in cfmap.Transform(m =>
                            new
                            {
                                m.Key,
                                List = new List<SuperColumn>
                                {
                                    new SuperColumn(columnParent.SuperColumn, GetColumnList(m.Value))
                                }
                            }))
                            result.Add(entry.Key, entry.List);
                    }
                    return result;
                }
            );
            OperateWithFailover(op);
            return op.Result;
        }
Ejemplo n.º 9
0
        public IDictionary<string, SuperColumn> MultigetSuperColumn(IList<string> keys, ColumnPath columnPath, bool reversed, int size)
        {
            AssertSuperColumnPath(columnPath);

            var result = new Dictionary<string, SuperColumn>();

            // only can get supercolumn by multigetSuperSlice
            var clp = new ColumnParent(columnPath.ColumnFamily, columnPath.SuperColumn);
            var sr = new SliceRange(reversed, size);
            var sp = new SlicePredicate(sr);
            var sclist = MultigetSuperSlice(keys, clp, sp);

            if (sclist == null || sclist.Count == 0)
                return result;

            foreach (var sc in sclist)
                if (sc.Value.Count > 0)
                    result.Add(sc.Key, sc.Value[0]);

            return result;
        }
Ejemplo n.º 10
0
        public IEnumerable<SuperColumn> GetSuperSlice(string key, ColumnParent columnParent, SlicePredicate predicate)
        {
            var op = new Operation<IEnumerable<SuperColumn>>(ClientCounter.READ_FAIL,
                client =>
                {
                    return client.get_slice(Name, key, columnParent.ToThrift(), predicate.ToThrift(), ConsistencyLevel.ToThrift())
                        .Transform(c => c.Super_column.ToModel());
                });

            OperateWithFailover(op);
            return op.Result;
        }
Ejemplo n.º 11
0
        public IDictionary<string, IList<SuperColumn>> GetSuperRangeSlice(ColumnParent columnParent, SlicePredicate predicate, string start, string finish, int count)
        {
            var op = new Operation<IDictionary<string, IList<SuperColumn>>>(ClientCounter.READ_FAIL,
                client =>
                {
                    var result = new Dictionary<string, IList<SuperColumn>>();
                    var keySlices = client.get_range_slice(Name, columnParent.ToThrift(), predicate.ToThrift(), start, finish, count, ConsistencyLevel.ToThrift());
                    if (keySlices == null || keySlices.Count == 0)
                        return result;

                    foreach (var entry in keySlices.Transform(entry => new { entry.Key, Columns = GetSuperColumnList(entry.Columns) }))
                        result.Add(entry.Key, entry.Columns);

                    return result;
                }
            );
            OperateWithFailover(op);
            return op.Result;
        }