MultigetSliceQuery fails with IndexOutOfBoundsException, when Integer type keys and column names are used

12 views
Skip to first unread message

Asil

unread,
Feb 27, 2011, 6:42:27 AM2/27/11
to hector...@googlegroups.com
hi there,

I am using MultigetSliceQuery to retrieve columns from multiple rows at once. This works absolutely fine if I use String type keys & column names but fails with an .IndexOutOfBoundsException, if I use Integer type names & rows keys. The exceptions details are as follows:-


Exception in thread "main" java.lang.IndexOutOfBoundsException
        at java.nio.Buffer.checkIndex(Buffer.java:514)
        at java.nio.HeapByteBuffer.get(HeapByteBuffer.java:121)
        at me.prettyprint.cassandra.serializers.IntegerSerializer.fromByteBuffer(IntegerSerializer.java:42)
        at me.prettyprint.cassandra.serializers.IntegerSerializer.fromByteBuffer(IntegerSerializer.java:12)
        at me.prettyprint.cassandra.serializers.AbstractSerializer.fromBytesMap(AbstractSerializer.java:115)
        at me.prettyprint.cassandra.model.thrift.ThriftMultigetSliceQuery$1.doInKeyspace(ThriftMultigetSliceQuery.java:67)
        at me.prettyprint.cassandra.model.thrift.ThriftMultigetSliceQuery$1.doInKeyspace(ThriftMultigetSliceQuery.java:59)
        at me.prettyprint.cassandra.model.KeyspaceOperationCallback.doInKeyspaceAndMeasure(KeyspaceOperationCallback.java:20)
        at me.prettyprint.cassandra.model.ExecutingKeyspace.doExecute(ExecutingKeyspace.java:65)
        at me.prettyprint.cassandra.model.thrift.ThriftMultigetSliceQuery.execute(ThriftMultigetSliceQuery.java:58)
        at parathacom.DatabaseExecutions.Database_2.readMutipleColumnsOfMultipleRows(Database_2.java:420)


What may be the cause of this error ?



I use multiget like this:-
      public static readMultipleRows(String columnfamily, K[] rowKeysList, N[] columnNameList, Serializer<K> keySerializer, Serializer<N> nameSerializer, Serializer<V> valueSerializer)
   {
 
            MultigetSliceQuery<K, N, V> query = HFactory.createMultigetSliceQuery("trialkeyspace", keySerializer, nameSerializer, valueSerializer);
 
            query.setColumnFamily(columnfamily).setKeys(rowKeysList).setColumnNames(columnNameList);
 
            QueryResult<Rows<K, N, V>> queryResult = query.execute();
 
            return queryResult.get();
    }



Asil

unread,
Feb 28, 2011, 9:59:08 PM2/28/11
to hector...@googlegroups.com
Can anyone point out if I have done anything wrong above ?

Thanks

Nate McCall

unread,
Feb 28, 2011, 11:01:05 PM2/28/11
to hector...@googlegroups.com, Asil
What are the values for the Serializers in the above code? Do they
match up with how you have declared the column family comparator?

Aklin_81

unread,
Mar 1, 2011, 1:35:28 AM3/1/11
to hector...@googlegroups.com
My column family(Standard) uses bytes type comparator. And I am
passing <Integer, Integer,byte[]> as serializers for
<keySerializer,nameSerializer, valueSerializer>

I tried the following code:-
*************************
Integer[] keys={43};
Integer[] columns={42};

MultigetSliceQuery<Integer, Integer,byte[]> query =
HFactory.createMultigetSliceQuery("trialKeyspace", integerSerializer,
integerSerializer, BYTES_ARRAY_SERIALIZER);

query.setColumnFamily("ProfileData").setKeys(keys).setColumnNames(columns);


QueryResult<Rows<Integer, Integer, byte[]>> queryResult = query.execute();

*****************************

However, If I change keyserializer & 'keys' to be of byte[] type, then
query is successful.

Nate McCall

unread,
Mar 1, 2011, 11:46:53 AM3/1/11
to hector...@googlegroups.com, Aklin_81
IntegerSerializer is going to be packing your key as a four byte
integer. How did you insert this data? Via the cassandra-cli? If so,
that may have packed the raw two byte value in that case, thus the
mismatch. If you created and inserted the row initially with
IntegerSerializer, than it would work (if you did use
IntegerSerializer for insertion, then we have an issue).

Aklin_81

unread,
Mar 1, 2011, 12:29:53 PM3/1/11
to hector...@googlegroups.com
Nate,
I inserted via hector only..

A thing to note is that, I am able to retrieve the same set of columns
through SliceQuery but not through MultigetsliceQuery.
MultigetSlicequery also works but if I use byte serializer as the key
serializer, but fails with integerSerializer passed for serializing
the key.

I inserted the columns with integer serializers only!

Thanks

Nate McCall

unread,
Mar 1, 2011, 12:31:22 PM3/1/11
to hector...@googlegroups.com
Hmm. Can you open a GH issue and if possible, attach some code to
reproduce? That would help me knock this out quicker.

Aklin_81

unread,
Mar 1, 2011, 12:44:57 PM3/1/11
to hector...@googlegroups.com
sure

Aklin_81

unread,
Mar 1, 2011, 2:32:42 PM3/1/11
to Nate McCall, hector...@googlegroups.com
Nate, another thing that you said about :- "IntegerSerializer is

going to be packing your key as a four byte
integer." . Does this mean that I should store the values that are
very very small than the 4 bytes as byte[] serialized, perhaps, as
that could help me economize some space, though quite minimal. I
thought that since cassandra works only with byte[] to store the data,
it would be smartly storing the integer values in efficient manner
consuming only the necessary bytes.

On Tue, Mar 1, 2011 at 10:16 PM, Nate McCall <na...@datastax.com> wrote:

Nate McCall

unread,
Mar 1, 2011, 2:38:11 PM3/1/11
to hector...@googlegroups.com
Cassandra is pretty efficient with storing bytes, yes. IMO, the amount
of space that would save is not at all worth the effort.

Aklin_81

unread,
Mar 1, 2011, 11:37:43 PM3/1/11
to hector...@googlegroups.com
Nate, the problem about multigetSlice was resolved when I migrated to
.28 version hector, however the data that was previously stored could
not be deserialized back for reads. I have no big problem since I am
playing in the development environment but fear about what these
inconsistencies could imply in the production environment.

Thanks for your efforts in helping resolve this.

Regards.
Asil.

Aklin_81

unread,
Mar 2, 2011, 1:50:05 AM3/2/11
to hector...@googlegroups.com
Sorry, I guess there might be no problems. I was reading the integral
column values that I had written as byte[] serialized using Integer
serializer. This was allowed in the previous version, that I was
using. Thus I was using this facility in the debugging mode. But this
does not work here thus I thought perhaps there was some problem, but
its seems that it is not just allowed here. So I will have to read the
integer that I had written as byte[] as with byte serializer only.
I wrote these integers as byte serialized since I could sometimes also
write valueless column as 'new byte[0]' as those column values

Thanks
Asil

Reply all
Reply to author
Forward
0 new messages