incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nate McCall <n...@datastax.com>
Subject Re: Creating comparator of (Dynamic)CompositeType with cassandra-cli
Date Mon, 18 Jul 2011 22:37:12 GMT
Your comparator is looking for the empty string as the first component.

For what you are trying to do, you probably want the TimeUUID to be
first so you can specify the range for the first positions, then ""
and "|" (or similarly brute-ish ascii search hack which would include
all the values of this comparator) for the composites in the 2nd
position (start and end respectively). This would give you the
timeUUID range.



On Mon, Jul 18, 2011 at 2:19 PM, Anthony Ikeda
<anthony.ikeda.dev@gmail.com> wrote:
> It's okay, it seems that you need to enclose the comparator with single
> quotes.....<sigh>
>
> On another note, can ranges be set without based on just one components of a
> composite column name?
>
> I have a the Composite below in the previous email and want to return all my
> transaction columns for a particular date range:
>
> public Set<TransactionType> findTransactions(String listId, long startTime,
> long endTime) {
>         DynamicCompositeSerializer ds = new DynamicCompositeSerializer();
>         SliceQuery<String, DynamicComposite, String> transQuery =
> HFactory.createSliceQuery(getKeyspace(), mStringSerializer, ds,
> mStringSerializer);
>         transQuery.setKey(listId);
>         transQuery.setColumnFamily(CF_TRANSACTIONS);
>         DynamicComposite startRange = null;
>         DynamicComposite endRange = null;
>
>         if (startTime > 0) {
>             mLog.debug("Setting startRange with startTime[" + startTime +
> "]");
>             startRange = new DynamicComposite("", newTimeUUID(startTime));
>         } else {
>             mLog.debug("Setting startRange to beginning of time!");
>             startRange = new DynamicComposite("", new UUID(0, 0));
>         }
>
>         if (startTime > 0 && endTime > 0) {
>             mLog.debug("Setting startRange with endTime[" + endTime + "]");
>             endRange = new DynamicComposite("", newTimeUUID(endTime));
>         } else {
>             mLog.debug("Setting endRange to end of time!");
>             endRange = new DynamicComposite("", new UUID(Long.MAX_VALUE |
> Long.MIN_VALUE, Long.MAX_VALUE | Long.MIN_VALUE));
>         }
>
>         mLog.debug("Setting range...");
>         transQuery.setRange(startRange, endRange, false, 100000);
>
>         mLog.debug("Executing query...");
>         QueryResult<ColumnSlice<DynamicComposite, String>> queryResults
=
> transQuery.execute();
>
> }
>
> But I'm finding I'm just getting 0 results even if I use the values of
> beginning of time ("00000000-0000-0000-0000-000000000000") and end of time
> ("ffffffff-ffff-ffff-ffff-ffffffffffff")
>
> I want to slice only across the Time component of the Composite.
>
> Is this possible?
>
> Anthony
>
>
> On Mon, Jul 18, 2011 at 10:52 AM, Anthony Ikeda
> <anthony.ikeda.dev@gmail.com> wrote:
>>
>> Is this possible? I'm trying to create a Column Family with a
>> CompositeType comparator, but I keep getting an error:
>>
>> create column family Transactions with comparator =
>> CompositeType(UTF8Type, UUIDType) and keys_cached=10000 and
>> rows_cached=1000;
>> Syntax error at position 84: missing EOF at '('
>>
>> Same issue if I try with DynamicCompositeType:
>>
>> create column family Transactions with comparator =
>> DynamicCompositeType(s=>UTF8Type, u=>UUIDType) and keys_cached=10000 and
>> rows_cached=1000;
>> Syntax error at position 84: missing EOF at '('
>>
>> I'm using Cassandra 0.8.1
>>
>> Anthony
>>
>
>

Mime
View raw message