我有一个 Cassandra 列族(使用 Pycassa 创建),其架构如下:
ColumnFamily: tracker
Key Validation Class: org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.DateType)
Default column value validator: org.apache.cassandra.db.marshal.BytesType
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
Bloom Filter FP chance: default
Built indexes: []
Compaction Strategy: org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy
Compression Options:
sstable_compression: org.apache.cassandra.io.compress.SnappyCompressor
我正在尝试使用以下行插入其中:
self.tracker_batcher.insert(tracker_key, dictionary_to_insert)
哪里tracker_key
是:
('cd7449e8-8f0d-4730-9ee4-ef60edfdd409', datetime.datetime(2013, 8, 14, 16, 47, 55, 856000))
我希望这能奏效——我在其他表中使用日期类型作为行键,它们很有效。此外 - 看起来我正在关注 Pycassa 网站上的教程(http://pycassa.github.io/pycassa/assorted/composite_types.html)。
有关更多信息,我正在使用 Pycassa 1.9.0 版和 Cassandra 1.2.8
谢谢,
马特
编辑:
在一个奇怪的事件中,我收到的第一条错误消息:
TypeError: A str or unicode value was expected, but datetime was received instead (2013-08-14 16:45:15.376000)
我尝试这样修改查询:
tracker_key = (str(dictionary_to_insert['session_id']), datetime.datetime.strftime(dictionary_to_insert['datestamp'], "%Y-%m-%d %H:%M:%S"))
即将日期时间更改为字符串
并收到以下错误消息:
raise TypeError('DateType arguments must be a datetime or timestamp')
TypeError: DateType arguments must be a datetime or timestamp
莫名其妙。