GetKeyIterator() public method

Return an iterator that will return only keys.
public GetKeyIterator ( ByteRangeParams ps ) : ByteKeyIterator
ps ByteRangeParams The parameters of iteration, as a .
return ByteKeyIterator
示例#1
0
        public bool IsConsistent()
        {
            TestUser     user;
            TestUserInfo cmpinfo;

            byte[] row;

            // byte array?
            foreach (string key in table.GetKeyIterator(new StringRangeParams()))
            {
                user = GetUser(key);

                row = tableByNick.Get(System.Text.Encoding.UTF8.GetBytes(user.info.Nick + "|" + user.info.id.ToString()));
                if (row == null)
                {
                    return(false);
                }
                cmpinfo = Utils.JsonDeserialize <TestUserInfo>(row);
                if (user.info != cmpinfo)
                {
                    return(false);
                }

                row = tableByBirth.Get(System.Text.Encoding.UTF8.GetBytes(user.info.DateOfBirth + "|" + user.info.id.ToString()));
                if (row == null)
                {
                    return(false);
                }
                cmpinfo = Utils.JsonDeserialize <TestUserInfo>(row);
                if (user.info != cmpinfo)
                {
                    return(false);
                }

                row = tableByLastLogin.Get(System.Text.Encoding.UTF8.GetBytes(user.info.LastLogin + "|" + user.info.id.ToString()));
                if (row == null)
                {
                    return(false);
                }
                cmpinfo = Utils.JsonDeserialize <TestUserInfo>(row);
                if (user.info != cmpinfo)
                {
                    return(false);
                }
            }

            return(true);
        }
示例#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);
        }