Apache.Cassandra.Cassandra.Client.get_count C# (CSharp) Method

get_count() public method

returns the number of columns matching predicate for a particular key, ColumnFamily and optionally SuperColumn.
public get_count ( byte key, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level ) : int
key byte
column_parent ColumnParent
predicate SlicePredicate
consistency_level ConsistencyLevel
return int
      public int get_count(byte[] key, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level)
      {
        #if !SILVERLIGHT
        send_get_count(key, column_parent, predicate, consistency_level);
        return recv_get_count();

        #else
        var asyncResult = Begin_get_count(null, null, key, column_parent, predicate, consistency_level);
        return End_get_count(asyncResult);

        #endif
      }
      #if SILVERLIGHT

Usage Example

Example #1
0
        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();
        }
Cassandra.Client