1

警告我是一个pycassa noobie:

我正在尝试使用 pycassa 保存一些数据,如下所示:

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

这会在 cassandra 上产生以下结果:

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

但我需要的是:

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

这是我的列族的定义:

  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

有谁知道我怎么能做到这一点?

4

1 回答 1

2

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

只需使用该值作为列名,就像这样。

于 2013-10-24T16:20:01.893 回答