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 625526D5C for ; Sat, 11 Jun 2011 02:09:57 +0000 (UTC) Received: (qmail 99285 invoked by uid 500); 11 Jun 2011 02:09:55 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 99254 invoked by uid 500); 11 Jun 2011 02:09:55 -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 99246 invoked by uid 99); 11 Jun 2011 02:09:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Jun 2011 02:09:55 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jbellis@gmail.com designates 74.125.82.44 as permitted sender) Received: from [74.125.82.44] (HELO mail-ww0-f44.google.com) (74.125.82.44) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Jun 2011 02:09:49 +0000 Received: by wwa36 with SMTP id 36so2830511wwa.25 for ; Fri, 10 Jun 2011 19:09:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type:content-transfer-encoding; bh=GwoVMRb4MCZimTFH2NiQX4Xe631y1DgP2z8Cro9iFZg=; b=MEOnfgxlyXOWkED+SAp9YiWHCJUhRgn7F5mLD0Yt50hGaLy4YqsWWQJZ57S4laDUQW A2DxQhIE34188/8/oktVi17Sh/JsXamGSIUfp24WARZILmsDFeLzfA8kpsYdFY7Y0sZi 5roPl9SRYqjJf4JQOTfoUtcsx2ApDZewOx75s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=hYYaKmbpBvuiRkfuIlI32DcepaNIShBR/92eFazn3wa5+jxliDt/vyJLRZt9AM7g7I x9+MH1+bhIuB8mIfZogkv3bFtic+TcZbCxwrcSVofO9/UkDnJ9ADqx6Se9e6WKfB5+o4 BkePxZP6nNJNNZgooh/pAl+xHg4+1E0EtJ+Dk= Received: by 10.216.120.129 with SMTP id p1mr2841327weh.81.1307758169094; Fri, 10 Jun 2011 19:09:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.45.144 with HTTP; Fri, 10 Jun 2011 19:09:09 -0700 (PDT) In-Reply-To: References: From: Jonathan Ellis Date: Fri, 10 Jun 2011 21:09:09 -0500 Message-ID: Subject: Re: simple get_slice() gives error? To: user@cassandra.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Don't use destructive operations on the bytebuffer, always use e.g. getLong(buffer.position) On Fri, Jun 10, 2011 at 8:47 PM, Yang wrote: > I'm using thrift.CassandraServer directly within the same cassandra JVM t= o > accomplish my application tasks. > (I understand that this is not the normal usage mode...., but the error h= ere > may also be appearing in Cassandra server code > development, so I thought it could be of some value to look at ) > I ran into some issues when I try to parse out values from column name > ByteBuffer: > > something like the following > List cols =3D cassandra_svr.get_slice(key, path, > predicate, ConsistencyLevel.ONE); > for(ColumnOrSuperColumn colOrSup: cols) { > Column col =3D colOrSup.column; > long ts =3D col.name.getLong(); =A0<=3D=3D=3D=3D=3D=3D > > sometimes the last sentence gives error "ByteBuffer underflow", I checked > that the buffer size is 8 bytes, and the "pos" points to 8 already. =A0it > seems that somewhere in > thrift.CassandraServer line 179---195 > =A0 =A0 public List thriftifyColumns(Collection > columns, boolean reverseOrder) > =A0 =A0 { > ........................................................... > =A0 =A0 =A0 =A0 =A0 =A0 { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Column thrift_column =3D new > Column(column.name()).setValue(column.value()).setTimestamp(column.timest= amp()); > the ctor of Column(Column ) is used, which just uses the old column.name > buffer, which also preserves the pos. > > is this some error on server code? (looks a flip() is needed somewhere) > > Thanks > Yang --=20 Jonathan Ellis Project Chair, Apache Cassandra co-founder of DataStax, the source for professional Cassandra support http://www.datastax.com