سؤال

warning i'm a pycassa noobie:

I'm trying to save some data with pycassa like this:

data="3bxxxxda-c262-xxxd-xxxf-2fdxxxxxx7c8"
another_data="fexxxxd4-f1ce-4xxe-bxx1-8bxxxxxxxx54"
my_column_family.insert(("cookie", data), {"column": str(another_data) })

this produces the following result on cassandra:

RowKey: cookie:3bxxxxda-c262-xxxd-xxxf-2fdxxxxxx7c8
=> (name=column, value=fexxxxd4-f1ce-4xxe-bxx1-8bxxxxxxxx54, timestamp=1382621290026500)

But what i need is:

RowKey: cookie:3bxxxxda-c262-xxxd-xxxf-2fdxxxxxx7c8
=> (column=fexxxxd4-f1ce-4xxe-bxx1-8bxxxxxxxx54, value=, timestamp=1382621290026500)

Heres is the definition of my column family:

  ColumnFamily: MyColumnFamily
  Key Validation Class: org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.UTF8Type)
  Default column value validator: org.apache.cassandra.db.marshal.UTF8Type
  Cells sorted by: org.apache.cassandra.db.marshal.UTF8Type
  GC grace seconds: 864000
  Compaction min/max thresholds: 4/32
  Read repair chance: 0.1
  DC Local Read repair chance: 0.0
  Populate IO Cache on flush: false
  Replicate on write: true
  Caching: KEYS_ONLY
  Default time to live: 0
  Bloom Filter FP chance: default
  Index interval: default
  Speculative Retry: NONE
  Built indexes: []
  Column Metadata:
    Column Name: xxxxxxxxx
      Validation Class: org.apache.cassandra.db.marshal.UUIDType
  Compaction Strategy: org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy
  Compression Options:
    sstable_compression: org.apache.cassandra.io.compress.SnappyCompressor

Anybody knows how can i achieve this?

هل كانت مفيدة؟

المحلول

my_column_family.insert(("cookie", data), {str(another_data) : ""})

Just use the value as column name, like this.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top