You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Anthony Ikeda <an...@gmail.com> on 2011/09/02 03:27:54 UTC

Limiting ColumnSlice range in second composite value

My Column name is of Composite(TimeUUIDType, UTF8Type) and I can query
across the TimeUUIDs correctly, but now I want to also range across the UTF8
component. Is this possible?

UUID start = uuidForDate(new Date(1979, 1, 1));

UUID end = uuidForDate(new Date(Long.MAX_VALUE));

String startState = "";

String endState = "";

if (desiredState != null) {

    mLog.debug("Restricting state to [" + desiredState.getValue() + "]");

    startState = desiredState.getValue();

    endState = desiredState.getValue().concat("_");

}



Composite startComp = new Composite(start, startState);

Composite endComp = new Composite(end, endState);

query.setRange(startComp, endComp, true, count);


So far I'm not seeing any effect setting my "endState" String value.


Anthony

Re: Limiting ColumnSlice range in second composite value

Posted by Boris Yen <yu...@gmail.com>.
It seems that you did not set the
AbstractComposite.ComponentEquality.GREATER_THAN_EQUAL
to the endComp. You could try something like:

endComp=new Compsite() ;
endComp.addComponent(timeUUID) ;
endComp.addComponent("ACTIVE", StringSerializer.get(), "UTF8Type",
AbstractComposite.ComponentEquality.GREATER_THAN_EQUAL) ;

Hope this would help.

On Sat, Sep 3, 2011 at 6:54 AM, Anthony Ikeda
<an...@gmail.com>wrote:

> This is what I'm trying to do:
>
> Sample of the data:
> RowKey: localhost
> => (column=e3f3c900-d5b0-11e0-aa6b-005056c00008:ACTIVE, value=<?xml
> version="1.0" encoding="UTF-8" standalone="yes"?>,
> timestamp=1315001665761000)
> => (column=e4515250-d5b0-11e0-aa6b-005056c00008:INACTIVE, value=<?xml
> version="1.0" encoding="UTF-8" standalone="yes"?>,
> timestamp=1315001654271000)
> => (column=e45549f0-d5b0-11e0-aa6b-005056c00008:INACTIVE, value=<?xml
> version="1.0" encoding="UTF-8" standalone="yes"?>,
> timestamp=1315001654327000)
> => (column=e45cc400-d5b0-11e0-aa6b-005056c00008:INACTIVE, value=<?xml
> version="1.0" encoding="UTF-8" standalone="yes"?>,
> timestamp=1315001654355000)
> => (column=e462de80-d5b0-11e0-aa6b-005056c00008:INACTIVE, value=<?xml
> version="1.0" encoding="UTF-8" standalone="yes"?>,
> timestamp=1315001654394000)
>
>
> I'll be activating and deactivating the inactive profiles in a
> chronological order.
>
>
>    - So I want to first retrieve current "ACTIVE" record (easy cause it's
>    cached)
>    - Put it to use and when ready, recreate the column - same timeUUID but
>    "EXHAUSTED" status (delete then add)
>    - Next I have to fetch the first "INACTIVE" column after this, delete
>    that and re-create the record with an "ACTIVE" composite (same timeuuid,
>    again add then delete) and repeat the process.
>
>
> The second part of my composite is an ENUM of String literals:
> Status.ACTIVE, Status.INACTIVE, Status.EXHAUSTED
>
> I want to get the current row key of value (startTimeUUID, "ACTIVE") which
> should only be one column (provided the code works)
>
> All earlier columns are (timeUUID, "EXHAUSTED"), all later columns should
> be (timeUUID, "INACTIVE")
>
> I'm thinking to find the column that is "ACTIVE" I would set the range:
>
> startComp = new Composite(timeUUID, "ACTIVE");
> endComp = new Composite(timeUUID, ""ACTIVE_");
>
> query.setRange(startComp, endComp, false, 2); //Fetch 2 just in case
>
> To get all "INACTIVE" columns I'd use
> startComp = new Composite(timeUUID, "INACTIVE");
> endComp = new Composite(timeUUID, ""INACTIVE_");
>
> query.setRange(startComp, endComp, false, 10);
>
> Thing is I'm getting back all columns regardless of what I set for the
> second half of the composite. Is what I'm trying to do possible?
>
> Anthony
>
>
> On Fri, Sep 2, 2011 at 12:29 PM, Nate McCall <na...@datastax.com> wrote:
>
>> Instead of empty strings, try Character.[MAX|MIN-]_VALUE.
>>
>> On Thu, Sep 1, 2011 at 8:27 PM, Anthony Ikeda
>> <an...@gmail.com> wrote:
>> > My Column name is of Composite(TimeUUIDType, UTF8Type) and I can query
>> > across the TimeUUIDs correctly, but now I want to also range across the
>> UTF8
>> > component. Is this possible?
>> >
>> > UUID start = uuidForDate(new Date(1979, 1, 1));
>> >
>> > UUID end = uuidForDate(new Date(Long.MAX_VALUE));
>> >
>> > String startState = "";
>> >
>> > String endState = "";
>> >
>> > if (desiredState != null) {
>> >
>> >     mLog.debug("Restricting state to [" + desiredState.getValue() +
>> "]");
>> >
>> >     startState = desiredState.getValue();
>> >
>> >     endState = desiredState.getValue().concat("_");
>> >
>> > }
>> >
>> >
>> >
>> > Composite startComp = new Composite(start, startState);
>> >
>> > Composite endComp = new Composite(end, endState);
>> >
>> > query.setRange(startComp, endComp, true, count);
>> >
>> > So far I'm not seeing any effect setting my "endState" String value.
>> >
>> > Anthony
>>
>
>

Re: Limiting ColumnSlice range in second composite value

Posted by Anthony Ikeda <an...@gmail.com>.
Okay, I reversed the composite and seem to have come up with a solution.
Although the rows are sorted by the status, the statuses are sorted
temporally which helps. I tell you this type of modeling really breaks the
rules :)

Anthony


On Fri, Sep 2, 2011 at 3:54 PM, Anthony Ikeda
<an...@gmail.com>wrote:

> This is what I'm trying to do:
>
> Sample of the data:
> RowKey: localhost
> => (column=e3f3c900-d5b0-11e0-aa6b-005056c00008:ACTIVE, value=<?xml
> version="1.0" encoding="UTF-8" standalone="yes"?>,
> timestamp=1315001665761000)
> => (column=e4515250-d5b0-11e0-aa6b-005056c00008:INACTIVE, value=<?xml
> version="1.0" encoding="UTF-8" standalone="yes"?>,
> timestamp=1315001654271000)
> => (column=e45549f0-d5b0-11e0-aa6b-005056c00008:INACTIVE, value=<?xml
> version="1.0" encoding="UTF-8" standalone="yes"?>,
> timestamp=1315001654327000)
> => (column=e45cc400-d5b0-11e0-aa6b-005056c00008:INACTIVE, value=<?xml
> version="1.0" encoding="UTF-8" standalone="yes"?>,
> timestamp=1315001654355000)
> => (column=e462de80-d5b0-11e0-aa6b-005056c00008:INACTIVE, value=<?xml
> version="1.0" encoding="UTF-8" standalone="yes"?>,
> timestamp=1315001654394000)
>
>
> I'll be activating and deactivating the inactive profiles in a
> chronological order.
>
>
>    - So I want to first retrieve current "ACTIVE" record (easy cause it's
>    cached)
>    - Put it to use and when ready, recreate the column - same timeUUID but
>    "EXHAUSTED" status (delete then add)
>    - Next I have to fetch the first "INACTIVE" column after this, delete
>    that and re-create the record with an "ACTIVE" composite (same timeuuid,
>    again add then delete) and repeat the process.
>
>
> The second part of my composite is an ENUM of String literals:
> Status.ACTIVE, Status.INACTIVE, Status.EXHAUSTED
>
> I want to get the current row key of value (startTimeUUID, "ACTIVE") which
> should only be one column (provided the code works)
>
> All earlier columns are (timeUUID, "EXHAUSTED"), all later columns should
> be (timeUUID, "INACTIVE")
>
> I'm thinking to find the column that is "ACTIVE" I would set the range:
>
> startComp = new Composite(timeUUID, "ACTIVE");
> endComp = new Composite(timeUUID, ""ACTIVE_");
>
> query.setRange(startComp, endComp, false, 2); //Fetch 2 just in case
>
> To get all "INACTIVE" columns I'd use
> startComp = new Composite(timeUUID, "INACTIVE");
> endComp = new Composite(timeUUID, ""INACTIVE_");
>
> query.setRange(startComp, endComp, false, 10);
>
> Thing is I'm getting back all columns regardless of what I set for the
> second half of the composite. Is what I'm trying to do possible?
>
> Anthony
>
>
> On Fri, Sep 2, 2011 at 12:29 PM, Nate McCall <na...@datastax.com> wrote:
>
>> Instead of empty strings, try Character.[MAX|MIN-]_VALUE.
>>
>> On Thu, Sep 1, 2011 at 8:27 PM, Anthony Ikeda
>> <an...@gmail.com> wrote:
>> > My Column name is of Composite(TimeUUIDType, UTF8Type) and I can query
>> > across the TimeUUIDs correctly, but now I want to also range across the
>> UTF8
>> > component. Is this possible?
>> >
>> > UUID start = uuidForDate(new Date(1979, 1, 1));
>> >
>> > UUID end = uuidForDate(new Date(Long.MAX_VALUE));
>> >
>> > String startState = "";
>> >
>> > String endState = "";
>> >
>> > if (desiredState != null) {
>> >
>> >     mLog.debug("Restricting state to [" + desiredState.getValue() +
>> "]");
>> >
>> >     startState = desiredState.getValue();
>> >
>> >     endState = desiredState.getValue().concat("_");
>> >
>> > }
>> >
>> >
>> >
>> > Composite startComp = new Composite(start, startState);
>> >
>> > Composite endComp = new Composite(end, endState);
>> >
>> > query.setRange(startComp, endComp, true, count);
>> >
>> > So far I'm not seeing any effect setting my "endState" String value.
>> >
>> > Anthony
>>
>
>

Re: Limiting ColumnSlice range in second composite value

Posted by Anthony Ikeda <an...@gmail.com>.
This is what I'm trying to do:

Sample of the data:
RowKey: localhost
=> (column=e3f3c900-d5b0-11e0-aa6b-005056c00008:ACTIVE, value=<?xml
version="1.0" encoding="UTF-8" standalone="yes"?>,
timestamp=1315001665761000)
=> (column=e4515250-d5b0-11e0-aa6b-005056c00008:INACTIVE, value=<?xml
version="1.0" encoding="UTF-8" standalone="yes"?>,
timestamp=1315001654271000)
=> (column=e45549f0-d5b0-11e0-aa6b-005056c00008:INACTIVE, value=<?xml
version="1.0" encoding="UTF-8" standalone="yes"?>,
timestamp=1315001654327000)
=> (column=e45cc400-d5b0-11e0-aa6b-005056c00008:INACTIVE, value=<?xml
version="1.0" encoding="UTF-8" standalone="yes"?>,
timestamp=1315001654355000)
=> (column=e462de80-d5b0-11e0-aa6b-005056c00008:INACTIVE, value=<?xml
version="1.0" encoding="UTF-8" standalone="yes"?>,
timestamp=1315001654394000)


I'll be activating and deactivating the inactive profiles in a chronological
order.


   - So I want to first retrieve current "ACTIVE" record (easy cause it's
   cached)
   - Put it to use and when ready, recreate the column - same timeUUID but
   "EXHAUSTED" status (delete then add)
   - Next I have to fetch the first "INACTIVE" column after this, delete
   that and re-create the record with an "ACTIVE" composite (same timeuuid,
   again add then delete) and repeat the process.


The second part of my composite is an ENUM of String literals:
Status.ACTIVE, Status.INACTIVE, Status.EXHAUSTED

I want to get the current row key of value (startTimeUUID, "ACTIVE") which
should only be one column (provided the code works)

All earlier columns are (timeUUID, "EXHAUSTED"), all later columns should be
(timeUUID, "INACTIVE")

I'm thinking to find the column that is "ACTIVE" I would set the range:

startComp = new Composite(timeUUID, "ACTIVE");
endComp = new Composite(timeUUID, ""ACTIVE_");

query.setRange(startComp, endComp, false, 2); //Fetch 2 just in case

To get all "INACTIVE" columns I'd use
startComp = new Composite(timeUUID, "INACTIVE");
endComp = new Composite(timeUUID, ""INACTIVE_");

query.setRange(startComp, endComp, false, 10);

Thing is I'm getting back all columns regardless of what I set for the
second half of the composite. Is what I'm trying to do possible?

Anthony


On Fri, Sep 2, 2011 at 12:29 PM, Nate McCall <na...@datastax.com> wrote:

> Instead of empty strings, try Character.[MAX|MIN-]_VALUE.
>
> On Thu, Sep 1, 2011 at 8:27 PM, Anthony Ikeda
> <an...@gmail.com> wrote:
> > My Column name is of Composite(TimeUUIDType, UTF8Type) and I can query
> > across the TimeUUIDs correctly, but now I want to also range across the
> UTF8
> > component. Is this possible?
> >
> > UUID start = uuidForDate(new Date(1979, 1, 1));
> >
> > UUID end = uuidForDate(new Date(Long.MAX_VALUE));
> >
> > String startState = "";
> >
> > String endState = "";
> >
> > if (desiredState != null) {
> >
> >     mLog.debug("Restricting state to [" + desiredState.getValue() + "]");
> >
> >     startState = desiredState.getValue();
> >
> >     endState = desiredState.getValue().concat("_");
> >
> > }
> >
> >
> >
> > Composite startComp = new Composite(start, startState);
> >
> > Composite endComp = new Composite(end, endState);
> >
> > query.setRange(startComp, endComp, true, count);
> >
> > So far I'm not seeing any effect setting my "endState" String value.
> >
> > Anthony
>

Re: Limiting ColumnSlice range in second composite value

Posted by Nate McCall <na...@datastax.com>.
Instead of empty strings, try Character.[MAX|MIN-]_VALUE.

On Thu, Sep 1, 2011 at 8:27 PM, Anthony Ikeda
<an...@gmail.com> wrote:
> My Column name is of Composite(TimeUUIDType, UTF8Type) and I can query
> across the TimeUUIDs correctly, but now I want to also range across the UTF8
> component. Is this possible?
>
> UUID start = uuidForDate(new Date(1979, 1, 1));
>
> UUID end = uuidForDate(new Date(Long.MAX_VALUE));
>
> String startState = "";
>
> String endState = "";
>
> if (desiredState != null) {
>
>     mLog.debug("Restricting state to [" + desiredState.getValue() + "]");
>
>     startState = desiredState.getValue();
>
>     endState = desiredState.getValue().concat("_");
>
> }
>
>
>
> Composite startComp = new Composite(start, startState);
>
> Composite endComp = new Composite(end, endState);
>
> query.setRange(startComp, endComp, true, count);
>
> So far I'm not seeing any effect setting my "endState" String value.
>
> Anthony