Example #1
0
        /**
         * Gets the range end of the given prefix.
         *
         * <p>The range end is the key plus one (e.g., "aa"+1 == "ab", "a\xff"+1 == "b").
         *
         * @param prefix the given prefix
         * @return the range end of the given prefix
         */
        public static ByteSequence PrefixEndOf(ByteSequence prefix)
        {
            byte[] endKey = (byte[])prefix.getBytes().Clone();
            for (int i = endKey.Length - 1; i >= 0; i--)
            {
                if (endKey[i] < 0xff)
                {
                    endKey[i] = (byte)(endKey[i] + 1);
                    byte[] dest = new byte[endKey.Length - i - 1];
                    Array.Copy(endKey, i + 1, dest, 0, dest.Length);
                    return(ByteSequence.from(dest));
                }
            }

            return(ByteSequence.from(NO_PREFIX_END));
        }
Example #2
0
 /**
  * Cmp on the <i>value</i>.
  *
  * @param value the value to compare
  * @return the value compare target
  */
 public static ValueCmpTarget Value(ByteSequence value)
 {
     return(new ValueCmpTarget(ByteString.CopyFrom(value.getBytes())));
 }
Example #3
0
 public Cmp(ByteSequence key, Op compareOp, CmpTarget <T> target)
 {
     this.key    = ByteString.CopyFrom(key.getBytes());
     this.op     = compareOp;
     this.target = target;
 }
Example #4
0
 public static DeleteOp delete(ByteSequence key, DeleteOption option)
 {
     return(new DeleteOp(ByteString.CopyFrom(key.getBytes()), option));
 }
Example #5
0
 public static GetOp get(ByteSequence key, GetOption option)
 {
     return(new GetOp(ByteString.CopyFrom(key.getBytes()), option));
 }
Example #6
0
 public static PutOp Put(ByteSequence key, ByteSequence value, PutOption option)
 {
     return(new PutOp(ByteString.CopyFrom(key.getBytes()), ByteString.CopyFrom(value.getBytes()),
                      option));
 }