ByteRangeParams is a convenient way to specify the byte[] parameters for iteration when using Table.GetKeyIterator(ByteRangeParams), Table.GetKeyValueIterator(ByteRangeParams) and Table.Count(ByteRangeParams).

The supported parameters are: prefix start key end key count direction

ByteRangeParams is convenient because is uses chaining, so you can write expressions like new ByteRangeParams().Prefix(prefix).StartKey(startKey).EndKey(endKey).Count(count) and it returns the ByteRangeParam instance. Optionally call .Backward() to get a backward iterator.

The default values are empty byte arrays and forward iteration.

Ejemplo n.º 1
0
 public ByteKeyIterator(Table table, ByteRangeParams ps)
 {
     this.table            = table;
     this.startKey         = ps.startKey;
     this.endKey           = ps.endKey;
     this.prefix           = ps.prefix;
     this.count            = ps.count;
     this.granularity      = ps.granularity;
     this.forwardDirection = ps.forwardDirection;
     Query(false);
 }
Ejemplo n.º 2
0
        internal ulong Count(ulong tableID, ByteRangeParams ps)
        {
            int status;

            unsafe
            {
                fixed(byte *pStartKey = ps.startKey, pEndKey = ps.endKey, pPrefix = ps.prefix)
                {
                    IntPtr ipStartKey = new IntPtr(pStartKey);
                    IntPtr ipEndKey   = new IntPtr(pEndKey);
                    IntPtr ipPrefix   = new IntPtr(pPrefix);

                    status = scaliendb_client.SDBP_CountCStr(cptr, tableID, ipStartKey, ps.startKey.Length, ipEndKey, ps.endKey.Length, ipPrefix, ps.prefix.Length, ps.forwardDirection);
                }
            }

            CheckResultStatus(status);
            ulong number = result.GetNumber();

            result.Close();
            return(number);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Return an iterator that will return keys and values as a <see cref="System.Collections.Generic.KeyValuePair{T, T}"/>.
 /// </summary>
 /// <param name="ps">The parameters of iteration, as a <see cref="Scalien.ByteRangeParams"/>.</param>
 /// <returns>The iterator.</returns>
 /// <seealso cref="System.Collections.Generic.KeyValuePair{T, T}"/>
 /// <seealso cref="Scalien.ByteRangeParams"/>
 /// <seealso cref="GetKeyValueIterator(StringRangeParams)"/>
 /// <seealso cref="GetKeyIterator(StringRangeParams)"/>
 /// <seealso cref="GetKeyIterator(ByteRangeParams)"/>
 public virtual ByteKeyValueIterator GetKeyValueIterator(ByteRangeParams ps)
 {
     return(new ByteKeyValueIterator(this, ps));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Return the number of matching keys in the table.
 /// </summary>
 /// <param name="ps">The filter parameters.</param>
 /// <returns>The number of matching keys in the table.</returns>
 /// <exception cref="SDBPException"/>
 /// <seealso cref="Scalien.ByteRangeParams"/>
 /// <seealso cref="Count(StringRangeParams)"/>
 public virtual ulong Count(ByteRangeParams ps)
 {
     return(client.Count(tableID, ps));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Return an iterator that will return keys and values as a <see cref="System.Collections.Generic.KeyValuePair{T, T}"/>.
 /// </summary>
 /// <param name="ps">The parameters of iteration, as a <see cref="Scalien.ByteRangeParams"/>.</param>
 /// <returns>The iterator.</returns>
 /// <seealso cref="System.Collections.Generic.KeyValuePair{T, T}"/>
 /// <seealso cref="Scalien.ByteRangeParams"/>
 /// <seealso cref="GetKeyValueIterator(StringRangeParams)"/>
 /// <seealso cref="GetKeyIterator(StringRangeParams)"/>
 /// <seealso cref="GetKeyIterator(ByteRangeParams)"/>
 public ByteKeyValueIterator GetKeyValueIterator(ByteRangeParams ps)
 {
     return new ByteKeyValueIterator(this, ps);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Return the number of matching keys in the table.
 /// </summary>
 /// <param name="ps">The filter parameters.</param>
 /// <returns>The number of matching keys in the table.</returns>
 /// <exception cref="SDBPException"/>
 /// <seealso cref="Scalien.ByteRangeParams"/>
 /// <seealso cref="Count(StringRangeParams)"/>
 public ulong Count(ByteRangeParams ps)
 {
     return client.Count(tableID, ps);
 }
Ejemplo n.º 7
0
        public void ListTestLinq()
        {
            Client client = new Client(Utils.GetConfigNodes());
            Table table = client.GetDatabase("Benchmark").GetTable("transactionNetworkTransaction");
            byte[] prefix = Utils.StringToByteArray("N:0000000000000|T:000000");
            byte[] startKey = Utils.StringToByteArray("N:0000000000000|T:0000001250847|");
            var rangeParams = new ByteRangeParams().StartKey(startKey).Prefix(prefix);
            ByteKeyValueIterator iterator = table.GetKeyValueIterator(rangeParams);

            var list = new List<KeyValuePair<byte[], byte[]>>();
            list.AddRange(iterator.Select(kv => kv));
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Return an iterator that will return only keys.
 /// </summary>
 /// <param name="ps">The parameters of iteration, as a <see cref="Scalien.ByteRangeParams"/>.</param>
 /// <returns>The iterator.</returns>
 /// <seealso cref="Scalien.ByteRangeParams"/>
 /// <seealso cref="GetKeyIterator(ByteRangeParams)"/>
 /// <seealso cref="GetKeyValueIterator(StringRangeParams)"/>
 /// <seealso cref="GetKeyValueIterator(ByteRangeParams)"/>
 public virtual ByteKeyIterator GetKeyIterator(ByteRangeParams ps)
 {
     return new ByteKeyIterator(this, ps);
 }