SlicePredicate for data between dates with TimeUUID names

50 views
Skip to first unread message

Adrian Rodriguez

unread,
Mar 5, 2012, 8:57:30 PM3/5/12
to Scale 7 - Libraries and systems for scalable computing
I'm storing some data with TimeUUID type names. I want to return the
data in reverse order between two dates. Is this possible using
Pelops?

I've tried a few different values for the start and end names in
Selector.newColumnsPredicate, but nothing seem to be working. Am I
going about this the wrong way?

If anyone could share an example, that would be great.

Thanks!

Dan Washusen

unread,
Mar 5, 2012, 9:27:10 PM3/5/12
to sca...@googlegroups.com
Give the following a go:

final DateTime latest = new DateTime(2011, 1, 1, 12, 0, 0, 0, DateTimeZone.UTC);
final DateTime earliest = new DateTime(2011, 1, 1, 1, 0, 0, 0, DateTimeZone.UTC);

selector.getColumnsFromRow(
    columnFamily, fromUuid(parentId) /* row key */,
    Selector.newColumnsPredicate(
        Bytes.fromUuid(UuidHelper.nonUniqueTimeUuidForDate(latest)), // create a uuid instance for the provided date
        Bytes.fromUuid(UuidHelper.nonUniqueTimeUuidForDate(earliest)), 
        true, // reverse order
        1000 // get the first thousand
    ),
    ConsistencyLevel.ONE
);


-- 
Dan Washusen
Make big files fly

Adrian Rodriguez

unread,
Mar 6, 2012, 1:37:02 PM3/6/12
to sca...@googlegroups.com
Perfect! Thank you very much. I was at this for so long that the problem I was having was an iOS client sending seconds instead of milliseconds for timestamps so I never received any results. 
Reply all
Reply to author
Forward
0 new messages