Permalink
Newer
Older
100644 57 lines (45 sloc) 1.6 KB
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using FluentCassandra.Types;
5
6
namespace FluentCassandra.Operations
7
{
8
public class GetSuperColumnFamilyRangeSlices : QueryableColumnFamilyOperation<FluentSuperColumnFamily>
9
{
10
public CassandraKeyRange KeyRange { get; private set; }
11
12
public CassandraObject SuperColumnName { get; private set; }
13
14
public override IEnumerable<FluentSuperColumnFamily> Execute()
16
var schema = ColumnFamily.GetSchema();
17
18
var parent = new CassandraColumnParent {
19
ColumnFamily = ColumnFamily.FamilyName
20
};
21
22
SlicePredicate = Helper.SetSchemaForSlicePredicate(SlicePredicate, schema, SuperColumnName == null);
23
24
var output = Session.GetClient().get_range_slices(
25
parent,
26
SlicePredicate,
27
KeyRange,
28
Session.ReadConsistency
29
);
30
31
foreach (var result in output)
33
var key = CassandraObject.GetCassandraObjectFromDatabaseByteArray(result.Key, schema.KeyValueType);
34
35
var r = new FluentSuperColumnFamily(key, ColumnFamily.FamilyName, schema, result.Columns.Select(col => {
36
var superCol = Helper.ConvertSuperColumnToFluentSuperColumn(col.Super_column, schema);
37
ColumnFamily.Context.Attach(superCol);
38
superCol.MutationTracker.Clear();
40
return superCol;
41
}));
42
ColumnFamily.Context.Attach(r);
43
r.MutationTracker.Clear();
45
yield return r;
49
public GetSuperColumnFamilyRangeSlices(CassandraKeyRange keyRange, CassandraObject superColumnName, CassandraSlicePredicate columnSlicePredicate)
52
SuperColumnName = superColumnName;
53
SlicePredicate = columnSlicePredicate;