cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sylvain Lebresne (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CASSANDRA-5852) json2sstable breaks on data exported from sstable2json.
Date Wed, 18 Sep 2013 16:15:52 GMT

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

Sylvain Lebresne commented on CASSANDRA-5852:
---------------------------------------------

You're right that getColumnDefinitionFromColumnName doesn't always work, but in fact to be
more reliable it shouldn't assume anything on the number of components after split. So I'd
changed it to something like:
{noformat}
ByteBuffer[] components = composite.split(columnName);
for (ColumnDefinition def : column_metadata.values())
{
    ByteBuffer toCompare;
    if (def.componentIndex == null)
    {
        toCompare = columnName;
    }
    else
    {
        if (def.componentIndex >= components.length)
            break;

        toCompare = components[def.componentIndex];
    }
    if (def.name.equals(toCompare))
        return def;
}
{noformat}

Other nits:
* the patch adds a println, not sure that was the intent.
* getValueValidator actually knows how to handle null, so we don't need to check the result
of getColumnDefinitionFromColumnName first.

As a side note, it's ok to only provide a 1.2 patch (unless the patch for 2.0 has important
differences that are related to the ticket, which is not the case here), I'll fix the 2.0
specificities during merge.

                
> json2sstable breaks on data exported from sstable2json.
> -------------------------------------------------------
>
>                 Key: CASSANDRA-5852
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-5852
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Tools
>    Affects Versions: 1.2.4, 1.2.9, 2.0 rc1
>            Reporter: Ryan McGuire
>            Assignee: Lyuben Todorov
>            Priority: Minor
>             Fix For: 2.0.1
>
>         Attachments: 5852_cassandra-1.2.patch, 5852_cassandra-1.2_v2.patch, 5852_cassandra-2.0.patch,
5852_cassandra-2.0_v2.patch, r.json
>
>
> Attached is a JSON formatted sstable generated by sstable2json.
> This file cannot be loaded back into Cassandra via json2sstable; it outputs this error:
> {code}
> Counting keys to import, please wait... (NOTE: to skip this use -n <num_keys>)
> Importing 16 keys...
> java.lang.NumberFormatException: Non-hex characters in value6
> 	at org.apache.cassandra.utils.Hex.hexToBytes(Hex.java:60)
> 	at org.apache.cassandra.utils.ByteBufferUtil.hexToBytes(ByteBufferUtil.java:503)
> 	at org.apache.cassandra.tools.SSTableImport.stringAsType(SSTableImport.java:578)
> 	at org.apache.cassandra.tools.SSTableImport.access$000(SSTableImport.java:59)
> 	at org.apache.cassandra.tools.SSTableImport$JsonColumn.<init>(SSTableImport.java:154)
> 	at org.apache.cassandra.tools.SSTableImport.addColumnsToCF(SSTableImport.java:231)
> 	at org.apache.cassandra.tools.SSTableImport.addToStandardCF(SSTableImport.java:214)
> 	at org.apache.cassandra.tools.SSTableImport.importSorted(SSTableImport.java:432)
> 	at org.apache.cassandra.tools.SSTableImport.importJson(SSTableImport.java:319)
> 	at org.apache.cassandra.tools.SSTableImport.main(SSTableImport.java:543)
> ERROR: Non-hex characters in value6
> {code}
> Steps to reproduce:
> {code}
> $ ccm create -v git:trunk test-json-import
> Fetching Cassandra updates...
> Current cluster is now: test-json-import
> $ ccm populate -n 1
> $ ccm start
> $ ccm node1 cqlsh
> Connected to test-json-import at 127.0.0.1:9160.
> [cqlsh 4.0.0 | Cassandra 2.0.0-rc1-SNAPSHOT | CQL spec 3.1.0 | Thrift protocol 19.37.0]
> Use HELP for help.
> cqlsh> CREATE KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor':
1};
> cqlsh> CREATE TABLE test.test (key varchar PRIMARY KEY, value varchar);
> cqlsh> INSERT INTO test.test (key, value) VALUES ('ryan', 'ryan');
> cqlsh> 
> $ ccm node1 flush
> $ ccm stop
> $ ~/.ccm/test-json-import/node1/bin/json2sstable -s -K test -c test ~/Downloads/import_error/r.json
~/.ccm/test-json-import/node1/data/test/test/test-test-ja-1-Data.db 
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message