You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Alexandru Sicoe <ad...@gmail.com> on 2011/10/03 19:02:25 UTC
CQL select not working for CF defined programatically with Hector API
Hi,
I am using Cassandra 0.8.5, Hector 0.8.0-2 and cqlsh (cql 1.0.3). If I
define a CF with comparator LongType like this:
BasicColumnFamilyDefinition columnFamilyDefinition = new
BasicColumnFamilyDefinition();
columnFamilyDefinition.setKeyspaceName("XXX");
columnFamilyDefinition.setName("YYY");
columnFamilyDefinition.setDefaultValidationClass(_BYTESTYPE);
columnFamilyDefinition.setMemtableOperationsInMillions(0.1);
columnFamilyDefinition.setMemtableThroughputInMb(40);
columnFamilyDefinition.setComparatorType(ComparatorType.LONGTYPE);
try {
cluster.addColumnFamily(new
ThriftCfDef(columnFamilyDefinition));
} catch(HectorException e) {
throw e;
}
Then I put some data in the CF.
The I try to do the following queries in cqlsh:
use XXX;
select * from YYY where KEY='aaa';
nothing is returned!
If I however do:
select * from YYY;
all the results are returned propperly!
So I have 2 questios:
1) Can I read with CQL if CFs were defined using the basic API? (the fact
that select * from YYY; works suggests that this is possible)
2) If yes, what is the correct query to use to read data with CQL? (I
suspect KEY is wrong...is there a default?)
Cheers,
Alex
Re: CQL select not working for CF defined programatically with Hector API
Posted by Alexandru Sicoe <ad...@gmail.com>.
Perfectly right. Sorry for not paying attention!
Thanks Eric,
Alex
On Tue, Oct 4, 2011 at 4:19 AM, Eric Evans <ee...@acunu.com> wrote:
> On Mon, Oct 3, 2011 at 12:02 PM, Alexandru Sicoe <ad...@gmail.com>
> wrote:
> > Hi,
> > I am using Cassandra 0.8.5, Hector 0.8.0-2 and cqlsh (cql 1.0.3). If I
> > define a CF with comparator LongType like this:
> >
> > BasicColumnFamilyDefinition columnFamilyDefinition = new
> > BasicColumnFamilyDefinition();
> > columnFamilyDefinition.setKeyspaceName("XXX");
> > columnFamilyDefinition.setName("YYY");
> > columnFamilyDefinition.setDefaultValidationClass(_BYTESTYPE);
> > columnFamilyDefinition.setMemtableOperationsInMillions(0.1);
> > columnFamilyDefinition.setMemtableThroughputInMb(40);
> >
> columnFamilyDefinition.setComparatorType(ComparatorType.LONGTYPE);
> > try {
> > cluster.addColumnFamily(new
> > ThriftCfDef(columnFamilyDefinition));
> > } catch(HectorException e) {
> > throw e;
> > }
> >
> > Then I put some data in the CF.
> >
> > The I try to do the following queries in cqlsh:
> >
> > use XXX;
> > select * from YYY where KEY='aaa';
> >
> > nothing is returned!
> >
> > If I however do:
> > select * from YYY;
> >
> > all the results are returned propperly!
> >
> > So I have 2 questios:
> > 1) Can I read with CQL if CFs were defined using the basic API? (the fact
> > that select * from YYY; works suggests that this is possible)
> > 2) If yes, what is the correct query to use to read data with CQL? (I
> > suspect KEY is wrong...is there a default?)
>
> I suspect that you did not select a key validation class, and ended up
> with a default of BytesType. CQL requires that your terms be hex
> encoded when using BytesType.
>
> --
> Eric Evans
> Acunu | http://www.acunu.com | @acunu
>
Re: CQL select not working for CF defined programatically with Hector API
Posted by Eric Evans <ee...@acunu.com>.
On Mon, Oct 3, 2011 at 12:02 PM, Alexandru Sicoe <ad...@gmail.com> wrote:
> Hi,
> I am using Cassandra 0.8.5, Hector 0.8.0-2 and cqlsh (cql 1.0.3). If I
> define a CF with comparator LongType like this:
>
> BasicColumnFamilyDefinition columnFamilyDefinition = new
> BasicColumnFamilyDefinition();
> columnFamilyDefinition.setKeyspaceName("XXX");
> columnFamilyDefinition.setName("YYY");
> columnFamilyDefinition.setDefaultValidationClass(_BYTESTYPE);
> columnFamilyDefinition.setMemtableOperationsInMillions(0.1);
> columnFamilyDefinition.setMemtableThroughputInMb(40);
> columnFamilyDefinition.setComparatorType(ComparatorType.LONGTYPE);
> try {
> cluster.addColumnFamily(new
> ThriftCfDef(columnFamilyDefinition));
> } catch(HectorException e) {
> throw e;
> }
>
> Then I put some data in the CF.
>
> The I try to do the following queries in cqlsh:
>
> use XXX;
> select * from YYY where KEY='aaa';
>
> nothing is returned!
>
> If I however do:
> select * from YYY;
>
> all the results are returned propperly!
>
> So I have 2 questios:
> 1) Can I read with CQL if CFs were defined using the basic API? (the fact
> that select * from YYY; works suggests that this is possible)
> 2) If yes, what is the correct query to use to read data with CQL? (I
> suspect KEY is wrong...is there a default?)
I suspect that you did not select a key validation class, and ended up
with a default of BytesType. CQL requires that your terms be hex
encoded when using BytesType.
--
Eric Evans
Acunu | http://www.acunu.com | @acunu