On Mon, Oct 26, 2009 at 9:08 AM, Jonathan Ellis <[email protected]> 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 <[email protected]> > 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 <[email protected]> > 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 <[email protected]> > 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 <[email protected]> > >>> 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 <[email protected]> > >>> > 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 <[email protected]> > >>> >> 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')]))] > >>> >> > > >>> > > >>> > > >> > > > > >
