Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

Commit

Permalink
Clarify that autopacking should be disabled with CFMap
Browse files Browse the repository at this point in the history
  • Loading branch information
thobbs committed Oct 27, 2010
1 parent 0bd89f0 commit b93354c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
23 changes: 18 additions & 5 deletions README.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,26 @@ You can also map existing classes using ColumnFamilyMap.
... float_column = pycassa.Float64(default=0.0)
... datetime_str_column = pycassa.DateTimeString() # default=None

The defaults will be filled in whenever you retrieve instances from the Cassandra server and the column doesn't exist. If, for example, you add columns in the future, you simply add the relevant column and the default will be there when you get old instances.

IntString, FloatString, and DateTimeString all use string representations for storage. Float64 is stored as a double and is native-endian. Be aware of any endian issues if you use it on different architectures, or perhaps make your own column type.

The defaults will be filled in whenever you retrieve instances from the
Cassandra server and the column doesn't exist. If, for example, you add columns
in the future, you simply add the relevant column and the default will be there
when you get old instances.

IntString, FloatString, and DateTimeString all use string representations for
storage. Float64 is stored as a double and is native-endian. Be aware of any
endian issues if you use it on different architectures, or perhaps make your
own column type.

When creating a ColumnFamily object for use with a ColumnFamilyMap, it's
important to disable autopacking in the ColumnFamily by setting
autopack_names=False and autopack_values=False in the constructor.

>>> cf = pycassa.ColumnFamily(connection, 'Standard1',
... autopack_names=False, autopack_values=False)
>>> Test.objects = pycassa.ColumnFamilyMap(Test, cf)

All the functions are exactly the same, except that they return instances of the supplied class when possible.
All the functions are exactly the same, except that they return instances of the
supplied class when possible.

>>> t = Test()
>>> t.key = 'maptest'
Expand Down
4 changes: 2 additions & 2 deletions pycassa/columnfamily.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ def __init__(self, client, column_family, buffer_size=1024,
:class:`~pycassa.columnfamilymap.ColumnFamilyMap`.
:param super: bool
*deprecated since 0.5.2*
*deprecated since 0.5.1*
Whether this ColumnFamily has SuperColumns. This is detected
automatically since 0.5.2.
automatically since 0.5.1.
"""

Expand Down
22 changes: 14 additions & 8 deletions pycassa/columnfamilymap.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,20 @@ def __init__(self, cls, column_family, columns=None, raw_columns=False):
"""
Construct a ObjectFamily
:Parameters:
`cls`: class
Instances of cls are generated on ``get*()`` requests
`column_family`: :class:`~pycassa.columnfamily.ColumnFamily`
The :class:`~pycassa.columnfamily.ColumnFamily` to tie with cls
`raw_columns`: boolean
Whether all columns should be fetched into the raw_columns field in
requests
:param cls:
Instances of cls are generated on ``get*()`` requests
:type cls: class
:param column_family:
The :class:`~pycassa.columnfamily.ColumnFamily` to tie with cls.
This should almost always have `autopack_names` and
`autopack_values` set to ``False``.
:type column_family: :class:`~pycassa.columnfamily.ColumnFamily`
:param raw_columns:
Whether all columns should be fetched into the `raw_columns` field in
requests
:type raw_columns: boolean
"""
self.cls = cls
self.column_family = column_family
Expand Down

0 comments on commit b93354c

Please sign in to comment.