You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by A J <s5...@gmail.com> on 2012/09/17 16:51:10 UTC

Astyanax error

Hello,

I am tyring to retrieve a list of Column Names (that are defined as
Integer) from a CF with RowKey as Integer as well. (I don't care for
the column values that are just nulls)

Following is snippet of my Astyanax code. I am getting 0 columns but I
know the key that I am querying contains a few hundred columns. Any
idea what part of the code below is incorrect ?

Thanks.

Astyanax code:
============
        ColumnFamily<Integer, Integer> CF1 =
                new ColumnFamily<Integer, Integer>(
                "CF1",                 // Column Family Name
                IntegerSerializer.get(),   // Key Serializer
                IntegerSerializer.get());  // Column Serializer

        //Reading data
        int NUM_EVENTS = 9;

        StopWatch clock = new StopWatch();
        clock.start();
        for (int i = 0; i < NUM_EVENTS; ++i) {
                ColumnList<Integer> result = keyspace.prepareQuery(CF1)
                        .getKey(1919)
                        .execute().getResult();
        System.out.println( "results are: " + result.size() );
        }
        clock.stop();



CF definition:
===========
[default@ks1] describe CF1;
    ColumnFamily: CF1
      Key Validation Class: org.apache.cassandra.db.marshal.IntegerType
      Default column value validator: org.apache.cassandra.db.marshal.BytesType
      Columns sorted by: org.apache.cassandra.db.marshal.IntegerType

Re: Astyanax error

Posted by A J <s5...@gmail.com>.
I traced this to the misnomer of Integer datatype in Cassandra.
IntegerType in Cassandra is infact a variable length BigInt. Changing
it to Int32Type solved the issue.
https://github.com/Netflix/astyanax/issues/59



On Mon, Sep 17, 2012 at 10:51 AM, A J <s5...@gmail.com> wrote:
> Hello,
>
> I am tyring to retrieve a list of Column Names (that are defined as
> Integer) from a CF with RowKey as Integer as well. (I don't care for
> the column values that are just nulls)
>
> Following is snippet of my Astyanax code. I am getting 0 columns but I
> know the key that I am querying contains a few hundred columns. Any
> idea what part of the code below is incorrect ?
>
> Thanks.
>
> Astyanax code:
> ============
>         ColumnFamily<Integer, Integer> CF1 =
>                 new ColumnFamily<Integer, Integer>(
>                 "CF1",                 // Column Family Name
>                 IntegerSerializer.get(),   // Key Serializer
>                 IntegerSerializer.get());  // Column Serializer
>
>         //Reading data
>         int NUM_EVENTS = 9;
>
>         StopWatch clock = new StopWatch();
>         clock.start();
>         for (int i = 0; i < NUM_EVENTS; ++i) {
>                 ColumnList<Integer> result = keyspace.prepareQuery(CF1)
>                         .getKey(1919)
>                         .execute().getResult();
>         System.out.println( "results are: " + result.size() );
>         }
>         clock.stop();
>
>
>
> CF definition:
> ===========
> [default@ks1] describe CF1;
>     ColumnFamily: CF1
>       Key Validation Class: org.apache.cassandra.db.marshal.IntegerType
>       Default column value validator: org.apache.cassandra.db.marshal.BytesType
>       Columns sorted by: org.apache.cassandra.db.marshal.IntegerType