You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by kevin <ke...@gmail.com> on 2009/10/26 00:17:25 UTC

are columns of a supercolumn name sorted?

i am inserting three columns x,a,z into a super column named 'sc_2'. the
config file says that the columns of a super column are timesorted, but when
i get_slice it is sorted by the name of the columns. how do i get it time
sorted so that i get the most recently inserted/updated column first?
cassandra version apache-cassandra-incubating-0.4.1-bin.tar.gz, and lazyboy
latest git clone.
thanks


>>> import lazyboy,time, pprint
>>> from cassandra import Cassandra
>>> from cassandra.ttypes import *


>>> client=lazyboy.connection.Client(['localhost:9160'])
>>> keyspace = "Keyspace1"
>>> key='mykeyx'
>>> column_path =
ColumnPath(column_family="Super1",column="x",super_column='sc_2')
>>> client.insert(keyspace, key, column_path, 'a', time.time(),
ConsistencyLevel.ONE);
>>> column_path =
ColumnPath(column_family="Super1",column="a",super_column='sc_2')
>>> client.insert(keyspace, key, column_path, 'a', time.time(),
ConsistencyLevel.ONE);
>>> column_path =
ColumnPath(column_family="Super1",column="z",super_column='sc_2')
>>> client.insert(keyspace, key, column_path, 'a', time.time(),
ConsistencyLevel.ONE);


>>> slice_range = SliceRange(start="", finish="")
>>> predicate = SlicePredicate(slice_range=slice_range)
>>> column_parent = ColumnParent(column_family="Super1")
>>> client.get_slice(keyspace, key, column_parent, predicate,
ConsistencyLevel.ONE)
[ColumnOrSuperColumn(column=None, super_column=SuperColumn(name='sc_2',
columns=[Column(timestamp=1256512261, name='a', value='a'),
Column(timestamp=1256512252, name='x', value='a'),
Column(timestamp=1256512267, name='z', value='a')]))]

Re: are columns of a supercolumn name sorted?

Posted by kevin <ke...@gmail.com>.
On Mon, Oct 26, 2009 at 9:35 AM, Jonathan Ellis <jb...@gmail.com> wrote:

> On Mon, Oct 26, 2009 at 10:25 AM, kevin <ke...@gmail.com>
> wrote:
> > correct me if i am wrong, but i can get only the count [100 default or
> more]
> > number of subcolumns right?
>
> if you are slicing supercolumns, you always get all the subcolumns of each
>
great thanks for clarifying  this. when im slicing super columns i will get
count number of super columns with each super column having all their sub
columns which i can reverse in my client.

Re: are columns of a supercolumn name sorted?

Posted by Jonathan Ellis <jb...@gmail.com>.
On Mon, Oct 26, 2009 at 10:25 AM, kevin <ke...@gmail.com> wrote:
> correct me if i am wrong, but i can get only the count [100 default or more]
> number of subcolumns right?

if you are slicing supercolumns, you always get all the subcolumns of each

if you are slicing subcolumns, then yes, but reversed will apply

> if i have a large number of subcolumns then it would be better to do on the
> server right?

no, the point is that the server actually has to change the ordering
of the results since thrift is batch-oriented, but the client can just
say "for foo in reversed(results)" and you don't have to mutate or
re-order anything.

-Jonathan

Re: are columns of a supercolumn name sorted?

Posted by kevin <ke...@gmail.com>.
On Mon, Oct 26, 2009 at 9:08 AM, Jonathan Ellis <jb...@gmail.com> wrote:

> if you're slicing supercolumns, you're going to get all the subcolumns
> back anyway, so there's not much point in reversing them on the server
>

correct me if i am wrong, but i can get only the count [100 default or more]
number of subcolumns right?



> -- it just adds overhead.   But you can iterate in reverse order
> client side w/ no performance penalty (since you don't actually have
> to re-order the list to do that).
>
>
if i have a large number of subcolumns then it would be better to do on the
server right?




>  On Mon, Oct 26, 2009 at 9:51 AM, kevin <ke...@gmail.com>
> wrote:
> > i got it, with what i specified the order of  super columns is reversed
> >
> >> client.get_slice(keyspace, key, ColumnParent(column_family="Super1"),
> >> SlicePredicate(slice_range=SliceRange(start="",
> finish="",reversed=True)),
> >> ConsistencyLevel.ONE)
> >
> > is there anyway i can specify reversed here so that the order of columns
> in
> > all the super columns are also reversed?
> >
> >
> >
> > if i set the super_column variable in the ColumnParent I can get the
> desired
> > behavior of columns in reverse chronological order.
> >
> >
> > On Sun, Oct 25, 2009 at 8:23 PM, kevin <ke...@gmail.com>
> wrote:
> >>
> >> thanks for the hint. i have inserted 3 columns into a super column with
> >> values 1, 2 and 3 in that order. but reversed variable in SliceRange has
> no
> >> effect on the order of column received.
> >>  reversed set to either True or False in SliceRange i get the column in
> >> the same order. it is not getting reversed.
> >> Can you tell what is wrong here?
> >>
> >> >>> import lazyboy,time, pprint,uuid
> >> >>> from cassandra import Cassandra
> >> >>> from cassandra.ttypes import *
> >> >>>
> >> >>>
> >> >>> client=lazyboy.connection.Client(['localhost:9160'])
> >> >>> keyspace = "Keyspace1"
> >> >>> key='mykeyx'
> >> >>> column_path =
> >> >>>
> ColumnPath(column_family="Super1",column=uuid.uuid1().bytes,super_column='sc_2')
> >> >>> client.insert(keyspace, key, column_path, '1', time.time(),
> >> >>> ConsistencyLevel.ONE);
> >> >>> column_path =
> >> >>>
> ColumnPath(column_family="Super1",column=uuid.uuid1().bytes,super_column='sc_2')
> >> >>> client.insert(keyspace, key, column_path, '2', time.time(),
> >> >>> ConsistencyLevel.ONE);
> >> >>> column_path =
> >> >>>
> ColumnPath(column_family="Super1",column=uuid.uuid1().bytes,super_column='sc_2')
> >> >>> client.insert(keyspace, key, column_path, '3', time.time(),
> >> >>> ConsistencyLevel.ONE);
> >> >>> client.get_slice(keyspace, key,
> ColumnParent(column_family="Super1"),
> >> >>> SlicePredicate(slice_range=SliceRange(start="",
> finish="",reversed=True)),
> >> >>> ConsistencyLevel.ONE)
> >> [ColumnOrSuperColumn(column=None, super_column=SuperColumn(name='sc_2',
> >> columns=[Column(timestamp=1256527256,
> >> name='\x93T\x12\x1c\xc1\xde\x11\xde\xa2;\x00%K\xcb\xc7F', value='1'),
> >> Column(timestamp=1256527257,
> >> name='\x93\x95`&\xc1\xde\x11\xde\xa4\x0c\x00%K\xcb\xc7F', value='2'),
> >> Column(timestamp=1256527257,
> >> name='\x93\xb1\x11T\xc1\xde\x11\xde\xae\xd7\x00%K\xcb\xc7F',
> value='3')]))]
> >> >>> client.get_slice(keyspace, key,
> ColumnParent(column_family="Super1"),
> >>
> >> SlicePredicate(slice_range=SliceRange(start="",
> >> finish="",reversed=False)), ConsistencyLevel.ONE)
> >> [ColumnOrSuperColumn(column=None, super_column=SuperColumn(name='sc_2',
> >> columns=[Column(timestamp=1256527256,
> >> name='\x93T\x12\x1c\xc1\xde\x11\xde\xa2;\x00%K\xcb\xc7F', value='1'),
> >> Column(timestamp=1256527257,
> >> name='\x93\x95`&\xc1\xde\x11\xde\xa4\x0c\x00%K\xcb\xc7F', value='2'),
> >> Column(timestamp=1256527257,
> >> name='\x93\xb1\x11T\xc1\xde\x11\xde\xae\xd7\x00%K\xcb\xc7F',
> value='3')]))]
> >> >>>
> >>
> >>
> >>
> >> On Sun, Oct 25, 2009 at 8:00 PM, Jonathan Ellis <jb...@gmail.com>
> wrote:
> >>>
> >>> it's the "column" attribute of the column_path parameter.
> >>>
> >>> uuids have a specific meaning:
> >>> http://en.wikipedia.org/wiki/Universally_Unique_Identifier
> >>>
> >>> test/system/test_server.py has an example of passing time uuids in
> >>> python.
> >>>
> >>> On Sun, Oct 25, 2009 at 8:52 PM, kevin <ke...@gmail.com>
> >>> wrote:
> >>> > i tried the TimeUUIDType and I get the error. can you tell me which
> >>> > here
> >>> > should be a UUID? what is time based uuid? and which parameter here
> >>> > should
> >>> > be uuid?
> >>> > thanks
> >>> >
> >>> >>>> import lazyboy,time, pprint
> >>> >>>> from cassandra import Cassandra
> >>> >>>> from cassandra.ttypes import *
> >>> >>>>
> >>> >>>>
> >>> >>>> client=lazyboy.connection.Client(['localhost:9160'])
> >>> >>>> keyspace = "Keyspace1"
> >>> >>>> key='mykeyx'
> >>> >>>> column_path =
> >>> >>>> ColumnPath(column_family="Super1",column="x",super_column='sc_2')
> >>> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
> >>> >>>> ConsistencyLevel.ONE);
> >>> > Traceback (most recent call last):
> >>> >   File "<stdin>", line 1, in <module>
> >>> >   File "/Users/kevin/common/lazyboy/connection.py", line 109, in func
> >>> >     raise e
> >>> > cassandra.ttypes.InvalidRequestException:
> >>> > InvalidRequestException(why='UUIDs
> >>> > must be exactly 16 bytes')
> >>> >
> >>> > this is the config in storage-conf.xml
> >>> >
> >>> >       <ColumnFamily CompareWith="BytesType"
> >>> >                     Name="Standard1"
> >>> >                     FlushPeriodInMinutes="60"/>
> >>> >       <ColumnFamily CompareWith="UTF8Type" Name="Standard2"/>
> >>> >       <ColumnFamily CompareWith="TimeUUIDType"
> Name="StandardByUUID1"/>
> >>> >       <ColumnFamily ColumnType="Super"
> >>> >                     CompareWith="UTF8Type"
> >>> >                     CompareSubcolumnsWith="TimeUUIDType"
> >>> >                     Name="Super1"/>
> >>> >
> >>> >
> >>> > On Sun, Oct 25, 2009 at 5:40 PM, Jonathan Ellis <jb...@gmail.com>
> >>> > wrote:
> >>> >>
> >>> >> Sorry, the paragraph about subcolumns always being sorted by time is
> >>> >> outdated.  (I've taken it out on the 0.4 branch now -- it was
> already
> >>> >> gone in trunk.)  Read just below that about how comparewith and
> >>> >> comparesubcolumnswith work.  Sounds like using TimeUUIDType for
> >>> >> subcolumns is what you want (with the reverse option to slice, to
> get
> >>> >> most-recent-first).
> >>> >>
> >>> >> On Sun, Oct 25, 2009 at 5:17 PM, kevin <ke...@gmail.com>
> >>> >> wrote:
> >>> >> > i am inserting three columns x,a,z into a super column named
> 'sc_2'.
> >>> >> > the
> >>> >> > config file says that the columns of a super column are
> timesorted,
> >>> >> > but
> >>> >> > when
> >>> >> > i get_slice it is sorted by the name of the columns. how do i get
> it
> >>> >> > time
> >>> >> > sorted so that i get the most recently inserted/updated column
> >>> >> > first?
> >>> >> > cassandra version apache-cassandra-incubating-0.4.1-bin.tar.gz,
> and
> >>> >> > lazyboy
> >>> >> > latest git clone.
> >>> >> > thanks
> >>> >> >
> >>> >> >
> >>> >> >>>> import lazyboy,time, pprint
> >>> >> >>>> from cassandra import Cassandra
> >>> >> >>>> from cassandra.ttypes import *
> >>> >> >
> >>> >> >
> >>> >> >>>> client=lazyboy.connection.Client(['localhost:9160'])
> >>> >> >>>> keyspace = "Keyspace1"
> >>> >> >>>> key='mykeyx'
> >>> >> >>>> column_path =
> >>> >> >>>>
> ColumnPath(column_family="Super1",column="x",super_column='sc_2')
> >>> >> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
> >>> >> >>>> ConsistencyLevel.ONE);
> >>> >> >>>> column_path =
> >>> >> >>>>
> ColumnPath(column_family="Super1",column="a",super_column='sc_2')
> >>> >> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
> >>> >> >>>> ConsistencyLevel.ONE);
> >>> >> >>>> column_path =
> >>> >> >>>>
> ColumnPath(column_family="Super1",column="z",super_column='sc_2')
> >>> >> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
> >>> >> >>>> ConsistencyLevel.ONE);
> >>> >> >
> >>> >> >
> >>> >> >>>> slice_range = SliceRange(start="", finish="")
> >>> >> >>>> predicate = SlicePredicate(slice_range=slice_range)
> >>> >> >>>> column_parent = ColumnParent(column_family="Super1")
> >>> >> >>>> client.get_slice(keyspace, key, column_parent, predicate,
> >>> >> >>>> ConsistencyLevel.ONE)
> >>> >> > [ColumnOrSuperColumn(column=None,
> >>> >> > super_column=SuperColumn(name='sc_2',
> >>> >> > columns=[Column(timestamp=1256512261, name='a', value='a'),
> >>> >> > Column(timestamp=1256512252, name='x', value='a'),
> >>> >> > Column(timestamp=1256512267, name='z', value='a')]))]
> >>> >> >
> >>> >
> >>> >
> >>
> >
> >
>

Re: are columns of a supercolumn name sorted?

Posted by Jonathan Ellis <jb...@gmail.com>.
right, you can only reverse the level you're slicing at.

if you're slicing supercolumns, you're going to get all the subcolumns
back anyway, so there's not much point in reversing them on the server
-- it just adds overhead.   But you can iterate in reverse order
client side w/ no performance penalty (since you don't actually have
to re-order the list to do that).

On Mon, Oct 26, 2009 at 9:51 AM, kevin <ke...@gmail.com> wrote:
> i got it, with what i specified the order of  super columns is reversed
>
>> client.get_slice(keyspace, key, ColumnParent(column_family="Super1"),
>> SlicePredicate(slice_range=SliceRange(start="", finish="",reversed=True)),
>> ConsistencyLevel.ONE)
>
> is there anyway i can specify reversed here so that the order of columns in
> all the super columns are also reversed?
>
>
>
> if i set the super_column variable in the ColumnParent I can get the desired
> behavior of columns in reverse chronological order.
>
>
> On Sun, Oct 25, 2009 at 8:23 PM, kevin <ke...@gmail.com> wrote:
>>
>> thanks for the hint. i have inserted 3 columns into a super column with
>> values 1, 2 and 3 in that order. but reversed variable in SliceRange has no
>> effect on the order of column received.
>>  reversed set to either True or False in SliceRange i get the column in
>> the same order. it is not getting reversed.
>> Can you tell what is wrong here?
>>
>> >>> import lazyboy,time, pprint,uuid
>> >>> from cassandra import Cassandra
>> >>> from cassandra.ttypes import *
>> >>>
>> >>>
>> >>> client=lazyboy.connection.Client(['localhost:9160'])
>> >>> keyspace = "Keyspace1"
>> >>> key='mykeyx'
>> >>> column_path =
>> >>> ColumnPath(column_family="Super1",column=uuid.uuid1().bytes,super_column='sc_2')
>> >>> client.insert(keyspace, key, column_path, '1', time.time(),
>> >>> ConsistencyLevel.ONE);
>> >>> column_path =
>> >>> ColumnPath(column_family="Super1",column=uuid.uuid1().bytes,super_column='sc_2')
>> >>> client.insert(keyspace, key, column_path, '2', time.time(),
>> >>> ConsistencyLevel.ONE);
>> >>> column_path =
>> >>> ColumnPath(column_family="Super1",column=uuid.uuid1().bytes,super_column='sc_2')
>> >>> client.insert(keyspace, key, column_path, '3', time.time(),
>> >>> ConsistencyLevel.ONE);
>> >>> client.get_slice(keyspace, key, ColumnParent(column_family="Super1"),
>> >>> SlicePredicate(slice_range=SliceRange(start="", finish="",reversed=True)),
>> >>> ConsistencyLevel.ONE)
>> [ColumnOrSuperColumn(column=None, super_column=SuperColumn(name='sc_2',
>> columns=[Column(timestamp=1256527256,
>> name='\x93T\x12\x1c\xc1\xde\x11\xde\xa2;\x00%K\xcb\xc7F', value='1'),
>> Column(timestamp=1256527257,
>> name='\x93\x95`&\xc1\xde\x11\xde\xa4\x0c\x00%K\xcb\xc7F', value='2'),
>> Column(timestamp=1256527257,
>> name='\x93\xb1\x11T\xc1\xde\x11\xde\xae\xd7\x00%K\xcb\xc7F', value='3')]))]
>> >>> client.get_slice(keyspace, key, ColumnParent(column_family="Super1"),
>>
>> SlicePredicate(slice_range=SliceRange(start="",
>> finish="",reversed=False)), ConsistencyLevel.ONE)
>> [ColumnOrSuperColumn(column=None, super_column=SuperColumn(name='sc_2',
>> columns=[Column(timestamp=1256527256,
>> name='\x93T\x12\x1c\xc1\xde\x11\xde\xa2;\x00%K\xcb\xc7F', value='1'),
>> Column(timestamp=1256527257,
>> name='\x93\x95`&\xc1\xde\x11\xde\xa4\x0c\x00%K\xcb\xc7F', value='2'),
>> Column(timestamp=1256527257,
>> name='\x93\xb1\x11T\xc1\xde\x11\xde\xae\xd7\x00%K\xcb\xc7F', value='3')]))]
>> >>>
>>
>>
>>
>> On Sun, Oct 25, 2009 at 8:00 PM, Jonathan Ellis <jb...@gmail.com> wrote:
>>>
>>> it's the "column" attribute of the column_path parameter.
>>>
>>> uuids have a specific meaning:
>>> http://en.wikipedia.org/wiki/Universally_Unique_Identifier
>>>
>>> test/system/test_server.py has an example of passing time uuids in
>>> python.
>>>
>>> On Sun, Oct 25, 2009 at 8:52 PM, kevin <ke...@gmail.com>
>>> wrote:
>>> > i tried the TimeUUIDType and I get the error. can you tell me which
>>> > here
>>> > should be a UUID? what is time based uuid? and which parameter here
>>> > should
>>> > be uuid?
>>> > thanks
>>> >
>>> >>>> import lazyboy,time, pprint
>>> >>>> from cassandra import Cassandra
>>> >>>> from cassandra.ttypes import *
>>> >>>>
>>> >>>>
>>> >>>> client=lazyboy.connection.Client(['localhost:9160'])
>>> >>>> keyspace = "Keyspace1"
>>> >>>> key='mykeyx'
>>> >>>> column_path =
>>> >>>> ColumnPath(column_family="Super1",column="x",super_column='sc_2')
>>> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
>>> >>>> ConsistencyLevel.ONE);
>>> > Traceback (most recent call last):
>>> >   File "<stdin>", line 1, in <module>
>>> >   File "/Users/kevin/common/lazyboy/connection.py", line 109, in func
>>> >     raise e
>>> > cassandra.ttypes.InvalidRequestException:
>>> > InvalidRequestException(why='UUIDs
>>> > must be exactly 16 bytes')
>>> >
>>> > this is the config in storage-conf.xml
>>> >
>>> >       <ColumnFamily CompareWith="BytesType"
>>> >                     Name="Standard1"
>>> >                     FlushPeriodInMinutes="60"/>
>>> >       <ColumnFamily CompareWith="UTF8Type" Name="Standard2"/>
>>> >       <ColumnFamily CompareWith="TimeUUIDType" Name="StandardByUUID1"/>
>>> >       <ColumnFamily ColumnType="Super"
>>> >                     CompareWith="UTF8Type"
>>> >                     CompareSubcolumnsWith="TimeUUIDType"
>>> >                     Name="Super1"/>
>>> >
>>> >
>>> > On Sun, Oct 25, 2009 at 5:40 PM, Jonathan Ellis <jb...@gmail.com>
>>> > wrote:
>>> >>
>>> >> Sorry, the paragraph about subcolumns always being sorted by time is
>>> >> outdated.  (I've taken it out on the 0.4 branch now -- it was already
>>> >> gone in trunk.)  Read just below that about how comparewith and
>>> >> comparesubcolumnswith work.  Sounds like using TimeUUIDType for
>>> >> subcolumns is what you want (with the reverse option to slice, to get
>>> >> most-recent-first).
>>> >>
>>> >> On Sun, Oct 25, 2009 at 5:17 PM, kevin <ke...@gmail.com>
>>> >> wrote:
>>> >> > i am inserting three columns x,a,z into a super column named 'sc_2'.
>>> >> > the
>>> >> > config file says that the columns of a super column are timesorted,
>>> >> > but
>>> >> > when
>>> >> > i get_slice it is sorted by the name of the columns. how do i get it
>>> >> > time
>>> >> > sorted so that i get the most recently inserted/updated column
>>> >> > first?
>>> >> > cassandra version apache-cassandra-incubating-0.4.1-bin.tar.gz, and
>>> >> > lazyboy
>>> >> > latest git clone.
>>> >> > thanks
>>> >> >
>>> >> >
>>> >> >>>> import lazyboy,time, pprint
>>> >> >>>> from cassandra import Cassandra
>>> >> >>>> from cassandra.ttypes import *
>>> >> >
>>> >> >
>>> >> >>>> client=lazyboy.connection.Client(['localhost:9160'])
>>> >> >>>> keyspace = "Keyspace1"
>>> >> >>>> key='mykeyx'
>>> >> >>>> column_path =
>>> >> >>>> ColumnPath(column_family="Super1",column="x",super_column='sc_2')
>>> >> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
>>> >> >>>> ConsistencyLevel.ONE);
>>> >> >>>> column_path =
>>> >> >>>> ColumnPath(column_family="Super1",column="a",super_column='sc_2')
>>> >> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
>>> >> >>>> ConsistencyLevel.ONE);
>>> >> >>>> column_path =
>>> >> >>>> ColumnPath(column_family="Super1",column="z",super_column='sc_2')
>>> >> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
>>> >> >>>> ConsistencyLevel.ONE);
>>> >> >
>>> >> >
>>> >> >>>> slice_range = SliceRange(start="", finish="")
>>> >> >>>> predicate = SlicePredicate(slice_range=slice_range)
>>> >> >>>> column_parent = ColumnParent(column_family="Super1")
>>> >> >>>> client.get_slice(keyspace, key, column_parent, predicate,
>>> >> >>>> ConsistencyLevel.ONE)
>>> >> > [ColumnOrSuperColumn(column=None,
>>> >> > super_column=SuperColumn(name='sc_2',
>>> >> > columns=[Column(timestamp=1256512261, name='a', value='a'),
>>> >> > Column(timestamp=1256512252, name='x', value='a'),
>>> >> > Column(timestamp=1256512267, name='z', value='a')]))]
>>> >> >
>>> >
>>> >
>>
>
>

Re: are columns of a supercolumn name sorted?

Posted by kevin <ke...@gmail.com>.
i got it, with what i specified the order of  super columns is reversed

client.get_slice(keyspace, key, ColumnParent(column_family="Super1"),
> SlicePredicate(slice_range=SliceRange(start="", finish="",reversed=True)),
> ConsistencyLevel.ONE)


is there anyway i can specify reversed here so that the order of columns in
all the super columns are also reversed?



if i set the super_column variable in the ColumnParent I can get the desired
behavior of columns in reverse chronological order.


On Sun, Oct 25, 2009 at 8:23 PM, kevin <ke...@gmail.com> wrote:

> thanks for the hint. i have inserted 3 columns into a super column with
> values 1, 2 and 3 in that order. but reversed variable in SliceRange has no
> effect on the order of column received.
>  reversed set to either True or False in SliceRange i get the column in the
> same order. it is not getting reversed.
> Can you tell what is wrong here?
>
> >>> import lazyboy,time, pprint,uuid
>
> >>> from cassandra import Cassandra
> >>> from cassandra.ttypes import *
> >>>
> >>>
> >>> client=lazyboy.connection.Client(['localhost:9160'])
> >>> keyspace = "Keyspace1"
> >>> key='mykeyx'
> >>> column_path =
> ColumnPath(column_family="Super1",column=uuid.uuid1().bytes,super_column='sc_2')
> >>> client.insert(keyspace, key, column_path, '1', time.time(),
> ConsistencyLevel.ONE);
> >>> column_path =
> ColumnPath(column_family="Super1",column=uuid.uuid1().bytes,super_column='sc_2')
> >>> client.insert(keyspace, key, column_path, '2', time.time(),
> ConsistencyLevel.ONE);
> >>> column_path =
> ColumnPath(column_family="Super1",column=uuid.uuid1().bytes,super_column='sc_2')
> >>> client.insert(keyspace, key, column_path, '3', time.time(),
> ConsistencyLevel.ONE);
> >>> client.get_slice(keyspace, key, ColumnParent(column_family="Super1"),
> SlicePredicate(slice_range=SliceRange(start="", finish="",reversed=True)),
> ConsistencyLevel.ONE)
> [ColumnOrSuperColumn(column=None, super_column=SuperColumn(name='sc_2',
> columns=[Column(timestamp=1256527256,
> name='\x93T\x12\x1c\xc1\xde\x11\xde\xa2;\x00%K\xcb\xc7F', value='1'),
> Column(timestamp=1256527257,
> name='\x93\x95`&\xc1\xde\x11\xde\xa4\x0c\x00%K\xcb\xc7F', value='2'),
> Column(timestamp=1256527257,
> name='\x93\xb1\x11T\xc1\xde\x11\xde\xae\xd7\x00%K\xcb\xc7F', value='3')]))]
> >>> client.get_slice(keyspace, key, ColumnParent(column_family="Super1"),
>
> SlicePredicate(slice_range=SliceRange(start="", finish="",reversed=False)),
> ConsistencyLevel.ONE)
> [ColumnOrSuperColumn(column=None, super_column=SuperColumn(name='sc_2',
> columns=[Column(timestamp=1256527256,
> name='\x93T\x12\x1c\xc1\xde\x11\xde\xa2;\x00%K\xcb\xc7F', value='1'),
> Column(timestamp=1256527257,
> name='\x93\x95`&\xc1\xde\x11\xde\xa4\x0c\x00%K\xcb\xc7F', value='2'),
> Column(timestamp=1256527257,
> name='\x93\xb1\x11T\xc1\xde\x11\xde\xae\xd7\x00%K\xcb\xc7F', value='3')]))]
>
> >>>
>
>
>
> On Sun, Oct 25, 2009 at 8:00 PM, Jonathan Ellis <jb...@gmail.com> wrote:
>
>> it's the "column" attribute of the column_path parameter.
>>
>> uuids have a specific meaning:
>> http://en.wikipedia.org/wiki/Universally_Unique_Identifier
>>
>> test/system/test_server.py has an example of passing time uuids in python.
>>
>> On Sun, Oct 25, 2009 at 8:52 PM, kevin <ke...@gmail.com>
>> wrote:
>> > i tried the TimeUUIDType and I get the error. can you tell me which here
>> > should be a UUID? what is time based uuid? and which parameter here
>> should
>> > be uuid?
>> > thanks
>> >
>> >>>> import lazyboy,time, pprint
>> >>>> from cassandra import Cassandra
>> >>>> from cassandra.ttypes import *
>> >>>>
>> >>>>
>> >>>> client=lazyboy.connection.Client(['localhost:9160'])
>> >>>> keyspace = "Keyspace1"
>> >>>> key='mykeyx'
>> >>>> column_path =
>> >>>> ColumnPath(column_family="Super1",column="x",super_column='sc_2')
>> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
>> >>>> ConsistencyLevel.ONE);
>> > Traceback (most recent call last):
>> >   File "<stdin>", line 1, in <module>
>> >   File "/Users/kevin/common/lazyboy/connection.py", line 109, in func
>> >     raise e
>> > cassandra.ttypes.InvalidRequestException:
>> InvalidRequestException(why='UUIDs
>> > must be exactly 16 bytes')
>> >
>> > this is the config in storage-conf.xml
>> >
>> >       <ColumnFamily CompareWith="BytesType"
>> >                     Name="Standard1"
>> >                     FlushPeriodInMinutes="60"/>
>> >       <ColumnFamily CompareWith="UTF8Type" Name="Standard2"/>
>> >       <ColumnFamily CompareWith="TimeUUIDType" Name="StandardByUUID1"/>
>> >       <ColumnFamily ColumnType="Super"
>> >                     CompareWith="UTF8Type"
>> >                     CompareSubcolumnsWith="TimeUUIDType"
>> >                     Name="Super1"/>
>> >
>> >
>> > On Sun, Oct 25, 2009 at 5:40 PM, Jonathan Ellis <jb...@gmail.com>
>> wrote:
>> >>
>> >> Sorry, the paragraph about subcolumns always being sorted by time is
>> >> outdated.  (I've taken it out on the 0.4 branch now -- it was already
>> >> gone in trunk.)  Read just below that about how comparewith and
>> >> comparesubcolumnswith work.  Sounds like using TimeUUIDType for
>> >> subcolumns is what you want (with the reverse option to slice, to get
>> >> most-recent-first).
>> >>
>> >> On Sun, Oct 25, 2009 at 5:17 PM, kevin <ke...@gmail.com>
>> wrote:
>> >> > i am inserting three columns x,a,z into a super column named 'sc_2'.
>> the
>> >> > config file says that the columns of a super column are timesorted,
>> but
>> >> > when
>> >> > i get_slice it is sorted by the name of the columns. how do i get it
>> >> > time
>> >> > sorted so that i get the most recently inserted/updated column first?
>> >> > cassandra version apache-cassandra-incubating-0.4.1-bin.tar.gz, and
>> >> > lazyboy
>> >> > latest git clone.
>> >> > thanks
>> >> >
>> >> >
>> >> >>>> import lazyboy,time, pprint
>> >> >>>> from cassandra import Cassandra
>> >> >>>> from cassandra.ttypes import *
>> >> >
>> >> >
>> >> >>>> client=lazyboy.connection.Client(['localhost:9160'])
>> >> >>>> keyspace = "Keyspace1"
>> >> >>>> key='mykeyx'
>> >> >>>> column_path =
>> >> >>>> ColumnPath(column_family="Super1",column="x",super_column='sc_2')
>> >> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
>> >> >>>> ConsistencyLevel.ONE);
>> >> >>>> column_path =
>> >> >>>> ColumnPath(column_family="Super1",column="a",super_column='sc_2')
>> >> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
>> >> >>>> ConsistencyLevel.ONE);
>> >> >>>> column_path =
>> >> >>>> ColumnPath(column_family="Super1",column="z",super_column='sc_2')
>> >> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
>> >> >>>> ConsistencyLevel.ONE);
>> >> >
>> >> >
>> >> >>>> slice_range = SliceRange(start="", finish="")
>> >> >>>> predicate = SlicePredicate(slice_range=slice_range)
>> >> >>>> column_parent = ColumnParent(column_family="Super1")
>> >> >>>> client.get_slice(keyspace, key, column_parent, predicate,
>> >> >>>> ConsistencyLevel.ONE)
>> >> > [ColumnOrSuperColumn(column=None,
>> super_column=SuperColumn(name='sc_2',
>> >> > columns=[Column(timestamp=1256512261, name='a', value='a'),
>> >> > Column(timestamp=1256512252, name='x', value='a'),
>> >> > Column(timestamp=1256512267, name='z', value='a')]))]
>> >> >
>> >
>> >
>>
>
>

Re: are columns of a supercolumn name sorted?

Posted by kevin <ke...@gmail.com>.
thanks for the hint. i have inserted 3 columns into a super column with
values 1, 2 and 3 in that order. but reversed variable in SliceRange has no
effect on the order of column received.
 reversed set to either True or False in SliceRange i get the column in the
same order. it is not getting reversed.
Can you tell what is wrong here?

>>> import lazyboy,time, pprint,uuid
>>> from cassandra import Cassandra
>>> from cassandra.ttypes import *
>>>
>>>
>>> client=lazyboy.connection.Client(['localhost:9160'])
>>> keyspace = "Keyspace1"
>>> key='mykeyx'
>>> column_path =
ColumnPath(column_family="Super1",column=uuid.uuid1().bytes,super_column='sc_2')
>>> client.insert(keyspace, key, column_path, '1', time.time(),
ConsistencyLevel.ONE);
>>> column_path =
ColumnPath(column_family="Super1",column=uuid.uuid1().bytes,super_column='sc_2')
>>> client.insert(keyspace, key, column_path, '2', time.time(),
ConsistencyLevel.ONE);
>>> column_path =
ColumnPath(column_family="Super1",column=uuid.uuid1().bytes,super_column='sc_2')
>>> client.insert(keyspace, key, column_path, '3', time.time(),
ConsistencyLevel.ONE);
>>> client.get_slice(keyspace, key, ColumnParent(column_family="Super1"),
SlicePredicate(slice_range=SliceRange(start="", finish="",reversed=True)),
ConsistencyLevel.ONE)
[ColumnOrSuperColumn(column=None, super_column=SuperColumn(name='sc_2',
columns=[Column(timestamp=1256527256,
name='\x93T\x12\x1c\xc1\xde\x11\xde\xa2;\x00%K\xcb\xc7F', value='1'),
Column(timestamp=1256527257,
name='\x93\x95`&\xc1\xde\x11\xde\xa4\x0c\x00%K\xcb\xc7F', value='2'),
Column(timestamp=1256527257,
name='\x93\xb1\x11T\xc1\xde\x11\xde\xae\xd7\x00%K\xcb\xc7F', value='3')]))]
>>> client.get_slice(keyspace, key, ColumnParent(column_family="Super1"),

SlicePredicate(slice_range=SliceRange(start="", finish="",reversed=False)),
ConsistencyLevel.ONE)
[ColumnOrSuperColumn(column=None, super_column=SuperColumn(name='sc_2',
columns=[Column(timestamp=1256527256,
name='\x93T\x12\x1c\xc1\xde\x11\xde\xa2;\x00%K\xcb\xc7F', value='1'),
Column(timestamp=1256527257,
name='\x93\x95`&\xc1\xde\x11\xde\xa4\x0c\x00%K\xcb\xc7F', value='2'),
Column(timestamp=1256527257,
name='\x93\xb1\x11T\xc1\xde\x11\xde\xae\xd7\x00%K\xcb\xc7F', value='3')]))]
>>>



On Sun, Oct 25, 2009 at 8:00 PM, Jonathan Ellis <jb...@gmail.com> wrote:

> it's the "column" attribute of the column_path parameter.
>
> uuids have a specific meaning:
> http://en.wikipedia.org/wiki/Universally_Unique_Identifier
>
> test/system/test_server.py has an example of passing time uuids in python.
>
> On Sun, Oct 25, 2009 at 8:52 PM, kevin <ke...@gmail.com> wrote:
> > i tried the TimeUUIDType and I get the error. can you tell me which here
> > should be a UUID? what is time based uuid? and which parameter here
> should
> > be uuid?
> > thanks
> >
> >>>> import lazyboy,time, pprint
> >>>> from cassandra import Cassandra
> >>>> from cassandra.ttypes import *
> >>>>
> >>>>
> >>>> client=lazyboy.connection.Client(['localhost:9160'])
> >>>> keyspace = "Keyspace1"
> >>>> key='mykeyx'
> >>>> column_path =
> >>>> ColumnPath(column_family="Super1",column="x",super_column='sc_2')
> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
> >>>> ConsistencyLevel.ONE);
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in <module>
> >   File "/Users/kevin/common/lazyboy/connection.py", line 109, in func
> >     raise e
> > cassandra.ttypes.InvalidRequestException:
> InvalidRequestException(why='UUIDs
> > must be exactly 16 bytes')
> >
> > this is the config in storage-conf.xml
> >
> >       <ColumnFamily CompareWith="BytesType"
> >                     Name="Standard1"
> >                     FlushPeriodInMinutes="60"/>
> >       <ColumnFamily CompareWith="UTF8Type" Name="Standard2"/>
> >       <ColumnFamily CompareWith="TimeUUIDType" Name="StandardByUUID1"/>
> >       <ColumnFamily ColumnType="Super"
> >                     CompareWith="UTF8Type"
> >                     CompareSubcolumnsWith="TimeUUIDType"
> >                     Name="Super1"/>
> >
> >
> > On Sun, Oct 25, 2009 at 5:40 PM, Jonathan Ellis <jb...@gmail.com>
> wrote:
> >>
> >> Sorry, the paragraph about subcolumns always being sorted by time is
> >> outdated.  (I've taken it out on the 0.4 branch now -- it was already
> >> gone in trunk.)  Read just below that about how comparewith and
> >> comparesubcolumnswith work.  Sounds like using TimeUUIDType for
> >> subcolumns is what you want (with the reverse option to slice, to get
> >> most-recent-first).
> >>
> >> On Sun, Oct 25, 2009 at 5:17 PM, kevin <ke...@gmail.com>
> wrote:
> >> > i am inserting three columns x,a,z into a super column named 'sc_2'.
> the
> >> > config file says that the columns of a super column are timesorted,
> but
> >> > when
> >> > i get_slice it is sorted by the name of the columns. how do i get it
> >> > time
> >> > sorted so that i get the most recently inserted/updated column first?
> >> > cassandra version apache-cassandra-incubating-0.4.1-bin.tar.gz, and
> >> > lazyboy
> >> > latest git clone.
> >> > thanks
> >> >
> >> >
> >> >>>> import lazyboy,time, pprint
> >> >>>> from cassandra import Cassandra
> >> >>>> from cassandra.ttypes import *
> >> >
> >> >
> >> >>>> client=lazyboy.connection.Client(['localhost:9160'])
> >> >>>> keyspace = "Keyspace1"
> >> >>>> key='mykeyx'
> >> >>>> column_path =
> >> >>>> ColumnPath(column_family="Super1",column="x",super_column='sc_2')
> >> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
> >> >>>> ConsistencyLevel.ONE);
> >> >>>> column_path =
> >> >>>> ColumnPath(column_family="Super1",column="a",super_column='sc_2')
> >> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
> >> >>>> ConsistencyLevel.ONE);
> >> >>>> column_path =
> >> >>>> ColumnPath(column_family="Super1",column="z",super_column='sc_2')
> >> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
> >> >>>> ConsistencyLevel.ONE);
> >> >
> >> >
> >> >>>> slice_range = SliceRange(start="", finish="")
> >> >>>> predicate = SlicePredicate(slice_range=slice_range)
> >> >>>> column_parent = ColumnParent(column_family="Super1")
> >> >>>> client.get_slice(keyspace, key, column_parent, predicate,
> >> >>>> ConsistencyLevel.ONE)
> >> > [ColumnOrSuperColumn(column=None,
> super_column=SuperColumn(name='sc_2',
> >> > columns=[Column(timestamp=1256512261, name='a', value='a'),
> >> > Column(timestamp=1256512252, name='x', value='a'),
> >> > Column(timestamp=1256512267, name='z', value='a')]))]
> >> >
> >
> >
>

Re: are columns of a supercolumn name sorted?

Posted by Jonathan Ellis <jb...@gmail.com>.
it's the "column" attribute of the column_path parameter.

uuids have a specific meaning:
http://en.wikipedia.org/wiki/Universally_Unique_Identifier

test/system/test_server.py has an example of passing time uuids in python.

On Sun, Oct 25, 2009 at 8:52 PM, kevin <ke...@gmail.com> wrote:
> i tried the TimeUUIDType and I get the error. can you tell me which here
> should be a UUID? what is time based uuid? and which parameter here should
> be uuid?
> thanks
>
>>>> import lazyboy,time, pprint
>>>> from cassandra import Cassandra
>>>> from cassandra.ttypes import *
>>>>
>>>>
>>>> client=lazyboy.connection.Client(['localhost:9160'])
>>>> keyspace = "Keyspace1"
>>>> key='mykeyx'
>>>> column_path =
>>>> ColumnPath(column_family="Super1",column="x",super_column='sc_2')
>>>> client.insert(keyspace, key, column_path, 'a', time.time(),
>>>> ConsistencyLevel.ONE);
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/Users/kevin/common/lazyboy/connection.py", line 109, in func
>     raise e
> cassandra.ttypes.InvalidRequestException: InvalidRequestException(why='UUIDs
> must be exactly 16 bytes')
>
> this is the config in storage-conf.xml
>
>       <ColumnFamily CompareWith="BytesType"
>                     Name="Standard1"
>                     FlushPeriodInMinutes="60"/>
>       <ColumnFamily CompareWith="UTF8Type" Name="Standard2"/>
>       <ColumnFamily CompareWith="TimeUUIDType" Name="StandardByUUID1"/>
>       <ColumnFamily ColumnType="Super"
>                     CompareWith="UTF8Type"
>                     CompareSubcolumnsWith="TimeUUIDType"
>                     Name="Super1"/>
>
>
> On Sun, Oct 25, 2009 at 5:40 PM, Jonathan Ellis <jb...@gmail.com> wrote:
>>
>> Sorry, the paragraph about subcolumns always being sorted by time is
>> outdated.  (I've taken it out on the 0.4 branch now -- it was already
>> gone in trunk.)  Read just below that about how comparewith and
>> comparesubcolumnswith work.  Sounds like using TimeUUIDType for
>> subcolumns is what you want (with the reverse option to slice, to get
>> most-recent-first).
>>
>> On Sun, Oct 25, 2009 at 5:17 PM, kevin <ke...@gmail.com> wrote:
>> > i am inserting three columns x,a,z into a super column named 'sc_2'. the
>> > config file says that the columns of a super column are timesorted, but
>> > when
>> > i get_slice it is sorted by the name of the columns. how do i get it
>> > time
>> > sorted so that i get the most recently inserted/updated column first?
>> > cassandra version apache-cassandra-incubating-0.4.1-bin.tar.gz, and
>> > lazyboy
>> > latest git clone.
>> > thanks
>> >
>> >
>> >>>> import lazyboy,time, pprint
>> >>>> from cassandra import Cassandra
>> >>>> from cassandra.ttypes import *
>> >
>> >
>> >>>> client=lazyboy.connection.Client(['localhost:9160'])
>> >>>> keyspace = "Keyspace1"
>> >>>> key='mykeyx'
>> >>>> column_path =
>> >>>> ColumnPath(column_family="Super1",column="x",super_column='sc_2')
>> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
>> >>>> ConsistencyLevel.ONE);
>> >>>> column_path =
>> >>>> ColumnPath(column_family="Super1",column="a",super_column='sc_2')
>> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
>> >>>> ConsistencyLevel.ONE);
>> >>>> column_path =
>> >>>> ColumnPath(column_family="Super1",column="z",super_column='sc_2')
>> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
>> >>>> ConsistencyLevel.ONE);
>> >
>> >
>> >>>> slice_range = SliceRange(start="", finish="")
>> >>>> predicate = SlicePredicate(slice_range=slice_range)
>> >>>> column_parent = ColumnParent(column_family="Super1")
>> >>>> client.get_slice(keyspace, key, column_parent, predicate,
>> >>>> ConsistencyLevel.ONE)
>> > [ColumnOrSuperColumn(column=None, super_column=SuperColumn(name='sc_2',
>> > columns=[Column(timestamp=1256512261, name='a', value='a'),
>> > Column(timestamp=1256512252, name='x', value='a'),
>> > Column(timestamp=1256512267, name='z', value='a')]))]
>> >
>
>

Re: are columns of a supercolumn name sorted?

Posted by kevin <ke...@gmail.com>.
i tried the TimeUUIDType and I get the error. can you tell me which here
should be a UUID? what is time based uuid? and which parameter here should
be uuid?
thanks

>>> import lazyboy,time, pprint
>>> from cassandra import Cassandra
>>> from cassandra.ttypes import *
>>>
>>>
>>> client=lazyboy.connection.Client(['localhost:9160'])
>>> keyspace = "Keyspace1"
>>> key='mykeyx'
>>> column_path =
ColumnPath(column_family="Super1",column="x",super_column='sc_2')
>>> client.insert(keyspace, key, column_path, 'a', time.time(),
ConsistencyLevel.ONE);
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/kevin/common/lazyboy/connection.py", line 109, in func
    raise e
cassandra.ttypes.InvalidRequestException: InvalidRequestException(why='UUIDs
must be exactly 16 bytes')

this is the config in storage-conf.xml

      <ColumnFamily CompareWith="BytesType"
                    Name="Standard1"
                    FlushPeriodInMinutes="60"/>
      <ColumnFamily CompareWith="UTF8Type" Name="Standard2"/>
      <ColumnFamily CompareWith="TimeUUIDType" Name="StandardByUUID1"/>
      <ColumnFamily ColumnType="Super"
                    CompareWith="UTF8Type"
                    CompareSubcolumnsWith="TimeUUIDType"
                    Name="Super1"/>


On Sun, Oct 25, 2009 at 5:40 PM, Jonathan Ellis <jb...@gmail.com> wrote:

> Sorry, the paragraph about subcolumns always being sorted by time is
> outdated.  (I've taken it out on the 0.4 branch now -- it was already
> gone in trunk.)  Read just below that about how comparewith and
> comparesubcolumnswith work.  Sounds like using TimeUUIDType for
> subcolumns is what you want (with the reverse option to slice, to get
> most-recent-first).
>
> On Sun, Oct 25, 2009 at 5:17 PM, kevin <ke...@gmail.com> wrote:
> > i am inserting three columns x,a,z into a super column named 'sc_2'. the
> > config file says that the columns of a super column are timesorted, but
> when
> > i get_slice it is sorted by the name of the columns. how do i get it time
> > sorted so that i get the most recently inserted/updated column first?
> > cassandra version apache-cassandra-incubating-0.4.1-bin.tar.gz, and
> lazyboy
> > latest git clone.
> > thanks
> >
> >
> >>>> import lazyboy,time, pprint
> >>>> from cassandra import Cassandra
> >>>> from cassandra.ttypes import *
> >
> >
> >>>> client=lazyboy.connection.Client(['localhost:9160'])
> >>>> keyspace = "Keyspace1"
> >>>> key='mykeyx'
> >>>> column_path =
> >>>> ColumnPath(column_family="Super1",column="x",super_column='sc_2')
> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
> >>>> ConsistencyLevel.ONE);
> >>>> column_path =
> >>>> ColumnPath(column_family="Super1",column="a",super_column='sc_2')
> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
> >>>> ConsistencyLevel.ONE);
> >>>> column_path =
> >>>> ColumnPath(column_family="Super1",column="z",super_column='sc_2')
> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
> >>>> ConsistencyLevel.ONE);
> >
> >
> >>>> slice_range = SliceRange(start="", finish="")
> >>>> predicate = SlicePredicate(slice_range=slice_range)
> >>>> column_parent = ColumnParent(column_family="Super1")
> >>>> client.get_slice(keyspace, key, column_parent, predicate,
> >>>> ConsistencyLevel.ONE)
> > [ColumnOrSuperColumn(column=None, super_column=SuperColumn(name='sc_2',
> > columns=[Column(timestamp=1256512261, name='a', value='a'),
> > Column(timestamp=1256512252, name='x', value='a'),
> > Column(timestamp=1256512267, name='z', value='a')]))]
> >
>

Re: are columns of a supercolumn name sorted?

Posted by Michael Greene <mi...@gmail.com>.
"reversed" is a boolean option on the SliceRange that you pass in the
get_slice method via its predicate parameter.

Michael

On Sun, Oct 25, 2009 at 8:26 PM, kevin <ke...@gmail.com> wrote:
> hi jonathan
> thanks for the clarification.
>
>>>>subcolumns is what you want (with the reverse option to slice, to get
>>>> most-recent-first).
>
> is reverse an option in get_slice method or in my python code or in the
> config file?
>
>
>
> On Sun, Oct 25, 2009 at 5:40 PM, Jonathan Ellis <jb...@gmail.com> wrote:
>>
>> Sorry, the paragraph about subcolumns always being sorted by time is
>> outdated.  (I've taken it out on the 0.4 branch now -- it was already
>> gone in trunk.)  Read just below that about how comparewith and
>> comparesubcolumnswith work.  Sounds like using TimeUUIDType for
>> subcolumns is what you want (with the reverse option to slice, to get
>> most-recent-first).
>>
>> On Sun, Oct 25, 2009 at 5:17 PM, kevin <ke...@gmail.com> wrote:
>> > i am inserting three columns x,a,z into a super column named 'sc_2'. the
>> > config file says that the columns of a super column are timesorted, but
>> > when
>> > i get_slice it is sorted by the name of the columns. how do i get it
>> > time
>> > sorted so that i get the most recently inserted/updated column first?
>> > cassandra version apache-cassandra-incubating-0.4.1-bin.tar.gz, and
>> > lazyboy
>> > latest git clone.
>> > thanks
>> >
>> >
>> >>>> import lazyboy,time, pprint
>> >>>> from cassandra import Cassandra
>> >>>> from cassandra.ttypes import *
>> >
>> >
>> >>>> client=lazyboy.connection.Client(['localhost:9160'])
>> >>>> keyspace = "Keyspace1"
>> >>>> key='mykeyx'
>> >>>> column_path =
>> >>>> ColumnPath(column_family="Super1",column="x",super_column='sc_2')
>> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
>> >>>> ConsistencyLevel.ONE);
>> >>>> column_path =
>> >>>> ColumnPath(column_family="Super1",column="a",super_column='sc_2')
>> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
>> >>>> ConsistencyLevel.ONE);
>> >>>> column_path =
>> >>>> ColumnPath(column_family="Super1",column="z",super_column='sc_2')
>> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
>> >>>> ConsistencyLevel.ONE);
>> >
>> >
>> >>>> slice_range = SliceRange(start="", finish="")
>> >>>> predicate = SlicePredicate(slice_range=slice_range)
>> >>>> column_parent = ColumnParent(column_family="Super1")
>> >>>> client.get_slice(keyspace, key, column_parent, predicate,
>> >>>> ConsistencyLevel.ONE)
>> > [ColumnOrSuperColumn(column=None, super_column=SuperColumn(name='sc_2',
>> > columns=[Column(timestamp=1256512261, name='a', value='a'),
>> > Column(timestamp=1256512252, name='x', value='a'),
>> > Column(timestamp=1256512267, name='z', value='a')]))]
>> >
>
>

Re: are columns of a supercolumn name sorted?

Posted by kevin <ke...@gmail.com>.
hi jonathan
thanks for the clarification.

>>>subcolumns is what you want (with the reverse option to slice, to get
most-recent-first).

is reverse an option in get_slice method or in my python code or in the
config file?



On Sun, Oct 25, 2009 at 5:40 PM, Jonathan Ellis <jb...@gmail.com> wrote:

> Sorry, the paragraph about subcolumns always being sorted by time is
> outdated.  (I've taken it out on the 0.4 branch now -- it was already
> gone in trunk.)  Read just below that about how comparewith and
> comparesubcolumnswith work.  Sounds like using TimeUUIDType for
> subcolumns is what you want (with the reverse option to slice, to get
> most-recent-first).
>
> On Sun, Oct 25, 2009 at 5:17 PM, kevin <ke...@gmail.com> wrote:
> > i am inserting three columns x,a,z into a super column named 'sc_2'. the
> > config file says that the columns of a super column are timesorted, but
> when
> > i get_slice it is sorted by the name of the columns. how do i get it time
> > sorted so that i get the most recently inserted/updated column first?
> > cassandra version apache-cassandra-incubating-0.4.1-bin.tar.gz, and
> lazyboy
> > latest git clone.
> > thanks
> >
> >
> >>>> import lazyboy,time, pprint
> >>>> from cassandra import Cassandra
> >>>> from cassandra.ttypes import *
> >
> >
> >>>> client=lazyboy.connection.Client(['localhost:9160'])
> >>>> keyspace = "Keyspace1"
> >>>> key='mykeyx'
> >>>> column_path =
> >>>> ColumnPath(column_family="Super1",column="x",super_column='sc_2')
> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
> >>>> ConsistencyLevel.ONE);
> >>>> column_path =
> >>>> ColumnPath(column_family="Super1",column="a",super_column='sc_2')
> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
> >>>> ConsistencyLevel.ONE);
> >>>> column_path =
> >>>> ColumnPath(column_family="Super1",column="z",super_column='sc_2')
> >>>> client.insert(keyspace, key, column_path, 'a', time.time(),
> >>>> ConsistencyLevel.ONE);
> >
> >
> >>>> slice_range = SliceRange(start="", finish="")
> >>>> predicate = SlicePredicate(slice_range=slice_range)
> >>>> column_parent = ColumnParent(column_family="Super1")
> >>>> client.get_slice(keyspace, key, column_parent, predicate,
> >>>> ConsistencyLevel.ONE)
> > [ColumnOrSuperColumn(column=None, super_column=SuperColumn(name='sc_2',
> > columns=[Column(timestamp=1256512261, name='a', value='a'),
> > Column(timestamp=1256512252, name='x', value='a'),
> > Column(timestamp=1256512267, name='z', value='a')]))]
> >
>

Re: are columns of a supercolumn name sorted?

Posted by Jonathan Ellis <jb...@gmail.com>.
Sorry, the paragraph about subcolumns always being sorted by time is
outdated.  (I've taken it out on the 0.4 branch now -- it was already
gone in trunk.)  Read just below that about how comparewith and
comparesubcolumnswith work.  Sounds like using TimeUUIDType for
subcolumns is what you want (with the reverse option to slice, to get
most-recent-first).

On Sun, Oct 25, 2009 at 5:17 PM, kevin <ke...@gmail.com> wrote:
> i am inserting three columns x,a,z into a super column named 'sc_2'. the
> config file says that the columns of a super column are timesorted, but when
> i get_slice it is sorted by the name of the columns. how do i get it time
> sorted so that i get the most recently inserted/updated column first?
> cassandra version apache-cassandra-incubating-0.4.1-bin.tar.gz, and lazyboy
> latest git clone.
> thanks
>
>
>>>> import lazyboy,time, pprint
>>>> from cassandra import Cassandra
>>>> from cassandra.ttypes import *
>
>
>>>> client=lazyboy.connection.Client(['localhost:9160'])
>>>> keyspace = "Keyspace1"
>>>> key='mykeyx'
>>>> column_path =
>>>> ColumnPath(column_family="Super1",column="x",super_column='sc_2')
>>>> client.insert(keyspace, key, column_path, 'a', time.time(),
>>>> ConsistencyLevel.ONE);
>>>> column_path =
>>>> ColumnPath(column_family="Super1",column="a",super_column='sc_2')
>>>> client.insert(keyspace, key, column_path, 'a', time.time(),
>>>> ConsistencyLevel.ONE);
>>>> column_path =
>>>> ColumnPath(column_family="Super1",column="z",super_column='sc_2')
>>>> client.insert(keyspace, key, column_path, 'a', time.time(),
>>>> ConsistencyLevel.ONE);
>
>
>>>> slice_range = SliceRange(start="", finish="")
>>>> predicate = SlicePredicate(slice_range=slice_range)
>>>> column_parent = ColumnParent(column_family="Super1")
>>>> client.get_slice(keyspace, key, column_parent, predicate,
>>>> ConsistencyLevel.ONE)
> [ColumnOrSuperColumn(column=None, super_column=SuperColumn(name='sc_2',
> columns=[Column(timestamp=1256512261, name='a', value='a'),
> Column(timestamp=1256512252, name='x', value='a'),
> Column(timestamp=1256512267, name='z', value='a')]))]
>