* @throws ParseException for errors encountered parsing JSON input
*/
public static void importJson(String jsonFile, String keyspace, String cf, String ssTablePath)
throws IOException, ParseException
{
ColumnFamily cfamily = ColumnFamily.create(keyspace, cf);
String cfType = cfamily.type(); // Super or Standard
IPartitioner<?> partitioner = DatabaseDescriptor.getPartitioner();
DataOutputBuffer dob = new DataOutputBuffer();
try
{
JSONObject json = (JSONObject)JSONValue.parseWithException(new FileReader(jsonFile));
SSTableWriter writer = new SSTableWriter(ssTablePath, json.size(), partitioner);
List<DecoratedKey<?>> decoratedKeys = new ArrayList<DecoratedKey<?>>();
for (String key : (Set<String>)json.keySet())
decoratedKeys.add(partitioner.decorateKey(key));
Collections.sort(decoratedKeys);
for (DecoratedKey<?> rowKey : decoratedKeys)
{
if (cfType.equals("Super"))
addToSuperCF((JSONObject)json.get(rowKey.key), cfamily);
else
addToStandardCF((JSONArray)json.get(rowKey.key), cfamily);
ColumnFamily.serializer().serializeWithIndexes(cfamily, dob);
writer.append(rowKey, dob);
dob.reset();
cfamily.clear();
}
writer.closeAndOpenReader(0);
}
catch (ClassCastException cce)