[ 
https://issues.apache.org/jira/browse/CASSANDRA-12594?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15458966#comment-15458966
 ] 

Andy Tolbert edited comment on CASSANDRA-12594 at 9/2/16 4:24 PM:
------------------------------------------------------------------

That is understandable (y).  I was working around 
{{ColumnDefinition.cellValueType()}} returning the same thing it returns for a 
non-frozen collection.   Wouldn't there also be an issue in the tools' 
dependence on {{AbstractType#getString}} to get a string representation of 
data?  Currently collections return hexstring representation for {{getString}} 
(via {{CollectionType}}, which doesn't seem useful for the sstabledump output). 
 Should the various {{CollectionType}} implementations implement their own 
{{getString}} as well?


was (Author: andrew.tolbert):
That is understandable (y).  I was working around 
{{ColumnDefinition.cellValueType()}} returning the same thing it returns for a 
non-frozen collection.   Wouldn't there also be an issue in the tools' 
dependence on {{AbstractType#getString}} to get a string representation of 
data?  Currently collections return hexstring representation for {{getString}} 
(via {{CollectionType}}, which doesn't seem useful for the sstabledump output.  
Should the various {{CollectionType}} implementations implement their own 
{{getString}} as well?

> sstabledump fails on frozen collection cells
> --------------------------------------------
>
>                 Key: CASSANDRA-12594
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-12594
>             Project: Cassandra
>          Issue Type: Bug
>            Reporter: Andy Tolbert
>            Assignee: Andy Tolbert
>            Priority: Minor
>             Fix For: 3.0.9, 3.9
>
>         Attachments: CASSANDRA-12594-3.0.txt, CASSANDRA-12594-3.0_2.txt
>
>
> sstabledump throws an exception when attempting to parse a cell that is a 
> frozen collection, i.e.:
> {noformat}
> [
>   {
>     "partition" : {
>       "key" : [ "0" ],
>       "position" : 0
>     },
>     "rows" : [
>       {
>         "type" : "row",
>         "position" : 18,
>         "liveness_info" : { "tstamp" : "2016-09-01T22:06:45.670810Z" },
>         "cells" : [
>           { "name" : "m", "value" }
>         ] }
>     ] }
> ]Exception in thread "main" java.lang.IllegalArgumentException
>       at java.nio.Buffer.limit(Buffer.java:275)
>       at 
> org.apache.cassandra.utils.ByteBufferUtil.readBytes(ByteBufferUtil.java:613)
>       at 
> org.apache.cassandra.db.marshal.TupleType.getString(TupleType.java:211)
>       at 
> org.apache.cassandra.tools.JsonTransformer.serializeCell(JsonTransformer.java:441)
>       at 
> org.apache.cassandra.tools.JsonTransformer.serializeColumnData(JsonTransformer.java:375)
>       at 
> org.apache.cassandra.tools.JsonTransformer.serializeRow(JsonTransformer.java:279)
>       at 
> org.apache.cassandra.tools.JsonTransformer.serializePartition(JsonTransformer.java:214)
>       at 
> java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
>       at 
> java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
>       at java.util.Iterator.forEachRemaining(Iterator.java:116)
>       at 
> java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
>       at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
>       at 
> java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
>       at 
> java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
>       at 
> java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
>       at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
>       at 
> java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
>       at 
> org.apache.cassandra.tools.JsonTransformer.toJson(JsonTransformer.java:102)
>       at org.apache.cassandra.tools.SSTableExport.main(SSTableExport.java:242)
> {noformat}
> This is because the code doesn't consider that the cell may be a frozen 
> collection, and attempts to get the string representation using the value 
> type which doesn't work.
> Example data:
> {noformat}
> CREATE KEYSPACE simple WITH replication = {'class': 'SimpleStrategy', 
> 'replication_factor': '1'};
> CREATE TABLE simple.unfrozen_map (
>     k int PRIMARY KEY,
>     m map<text, frozen<tuple<text, text>>>
> );
> CREATE TABLE simple.frozen_map (
>     k int PRIMARY KEY,
>     m frozen<map<text, frozen<tuple<text, text>>>>
> );
> insert into unfrozen_map (k, m) values (0, {'a': ('b', 'c'), 'd': ('e', 'f'), 
> 'g': ('h', 'i')});
> insert into frozen_map (k, m) values (0, {'a': ('b', 'c'), 'd': ('e', 'f'), 
> 'g': ('h', 'i')});
> {noformat}
> unfrozen_map will properly dump each cell individually, but frozen_map fails.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to