Skip to content
This repository
Browse code

added thrift from latest build

  • Loading branch information...
commit 50d830b25d508ea86e84479e3d9bf07042224044 1 parent 9e8c988
Nick Berardi authored September 04, 2010

Showing 23 changed files with 263 additions and 143 deletions. Show diff stats Hide diff stats

  1. 3  FluentCassandra.Test/FluentCassandra.Test.csproj
  2. 6  FluentCassandra.Test/Operations/ColumnCountTest.cs
  3. 12  FluentCassandra.Test/Operations/MultiGetSliceTest.cs
  4. 10  FluentCassandra.Test/Operations/RemoveColumnTest.cs
  5. 12  FluentCassandra.Test/Test.Keyspace.xml
  6. 11  FluentCassandra.Test/Test.Keyspace.yaml
  7. 2  FluentCassandra.Test/Types/AsciiTypeTest.cs
  8. 13  FluentCassandra.Test/Types/BytesTypeTest.cs
  9. 2  FluentCassandra.Test/Types/LongTypeTest.cs
  10. 17  FluentCassandra.Test/Types/NullTypeTest.cs
  11. 2  FluentCassandra.Test/Types/TimeUUIDTypeTest.cs
  12. 2  FluentCassandra.Test/Types/UTF8TypeTest.cs
  13. 64  FluentCassandra.Test/_CassandraSetup.cs
  14. 110  FluentCassandra/Apache/Cassandra/Cassandra.cs
  15. 2  FluentCassandra/Apache/Cassandra/Constants.cs
  16. 4  FluentCassandra/Apache/Cassandra/IndexOperator.cs
  17. 18  FluentCassandra/CassandraContext.cs
  18. 69  FluentCassandra/CassandraSession.cs
  19. 26  FluentCassandra/Connection/Connection.cs
  20. 10  FluentCassandra/Connection/ConnectionProvider.cs
  21. 2  FluentCassandra/Connection/IConnection.cs
  22. 6  FluentCassandra/Connection/NormalConnectionProvider.cs
  23. 3  FluentCassandra/Operations/ColumnFamilyOperation.cs
3  FluentCassandra.Test/FluentCassandra.Test.csproj
@@ -53,6 +53,7 @@
53 53
     <Compile Include="CassandraQueryTest.cs" />
54 54
     <Compile Include="Connection\ConnectionProviderTest.cs" />
55 55
     <Compile Include="Connection\NormalConnectionProviderTest.cs" />
  56
+    <Compile Include="_CassandraSetup.cs" />
56 57
     <Compile Include="FluentSuperColumnFamilyTest.cs" />
57 58
     <Compile Include="FluentColumnFamilyTest.cs" />
58 59
     <Compile Include="FluentColumnTest.cs" />
@@ -81,7 +82,7 @@
81 82
     </ProjectReference>
82 83
   </ItemGroup>
83 84
   <ItemGroup>
84  
-    <Content Include="Test.Keyspace.xml" />
  85
+    <None Include="Test.Keyspace.yaml" />
85 86
   </ItemGroup>
86 87
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
87 88
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
6  FluentCassandra.Test/Operations/ColumnCountTest.cs
@@ -41,7 +41,7 @@ public void ColumnFamily_Key()
41 41
 			_family.InsertColumn(_testKey, "Test3", Math.PI);
42 42
 
43 43
 			// act
44  
-			int actual = _family.ColumnCount(_testKey);
  44
+			int actual = _family.ColumnCount(_testKey, null, null);
45 45
 
46 46
 			// assert
47 47
 			Assert.AreEqual(expected, actual);
@@ -57,7 +57,7 @@ public void SuperColumnFamily_Key()
57 57
 			_superFamily.InsertColumn(_testKey, _testSuperName, "Test3", Math.PI);
58 58
 
59 59
 			// act
60  
-			int actual = _superFamily.ColumnCount(_testKey);
  60
+			int actual = _superFamily.ColumnCount(_testKey, null, null);
61 61
 
62 62
 			// assert
63 63
 			Assert.AreEqual(expected, actual);
@@ -73,7 +73,7 @@ public void SuperColumnFamily_Key_And_SuperColumnName()
73 73
 			_superFamily.InsertColumn(_testKey, _testSuperName, "Test3", Math.PI);
74 74
 
75 75
 			// act
76  
-			int actual = _superFamily.ColumnCount(_testKey, _testSuperName);
  76
+			int actual = _superFamily.ColumnCount(_testKey, _testSuperName, null, null);
77 77
 
78 78
 			// assert
79 79
 			Assert.AreEqual(expected, actual);
12  FluentCassandra.Test/Operations/MultiGetSliceTest.cs
@@ -55,7 +55,7 @@ public void Standard_GetSlice_Columns()
55 55
 			int expectedCount = 2;
56 56
 
57 57
 			// act
58  
-			var columns = _family.Get(new[] { _testKey, _testKey2 }, new AsciiType[] { "Test1", "Test2" });
  58
+			var columns = _family.Get(new BytesType[] { _testKey, _testKey2 }, new AsciiType[] { "Test1", "Test2" });
59 59
 
60 60
 			// assert
61 61
 			Assert.AreEqual(expectedCount, columns.Count());
@@ -68,7 +68,7 @@ public void Super_GetSlice_Columns()
68 68
 			int expectedCount = 2;
69 69
 
70 70
 			// act
71  
-			var columns = _superFamily.GetSuperColumns(new[] { _testKey, _testKey2 }, _testSuperName, new AsciiType[] { "Test1", "Test2" });
  71
+			var columns = _superFamily.GetSuperColumns(new BytesType[] { _testKey, _testKey2 }, _testSuperName, new AsciiType[] { "Test1", "Test2" });
72 72
 
73 73
 			// assert
74 74
 			Assert.AreEqual(expectedCount, columns.Count());
@@ -81,7 +81,7 @@ public void Super_GetSuperSlice_Columns()
81 81
 			int expectedCount = 2;
82 82
 
83 83
 			// act
84  
-			var columns = _superFamily.Get(new[] { _testKey, _testKey2 }, new AsciiType[] { _testSuperName });
  84
+			var columns = _superFamily.Get(new BytesType[] { _testKey, _testKey2 }, new AsciiType[] { _testSuperName });
85 85
 
86 86
 			// assert
87 87
 			Assert.AreEqual(expectedCount, columns.Count());
@@ -94,7 +94,7 @@ public void Standard_GetSlice_Range()
94 94
 			int expectedCount = 2;
95 95
 
96 96
 			// act
97  
-			var columns = _family.Get(new[] { _testKey, _testKey2 }, _testName, null, columnCount: 2);
  97
+			var columns = _family.Get(new BytesType[] { _testKey, _testKey2 }, _testName, null, columnCount: 2);
98 98
 
99 99
 			// assert
100 100
 			Assert.AreEqual(expectedCount, columns.Count());
@@ -107,7 +107,7 @@ public void Super_GetSlice_Range()
107 107
 			int expectedCount = 2;
108 108
 
109 109
 			// act
110  
-			var columns = _superFamily.GetSuperColumns(new[] { _testKey, _testKey2 }, _testSuperName, _testName, null, columnCount: 2);
  110
+			var columns = _superFamily.GetSuperColumns(new BytesType[] { _testKey, _testKey2 }, _testSuperName, _testName, null, columnCount: 2);
111 111
 
112 112
 			// assert
113 113
 			Assert.AreEqual(expectedCount, columns.Count());
@@ -120,7 +120,7 @@ public void Super_GetSuperSlice_Range()
120 120
 			int expectedCount = 2;
121 121
 
122 122
 			// act
123  
-			var columns = _superFamily.Get(new[] { _testKey, _testKey2 }, _testSuperName, null, columnCount: 1);
  123
+			var columns = _superFamily.Get(new BytesType[] { _testKey, _testKey2 }, _testSuperName, null, columnCount: 1);
124 124
 
125 125
 			// assert
126 126
 			Assert.AreEqual(expectedCount, columns.Count());
10  FluentCassandra.Test/Operations/RemoveColumnTest.cs
@@ -49,7 +49,7 @@ public void Standard_RemoveColumn()
49 49
 			_family.RemoveColumn(_testKey, _testName);
50 50
 
51 51
 			// assert
52  
-			int actualCount = _family.ColumnCount(_testKey);
  52
+			int actualCount = _family.ColumnCount(_testKey, null, null);
53 53
 			Assert.AreEqual(expectedCount, actualCount);
54 54
 		}
55 55
 
@@ -63,7 +63,7 @@ public void Standard_RemoveKey()
63 63
 			_family.RemoveKey(_testKey);
64 64
 
65 65
 			// assert
66  
-			int actualCount = _family.ColumnCount(_testKey);
  66
+			int actualCount = _family.ColumnCount(_testKey, null, null);
67 67
 			Assert.AreEqual(expectedCount, actualCount);
68 68
 		}
69 69
 
@@ -77,7 +77,7 @@ public void Super_RemoveColumn()
77 77
 			_superFamily.RemoveColumn(_testKey, _testSuperName, _testName);
78 78
 
79 79
 			// assert
80  
-			int actualCount = _superFamily.ColumnCount(_testKey, _testSuperName);
  80
+			int actualCount = _superFamily.ColumnCount(_testKey, _testSuperName, null, null);
81 81
 			Assert.AreEqual(expectedCount, actualCount);
82 82
 		}
83 83
 
@@ -91,7 +91,7 @@ public void Super_RemoveSuperColumn()
91 91
 			_superFamily.RemoveSuperColumn(_testKey, _testSuperName);
92 92
 
93 93
 			// assert
94  
-			int actualCount = _superFamily.ColumnCount(_testKey);
  94
+			int actualCount = _superFamily.ColumnCount(_testKey, null, null);
95 95
 			Assert.AreEqual(expectedCount, actualCount);
96 96
 		}
97 97
 
@@ -105,7 +105,7 @@ public void Super_RemoveKey()
105 105
 			_superFamily.RemoveKey(_testKey);
106 106
 
107 107
 			// assert
108  
-			int actualCount = _superFamily.ColumnCount(_testKey);
  108
+			int actualCount = _superFamily.ColumnCount(_testKey, null, null);
109 109
 			Assert.AreEqual(expectedCount, actualCount);
110 110
 		}
111 111
 	}
12  FluentCassandra.Test/Test.Keyspace.xml
... ...
@@ -1,12 +0,0 @@
1  
-<Keyspace Name="Testing">
2  
-	<ColumnFamily Name="Standard"
3  
-		CompareWith="AsciiType"/>
4  
-	<ColumnFamily Name="Super"
5  
-		ColumnType="Super"
6  
-		CompareWith="AsciiType"
7  
-		CompareSubcolumnsWith="AsciiType" />
8  
-
9  
-	<ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
10  
-	<ReplicationFactor>1</ReplicationFactor>
11  
-	<EndPointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndPointSnitch>
12  
-</Keyspace>
11  FluentCassandra.Test/Test.Keyspace.yaml
... ...
@@ -0,0 +1,11 @@
  1
+    - name: Testing
  2
+      replica_placement_strategy: org.apache.cassandra.locator.RackUnawareStrategy
  3
+      replication_factor: 1
  4
+      column_families:
  5
+        - name: Standard
  6
+          compare_with: AsciiType
  7
+
  8
+        - name: Super
  9
+          column_type: Super
  10
+          compare_with: AsciiType
  11
+          compare_subcolumns_with: AsciiType
2  FluentCassandra.Test/Types/AsciiTypeTest.cs
@@ -5,7 +5,7 @@
5 5
 using System.Text;
6 6
 using System.Linq;
7 7
 
8  
-namespace FluentCassandra.Test
  8
+namespace FluentCassandra.Test.Types
9 9
 {
10 10
 	[TestClass]
11 11
 	public class AsciiTypeTest
13  FluentCassandra.Test/Types/BytesTypeTest.cs
@@ -11,6 +11,19 @@ namespace FluentCassandra.Test.Types
11 11
 	public class BytesTypeTest
12 12
 	{
13 13
 		[TestMethod]
  14
+		public void String_To_BytesType()
  15
+		{
  16
+			// arrange
  17
+			string expected = "Something Good";
  18
+
  19
+			// act
  20
+			BytesType actual = expected;
  21
+
  22
+			// assert
  23
+			Assert.AreEqual(expected, (string)actual);
  24
+		}
  25
+
  26
+		[TestMethod]
14 27
 		public void Double_To_BytesType()
15 28
 		{
16 29
 			// arrange
2  FluentCassandra.Test/Types/LongTypeTest.cs
@@ -5,7 +5,7 @@
5 5
 using System.Text;
6 6
 using System.Linq;
7 7
 
8  
-namespace FluentCassandra.Test
  8
+namespace FluentCassandra.Test.Types
9 9
 {
10 10
 	[TestClass]
11 11
 	public class LongTypeTest
17  FluentCassandra.Test/Types/NullTypeTest.cs
@@ -5,7 +5,7 @@
5 5
 using System.Text;
6 6
 using System.Linq;
7 7
 
8  
-namespace FluentCassandra.Test
  8
+namespace FluentCassandra.Test.Types
9 9
 {
10 10
 	[TestClass]
11 11
 	public class NullTypeTest
@@ -20,17 +20,10 @@ public class NullTypeTest
20 20
 		[TestInitialize]
21 21
 		public void TestInit()
22 22
 		{
23  
-			_db = new CassandraContext("Testing", "localhost");
24  
-			_family = _db.GetColumnFamily<AsciiType>("Standard");
25  
-			_superFamily = _db.GetColumnFamily<AsciiType, AsciiType>("Super");
26  
-
27  
-			_family.InsertColumn(_testKey, "Test1", Math.PI);
28  
-			_family.InsertColumn(_testKey, "Test2", Math.PI);
29  
-			_family.InsertColumn(_testKey, "Test3", Math.PI);
30  
-
31  
-			_superFamily.InsertColumn(_testKey, _testSuperName, "Test1", Math.PI);
32  
-			_superFamily.InsertColumn(_testKey, _testSuperName, "Test2", Math.PI);
33  
-			_superFamily.InsertColumn(_testKey, _testSuperName, "Test3", Math.PI);
  23
+			var setup = new _CassandraSetup();
  24
+			_db = setup.DB;
  25
+			_family = setup.Family;
  26
+			_superFamily = setup.SuperFamily;
34 27
 		}
35 28
 
36 29
 		[TestCleanup]
2  FluentCassandra.Test/Types/TimeUUIDTypeTest.cs
@@ -5,7 +5,7 @@
5 5
 using Microsoft.VisualStudio.TestTools.UnitTesting;
6 6
 using FluentCassandra.Types;
7 7
 
8  
-namespace FluentCassandra.Test.Types
  8
+namespace FluentCassandra.Test.Types.Types
9 9
 {
10 10
 	[TestClass]
11 11
 	public class TimeUUIDTypeTest
2  FluentCassandra.Test/Types/UTF8TypeTest.cs
@@ -5,7 +5,7 @@
5 5
 using System.Text;
6 6
 using System.Linq;
7 7
 
8  
-namespace FluentCassandra.Test
  8
+namespace FluentCassandra.Test.Types
9 9
 {
10 10
 	[TestClass]
11 11
 	public class UTF8TypeTest
64  FluentCassandra.Test/_CassandraSetup.cs
... ...
@@ -0,0 +1,64 @@
  1
+using System;
  2
+using System.Collections.Generic;
  3
+using System.Linq;
  4
+using System.Text;
  5
+using FluentCassandra.Types;
  6
+using Apache.Cassandra;
  7
+
  8
+namespace FluentCassandra.Test
  9
+{
  10
+	internal class _CassandraSetup
  11
+	{
  12
+		public CassandraContext DB;
  13
+		public CassandraColumnFamily<AsciiType> Family;
  14
+		public CassandraSuperColumnFamily<AsciiType, AsciiType> SuperFamily;
  15
+
  16
+		public const string TestKey = "Test1";
  17
+		public const string TestStandardName = "Test1";
  18
+		public const string TestSuperName = "SubTest1";
  19
+
  20
+		public _CassandraSetup()
  21
+		{
  22
+			var keyspace = "Testing";
  23
+			var server = new Server("localhost");
  24
+
  25
+			var ksDef = new KsDef {
  26
+				Name = "Testing",
  27
+				Replication_factor = 1,
  28
+				Strategy_class = "org.apache.cassandra.locator.RackUnawareStrategy",
  29
+				Cf_defs = new List<CfDef>()
  30
+			};
  31
+
  32
+			ksDef.Cf_defs.Add(new CfDef {
  33
+				Name = TestStandardName,
  34
+				Keyspace = "Testing",
  35
+				Column_type = "Standard",
  36
+				Comparator_type = "AsciiType",
  37
+				Comment = "Used for testing Standard family."
  38
+			});
  39
+
  40
+			ksDef.Cf_defs.Add(new CfDef {
  41
+				Name = TestSuperName,
  42
+				Keyspace = "Testing",
  43
+				Column_type = "Super",
  44
+				Comparator_type = "AsciiType",
  45
+				Subcomparator_type = "AsciiType",
  46
+				Comment = "Used for testing Super family."
  47
+			});
  48
+
  49
+			CassandraSession.AddKeyspace(server, ksDef);
  50
+
  51
+			DB = new CassandraContext(keyspace, server);
  52
+			Family = DB.GetColumnFamily<AsciiType>("Standard");
  53
+			SuperFamily = DB.GetColumnFamily<AsciiType, AsciiType>("Super");
  54
+
  55
+			Family.InsertColumn(TestKey, "Test1", Math.PI);
  56
+			Family.InsertColumn(TestKey, "Test2", Math.PI);
  57
+			Family.InsertColumn(TestKey, "Test3", Math.PI);
  58
+
  59
+			SuperFamily.InsertColumn(TestKey, TestSuperName, "Test1", Math.PI);
  60
+			SuperFamily.InsertColumn(TestKey, TestSuperName, "Test2", Math.PI);
  61
+			SuperFamily.InsertColumn(TestKey, TestSuperName, "Test3", Math.PI);
  62
+		}
  63
+	}
  64
+}
110  FluentCassandra/Apache/Cassandra/Cassandra.cs
@@ -30,12 +30,12 @@ public interface Iface {
30 30
       void batch_mutate(Dictionary<byte[], Dictionary<string, List<Mutation>>> mutation_map, ConsistencyLevel consistency_level);
31 31
       void truncate(string cfname);
32 32
       Dictionary<string, List<string>> check_schema_agreement();
33  
-      THashSet<string> describe_keyspaces();
  33
+      List<KsDef> describe_keyspaces();
34 34
       string describe_cluster_name();
35 35
       string describe_version();
36 36
       List<TokenRange> describe_ring(string keyspace);
37 37
       string describe_partitioner();
38  
-      Dictionary<string, Dictionary<string, string>> describe_keyspace(string keyspace);
  38
+      KsDef describe_keyspace(string keyspace);
39 39
       List<string> describe_splits(string keyspace, string cfName, string start_token, string end_token, int keys_per_split);
40 40
       string system_add_column_family(CfDef cf_def);
41 41
       string system_drop_column_family(string column_family);
@@ -655,7 +655,7 @@ public void send_check_schema_agreement()
655 655
         throw new TApplicationException(TApplicationException.ExceptionType.MissingResult, "check_schema_agreement failed: unknown result");
656 656
       }
657 657
 
658  
-      public THashSet<string> describe_keyspaces()
  658
+      public List<KsDef> describe_keyspaces()
659 659
       {
660 660
         send_describe_keyspaces();
661 661
         return recv_describe_keyspaces();
@@ -670,7 +670,7 @@ public void send_describe_keyspaces()
670 670
         oprot_.Transport.Flush();
671 671
       }
672 672
 
673  
-      public THashSet<string> recv_describe_keyspaces()
  673
+      public List<KsDef> recv_describe_keyspaces()
674 674
       {
675 675
         TMessage msg = iprot_.ReadMessageBegin();
676 676
         if (msg.Type == TMessageType.Exception) {
@@ -819,7 +819,7 @@ public string recv_describe_partitioner()
819 819
         throw new TApplicationException(TApplicationException.ExceptionType.MissingResult, "describe_partitioner failed: unknown result");
820 820
       }
821 821
 
822  
-      public Dictionary<string, Dictionary<string, string>> describe_keyspace(string keyspace)
  822
+      public KsDef describe_keyspace(string keyspace)
823 823
       {
824 824
         send_describe_keyspace(keyspace);
825 825
         return recv_describe_keyspace();
@@ -835,7 +835,7 @@ public void send_describe_keyspace(string keyspace)
835 835
         oprot_.Transport.Flush();
836 836
       }
837 837
 
838  
-      public Dictionary<string, Dictionary<string, string>> recv_describe_keyspace()
  838
+      public KsDef recv_describe_keyspace()
839 839
       {
840 840
         TMessage msg = iprot_.ReadMessageBegin();
841 841
         if (msg.Type == TMessageType.Exception) {
@@ -6380,9 +6380,9 @@ public void Read (TProtocol iprot)
6380 6380
     [Serializable]
6381 6381
     public partial class describe_keyspaces_result : TBase
6382 6382
     {
6383  
-      private THashSet<string> success;
  6383
+      private List<KsDef> success;
6384 6384
 
6385  
-      public THashSet<string> Success
  6385
+      public List<KsDef> Success
6386 6386
       {
6387 6387
         get
6388 6388
         {
@@ -6418,17 +6418,18 @@ public void Read (TProtocol iprot)
6418 6418
           switch (field.ID)
6419 6419
           {
6420 6420
             case 0:
6421  
-              if (field.Type == TType.Set) {
  6421
+              if (field.Type == TType.List) {
6422 6422
                 {
6423  
-                  this.success = new THashSet<string>();
6424  
-                  TSet _set95 = iprot.ReadSetBegin();
6425  
-                  for( int _i96 = 0; _i96 < _set95.Count; ++_i96)
  6423
+                  this.success = new List<KsDef>();
  6424
+                  TList _list95 = iprot.ReadListBegin();
  6425
+                  for( int _i96 = 0; _i96 < _list95.Count; ++_i96)
6426 6426
                   {
6427  
-                    string _elem97 = null;
6428  
-                    _elem97 = iprot.ReadString();
  6427
+                    KsDef _elem97 = new KsDef();
  6428
+                    _elem97 = new KsDef();
  6429
+                    _elem97.Read(iprot);
6429 6430
                     this.success.Add(_elem97);
6430 6431
                   }
6431  
-                  iprot.ReadSetEnd();
  6432
+                  iprot.ReadListEnd();
6432 6433
                 }
6433 6434
                 this.__isset.success = true;
6434 6435
               } else { 
@@ -6452,15 +6453,15 @@ public void Read (TProtocol iprot)
6452 6453
         if (this.__isset.success) {
6453 6454
           if (this.success != null) {
6454 6455
             field.Name = "success";
6455  
-            field.Type = TType.Set;
  6456
+            field.Type = TType.List;
6456 6457
             field.ID = 0;
6457 6458
             oprot.WriteFieldBegin(field);
6458 6459
             {
6459  
-              oprot.WriteSetBegin(new TSet(TType.String, this.success.Count));
6460  
-              foreach (string _iter98 in this.success)
  6460
+              oprot.WriteListBegin(new TList(TType.Struct, this.success.Count));
  6461
+              foreach (KsDef _iter98 in this.success)
6461 6462
               {
6462  
-                oprot.WriteString(_iter98);
6463  
-                oprot.WriteSetEnd();
  6463
+                _iter98.Write(oprot);
  6464
+                oprot.WriteListEnd();
6464 6465
               }
6465 6466
             }
6466 6467
             oprot.WriteFieldEnd();
@@ -7185,10 +7186,10 @@ public void Read (TProtocol iprot)
7185 7186
     [Serializable]
7186 7187
     public partial class describe_keyspace_result : TBase
7187 7188
     {
7188  
-      private Dictionary<string, Dictionary<string, string>> success;
  7189
+      private KsDef success;
7189 7190
       private NotFoundException nfe;
7190 7191
 
7191  
-      public Dictionary<string, Dictionary<string, string>> Success
  7192
+      public KsDef Success
7192 7193
       {
7193 7194
         get
7194 7195
         {
@@ -7238,32 +7239,9 @@ public void Read (TProtocol iprot)
7238 7239
           switch (field.ID)
7239 7240
           {
7240 7241
             case 0:
7241  
-              if (field.Type == TType.Map) {
7242  
-                {
7243  
-                  this.success = new Dictionary<string, Dictionary<string, string>>();
7244  
-                  TMap _map103 = iprot.ReadMapBegin();
7245  
-                  for( int _i104 = 0; _i104 < _map103.Count; ++_i104)
7246  
-                  {
7247  
-                    string _key105;
7248  
-                    Dictionary<string, string> _val106;
7249  
-                    _key105 = iprot.ReadString();
7250  
-                    {
7251  
-                      _val106 = new Dictionary<string, string>();
7252  
-                      TMap _map107 = iprot.ReadMapBegin();
7253  
-                      for( int _i108 = 0; _i108 < _map107.Count; ++_i108)
7254  
-                      {
7255  
-                        string _key109;
7256  
-                        string _val110;
7257  
-                        _key109 = iprot.ReadString();
7258  
-                        _val110 = iprot.ReadString();
7259  
-                        _val106[_key109] = _val110;
7260  
-                      }
7261  
-                      iprot.ReadMapEnd();
7262  
-                    }
7263  
-                    this.success[_key105] = _val106;
7264  
-                  }
7265  
-                  iprot.ReadMapEnd();
7266  
-                }
  7242
+              if (field.Type == TType.Struct) {
  7243
+                this.success = new KsDef();
  7244
+                this.success.Read(iprot);
7267 7245
                 this.__isset.success = true;
7268 7246
               } else { 
7269 7247
                 TProtocolUtil.Skip(iprot, field.Type);
@@ -7295,26 +7273,10 @@ public void Read (TProtocol iprot)
7295 7273
         if (this.__isset.success) {
7296 7274
           if (this.success != null) {
7297 7275
             field.Name = "success";
7298  
-            field.Type = TType.Map;
  7276
+            field.Type = TType.Struct;
7299 7277
             field.ID = 0;
7300 7278
             oprot.WriteFieldBegin(field);
7301  
-            {
7302  
-              oprot.WriteMapBegin(new TMap(TType.String, TType.Map, this.success.Count));
7303  
-              foreach (string _iter111 in this.success.Keys)
7304  
-              {
7305  
-                oprot.WriteString(_iter111);
7306  
-                {
7307  
-                  oprot.WriteMapBegin(new TMap(TType.String, TType.String, this.success[_iter111].Count));
7308  
-                  foreach (string _iter112 in this.success[_iter111].Keys)
7309  
-                  {
7310  
-                    oprot.WriteString(_iter112);
7311  
-                    oprot.WriteString(this.success[_iter111][_iter112]);
7312  
-                    oprot.WriteMapEnd();
7313  
-                  }
7314  
-                }
7315  
-                oprot.WriteMapEnd();
7316  
-              }
7317  
-            }
  7279
+            this.success.Write(oprot);
7318 7280
             oprot.WriteFieldEnd();
7319 7281
           }
7320 7282
         } else if (this.__isset.nfe) {
@@ -7334,7 +7296,7 @@ public void Read (TProtocol iprot)
7334 7296
       public override string ToString() {
7335 7297
         StringBuilder sb = new StringBuilder("describe_keyspace_result(");
7336 7298
         sb.Append("success: ");
7337  
-        sb.Append(this.success);
  7299
+        sb.Append(this.success== null ? "<null>" : this.success.ToString());
7338 7300
         sb.Append(",nfe: ");
7339 7301
         sb.Append(this.nfe== null ? "<null>" : this.nfe.ToString());
7340 7302
         sb.Append(")");
@@ -7604,12 +7566,12 @@ public void Read (TProtocol iprot)
7604 7566
               if (field.Type == TType.List) {
7605 7567
                 {
7606 7568
                   this.success = new List<string>();
7607  
-                  TList _list113 = iprot.ReadListBegin();
7608  
-                  for( int _i114 = 0; _i114 < _list113.Count; ++_i114)
  7569
+                  TList _list103 = iprot.ReadListBegin();
  7570
+                  for( int _i104 = 0; _i104 < _list103.Count; ++_i104)
7609 7571
                   {
7610  
-                    string _elem115 = null;
7611  
-                    _elem115 = iprot.ReadString();
7612  
-                    this.success.Add(_elem115);
  7572
+                    string _elem105 = null;
  7573
+                    _elem105 = iprot.ReadString();
  7574
+                    this.success.Add(_elem105);
7613 7575
                   }
7614 7576
                   iprot.ReadListEnd();
7615 7577
                 }
@@ -7640,9 +7602,9 @@ public void Read (TProtocol iprot)
7640 7602
             oprot.WriteFieldBegin(field);
7641 7603
             {
7642 7604
               oprot.WriteListBegin(new TList(TType.String, this.success.Count));
7643  
-              foreach (string _iter116 in this.success)
  7605
+              foreach (string _iter106 in this.success)
7644 7606
               {
7645  
-                oprot.WriteString(_iter116);
  7607
+                oprot.WriteString(_iter106);
7646 7608
                 oprot.WriteListEnd();
7647 7609
               }
7648 7610
             }
2  FluentCassandra/Apache/Cassandra/Constants.cs
@@ -15,6 +15,6 @@ namespace Apache.Cassandra
15 15
 {
16 16
   public class Constants
17 17
   {
18  
-    public static string VERSION = "10.0.0";
  18
+    public static string VERSION = "11.1.0";
19 19
   }
20 20
 }
4  FluentCassandra/Apache/Cassandra/IndexOperator.cs
@@ -9,5 +9,9 @@ namespace Apache.Cassandra
9 9
   public enum IndexOperator
10 10
   {
11 11
     EQ = 0,
  12
+    GTE = 1,
  13
+    GT = 2,
  14
+    LTE = 3,
  15
+    LT = 4,
12 16
   }
13 17
 }
18  FluentCassandra/CassandraContext.cs
@@ -26,6 +26,15 @@ public static ConnectionBuilder CurrentConnectionBuilder
26 26
 		/// 
27 27
 		/// </summary>
28 28
 		/// <param name="keyspace"></param>
  29
+		/// <param name="server"></param>
  30
+		/// <param name="timeout"></param>
  31
+		public CassandraContext(string keyspace, Server server, int timeout = 0)
  32
+			: this(keyspace, server.Host, server.Port, timeout) { }
  33
+
  34
+		/// <summary>
  35
+		/// 
  36
+		/// </summary>
  37
+		/// <param name="keyspace"></param>
29 38
 		/// <param name="host"></param>
30 39
 		/// <param name="port"></param>
31 40
 		/// <param name="timeout"></param>
@@ -192,10 +201,13 @@ public void Dispose()
192 201
 		/// </param>
193 202
 		protected virtual void Dispose(bool disposing)
194 203
 		{
195  
-			if (!this._disposed && disposing && CassandraSession.Current != null)
  204
+			if (!_disposed && disposing && CassandraSession.Current != null)
  205
+			{
  206
+				CassandraSession.Current.Dispose();
196 207
 				CassandraSession.Current = null;
  208
+			}
197 209
 
198  
-			this._disposed = true;
  210
+			_disposed = true;
199 211
 		}
200 212
 
201 213
 		/// <summary>
@@ -203,7 +215,7 @@ protected virtual void Dispose(bool disposing)
203 215
 		/// </summary>
204 216
 		~CassandraContext()
205 217
 		{
206  
-			this.Dispose(false);
  218
+			Dispose(false);
207 219
 		}
208 220
 
209 221
 		#endregion
69  FluentCassandra/CassandraSession.cs
@@ -17,9 +17,61 @@ public static CassandraSession Current
17 17
 			internal set { _current = value; }
18 18
 		}
19 19
 
  20
+		#region Cassandra System For Server
  21
+
  22
+		public static string AddColumnFamily(Server server, CfDef definition)
  23
+		{
  24
+			using (var session = new CassandraSession(server))
  25
+			{
  26
+				return session.GetClient().system_add_column_family(definition);
  27
+			}
  28
+		}
  29
+
  30
+		public static string DropColumnFamily(Server server, string columnFamily)
  31
+		{
  32
+			using (var session = new CassandraSession(server))
  33
+			{
  34
+				return session.GetClient().system_drop_column_family(columnFamily);
  35
+			}
  36
+		}
  37
+
  38
+		public static string RenameColumnFamily(Server server, string oldColumnFamily, string newColumnFamily)
  39
+		{
  40
+			using (var session = new CassandraSession(server))
  41
+			{
  42
+				return session.GetClient().system_rename_column_family(oldColumnFamily, newColumnFamily);
  43
+			}
  44
+		}
  45
+
  46
+		public static string AddKeyspace(Server server, KsDef definition)
  47
+		{
  48
+			using (var session = new CassandraSession(server))
  49
+			{
  50
+				return session.GetClient().system_add_keyspace(definition);
  51
+			}
  52
+		}
  53
+
  54
+		public static string DropKeyspace(Server server, string keyspace)
  55
+		{
  56
+			using (var session = new CassandraSession(server))
  57
+			{
  58
+				return session.GetClient().system_drop_keyspace(keyspace);
  59
+			}
  60
+		}
  61
+
  62
+		public static string RenameKeyspace(Server server, string oldKeyspace, string newKeyspace)
  63
+		{
  64
+			using (var session = new CassandraSession(server))
  65
+			{
  66
+				return session.GetClient().system_rename_keyspace(oldKeyspace, newKeyspace);
  67
+			}
  68
+		}
  69
+
  70
+		#endregion
  71
+
20 72
 		#region Cassandra Descriptions For Server
21 73
 
22  
-		public static IEnumerable<CassandraKeyspace> DescribeKeyspacesFor(Server server)
  74
+		public static IEnumerable<CassandraKeyspace> DescribeKeyspaces(Server server)
23 75
 		{
24 76
 			using (var session = new CassandraSession(server))
25 77
 			{
@@ -30,7 +82,7 @@ public static IEnumerable<CassandraKeyspace> DescribeKeyspacesFor(Server server)
30 82
 			}
31 83
 		}
32 84
 
33  
-		public static string DescribeClusterNameFor(Server server)
  85
+		public static string DescribeClusterName(Server server)
34 86
 		{
35 87
 			using (var session = new CassandraSession(server))
36 88
 			{
@@ -39,7 +91,7 @@ public static string DescribeClusterNameFor(Server server)
39 91
 			}
40 92
 		}
41 93
 
42  
-		public static string DescribeVersionFor(Server server)
  94
+		public static string DescribeVersion(Server server)
43 95
 		{
44 96
 			using (var session = new CassandraSession(server))
45 97
 			{
@@ -48,7 +100,7 @@ public static string DescribeVersionFor(Server server)
48 100
 			}
49 101
 		}
50 102
 
51  
-		public static string DescribePartitionerFor(Server server)
  103
+		public static string DescribePartitioner(Server server)
52 104
 		{
53 105
 			using (var session = new CassandraSession(server))
54 106
 			{
@@ -85,7 +137,6 @@ public CassandraSession(IConnectionProvider connectionProvider, ConsistencyLevel
85 137
 		}
86 138
 
87 139
 		public CassandraSession(Server server)
88  
-			: this()
89 140
 		{
90 141
 			_connection = new Connection(server);
91 142
 		}
@@ -116,8 +167,14 @@ public CassandraSession(Server server)
116 167
 		/// <returns></returns>
117 168
 		internal Cassandra.Client GetClient()
118 169
 		{
119  
-			if (_connection == null || !_connection.IsOpen)
  170
+			if (_connection == null)
  171
+			{
120 172
 				_connection = ConnectionProvider.Open();
  173
+				_connection.SetKeyspace(Keyspace.KeyspaceName);
  174
+			}
  175
+
  176
+			if (!_connection.IsOpen)
  177
+				_connection.Open();
121 178
 
122 179
 			return _connection.Client;
123 180
 		}
26  FluentCassandra/Connection/Connection.cs
@@ -2,6 +2,7 @@
2 2
 using Thrift.Transport;
3 3
 using Thrift.Protocol;
4 4
 using Apache.Cassandra;
  5
+using System.Net.Sockets;
5 6
 
6 7
 namespace FluentCassandra
7 8
 {
@@ -28,7 +29,17 @@ internal Connection(Server server, int timeout = 0)
28 29
 			Server = server;
29 30
 			Timeout = timeout;
30 31
 
31  
-			_transport = new TSocket(Server.Host, Server.Port, Timeout);
  32
+			//TcpClient client = new TcpClient(server.Host, server.Port);
  33
+			//client.NoDelay = true;
  34
+			//client.SendBufferSize = timeout;
  35
+			//client.ReceiveTimeout = timeout;
  36
+
  37
+			//TTransport socket = new TSocket(client);
  38
+
  39
+			TTransport socket = new TSocket(server.Host, server.Port, timeout);
  40
+			_transport = new TFramedTransport(socket);
  41
+
  42
+			//_transport = socket;
32 43
 			_protocol = new TBinaryProtocol(_transport);
33 44
 			_client = new Cassandra.Client(_protocol);
34 45
 		}
@@ -90,6 +101,11 @@ public void Close()
90 101
 			_transport.Close();
91 102
 		}
92 103
 
  104
+		public void SetKeyspace(string keyspace) 
  105
+		{
  106
+			Client.set_keyspace(keyspace);
  107
+		}
  108
+
93 109
 		/// <summary>
94 110
 		/// 
95 111
 		/// </summary>
@@ -99,6 +115,14 @@ public Cassandra.Client Client
99 115
 		}
100 116
 
101 117
 		/// <summary>
  118
+		/// 
  119
+		/// </summary>
  120
+		public override string ToString()
  121
+		{
  122
+			return String.Format("{0}/{1}", Server, Created);
  123
+		}
  124
+
  125
+		/// <summary>
102 126
 		/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
103 127
 		/// </summary>
104 128
 		public void Dispose()
10  FluentCassandra/Connection/ConnectionProvider.cs
@@ -30,20 +30,12 @@ protected ConnectionProvider(ConnectionBuilder builder)
30 30
 		/// <summary>
31 31
 		/// 
32 32
 		/// </summary>
33  
-		/// <param name="connection"></param>
34  
-		public virtual void SetKeyspace(IConnection connection)
35  
-		{
36  
-			connection.Client.set_keyspace(Builder.Keyspace);
37  
-		}
38  
-
39  
-		/// <summary>
40  
-		/// 
41  
-		/// </summary>
42 33
 		/// <returns></returns>
43 34
 		public virtual IConnection Open()
44 35
 		{
45 36
 			var conn = CreateConnection();
46 37
 			conn.Open();
  38
+
47 39
 			return conn;
48 40
 		}
49 41
 
2  FluentCassandra/Connection/IConnection.cs
@@ -14,6 +14,8 @@ public interface IConnection : IDisposable
14 14
 		Server Server { get; }
15 15
 		Cassandra.Client Client { get; }
16 16
 
  17
+		void SetKeyspace(string keyspace);
  18
+
17 19
 		void Open();
18 20
 		void Close();
19 21
 	}
6  FluentCassandra/Connection/NormalConnectionProvider.cs
... ...
@@ -1,10 +1,6 @@
1 1
 using System;
2 2
 using System.Collections.Generic;
3  
-using System.Linq;
4  
-using System.Text;
5 3
 using System.Net.Sockets;
6  
-using System.Collections.Concurrent;
7  
-using System.Collections;
8 4
 
9 5
 namespace FluentCassandra
10 6
 {
@@ -89,8 +85,6 @@ public override IConnection CreateConnection()
89 85
 			var server = Builder.Servers[_random.Next(ActiveServers.Count)];
90 86
 			var conn = new Connection(server, Timeout);
91 87
 
92  
-			SetKeyspace(conn);
93  
-			
94 88
 			return conn;
95 89
 		}
96 90
 	}
3  FluentCassandra/Operations/ColumnFamilyOperation.cs
@@ -3,6 +3,7 @@
3 3
 using System.Linq;
4 4
 using System.Text;
5 5
 using Apache.Cassandra;
  6
+using System.Diagnostics;
6 7
 
7 8
 namespace FluentCassandra.Operations
8 9
 {
@@ -25,6 +26,8 @@ public virtual bool TryExecute(BaseCassandraColumnFamily columnFamily, out TResu
25 26
 			}
26 27
 			catch (Exception exc)
27 28
 			{
  29
+				Debug.WriteLine(exc);
  30
+
28 31
 				result = default(TResult);
29 32
 				HasError = true;
30 33
 				Error = new CassandraException(exc.Message, exc);

0 notes on commit 50d830b

Please sign in to comment.
Something went wrong with that request. Please try again.