mirror of https://github.com/apache/cassandra
(de)serialize columns to/from hex regardless of comparator
Patch by eevans; reviewed by Ramzi Rabah for CASSANDRA-618 git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@890480 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9572076a8e
commit
93d9a81dcf
|
|
@ -31,7 +31,7 @@ import org.apache.cassandra.dht.IPartitioner;
|
|||
import org.apache.cassandra.io.IteratingRow;
|
||||
import org.apache.cassandra.io.SSTableReader;
|
||||
import org.apache.cassandra.io.SSTableScanner;
|
||||
import org.apache.cassandra.utils.FBUtilities;
|
||||
import static org.apache.cassandra.utils.FBUtilities.bytesToHex;
|
||||
import org.apache.commons.cli.*;
|
||||
|
||||
/**
|
||||
|
|
@ -77,9 +77,9 @@ public class SSTableExport
|
|||
{
|
||||
json.append("[");
|
||||
IColumn column = iter.next();
|
||||
json.append(quote(comp.getString(column.name())));
|
||||
json.append(quote(bytesToHex(column.name())));
|
||||
json.append(", ");
|
||||
json.append(quote(FBUtilities.bytesToHex(column.value())));
|
||||
json.append(quote(bytesToHex(column.value())));
|
||||
json.append(", ");
|
||||
json.append(column.timestamp());
|
||||
json.append(", ");
|
||||
|
|
@ -108,7 +108,7 @@ public class SSTableExport
|
|||
while (iter.hasNext())
|
||||
{
|
||||
IColumn column = iter.next();
|
||||
json.append(asKey(comparator.getString(column.name())));
|
||||
json.append(asKey(bytesToHex(column.name())));
|
||||
json.append("{");
|
||||
json.append(asKey("deletedAt"));
|
||||
json.append(column.getMarkedForDeleteAt());
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import org.apache.cassandra.db.filter.QueryPath;
|
|||
import org.apache.cassandra.dht.IPartitioner;
|
||||
import org.apache.cassandra.io.DataOutputBuffer;
|
||||
import org.apache.cassandra.io.SSTableWriter;
|
||||
import org.apache.cassandra.utils.FBUtilities;
|
||||
import static org.apache.cassandra.utils.FBUtilities.hexToBytes;
|
||||
import org.apache.commons.cli.*;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
|
@ -85,9 +85,9 @@ public class SSTableImport
|
|||
{
|
||||
for (Object c : row)
|
||||
{
|
||||
JsonColumn col = new JsonColumn(c);
|
||||
QueryPath path = new QueryPath(cfamily.name(), null, col.name.getBytes());
|
||||
cfamily.addColumn(path, FBUtilities.hexToBytes(col.value), col.timestamp, col.isDeleted);
|
||||
JsonColumn col = new JsonColumn(c);
|
||||
QueryPath path = new QueryPath(cfamily.name(), null, hexToBytes(col.name));
|
||||
cfamily.addColumn(path, hexToBytes(col.value), col.timestamp, col.isDeleted);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +102,7 @@ public class SSTableImport
|
|||
// Super columns
|
||||
for (Map.Entry<String, JSONObject> entry : (Set<Map.Entry<String, JSONObject>>)row.entrySet())
|
||||
{
|
||||
byte[] superName = entry.getKey().getBytes();
|
||||
byte[] superName = hexToBytes(entry.getKey());
|
||||
long deletedAt = (Long)entry.getValue().get("deletedAt");
|
||||
JSONArray subColumns = (JSONArray)entry.getValue().get("subColumns");
|
||||
|
||||
|
|
@ -110,8 +110,8 @@ public class SSTableImport
|
|||
for (Object c : subColumns)
|
||||
{
|
||||
JsonColumn col = new JsonColumn(c);
|
||||
QueryPath path = new QueryPath(cfamily.name(), superName, col.name.getBytes());
|
||||
cfamily.addColumn(path, FBUtilities.hexToBytes(col.value), col.timestamp, col.isDeleted);
|
||||
QueryPath path = new QueryPath(cfamily.name(), superName, hexToBytes(col.name));
|
||||
cfamily.addColumn(path, hexToBytes(col.value), col.timestamp, col.isDeleted);
|
||||
}
|
||||
|
||||
SuperColumn superColumn = (SuperColumn)cfamily.getColumn(superName);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"rowA": [["colAA", "76616c4141", 1, false], ["colAB", "76616c4142", 1, false]],
|
||||
"rowB": [["colBA", "76616c4241", 1, false], ["colBB", "76616c4242", 1, false]]
|
||||
"rowA": [["636f6c4141", "76616c4141", 1, false], ["636f6c4142", "76616c4142", 1, false]],
|
||||
"rowB": [["636f6c4241", "76616c4241", 1, false], ["636f6c4242", "76616c4242", 1, false]]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"rowA": {"superA": {"deletedAt": -9223372036854775808, "subColumns": [["colAA", "76616c75654141", 1, false], ["colAB", "76616c75654142", 1, false]]}},
|
||||
"rowB": {"superB": {"deletedAt": -9223372036854775808, "subColumns": [["colBA", "76616c75654241", 1, false], ["colBB", "76616c75654242", 1, false]]}}
|
||||
"rowA": {"737570657241": {"deletedAt": -9223372036854775808, "subColumns": [["636f6c4141", "76616c75654141", 1, false], ["636f6c4142", "76616c75654142", 1, false]]}},
|
||||
"rowB": {"737570657242": {"deletedAt": -9223372036854775808, "subColumns": [["636f6c4241", "76616c75654241", 1, false], ["636f6c4242", "76616c75654242", 1, false]]}}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue