Return-Path: X-Original-To: apmail-cassandra-user-archive@www.apache.org Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C15A799EC for ; Wed, 1 Feb 2012 11:42:35 +0000 (UTC) Received: (qmail 88143 invoked by uid 500); 1 Feb 2012 11:42:33 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 88032 invoked by uid 500); 1 Feb 2012 11:42:32 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 88024 invoked by uid 99); 1 Feb 2012 11:42:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Feb 2012 11:42:31 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ross.w.black@gmail.com designates 209.85.212.44 as permitted sender) Received: from [209.85.212.44] (HELO mail-vw0-f44.google.com) (209.85.212.44) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Feb 2012 11:42:25 +0000 Received: by vbbfr13 with SMTP id fr13so950463vbb.31 for ; Wed, 01 Feb 2012 03:42:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=Wu5nt4SqpOIb4NoL8F3SLi7SlJvsrx+vWKiYjj9jD+s=; b=FSBZkWSQ0ZLhXJ5ORIzaQI2nvrxun23vb9KIuQxUfVvYXpG1sD/re7AUpIJacUyrUL s5eYqXXDO8BHqK4pUoUubY2eCNqCWqkFT+j0ve7H3fjASpjfG0LMeVJApZekZAQr1lUH tY5G6+Jg80z44AlzvPHvta4dPbp/evrtZxEIQ= MIME-Version: 1.0 Received: by 10.52.65.100 with SMTP id w4mr12549585vds.3.1328096524603; Wed, 01 Feb 2012 03:42:04 -0800 (PST) Received: by 10.52.97.137 with HTTP; Wed, 1 Feb 2012 03:42:04 -0800 (PST) Date: Wed, 1 Feb 2012 22:42:04 +1100 Message-ID: Subject: problem with keys returned from multiget_slice From: Ross Black To: user@cassandra.apache.org Content-Type: multipart/alternative; boundary=20cf307f32ba938fb704b7e59127 --20cf307f32ba938fb704b7e59127 Content-Type: text/plain; charset=ISO-8859-1 Hi, I am trying to get multiget_slice working with the raw thrift client, but am having problems interpreting the returned keys. I assume I am doing something wrong but figure what. Here is the test program... import org.apache.cassandra.thrift.*; import org.apache.thrift.protocol.TBinaryProtocol; import org.apache.thrift.protocol.TProtocol; import org.apache.thrift.transport.TFramedTransport; import org.apache.thrift.transport.TSocket; import org.apache.thrift.transport.TTransport; import java.nio.ByteBuffer; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; public class TestMultiGet { private static final String KEYSPACE = "junk"; private static final String COLUMN_FAMILY = "blah"; public static void main(String[] args) throws Exception { TTransport transport = new TFramedTransport(new TSocket("localhost", 9160, 30 * 1000)); transport.open(); TProtocol protocol = new TBinaryProtocol(transport); Cassandra.Client client = new Cassandra.Client(protocol); ByteBuffer rowKey = ByteBuffer.wrap("row111".getBytes()); ByteBuffer colKey = ByteBuffer.wrap("BBB".getBytes()); ByteBuffer value = ByteBuffer.wrap("datadata".getBytes()); long timestamp = System.currentTimeMillis(); ColumnParent columnParent = new ColumnParent(COLUMN_FAMILY); Column column = new Column().setName(colKey).setValue(value).setTimestamp(timestamp); client.set_keyspace(KEYSPACE); client.insert(rowKey, columnParent, column, ConsistencyLevel.ONE); SlicePredicate predicate = new SlicePredicate().setColumn_names(Collections.singletonList(colKey)); Map> sliceMap = client.multiget_slice(Collections.singletonList(rowKey), columnParent, predicate, ConsistencyLevel.QUORUM); for (Map.Entry> entry : sliceMap.entrySet()) { byte[] key = entry.getKey().array(); System.err.println("Row bytes = " + Arrays.toString(key)); System.err.println("Row = ###\n" + new String(key) + "###"); List columns = entry.getValue(); for (ColumnOrSuperColumn col : columns) { byte[] name = col.getColumn().getName(); System.err.println("Column = " + new String(name)); } } } } And here is the output I get when I run it... Row bytes = [-128, 1, 0, 2, 0, 0, 0, 14, 109, 117, 108, 116, 105, 103, 101, 116, 95, 115, 108, 105, 99, 101, 0, 0, 0, 3, 13, 0, 0, 11, 15, 0, 0, 0, 1, 0, 0, 0, 6, 114, 111, 119, 49, 49, 49, 12, 0, 0, 0, 1, 12, 0, 1, 11, 0, 1, 0, 0, 0, 3, 66, 66, 66, 11, 0, 2, 0, 0, 0, 8, 100, 97, 116, 97, 100, 97, 116, 97, 10, 0, 3, 0, 0, 1, 53, 56, -84, 0, 87, 0, 0, 0] Row = ###@row111@BBB@datadata@### Column = BBB where the @ represents unprintable chars. I assumed that the keys in the returned Map would be the same as the keys passed in, but they instead seem to contain the entire result. I have tried this with 0.8.x and 1.0.7 with the same result. Should the returned keys be the same as the requested keys, or do they need to be interpreted as some other data structure? What do I need to do to fix this? Thanks, Ross --20cf307f32ba938fb704b7e59127 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi,

I am trying to get multiget_slice working with the raw thrift cl= ient, but am having problems interpreting the returned keys.
I assume I = am doing something wrong but figure what.

Here is the test program..= .

import org.apache.cassandra.thrift.*;
import org.apache.thrift.proto= col.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
imp= ort org.apache.thrift.transport.TFramedTransport;
import org.apache.thri= ft.transport.TSocket;
import org.apache.thrift.transport.TTransport;

import java.nio.ByteB= uffer;
import java.util.Arrays;
import java.util.Collections;
impo= rt java.util.List;
import java.util.Map;

public class TestMultiGe= t {

=A0=A0=A0 private static final String KEYSPACE =3D "junk";=A0=A0=A0 private static final String COLUMN_FAMILY =3D "blah";<= br>
=A0=A0=A0 public static void main(String[] args) throws Exception {<= br>=A0=A0=A0=A0=A0=A0=A0 TTransport transport =3D new TFramedTransport(new = TSocket("localhost", 9160, 30 * 1000));
=A0=A0=A0=A0=A0=A0=A0 transport.open();
=A0=A0=A0=A0=A0=A0=A0 TProtocol = protocol =3D new TBinaryProtocol(transport);
=A0=A0=A0=A0=A0=A0=A0 Cassa= ndra.Client client =3D new Cassandra.Client(protocol);

=A0=A0=A0=A0= =A0=A0=A0 ByteBuffer rowKey =3D ByteBuffer.wrap("row111".getBytes= ());
=A0=A0=A0=A0=A0=A0=A0 ByteBuffer colKey =3D ByteBuffer.wrap("BBB"= .getBytes());
=A0=A0=A0=A0=A0=A0=A0 ByteBuffer value =3D ByteBuffer.wrap= ("datadata".getBytes());
=A0=A0=A0=A0=A0=A0=A0 long timestamp = =3D System.currentTimeMillis();
=A0=A0=A0=A0=A0=A0=A0 ColumnParent colum= nParent =3D new ColumnParent(COLUMN_FAMILY);
=A0=A0=A0=A0=A0=A0=A0 Column column =3D new Column().setName(colKey).setVal= ue(value).setTimestamp(timestamp);

=A0=A0=A0=A0=A0=A0=A0 client.set_= keyspace(KEYSPACE);
=A0=A0=A0=A0=A0=A0=A0 client.insert(rowKey, columnPa= rent, column, ConsistencyLevel.ONE);

=A0=A0=A0=A0=A0=A0=A0 SlicePredicate predicate =3D new SlicePredicate()= .setColumn_names(Collections.singletonList(colKey));
=A0=A0=A0=A0=A0=A0= =A0 Map<ByteBuffer, List<ColumnOrSuperColumn>> sliceMap =3D cli= ent.multiget_slice(Collections.singletonList(rowKey), columnParent, predica= te, ConsistencyLevel.QUORUM);
=A0=A0=A0=A0=A0=A0=A0 for (Map.Entry<ByteBuffer, List<ColumnOrSuperCo= lumn>> entry : sliceMap.entrySet()) {
=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0 byte[] key =3D entry.getKey().array();
=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0 System.err.println("Row bytes =3D " + Arrays.toString(k= ey));
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 System.err.println("Row =3D ###\n&qu= ot; + new String(key) + "###");

=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0 List<ColumnOrSuperColumn> columns =3D entry.getValue();
= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 for (ColumnOrSuperColumn col : columns) {=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 byte[] name =3D col.getColumn= ().getName();
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 System.err.p= rintln("Column =3D " + new String(name));
=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0 }
=A0=A0=A0=A0=A0=A0=A0 }
=A0=A0=A0 }
}

And here is the output I get when I run it...
Row bytes =3D [-128, 1, 0, 2, 0, 0, 0, 14, 109, 117, 108, 116, 105, 103, 10= 1, 116, 95, 115, 108, 105, 99, 101, 0, 0, 0, 3, 13, 0, 0, 11, 15, 0, 0, 0, = 1, 0, 0, 0, 6, 114, 111, 119, 49, 49, 49, 12, 0, 0, 0, 1, 12, 0, 1, 11, 0, = 1, 0, 0, 0, 3, 66, 66, 66, 11, 0, 2, 0, 0, 0, 8, 100, 97, 116, 97, 100, 97,= 116, 97, 10, 0, 3, 0, 0, 1, 53, 56, -84, 0, 87, 0, 0, 0]
Row =3D ###@row111@BBB@datadata@###
Column =3D BBB

where the @ re= presents unprintable chars.

I assumed that the keys in the returned = Map would be the same as the keys passed in, but they instead seem to conta= in the entire result.
I have tried this with 0.8.x and 1.0.7 with the same result.

Should = the returned keys be the same as the requested keys, or do they need to be = interpreted as some other data structure?
What do I need to do to fix th= is?


Thanks,
Ross

--20cf307f32ba938fb704b7e59127--