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 1A0EB9DAF for ; Tue, 20 Dec 2011 21:50:27 +0000 (UTC) Received: (qmail 61159 invoked by uid 500); 20 Dec 2011 21:50:24 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 61133 invoked by uid 500); 20 Dec 2011 21:50:24 -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 61125 invoked by uid 99); 20 Dec 2011 21:50:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Dec 2011 21:50:24 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of s5alye@gmail.com designates 209.85.210.172 as permitted sender) Received: from [209.85.210.172] (HELO mail-iy0-f172.google.com) (209.85.210.172) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Dec 2011 21:50:19 +0000 Received: by iaen33 with SMTP id n33so2637817iae.31 for ; Tue, 20 Dec 2011 13:49:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=1qZow6X/cF/jiXvZtTHdv7nwKjzyigMg5h5KipQf74M=; b=E0I5Hp/WBtRGMVeUnfkH19xp7HPk+RoSm+HuMOfC4VUMJf/MfiEUml0MiR/0SbZ9Ji iJPrVsTvRryDzYfSVuerah6fzH5dex8uxboga9COc33KetrKgbqmden1V9IRDWQlya1X 07R2qS82r5BDQwIFLHz0BTv2ICGJsMQZ+x2bY= MIME-Version: 1.0 Received: by 10.42.151.195 with SMTP id f3mr4015481icw.19.1324417793167; Tue, 20 Dec 2011 13:49:53 -0800 (PST) Received: by 10.231.113.86 with HTTP; Tue, 20 Dec 2011 13:49:53 -0800 (PST) In-Reply-To: <1324415030.v2.mailanyonewebmail-596227@fuseweb2e> References: <1324415030.v2.mailanyonewebmail-596227@fuseweb2e> Date: Tue, 20 Dec 2011 16:49:53 -0500 Message-ID: Subject: Re: java thrift error From: A J To: dbrosius@mebigfatguy.com Cc: user@cassandra.apache.org Content-Type: multipart/alternative; boundary=90e6ba6e86da18905d04b48d0c95 --90e6ba6e86da18905d04b48d0c95 Content-Type: text/plain; charset=ISO-8859-1 The following worked: import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.Charset; import java.nio.charset.CharacterCodingException; import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; import java.nio.charset.CodingErrorAction; ..... public static Charset charset = Charset.forName("UTF-8"); public static CharsetEncoder encoder = charset.newEncoder(); public static CharsetDecoder decoder = charset.newDecoder(); public static ByteBuffer str_to_bb(String msg){ try{ return encoder.encode(CharBuffer.wrap(msg)); }catch(Exception e){e.printStackTrace();} return null; } and then instead of "count_key".getBytes("UTF-8") do str_to_bb("count_key") On Tue, Dec 20, 2011 at 4:03 PM, Dave Brosius wrote: > A ByteBuffer is not a byte[] to convert a String to a ByteBuffer do > something like > > public static ByteBuffer toByteBuffer(String value) throws UnsupportedEncodingException { return ByteBuffer.wrap(value.getBytes("UTF-8")); } > > > > see http://wiki.apache.org/cassandra/ThriftExamples > > > *----- Original Message -----* > *From:* "A J" > *Sent:* Tue, December 20, 2011 15:52 > *Subject:* java thrift error > > The following syntax : > import org.apache.cassandra.thrift.*; > ..... > ..... > ColumnOrSuperColumn col = client.get("count_key".getBytes("UTF-8"), > cp, ConsistencyLevel.QUORUM); > > > is giving the error: > get(java.nio.ByteBuffer,org.apache.cassandra.thrift.ColumnPath,org.apache.cassandra.thrift.ConsistencyLevel) > in org.apache.cassandra.thrift.Cassandra.Client cannot be applied to > (byte[],org.apache.cassandra.thrift.ColumnPath,org.apache.cassandra.thrift.ConsistencyLevel) > > > Any idea on how to cast? > > Thanks. > > --90e6ba6e86da18905d04b48d0c95 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
The following worked:
import java.nio.ByteBuffer;
import = java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio= .charset.CharacterCodingException;
import java.nio.charset.CharsetDecode= r;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CodingEr= rorAction;
.....
public static Charset charset =3D Charset.for= Name("UTF-8");
public static CharsetEncoder encoder =3D charse= t.newEncoder();
public static CharsetDecoder decoder =3D charset.newDecoder();
= =A0
public static ByteBuffer str_to_bb(String msg){
=A0 try{=A0=A0=A0 return encoder.encode(CharBuffer.wrap(msg));
=A0 }catch(Exce= ption e){e.printStackTrace();}
=A0 return null;
}
=A0
and then instead of "= ;count_key".getBytes("UTF-8")
do
str_to= _bb("count_key")

On Tue, = Dec 20, 2011 at 4:03 PM, Dave Brosius <dbrosius@mebigfatguy.com> wrote:=
A ByteBuffer is not a byte[] to convert a String to a Byte= Buffer do something like

public static ByteBuffer toByteBuffer(String val=
ue) 
    throws Unsupporte=
dEncodingException
    {
        return ByteBu=
ffer.wrap(value.getBytes("UTF-8"<=
span style=3D"color:rgb(0,0,192)">));
    }

see=A0http://wiki.apache.org/cassandra/ThriftExamples


----- Original Message -----
Fr= om: "A J" <s5alye@gmail.com>
Sent: Tue, December 20, 2011 15:52
Subject: java thrift error

The following syntax :
import org.apache.cassandra.thrift.*;
.....
.....
ColumnOrSuperColumn col =3D client.get("count_key".getBytes("=
;UTF-8"),
cp, ConsistencyLevel.QUORUM);


is giving the error:
get(java.nio.ByteBuffer,org.apache.cassandra.thrift.ColumnPath,org.apache.c=
assandra.thrift.ConsistencyLevel)
in org.apache.cassandra.thrift.Cassandra.Client cannot be applied to
(byte[],org.apache.cassandra.thrift.ColumnPath,org.apache.cassandra.thrift.=
ConsistencyLevel)


Any idea on how to cast?

Thanks.

--90e6ba6e86da18905d04b48d0c95--