use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class SystemTable method isIndexBuilt.
public static boolean isIndexBuilt(String table, String indexName) {
ColumnFamilyStore cfs = Table.open(Table.SYSTEM_TABLE).getColumnFamilyStore(INDEX_CF);
QueryFilter filter = QueryFilter.getNamesFilter(decorate(ByteBufferUtil.bytes(table)), new QueryPath(INDEX_CF), ByteBufferUtil.bytes(indexName));
return ColumnFamilyStore.removeDeleted(cfs.getColumnFamily(filter), Integer.MAX_VALUE) != null;
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class SliceByNamesReadCommandSerializer method deserialize.
public SliceByNamesReadCommand deserialize(DataInput dis, int version) throws IOException {
boolean isDigest = dis.readBoolean();
String table = dis.readUTF();
ByteBuffer key = ByteBufferUtil.readWithShortLength(dis);
QueryPath columnParent = QueryPath.deserialize(dis);
int size = dis.readInt();
List<ByteBuffer> columns = new ArrayList<ByteBuffer>();
for (int i = 0; i < size; ++i) {
columns.add(ByteBufferUtil.readWithShortLength(dis));
}
SliceByNamesReadCommand command = new SliceByNamesReadCommand(table, key, columnParent, columns);
command.setDigestQuery(isDigest);
return command;
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class LongTableTest method testGetRowMultiColumn.
@Test
public void testGetRowMultiColumn() throws Throwable {
final Table table = Table.open("Keyspace1");
final ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1");
for (int i = 1; i < 5000; i += 100) {
RowMutation rm = new RowMutation("Keyspace1", Util.dk("key" + i).key);
ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1");
for (int j = 0; j < i; j++) cf.addColumn(column("c" + j, "v" + j, 1L));
rm.add(cf);
rm.applyUnsafe();
}
Runnable verify = new WrappedRunnable() {
public void runMayThrow() throws Exception {
ColumnFamily cf;
for (int i = 1; i < 5000; i += 100) {
for (int j = 0; j < i; j++) {
cf = cfStore.getColumnFamily(QueryFilter.getNamesFilter(Util.dk("key" + i), new QueryPath("Standard1"), ByteBufferUtil.bytes("c" + j)));
TableTest.assertColumns(cf, "c" + j);
}
}
}
};
TableTest.reTest(table.getColumnFamilyStore("Standard1"), verify);
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class SSTableExportTest method testRoundTripStandardCf.
@Test
public void testRoundTripStandardCf() throws IOException, ParseException {
File tempSS = tempSSTableFile("Keyspace1", "Standard1");
ColumnFamily cfamily = ColumnFamily.create("Keyspace1", "Standard1");
SSTableWriter writer = new SSTableWriter(tempSS.getPath(), 2);
// Add rowA
cfamily.addColumn(new QueryPath("Standard1", null, ByteBufferUtil.bytes("name")), ByteBufferUtil.bytes("val"), System.currentTimeMillis());
writer.append(Util.dk("rowA"), cfamily);
cfamily.clear();
// Add rowExclude
cfamily.addColumn(new QueryPath("Standard1", null, ByteBufferUtil.bytes("name")), ByteBufferUtil.bytes("val"), System.currentTimeMillis());
writer.append(Util.dk("rowExclude"), cfamily);
cfamily.clear();
SSTableReader reader = writer.closeAndOpenReader();
// Export to JSON and verify
File tempJson = File.createTempFile("Standard1", ".json");
SSTableExport.export(reader, new PrintStream(tempJson.getPath()), new String[] { asHex("rowExclude") });
// Import JSON to another SSTable file
File tempSS2 = tempSSTableFile("Keyspace1", "Standard1");
SSTableImport.importJson(tempJson.getPath(), "Keyspace1", "Standard1", tempSS2.getPath());
reader = SSTableReader.open(Descriptor.fromFilename(tempSS2.getPath()));
QueryFilter qf = QueryFilter.getNamesFilter(Util.dk("rowA"), new QueryPath("Standard1", null, null), ByteBufferUtil.bytes("name"));
ColumnFamily cf = qf.getSSTableColumnIterator(reader).getColumnFamily();
assertTrue(cf != null);
assertTrue(cf.getColumn(ByteBufferUtil.bytes("name")).value().equals(hexToBytes("76616c")));
qf = QueryFilter.getNamesFilter(Util.dk("rowExclude"), new QueryPath("Standard1", null, null), ByteBufferUtil.bytes("name"));
cf = qf.getSSTableColumnIterator(reader).getColumnFamily();
assert cf == null;
}
use of org.apache.cassandra.db.filter.QueryPath in project eiger by wlloyd.
the class SSTableExportTest method testExportSuperCf.
@Test
public void testExportSuperCf() throws IOException {
File tempSS = tempSSTableFile("Keyspace1", "Super4");
ColumnFamily cfamily = ColumnFamily.create("Keyspace1", "Super4");
SSTableWriter writer = new SSTableWriter(tempSS.getPath(), 2);
// Add rowA
cfamily.addColumn(new QueryPath("Super4", ByteBufferUtil.bytes("superA"), ByteBufferUtil.bytes("colA")), ByteBufferUtil.bytes("valA"), System.currentTimeMillis());
writer.append(Util.dk("rowA"), cfamily);
cfamily.clear();
// Add rowB
cfamily.addColumn(new QueryPath("Super4", ByteBufferUtil.bytes("superB"), ByteBufferUtil.bytes("colB")), ByteBufferUtil.bytes("valB"), System.currentTimeMillis());
writer.append(Util.dk("rowB"), cfamily);
cfamily.clear();
// Add rowExclude
cfamily.addColumn(new QueryPath("Super4", ByteBufferUtil.bytes("superX"), ByteBufferUtil.bytes("colX")), ByteBufferUtil.bytes("valX"), System.currentTimeMillis());
writer.append(Util.dk("rowExclude"), cfamily);
cfamily.clear();
SSTableReader reader = writer.closeAndOpenReader();
// Export to JSON and verify
File tempJson = File.createTempFile("Super4", ".json");
SSTableExport.export(reader, new PrintStream(tempJson.getPath()), new String[] { asHex("rowExclude") });
JSONObject json = (JSONObject) JSONValue.parse(new FileReader(tempJson));
JSONObject rowA = (JSONObject) json.get(asHex("rowA"));
JSONObject superA = (JSONObject) rowA.get(cfamily.getComparator().getString(ByteBufferUtil.bytes("superA")));
JSONArray subColumns = (JSONArray) superA.get("subColumns");
JSONArray colA = (JSONArray) subColumns.get(0);
JSONObject rowExclude = (JSONObject) json.get(asHex("rowExclude"));
assert hexToBytes((String) colA.get(1)).equals(ByteBufferUtil.bytes("valA"));
assert colA.size() == 3;
assert rowExclude == null;
}
Aggregations