public void loadTable(String tableName) throws BlurException, TException, InterruptedException {
loadTable(tableName, 1);
}
public void loadTable(String tableName, int pass) throws BlurException, TException, InterruptedException {
Iface client = getClient();
int maxFacetValue = 100;
List<RowMutation> mutations = new ArrayList<RowMutation>();
Random random = new Random(1);
for (int i = 0; i < numberOfDocs; i++) {
String rowId = UUID.randomUUID().toString();
RecordMutation mutation = BlurThriftHelper.newRecordMutation("test", rowId,
BlurThriftHelper.newColumn("test", "value"),
BlurThriftHelper.newColumn("facet", Integer.toString(random.nextInt(maxFacetValue))),
BlurThriftHelper.newColumn("facetFixed", "test"));
RowMutation rowMutation = BlurThriftHelper.newRowMutation(tableName, rowId, mutation);
mutations.add(rowMutation);
}
ColumnDefinition columnDefinition = new ColumnDefinition();
columnDefinition.setFamily("test");
columnDefinition.setColumnName("facet");
columnDefinition.setFieldLessIndexed(true);
columnDefinition.setFieldType("string");
columnDefinition.setSortable(true);
client.addColumnDefinition(tableName, columnDefinition);
long s = System.nanoTime();
client.mutateBatch(mutations);
long e = System.nanoTime();
System.out.println("mutateBatch took [" + (e - s) / 1000000.0 + "]");
BlurQuery blurQueryRow = new BlurQuery();
Query queryRow = new Query();
queryRow.setQuery("test.test:value");
blurQueryRow.setQuery(queryRow);
blurQueryRow.setUseCacheIfPresent(false);
blurQueryRow.setCacheResult(false);
BlurResults resultsRow = client.query(tableName, blurQueryRow);
assertRowResults(resultsRow);
assertEquals(numberOfDocs * pass, resultsRow.getTotalResults());
BlurQuery blurQueryRecord = new BlurQuery();
Query queryRecord = new Query();
queryRecord.rowQuery = false;
queryRecord.setQuery("test.test:value");
blurQueryRecord.setQuery(queryRecord);
BlurResults resultsRecord = client.query(tableName, blurQueryRecord);
assertRecordResults(resultsRecord);
assertEquals(numberOfDocs * pass, resultsRecord.getTotalResults());
Schema schema = client.schema(tableName);
assertFalse(schema.getFamilies().isEmpty());
}