简单的JSON给Cassandra Python客户。
CassandraJsonMapper的Python项目详细描述
#cassandrajsonmapper
cassandrajsonmapper是一个apache cassandra python驱动程序,用于直接存储映射到cassandra复合列的json样式的对象。
重量轻,读写速度快,适合短脉冲数据。我正在处理rest api调用返回的json,稍后我将对其进行轻量级分析。这很适合我的用例,
所以我决定共享它。
cassandrajsonmapper将使用的列族的模式必须与提供的类似。
**注意:**
请记住,创建的复合列数必须至少与要保存的最深的json文档的深度相同。
``sql
create keyspace json
with placement撸strategy='simplestrategy'
,strategy撸options={replication撸factor:1};
使用json;
org.apache.cassandra.db.marshall.bytestype,
org.apache.cassandra.db.marshall.bytestype,org.apache.cassandra.db.marshall.bytestype,
org.apache.cassandra.db.marshall.bytestype,org.apache.cassandra.db.marshall.bytestype,
org.apache.cassandra.db.marshall.bytestype,org.apache.cassandra.db.marshall.bytestype,
org.apache.cassandra.db.marshall.bytestype,org.apache.cassandra.db.marshall.bytestype,
org.apache.cassandra.db.marshall.bytestype,org.apache.cassandra.db.marshall.bytestype,
org.apache.cassandra.db.marshall.bytestype,org.apache.cassandra.db.marshall.bytestype,
org.apache.cassandra.db.marshall.bytestype,org.apache.cassandra.db.marshall.bytestype,
org.apache.cassandra.db.marshall.bytestype,org.apache.cassandra.db.marshall.bytestype)
,默认的验证类为“bytestype”
,键验证类为“bytestype”;
```
列“json”
'key2':{
'test':'好的'
}
}
db.save(document)
assert db.get('key2')==document['key2']
db.delete('key2')
assert db.get('key2')={}
```
示例
``python
db.mt_save(document)
db.mt_finish()
assert db.get('key2')==document['key2']
`````
不支持以下操作:
*不能附加到列表。
*不能删除文档的部分。
*可能无法完整返回读取结果,但是支持分页。
写入一致性=一致性级别。一,
读取一致性=一致性级别。一,
请求大小=100,批处理大小=6000,线程计数=20)
“创建cassandra连接池和cf连接。”
def save(self,dictionary有效负载,write一致性=none,批处理大小=无)
“将字典转换并保存到cassandra。”
def get(self,key,read_consistency=none,
return_lastow=false,column_start=none,request_size=none)
“读取cassandra响应并将其转换为字典。”
“从cassandra中删除字典。”
“异步保存字典。”
def mt_finish(self)
“等待执行所有挂起的插入。”
```
cassandrajsonmapper是一个apache cassandra python驱动程序,用于直接存储映射到cassandra复合列的json样式的对象。
重量轻,读写速度快,适合短脉冲数据。我正在处理rest api调用返回的json,稍后我将对其进行轻量级分析。这很适合我的用例,
所以我决定共享它。
cassandrajsonmapper将使用的列族的模式必须与提供的类似。
**注意:**
请记住,创建的复合列数必须至少与要保存的最深的json文档的深度相同。
``sql
create keyspace json
with placement撸strategy='simplestrategy'
,strategy撸options={replication撸factor:1};
使用json;
org.apache.cassandra.db.marshall.bytestype,
org.apache.cassandra.db.marshall.bytestype,org.apache.cassandra.db.marshall.bytestype,
org.apache.cassandra.db.marshall.bytestype,org.apache.cassandra.db.marshall.bytestype,
org.apache.cassandra.db.marshall.bytestype,org.apache.cassandra.db.marshall.bytestype,
org.apache.cassandra.db.marshall.bytestype,org.apache.cassandra.db.marshall.bytestype,
org.apache.cassandra.db.marshall.bytestype,org.apache.cassandra.db.marshall.bytestype,
org.apache.cassandra.db.marshall.bytestype,org.apache.cassandra.db.marshall.bytestype,
org.apache.cassandra.db.marshall.bytestype,org.apache.cassandra.db.marshall.bytestype,
org.apache.cassandra.db.marshall.bytestype,org.apache.cassandra.db.marshall.bytestype)
,默认的验证类为“bytestype”
,键验证类为“bytestype”;
```
列“json”
'test':'好的'
}
}
db.save(document)
assert db.get('key2')==document['key2']
db.delete('key2')
assert db.get('key2')={}
```
示例
``python
db.mt_save(document)
db.mt_finish()
assert db.get('key2')==document['key2']
`````
不支持以下操作:
*不能附加到列表。
*不能删除文档的部分。
*可能无法完整返回读取结果,但是支持分页。
写入一致性=一致性级别。一,
读取一致性=一致性级别。一,
请求大小=100,批处理大小=6000,线程计数=20)
“创建cassandra连接池和cf连接。”
def save(self,dictionary有效负载,write一致性=none,批处理大小=无)
“将字典转换并保存到cassandra。”
def get(self,key,read_consistency=none,
return_lastow=false,column_start=none,request_size=none)
“读取cassandra响应并将其转换为字典。”
def mt_finish(self)
“等待执行所有挂起的插入。”
```