I had a question about using a Scan on part of a composite key. Say I have 
order line item rows, and the ID is order ID + line item ID. Each ID is a 
random string. I want to get all line items for an order with my Scan object.

Setting the startRow on Scan is easy enough, just set it to the order ID and 
leave off the line item ID. However, because endRow is exclusive, I need to 
come up with a key that is just past the order ID. This would be 
straightforward if the keys are numeric (just add one to the order ID), but 
becomes kind of a kludge when the keys are strings.

Right now I build the keys with a byte separator between the two strings and 
set it to 0 when storing. Then when I want to scan, I create the startRow with 
the Order ID + (byte)0, and the endRow with Order ID + (byte)1. Seems like kind 
of a waste to have that extra byte just for this purpose, though. Is there a 
better approach, like specifying the endRow inclusively?

Reply via email to