Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 122 lines (106 sloc) 3.117 kb
2db6327 @nberardi going through some changes to make the interface the objects more use…
nberardi authored
1 using System;
2 using System.Collections.Generic;
b9d2f58 @nberardi all tests pass after most recent changes
nberardi authored
3 using System.Linq;
b94a37c @nberardi uncompilable - getting query side of LINQ worked out
nberardi authored
4 using System.Linq.Expressions;
90285fe @nberardi fixed some problem decoding problems with Int32, Double, FLoat, Boole…
nberardi authored
5 using FluentCassandra.Operations;
d576460 @nberardi made the type system more robus to support parsing of complex types f…
nberardi authored
6 using FluentCassandra.Types;
2db6327 @nberardi going through some changes to make the interface the objects more use…
nberardi authored
7
8 namespace FluentCassandra
9 {
10 /// <seealso href="http://wiki.apache.org/cassandra/API"/>
1e57fcf @nberardi refactored the cassandra slice query to be more inteligent and requir…
nberardi authored
11 public abstract class BaseCassandraColumnFamily
2db6327 @nberardi going through some changes to make the interface the objects more use…
nberardi authored
12 {
bfe118e @nberardi got rid of the CassandraSession.Current since it was an anti-pattern …
nberardi authored
13 private readonly CassandraContext _context;
2db6327 @nberardi going through some changes to make the interface the objects more use…
nberardi authored
14
15 /// <summary>
16 ///
17 /// </summary>
18 /// <param name="keyspace"></param>
19 /// <param name="connection"></param>
222aa24 @nberardi connections can now failover, pool, and load balance
nberardi authored
20 public BaseCassandraColumnFamily(CassandraContext context, string columnFamily)
2db6327 @nberardi going through some changes to make the interface the objects more use…
nberardi authored
21 {
22 _context = context;
23 FamilyName = columnFamily;
24 }
25
26 /// <summary>
27 /// The context the column family currently belongs to.
28 /// </summary>
29 public CassandraContext Context { get { return _context; } }
30
31 /// <summary>
32 /// The family name for this column family.
33 /// </summary>
34 public string FamilyName { get; private set; }
35
36 /// <summary>
37 /// Verifies that the family passed in is part of this family.
38 /// </summary>
39 /// <param name="family"></param>
40 /// <returns></returns>
210341a @nberardi started to import in the client objects, still needs more tests
nberardi authored
41 public bool IsPartOfFamily(IFluentBaseColumnFamily family)
2db6327 @nberardi going through some changes to make the interface the objects more use…
nberardi authored
42 {
43 return String.Equals(family.FamilyName, FamilyName);
44 }
45
46 /// <summary>
b9d2f58 @nberardi all tests pass after most recent changes
nberardi authored
47 ///
48 /// </summary>
49 /// <returns></returns>
2f86912 @nberardi all tests now compile, so the new genericless types have been provide…
nberardi authored
50 public abstract CassandraColumnFamilySchema GetSchema();
b9d2f58 @nberardi all tests pass after most recent changes
nberardi authored
51
2f86912 @nberardi all tests now compile, so the new genericless types have been provide…
nberardi authored
52 /// <summary>
53 ///
54 /// </summary>
55 /// <param name="schema"></param>
56 public abstract void SetSchema(CassandraColumnFamilySchema schema);
b9d2f58 @nberardi all tests pass after most recent changes
nberardi authored
57
58 /// <summary>
59 ///
60 /// </summary>
2f86912 @nberardi all tests now compile, so the new genericless types have been provide…
nberardi authored
61 public abstract void ClearCachedColumnFamilySchema();
b9d2f58 @nberardi all tests pass after most recent changes
nberardi authored
62
63 /// <summary>
4526a65 @nberardi some much needed refactoring of the schema
nberardi authored
64 ///
65 /// </summary>
66 public void TryCreateSelf()
67 {
68 Context.Keyspace.TryCreateColumnFamily(GetSchema());
69 }
70
71 /// <summary>
d576460 @nberardi made the type system more robus to support parsing of complex types f…
nberardi authored
72 ///
73 /// </summary>
74 /// <param name="key"></param>
75 public void RemoveKey(CassandraObject key)
76 {
77 var op = new Remove(key);
78 ExecuteOperation(op);
79 }
80
81 /// <summary>
ce017c8 @nberardi all tests working for 0.7
nberardi authored
82 /// Removes all the rows from the given column family.
83 /// </summary>
84 public void RemoveAllRows()
85 {
b9d2f58 @nberardi all tests pass after most recent changes
nberardi authored
86 _context.ExecuteOperation(new SimpleOperation<int>(ctx => {
87 ctx.Session.GetClient().truncate(FamilyName);
88 return 0;
89 }));
ce017c8 @nberardi all tests working for 0.7
nberardi authored
90 }
91
92 /// <summary>
2e93bd7 @nberardi all tests passing for GetColumn for both standard and super families
nberardi authored
93 /// Execute the column family operation against the connection to the server.
2db6327 @nberardi going through some changes to make the interface the objects more use…
nberardi authored
94 /// </summary>
95 /// <typeparam name="TResult"></typeparam>
96 /// <param name="action"></param>
2e93bd7 @nberardi all tests passing for GetColumn for both standard and super families
nberardi authored
97 /// <param name="throwOnError"></param>
98 /// <returns></returns>
e384304 @nberardi finished up tests for 0.7
nberardi authored
99 public TResult ExecuteOperation<TResult>(ColumnFamilyOperation<TResult> action, bool? throwOnError = null)
2e93bd7 @nberardi all tests passing for GetColumn for both standard and super families
nberardi authored
100 {
3254baf @nberardi cleaned up session, context, and keyspace objects
nberardi authored
101 action.ColumnFamily = this;
e4efc4c @nberardi added support for session based configurations, as well as dynamic pr…
nberardi authored
102
bfe118e @nberardi got rid of the CassandraSession.Current since it was an anti-pattern …
nberardi authored
103 return _context.ExecuteOperation(action, throwOnError);
2db6327 @nberardi going through some changes to make the interface the objects more use…
nberardi authored
104 }
603b876 @nberardi First working testing in the Cassandra LINQ-like syntax.
nberardi authored
105
1e57fcf @nberardi refactored the cassandra slice query to be more inteligent and requir…
nberardi authored
106 public CassandraSlicePredicateQuery<TResult> CreateCassandraSlicePredicateQuery<TResult>(Expression expression)
603b876 @nberardi First working testing in the Cassandra LINQ-like syntax.
nberardi authored
107 {
1e57fcf @nberardi refactored the cassandra slice query to be more inteligent and requir…
nberardi authored
108 return new CassandraSlicePredicateQuery<TResult>(this, expression);
603b876 @nberardi First working testing in the Cassandra LINQ-like syntax.
nberardi authored
109 }
110
1e57fcf @nberardi refactored the cassandra slice query to be more inteligent and requir…
nberardi authored
111 public IEnumerable<TResult> ExecuteCassandraSlicePredicateQuery<TResult>(CassandraSlicePredicateQuery<TResult> query)
603b876 @nberardi First working testing in the Cassandra LINQ-like syntax.
nberardi authored
112 {
9e8c988 @nberardi moved around some stuff to support the new count methods in the LINQ …
nberardi authored
113 var op = query.BuildQueryableOperation();
1e57fcf @nberardi refactored the cassandra slice query to be more inteligent and requir…
nberardi authored
114 return ExecuteOperation((QueryableColumnFamilyOperation<TResult>)op);
9e8c988 @nberardi moved around some stuff to support the new count methods in the LINQ …
nberardi authored
115 }
116
9ee2ff9 @nberardi moved provider to cassandra column family object since it made more s…
nberardi authored
117 public override string ToString()
118 {
119 return FamilyName;
120 }
2db6327 @nberardi going through some changes to make the interface the objects more use…
nberardi authored
121 }
122 }
Something went wrong with that request. Please try again.