public set_keyspace ( string keyspace ) : void | ||
keyspace | string | |
return | void |
private static void Main() { TTransport framedTransport = new TFramedTransport(new TSocket("localhost", 9160)); TTransport socketTransport = new TSocket("localhost", 9160); TProtocol framedProtocol = new TBinaryProtocol(framedTransport); TProtocol socketProtocol = new TBinaryProtocol(socketTransport); var client = new Cassandra.Client(framedProtocol, framedProtocol); // all framed //var client = new Cassandra.Client(socketProtocol, socketProtocol); // all socket //var client = new Cassandra.Client(framedProtocol, socketProtocol); // in: framed out: socket //var client = new Cassandra.Client(socketProtocol, framedProtocol); // in: socket out: framed framedTransport.Open(); socketTransport.Open(); Console.WriteLine("Start"); client.set_keyspace("Keyspace1"); Console.WriteLine("Count Key"); var key = Encoding.ASCII.GetBytes("MyKey"); var columns = new List<byte[]>(new[] { Encoding.ASCII.GetBytes("MyColumn") }); var column_parent = new ColumnParent { Column_family = "Standard1" }; var predicate = new SlicePredicate { Column_names = columns }; client.get_count(key, column_parent, predicate, ConsistencyLevel.ALL); Console.WriteLine("Done"); Console.Read(); }
public static Cassandra.Client GetClient() { if (_client == null) { if (_transport == null) _transport = new TFramedTransport(new TSocket("localhost", 9160)); var client = new Cassandra.Client(new TBinaryProtocol(_transport)); if (!_transport.IsOpen) { try { _transport.Open(); } catch (Exception e) { Utility.Logging("transport open fail:" + e.Message); } } if (!_setKeySpace) { client.set_keyspace(_keySpace); _setKeySpace = true; } //return client; _client = client; } return _client; }
public static Cassandra.Client GetWebClient() { var transport = new TFramedTransport(new TSocket("localhost", 9160)); var client = new Cassandra.Client(new TBinaryProtocol(transport)); transport.Open(); client.set_keyspace(_keySpace); return client; }
public static Cassandra.Client GetClient(string keyspace, ref TTransport transport) { TTransport frameTransport = new TFramedTransport(new TSocket("localhost", 9160)); TProtocol frameProtocol = new TBinaryProtocol(frameTransport); var client = new Cassandra.Client(frameProtocol, frameProtocol); frameTransport.Open(); client.set_keyspace(keyspace); transport = frameTransport; return client; }