【问题标题】:Cassandra list<blob> read data incorrectlyCassandra list<blob> 读取数据不正确
【发布时间】:2015-08-20 03:01:04
【问题描述】:

从列表中读取并得到错误的数据。

CREATE TABLE tt (k text PRIMARY KEY, msg list<blob>); 


static byte[] msg = new byte[] { 6, 6 };
static byte[] msg1 = new byte[] { 7, 7 };

    PreparedStatement upsert = session.prepare("update tt set msg = msg + ? where k = ?");
    session.execute(upsert.bind(Collections.singletonList(ByteBuffer.wrap(msg)), key));

    upsert = session.prepare("update tt set msg = msg + ? where k = ?");
    session.execute(upsert.bind(Collections.singletonList(ByteBuffer.wrap(msg1)), key));

    PreparedStatement statement = session.prepare("SELECT msg FROM tt where k = ?");
    ResultSet rs = session.execute(statement.bind(key));
    for (ByteBuffer bs : rs.one().getList("msg", ByteBuffer.class)) {
        for (byte b : bs.array())
            System.out.print(b + ", ");
        System.out.println();
    }

数据存储正确:

cqlsh:bellrock> select msg from tt;

 msg
------------------
 [0x0606, 0x0707]

但它输出为:

0, 0, 0, 2, 0, 0, 0, 2, 6, 6, 0, 0, 0, 2, 7, 7,
0, 0, 0, 2, 0, 0, 0, 2, 6, 6, 0, 0, 0, 2, 7, 7,

cqlsh:ks> show version
[cqlsh 5.0.1 | Cassandra 2.2.0 | CQL spec 3.3.0 | Native protocol v4]

驱动版本:cassandra-driver-core 2.1.7.1

【问题讨论】:

    标签: cassandra cassandra-2.0


    【解决方案1】:

    原来是驱动程序 cassandra-driver-core 2.1.7.1 中的一个错误 在我放入早期版本 2.0.10.1 后它工作正常

    【讨论】:

      猜你喜欢
      • 2014-10-11
      • 1970-01-01
      • 2018-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-14
      • 2018-03-26
      • 2019-09-02
      相关资源
      最近更新 更多