Re: Astyanax InstantiationException when accessing ColumnList

2012-09-11 Thread Ran User
Oops, forgot to mention Cassandra version - 1.1.4

On Tue, Sep 11, 2012 at 5:54 AM, Ran User  wrote:

> Stuck for hours on this one, thanks in advance!
>
> -  Scala 2.9.2
> - Astyanax 1.0.6 (also tried 1.0.5)
> - Using CompositeRowKey, CompositeColumnName
> - No problem inserting into Cassandra
> - Can read a row, ColumnList.size() returns correct count however any
> attempt to access ColumnList (i.e. iterate, access iterate ColumnList,
> getColumnByIndex(), getColumnByName(), etc) will throw the following
> exception:
>
> Exception:
>
> java.lang.RuntimeException: java.lang.InstantiationException
>
> relevant stack trace:
>
> java.lang.RuntimeException: java.lang.InstantiationException:
> shops.integration.db.scalaquery.ReportingDao$MetricsLogFileCompositeColumn
> at
> com.netflix.astyanax.serializers.AnnotatedCompositeSerializer.fromByteBuffer(AnnotatedCompositeSerializer.java:136)
> at
> com.netflix.astyanax.serializers.AbstractSerializer.fromBytes(AbstractSerializer.java:40)
> at
> com.netflix.astyanax.thrift.model.ThriftColumnOrSuperColumnListImpl.constructMap(ThriftColumnOrSuperColumnListImpl.java:201)
> at
> com.netflix.astyanax.thrift.model.ThriftColumnOrSuperColumnListImpl.getColumn(ThriftColumnOrSuperColumnListImpl.java:189)
> at
> com.netflix.astyanax.thrift.model.ThriftColumnOrSuperColumnListImpl.getColumnByName(ThriftColumnOrSuperColumnListImpl.java:103)
>
> Relevant sample code:
>
> class TestCompositeColumn(@(Component @field) var logFileId: Long,
> @(Component @field) var dt: String, @(Component @field) var dk: String)
> extends Ordered[TestCompositeColumn] {
> def this() = this(0l, "", "")
> //equals, hashCode, compare all implemented
> }
>
> I've also tried this variation on the class:
>
> class TestCompositeColumn(idIn: Long, key1In: String, key2In: String)
> extends Ordered[TestCompositeColumn] {
> @Component(ordinal = 0) var id: Long = idIn
> @Component(ordinal = 1) var key1: String = key1In
> @Component(ordinal = 2) var key2: String = key2In
>
> def this() = this(0, null, null)
> //equals, hashCode, compare all implemented
> }
> val TEST_COLUMN_FAMILY = new ColumnFamily[TestRowKey, TestCompositeColumn](
> "test_column_family",
> new AnnotatedCompositeSerializer[TestRowKey](classOf[TestRowKey]),
> new
> AnnotatedCompositeSerializer[TestCompositeColumn](classOf[TestCompositeColumn]),
> BytesArraySerializer.get());
>
> var columnList = keyspace.prepareQuery(TEST_COLUMN_FAMILY)
> .getKey(TestRowKey(1l, 2012090100))
> .execute().getResult()
>
> // OK - will return 6 for example, also verified via cassandra-cli
> println(columnList.size())
>
> // ERROR - will throw exception above.  Iterating, or any type of access
> will also throw same exception
> println(columnList.getColumnByIndex(0).getStringValue())
>
> Thank you!!!
>
>
>


Re: Astyanax InstantiationException when accessing ColumnList

2012-09-12 Thread aaron morton
Was there more to the error message ? Looks likes there should be a caused by 
exception there 
https://github.com/Netflix/astyanax/blob/master/src/main/java/com/netflix/astyanax/serializers/AnnotatedCompositeSerializer.java#L114

The InstationError is being raised when it tries to create an instance of the 
column type 
https://github.com/Netflix/astyanax/blob/master/src/main/java/com/netflix/astyanax/serializers/AnnotatedCompositeSerializer.java#L166

I would check everything is in the class path and create an issue on 
https://github.com/Netflix/astyanax/issues if you get stuck. 

Cheers



-
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 12/09/2012, at 2:04 PM, Ran User  wrote:

> Oops, forgot to mention Cassandra version - 1.1.4
> 
> On Tue, Sep 11, 2012 at 5:54 AM, Ran User  wrote:
> Stuck for hours on this one, thanks in advance!
>  
> -  Scala 2.9.2
> - Astyanax 1.0.6 (also tried 1.0.5)
> - Using CompositeRowKey, CompositeColumnName
> - No problem inserting into Cassandra
> - Can read a row, ColumnList.size() returns correct count however any attempt 
> to access ColumnList (i.e. iterate, access iterate ColumnList, 
> getColumnByIndex(), getColumnByName(), etc) will throw the following 
> exception:
> Exception:
> 
> java.lang.RuntimeException: java.lang.InstantiationException
> 
> relevant stack trace:
> 
> java.lang.RuntimeException: java.lang.InstantiationException: 
> shops.integration.db.scalaquery.ReportingDao$MetricsLogFileCompositeColumn
> at 
> com.netflix.astyanax.serializers.AnnotatedCompositeSerializer.fromByteBuffer(AnnotatedCompositeSerializer.java:136)
> at 
> com.netflix.astyanax.serializers.AbstractSerializer.fromBytes(AbstractSerializer.java:40)
> at 
> com.netflix.astyanax.thrift.model.ThriftColumnOrSuperColumnListImpl.constructMap(ThriftColumnOrSuperColumnListImpl.java:201)
> at 
> com.netflix.astyanax.thrift.model.ThriftColumnOrSuperColumnListImpl.getColumn(ThriftColumnOrSuperColumnListImpl.java:189)
> at 
> com.netflix.astyanax.thrift.model.ThriftColumnOrSuperColumnListImpl.getColumnByName(ThriftColumnOrSuperColumnListImpl.java:103)
> 
> Relevant sample code:
> 
> class TestCompositeColumn(@(Component @field) var logFileId: Long, 
> @(Component @field) var dt: String, @(Component @field) var dk: String) 
> extends Ordered[TestCompositeColumn] {
> def this() = this(0l, "", "")
> //equals, hashCode, compare all implemented
> }
> 
> I've also tried this variation on the class:
> 
> class TestCompositeColumn(idIn: Long, key1In: String, key2In: String) 
> extends Ordered[TestCompositeColumn] {
> @Component(ordinal = 0) var id: Long = idIn
> @Component(ordinal = 1) var key1: String = key1In
> @Component(ordinal = 2) var key2: String = key2In
> 
> def this() = this(0, null, null)
> //equals, hashCode, compare all implemented
> }
> 
> val TEST_COLUMN_FAMILY = new ColumnFamily[TestRowKey, TestCompositeColumn](
> "test_column_family",
> new AnnotatedCompositeSerializer[TestRowKey](classOf[TestRowKey]),
> new 
> AnnotatedCompositeSerializer[TestCompositeColumn](classOf[TestCompositeColumn]),
> BytesArraySerializer.get());
>  
> var columnList = keyspace.prepareQuery(TEST_COLUMN_FAMILY)
> .getKey(TestRowKey(1l, 2012090100))
> .execute().getResult()
> 
> // OK - will return 6 for example, also verified via cassandra-cli
> println(columnList.size()) 
> 
> // ERROR - will throw exception above.  Iterating, or any type of access will 
> also throw same exception
> println(columnList.getColumnByIndex(0).getStringValue()) 
>  
> Thank you!!!
>  
> 



Re: Astyanax InstantiationException when accessing ColumnList

2012-09-12 Thread Ran User
Yes you are right, the issue is here in Astyanax
*AnnotatedCompositeSerializer.java
:*

private T createContents(Class clazz) throws
InstantiationException, IllegalAccessException {
return clazz.newInstance();
}

I'm not sure how to get that reflection call working with my Scala
TestCompositeColumn class.  I've posted in scala-user hoping someone there
will likely know the Java -> Scala path.

If anyone here has used Astyanax in Scala w/ composite columns, and can
successfully read from Cassandra, I'd love to see one Scala class and
companion object example :)


On Wed, Sep 12, 2012 at 10:28 PM, aaron morton wrote:

> Was there more to the error message ? Looks likes there should be a caused
> by exception there
> https://github.com/Netflix/astyanax/blob/master/src/main/java/com/netflix/astyanax/serializers/AnnotatedCompositeSerializer.java#L114
>
> The InstationError is being raised when it tries to create an instance of
> the column type
>
> https://github.com/Netflix/astyanax/blob/master/src/main/java/com/netflix/astyanax/serializers/AnnotatedCompositeSerializer.java#L166
>
> I would check everything is in the class path and create an issue on
> https://github.com/Netflix/astyanax/issues if you get stuck.
>
> Cheers
>
>
>
> -
> Aaron Morton
> Freelance Developer
> @aaronmorton
> http://www.thelastpickle.com
>
> On 12/09/2012, at 2:04 PM, Ran User  wrote:
>
> Oops, forgot to mention Cassandra version - 1.1.4
>
> On Tue, Sep 11, 2012 at 5:54 AM, Ran User  wrote:
>
>> Stuck for hours on this one, thanks in advance!
>>
>> -  Scala 2.9.2
>> - Astyanax 1.0.6 (also tried 1.0.5)
>> - Using CompositeRowKey, CompositeColumnName
>> - No problem inserting into Cassandra
>> - Can read a row, ColumnList.size() returns correct count however any
>> attempt to access ColumnList (i.e. iterate, access iterate ColumnList,
>> getColumnByIndex(), getColumnByName(), etc) will throw the following
>> exception:
>>
>> Exception:
>>
>> java.lang.RuntimeException: java.lang.InstantiationException
>>
>> relevant stack trace:
>>
>> java.lang.RuntimeException: java.lang.InstantiationException:
>> shops.integration.db.scalaquery.ReportingDao$MetricsLogFileCompositeColumn
>> at
>> com.netflix.astyanax.serializers.AnnotatedCompositeSerializer.fromByteBuffer(AnnotatedCompositeSerializer.java:136)
>> at
>> com.netflix.astyanax.serializers.AbstractSerializer.fromBytes(AbstractSerializer.java:40)
>> at
>> com.netflix.astyanax.thrift.model.ThriftColumnOrSuperColumnListImpl.constructMap(ThriftColumnOrSuperColumnListImpl.java:201)
>> at
>> com.netflix.astyanax.thrift.model.ThriftColumnOrSuperColumnListImpl.getColumn(ThriftColumnOrSuperColumnListImpl.java:189)
>> at
>> com.netflix.astyanax.thrift.model.ThriftColumnOrSuperColumnListImpl.getColumnByName(ThriftColumnOrSuperColumnListImpl.java:103)
>>
>> Relevant sample code:
>>
>> class TestCompositeColumn(@(Component @field) var logFileId: Long,
>> @(Component @field) var dt: String, @(Component @field) var dk: String)
>> extends Ordered[TestCompositeColumn] {
>> def this() = this(0l, "", "")
>> //equals, hashCode, compare all implemented
>> }
>>
>> I've also tried this variation on the class:
>>
>> class TestCompositeColumn(idIn: Long, key1In: String, key2In: String)
>> extends Ordered[TestCompositeColumn] {
>> @Component(ordinal = 0) var id: Long = idIn
>> @Component(ordinal = 1) var key1: String = key1In
>> @Component(ordinal = 2) var key2: String = key2In
>>
>> def this() = this(0, null, null)
>> //equals, hashCode, compare all implemented
>> }
>> val TEST_COLUMN_FAMILY = new ColumnFamily[TestRowKey,
>> TestCompositeColumn](
>> "test_column_family",
>> new AnnotatedCompositeSerializer[TestRowKey](classOf[TestRowKey]),
>> new
>> AnnotatedCompositeSerializer[TestCompositeColumn](classOf[TestCompositeColumn]),
>> BytesArraySerializer.get());
>>
>> var columnList = keyspace.prepareQuery(TEST_COLUMN_FAMILY)
>> .getKey(TestRowKey(1l, 2012090100))
>> .execute().getResult()
>>
>> // OK - will return 6 for example, also verified via cassandra-cli
>> println(columnList.size())
>>
>> // ERROR - will throw exception above.  Iterating, or any type of access
>> will also throw same exception
>> println(columnList.getColumnByIndex(0).getStringValue())
>>
>> Thank you!!!
>>
>>
>
>
>