Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 74 lines (58 sloc) 2.147 kb
30ce4f8 @nberardi added multi_get_slice and tests, last to add is get_range_slice
nberardi authored
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using FluentCassandra.Types;
5
6 namespace FluentCassandra.Operations
7 {
e1b11ad @nberardi [breaking change] with recent changes in the Cassandra API and the new d...
nberardi authored
8 public class MultiGetSuperColumnFamilySlice : QueryableColumnFamilyOperation<FluentSuperColumnFamily>
30ce4f8 @nberardi added multi_get_slice and tests, last to add is get_range_slice
nberardi authored
9 {
d576460 @nberardi made the type system more robus to support parsing of complex types from...
nberardi authored
10 public List<CassandraObject> Keys { get; private set; }
30ce4f8 @nberardi added multi_get_slice and tests, last to add is get_range_slice
nberardi authored
11
d576460 @nberardi made the type system more robus to support parsing of complex types from...
nberardi authored
12 public CassandraObject SuperColumnName { get; private set; }
30ce4f8 @nberardi added multi_get_slice and tests, last to add is get_range_slice
nberardi authored
13
e1b11ad @nberardi [breaking change] with recent changes in the Cassandra API and the new d...
nberardi authored
14 public override IEnumerable<FluentSuperColumnFamily> Execute()
30ce4f8 @nberardi added multi_get_slice and tests, last to add is get_range_slice
nberardi authored
15 {
0592960 @nberardi all expected tests are now running
nberardi authored
16 var schema = ColumnFamily.GetSchema();
17
2645bc7 @nberardi cleaned up the use of sessions in the code
nberardi authored
18 var parent = new CassandraColumnParent {
19 ColumnFamily = ColumnFamily.FamilyName
20 };
21
d576460 @nberardi made the type system more robus to support parsing of complex types from...
nberardi authored
22 if (SuperColumnName != null)
23 parent.SuperColumn = SuperColumnName;
24
fc725a6 @nberardi fixed issues discovered while running sandbox
nberardi authored
25 SlicePredicate = Helper.SetSchemaForSlicePredicate(SlicePredicate, schema, SuperColumnName == null);
26
2645bc7 @nberardi cleaned up the use of sessions in the code
nberardi authored
27 var output = Session.GetClient().multiget_slice(
28 Keys,
29 parent,
30 SlicePredicate,
31 Session.ReadConsistency
32 );
33
34 foreach (var result in output)
30ce4f8 @nberardi added multi_get_slice and tests, last to add is get_range_slice
nberardi authored
35 {
a9597c9 @nberardi refactored a couple of schema related changes
nberardi authored
36 var key = CassandraObject.GetCassandraObjectFromDatabaseByteArray(result.Key, schema.KeyValueType);
0592960 @nberardi all expected tests are now running
nberardi authored
37
38 var superColumns = (IEnumerable<FluentSuperColumn>)null;
eeb86f3 @nberardi continued adding support for composite types, added some new tests to ve...
nberardi authored
39
0592960 @nberardi all expected tests are now running
nberardi authored
40 if (SuperColumnName != null)
41 {
42 var superColSchema = new CassandraColumnSchema {
43 NameType = schema.SuperColumnNameType,
44 Name = SuperColumnName,
45 ValueType = schema.ColumnNameType
46 };
47
48 var superCol = new FluentSuperColumn(superColSchema, result.Value.Select(col => Helper.ConvertColumnToFluentColumn(col.Column, schema)));
2645bc7 @nberardi cleaned up the use of sessions in the code
nberardi authored
49 ColumnFamily.Context.Attach(superCol);
30ce4f8 @nberardi added multi_get_slice and tests, last to add is get_range_slice
nberardi authored
50
0592960 @nberardi all expected tests are now running
nberardi authored
51 superColumns = new[] { superCol };
52 }
53 else
54 {
2c77dfc @nberardi refactored mutation handling to better handle super columns which fixed ...
nberardi authored
55 superColumns = result.Value.Select(col => Helper.ConvertSuperColumnToFluentSuperColumn(col.Super_column, schema));
0592960 @nberardi all expected tests are now running
nberardi authored
56 }
eeb86f3 @nberardi continued adding support for composite types, added some new tests to ve...
nberardi authored
57
2645bc7 @nberardi cleaned up the use of sessions in the code
nberardi authored
58 var familyName = ColumnFamily.FamilyName;
e1b11ad @nberardi [breaking change] with recent changes in the Cassandra API and the new d...
nberardi authored
59 var r = new FluentSuperColumnFamily(key, familyName, schema, superColumns);
2645bc7 @nberardi cleaned up the use of sessions in the code
nberardi authored
60 ColumnFamily.Context.Attach(r);
30ce4f8 @nberardi added multi_get_slice and tests, last to add is get_range_slice
nberardi authored
61
2645bc7 @nberardi cleaned up the use of sessions in the code
nberardi authored
62 yield return r;
30ce4f8 @nberardi added multi_get_slice and tests, last to add is get_range_slice
nberardi authored
63 }
64 }
65
d576460 @nberardi made the type system more robus to support parsing of complex types from...
nberardi authored
66 public MultiGetSuperColumnFamilySlice(IEnumerable<CassandraObject> keys, CassandraObject superColumnName, CassandraSlicePredicate columnSlicePredicate)
30ce4f8 @nberardi added multi_get_slice and tests, last to add is get_range_slice
nberardi authored
67 {
e06a0b5 @nberardi everything compiles
nberardi authored
68 Keys = keys.ToList();
d576460 @nberardi made the type system more robus to support parsing of complex types from...
nberardi authored
69 SuperColumnName = superColumnName;
e06a0b5 @nberardi everything compiles
nberardi authored
70 SlicePredicate = columnSlicePredicate;
30ce4f8 @nberardi added multi_get_slice and tests, last to add is get_range_slice
nberardi authored
71 }
72 }
73 }
Something went wrong with that request. Please try again.