StringRangeParams is a convenient way to specify the string parameters for iteration when using Table.GetKeyIterator(StringRangeParams), Table.GetKeyValueIterator(StringRangeParams) and Table.Count(StringRangeParams).

The supported parameters are: prefix start key end key direction

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

The default values are empty strings and forward iteration.

 public StringKeyIterator(Table table, StringRangeParams ps)
 {
     this.table            = table;
     this.startKey         = ps.startKey;
     this.endKey           = ps.endKey;
     this.prefix           = ps.prefix;
     this.count            = ps.count;
     this.forwardDirection = ps.forwardDirection;
     this.granularity      = ps.granularity;
     Query(false);
 }
Exemple #2
0
        public void PerformListTest(Table tbl, StringRangeParams ps, uint expected)
        {
            int cnt;

            cnt = 0;
            foreach (String key in tbl.GetKeyIterator(ps))
            {
                //Console.WriteLine(key);
                cnt++;
            }
            Console.WriteLine("Expecting {0}, received {1}", expected, cnt);
            Assert.IsTrue(expected == cnt);

            cnt = 0;
            foreach (KeyValuePair<string, string> kv in tbl.GetKeyValueIterator(ps))
            {
                cnt++;
            }
            Console.WriteLine("Expecting {0}, received {1}", expected, cnt);
            Assert.IsTrue(expected == cnt);
        }
Exemple #3
0
        public void ListTest7(Table tbl, uint num)
        {
            uint count = 1234;

            StringRangeParams ps = new StringRangeParams();
            ps.Backward();
            ps.Count(count);

            uint expected = count;
            PerformListTest(tbl, ps, expected);
        }
Exemple #4
0
        public void ListTest9(Table tbl, uint num)
        {
            StringRangeParams ps = new StringRangeParams();
            ps.EndKey(Utils.Id(15000));
            ps.Backward();

            uint expected = num - 15000 - 1;
            PerformListTest(tbl, ps, expected);
        }
Exemple #5
0
 internal ulong Count(ulong tableID, StringRangeParams ps)
 {
     return(Count(tableID, ps.ToByteRangeParams()));
 }
Exemple #6
0
 public void ListTest5(Table tbl, uint num)
 {
     StringRangeParams ps = new StringRangeParams();
     ps.Backward();
     PerformListTest(tbl, ps, num);
 }
Exemple #7
0
        public void ListTest27(Table tbl, uint num)
        {
            for (uint i = num; i > 0; i -= 1000)
            {
                StringRangeParams ps = new StringRangeParams();
                ps.StartKey(Utils.Id(i));
                ps.EndKey(Utils.Id(i - 1000));
                ps.Backward();

                uint expected;
                if (i == 22000)
                    expected = 999;
                else
                    expected = 1000;
                PerformListTest(tbl, ps, expected);
            }
        }
Exemple #8
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.StringRangeParams"/>
 /// <seealso cref="Count(ByteRangeParams)"/>
 public virtual ulong Count(StringRangeParams ps)
 {
     return(client.Count(tableID, ps));
 }
Exemple #9
0
        public void ListTest25(Table tbl, uint num)
        {
            StringRangeParams ps = new StringRangeParams();
            ps.StartKey(Utils.Id(22000));
            ps.EndKey(Utils.Id(18000));
            ps.Backward();

            uint expected = 3999;
            PerformListTest(tbl, ps, expected);
        }
Exemple #10
0
        public void ListTest26(Table tbl, uint num)
        {
            for (uint i = 0; i < num; i += 1000)
            {
                StringRangeParams ps = new StringRangeParams();
                ps.StartKey(Utils.Id(i));
                ps.EndKey(Utils.Id(i + 1000));

                uint expected = 1000;
                PerformListTest(tbl, ps, expected);
            }
        }
Exemple #11
0
        public void ListTest22(Table tbl, uint num)
        {
            StringRangeParams ps = new StringRangeParams();
            ps.StartKey(Utils.Id(10000));
            ps.EndKey(Utils.Id(13000));

            uint expected = 3000;
            PerformListTest(tbl, ps, expected);
        }
Exemple #12
0
        public void ListTest19(Table tbl, uint num)
        {
            StringRangeParams ps = new StringRangeParams();
            ps.StartKey(Utils.Id(12000));
            ps.Prefix("0000000013");
            ps.Backward();

            uint expected = 0;
            PerformListTest(tbl, ps, expected);
        }
Exemple #13
0
        public void ListTest17(Table tbl, uint num)
        {
            StringRangeParams ps = new StringRangeParams();
            ps.Prefix("000000002");
            ps.Backward();

            uint expected = 2000;
            PerformListTest(tbl, ps, expected);
        }
Exemple #14
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.StringRangeParams"/>
 /// <seealso cref="Count(ByteRangeParams)"/>
 public ulong Count(StringRangeParams ps)
 {
     return client.Count(tableID, ps);
 }
Exemple #15
0
        public void ListTest29(Table tbl, uint num)
        {
            for (uint i = 0; i < (num/1000); i++)
            {
                StringRangeParams ps = new StringRangeParams();
                ps.Prefix("00000000" + i.ToString("D2"));
                ps.Backward();

                uint expected = 1000;
                PerformListTest(tbl, ps, expected);
            }
        }
Exemple #16
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.StringRangeParams"/>.</param>
 /// <returns>The iterator.</returns>
 /// <example><code>
 /// db = client.GetDatabase("testDatabase");
 /// table = db.GetTable("testTable");
 /// foreach (KeyValuePair&lt;string, string&gt; kv in table.GetKeyValueIterator(new StringRangeParams().Prefix("foo")))
 ///     System.Console.WriteLine(kv.Key + " => " + kv.Value);
 /// </code></example>
 /// <seealso cref="System.Collections.Generic.KeyValuePair{T, T}"/>
 /// <seealso cref="Scalien.StringRangeParams"/>
 /// <seealso cref="GetKeyValueIterator(ByteRangeParams)"/>
 /// <seealso cref="GetKeyIterator(StringRangeParams)"/>
 /// <seealso cref="GetKeyIterator(ByteRangeParams)"/>
 public StringKeyValueIterator GetKeyValueIterator(StringRangeParams ps)
 {
     return new StringKeyValueIterator(this, ps);
 }
Exemple #17
0
        public void ListTest3(Table tbl, uint num)
        {
            uint count = 100;

            StringRangeParams ps = new StringRangeParams();
            ps.StartKey(Utils.Id(100));
            ps.Count(count);
            ps.Backward();

            uint expected = count;
            PerformListTest(tbl, ps, expected);
        }
Exemple #18
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.StringRangeParams"/>.</param>
 /// <returns>The iterator.</returns>
 /// <example><code>
 /// db = client.GetDatabase("testDatabase");
 /// table = db.GetTable("testTable");
 /// foreach (KeyValuePair&lt;string, string&gt; kv in table.GetKeyValueIterator(new StringRangeParams().Prefix("foo")))
 ///     System.Console.WriteLine(kv.Key + " => " + kv.Value);
 /// </code></example>
 /// <seealso cref="System.Collections.Generic.KeyValuePair{T, T}"/>
 /// <seealso cref="Scalien.StringRangeParams"/>
 /// <seealso cref="GetKeyValueIterator(ByteRangeParams)"/>
 /// <seealso cref="GetKeyIterator(StringRangeParams)"/>
 /// <seealso cref="GetKeyIterator(ByteRangeParams)"/>
 public virtual StringKeyValueIterator GetKeyValueIterator(StringRangeParams ps)
 {
     return(new StringKeyValueIterator(this, ps));
 }
Exemple #19
0
 /// <summary>
 /// Return an iterator that will return only keys.
 /// </summary>
 /// <param name="ps">The parameters of iteration, as a <see cref="Scalien.StringRangeParams"/>.</param>
 /// <returns>The iterator.</returns>
 /// <example><code>
 /// db = client.GetDatabase("testDatabase");
 /// table = db.GetTable("testTable");
 /// foreach (string s in table.GetKeyIterator(new StringRangeParams().Prefix("foo")))
 ///     System.Console.WriteLine(s);
 /// </code></example>
 /// <seealso cref="Scalien.StringRangeParams"/>
 /// <seealso cref="GetKeyIterator(ByteRangeParams)"/>
 /// <seealso cref="GetKeyValueIterator(StringRangeParams)"/>
 /// <seealso cref="GetKeyValueIterator(ByteRangeParams)"/>
 public virtual StringKeyIterator GetKeyIterator(StringRangeParams ps)
 {
     return new StringKeyIterator(this, ps);
 }