You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Apurva Jalit <ap...@gmail.com> on 2013/04/02 07:48:55 UTC
Unable to prefix in astyanax read query
I have a scheme as follows:
TimeStamp
Device ID
Device Name
Device Owner
Device location
I have created this column family using CQL and defined the primary key as
(TimeStamp,Device ID, Device Name). Through a serializable object that has
fields for DeviceID, name and a field name (which stores either Device Owner or
Device Location). I have inserted some records using Astyanax.
As per my understanding, the columns for a row are created by combining Device
ID, Device Name and field name as column name and the value to be the value for
that particular field. Thus for a particular timestamp and device, the column
names would be in the pattern (Device ID:Device Name: ...).
So I believe we can use these 2 fields as prefix to obtain all the entries for a
particular time-device combination.
I am using the following query to obtain the results:
RowSliceQuery<String, ApBaseData> query = adu.keyspace
.prepareQuery(columnFamily)
.getKeySlice(timeStamp)
.withColumnRange(new RangeBuilder()
.setStart(deviceID+deviceName+"_\u00000")
.setEnd(deviceID+deviceName+"_\uffff")
.setLimit(batch_size)
.build());
But on executing the above query I get the following Exception:
BadRequestException: [host=localhost(127.0.0.1):9160, latency=6(6),
attempts=1]InvalidRequestException(why:Not enough bytes to read value of
component 0)
Can any one help to understand where am I going wrong?
Unable to prefix in astyanax read query
Posted by Pushkar Prasad <pu...@airtightnetworks.net>.
Hi,
This is a Astyanax issue that we've encountered.
I have a scheme as follows:
TimeStamp
Device ID
Device Name
Device Owner
Device location
I have created this column family using CQL and defined the primary key as
(TimeStamp,Device ID, Device Name). Through a serializable object that has
fields for DeviceID, name and a field name (which stores either Device Owner
or
Device Location). I have inserted some records using Astyanax.
As per my understanding, the columns for a row are created by combining
Device ID, Device Name and field name as column name and the value to be the
value for that particular field. Thus for a particular timestamp and device,
the column names would be in the pattern (Device ID:Device Name: ...).
So I believe we can use these 2 fields as prefix to obtain all the entries
for a particular time-device combination.
I am using the following query to obtain the results:
RowSliceQuery<String, ApBaseData> query = adu.keyspace
.prepareQuery(columnFamily)
.getKeySlice(timeStamp)
.withColumnRange(new RangeBuilder()
.setStart(deviceID+deviceName+"_\u00000")
.setEnd(deviceID+deviceName+"_\uffff")
.setLimit(batch_size)
.build());
But on executing the above query I get the following Exception:
BadRequestException: [host=localhost(127.0.0.1):9160, latency=6(6),
attempts=1]InvalidRequestException(why:Not enough bytes to read value of
component 0)
Can any one help to understand where am I going wrong?
Re: Unable to prefix in astyanax read query
Posted by aaron morton <aa...@thelastpickle.com>.
>> I have created this column family using CQL and defined the primary key
>> as
What was the create table statement ?
>> BadRequestException: [host=localhost(127.0.0.1):9160, latency=6(6),
>> attempts=1]InvalidRequestException(why:Not enough bytes to read value of
>> component 0)
Unless the CQL 3 create table statement specifies USE COMPACT_STORAGE it will use composites in the row keys and Astyanax may not be expected this.
Unless astyanax specifically says it can write to CQL 3 tables it's best to only access them using CQL 3.
Cheers
-----------------
Aaron Morton
Freelance Cassandra Consultant
New Zealand
@aaronmorton
http://www.thelastpickle.com
On 2/04/2013, at 6:07 PM, "Hiller, Dean" <De...@nrel.gov> wrote:
> We ran into some similar errors in playorm development. Basically, you
> defined a composite probably but are not correctly using that composite.
> I am not sure about queries though as we had the issue when saving data
> (ie. Using deviceID+deviceName did not work and we had to create an full
> blown composite object). I think you need to read up on how astyanax
> works with compositesŠ..I am not sure this is a cassandra question
> reallyŠ.more of an astyanax one.
>
> Dean
>
> On 4/1/13 11:48 PM, "Apurva Jalit" <ap...@gmail.com> wrote:
>
>> I have a scheme as follows:
>>
>> TimeStamp
>> Device ID
>> Device Name
>> Device Owner
>> Device location
>>
>> I have created this column family using CQL and defined the primary key
>> as
>> (TimeStamp,Device ID, Device Name). Through a serializable object that
>> has
>> fields for DeviceID, name and a field name (which stores either Device
>> Owner or
>> Device Location). I have inserted some records using Astyanax.
>>
>> As per my understanding, the columns for a row are created by combining
>> Device
>> ID, Device Name and field name as column name and the value to be the
>> value for
>> that particular field. Thus for a particular timestamp and device, the
>> column
>> names would be in the pattern (Device ID:Device Name: ...).
>>
>> So I believe we can use these 2 fields as prefix to obtain all the
>> entries for a
>> particular time-device combination.
>>
>> I am using the following query to obtain the results:
>>
>> RowSliceQuery<String, ApBaseData> query = adu.keyspace
>> .prepareQuery(columnFamily)
>> .getKeySlice(timeStamp)
>> .withColumnRange(new RangeBuilder()
>> .setStart(deviceID+deviceName+"_\u00000")
>> .setEnd(deviceID+deviceName+"_\uffff")
>> .setLimit(batch_size)
>> .build());
>>
>> But on executing the above query I get the following Exception:
>>
>> BadRequestException: [host=localhost(127.0.0.1):9160, latency=6(6),
>> attempts=1]InvalidRequestException(why:Not enough bytes to read value of
>> component 0)
>>
>> Can any one help to understand where am I going wrong?
>>
>>
>
Re: Unable to prefix in astyanax read query
Posted by "Hiller, Dean" <De...@nrel.gov>.
We ran into some similar errors in playorm development. Basically, you
defined a composite probably but are not correctly using that composite.
I am not sure about queries though as we had the issue when saving data
(ie. Using deviceID+deviceName did not work and we had to create an full
blown composite object). I think you need to read up on how astyanax
works with compositesŠ..I am not sure this is a cassandra question
reallyŠ.more of an astyanax one.
Dean
On 4/1/13 11:48 PM, "Apurva Jalit" <ap...@gmail.com> wrote:
>I have a scheme as follows:
>
> TimeStamp
> Device ID
> Device Name
> Device Owner
> Device location
>
>I have created this column family using CQL and defined the primary key
>as
>(TimeStamp,Device ID, Device Name). Through a serializable object that
>has
>fields for DeviceID, name and a field name (which stores either Device
>Owner or
>Device Location). I have inserted some records using Astyanax.
>
>As per my understanding, the columns for a row are created by combining
>Device
>ID, Device Name and field name as column name and the value to be the
>value for
>that particular field. Thus for a particular timestamp and device, the
>column
>names would be in the pattern (Device ID:Device Name: ...).
>
>So I believe we can use these 2 fields as prefix to obtain all the
>entries for a
>particular time-device combination.
>
>I am using the following query to obtain the results:
>
> RowSliceQuery<String, ApBaseData> query = adu.keyspace
> .prepareQuery(columnFamily)
> .getKeySlice(timeStamp)
> .withColumnRange(new RangeBuilder()
> .setStart(deviceID+deviceName+"_\u00000")
> .setEnd(deviceID+deviceName+"_\uffff")
> .setLimit(batch_size)
> .build());
>
>But on executing the above query I get the following Exception:
>
>BadRequestException: [host=localhost(127.0.0.1):9160, latency=6(6),
>attempts=1]InvalidRequestException(why:Not enough bytes to read value of
>component 0)
>
>Can any one help to understand where am I going wrong?
>
>