I'm encountering some problems w.r.t. variable-length keys and the DPL. The natural keys for one of my entities is a tuple of longs, but neither EntityStore or @KeyField allow anything but simple types.
Ideally, I'd like to be able to use a byte array, since we can use delta compression and variable-length encoding to reduce the size of the keys (and therefore fit more keys in the cache). But I can't find a way of doing this.
As you've discovered, it is not supported in the DPL currently. This has been asked several times before, for example: Re: Using a byte as a secondary index's key within the Collection's API Re: byte as primary key
When you say a tuple of longs I assume you mean a variable length tuple. In that case, you are correct that it is not supported. A fixed length tuple of longs is supported using @KeyField, but I think you already know that.
Using a string is possible, but has drawbacks (see 2nd link above). It works if you only use the lower 7-bits in each char in the string, which means that UTF-8 encoding will represent each char as one byte. This sacrifices 1/8 of your storage space, but may be the best option. Note that a zero char is represented as two bytes in UTF-8, so you may want to use char values from 1 to 0x7F.
I should add that a BigInteger key is also a possibility, see: Re: byte as primary key
With JE 5.0 a BigDecimal key is also a possibility, but the fact that trailing zeros after the decimal are stripped will probably be an issue. See the change log for pointers to the doc for this new feature. For details on the binary format see the javadoc package description of com.sleepycat.bind.tuple, and also the TupleInput and TupleOutput source code in that package if you're interested.