How to clear all keys in FoundationDB using Java?

There are possibly two problems:

  • "xFF" looks like a string of 3 characters x, F and F. You probably want "\u00FF" for a string with a single character (don’t know the string escaping rules for Clojure). This is one example where using strings to represent byte sequences is not always the best idea because 0xFF is not a valid Unicode character and can cause issues in most languages.
  • Tuple/from(...) uses the Tuple Layer encoding, which turns vectors of values into binary. For elements of type string, it adds a 0x02 byte prefix before the string (encoded as UTF8), and a 0x00 suffix.

So to sum up, you are calling clear with the range (in pseudo hexa): { 02 00 }{ 02 'x' 'F' 'F' 00 } which will delete all keys encoded as tuple, starting from the ( "", ) up ( “xFF”, ), leaving all keys(“xFF…”, )...(“zzzzz…”, )` alive.

If you want to erase all the keys in the database (not only the ones encoded as tuples), you need to use the empty byte array as the begin, and a byte array containing a single 255 as the end to get (in pseudo hexa): { }{ FF }. (don’t know the sequence for that in Clojure).

2 Likes