Cassandra列表<blob>错误地读取数据

时间:2015-08-19 16:54:45

标签: cassandra cassandra-2.0

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

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,0,7,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

1 个答案:

答案 0 :(得分:1)

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

后,它工作正常