Details
-
Bug
-
Status: Resolved
-
Low
-
Resolution: Duplicate
-
None
-
None
-
Low
Description
sstabledump throws an exception when attempting to parse a cell that is a frozen collection, i.e.:
[ { "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)
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:
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')});
unfrozen_map will properly dump each cell individually, but frozen_map fails.
Attachments
Attachments
Issue Links
- duplicates
-
CASSANDRA-12628 sstabledump should use AbstractType.toJSONString() instead of getString()
- Open
- is duplicated by
-
CASSANDRA-13573 ColumnMetadata.cellValueType() doesn't return correct type for non-frozen collection
- Resolved