use of org.apache.phoenix.pherf.util.RowCalculator in project phoenix by apache.
the class RowCalculatorTest method assertRowsSum.
private void assertRowsSum(int threadPoolSize, int tableRowCount) {
int sum = 0;
RowCalculator rc = new RowCalculator(threadPoolSize, tableRowCount);
assertEquals("Rows generated did not match expected count! ", threadPoolSize, rc.size());
// Sum of all rows should equal expected row count
for (int i = 0; i < threadPoolSize; i++) {
sum += rc.getNext();
}
assertEquals("Rows did not sum up correctly", tableRowCount, sum);
// Ensure rows were removed from list
assertEquals(rc.size(), 0);
}
use of org.apache.phoenix.pherf.util.RowCalculator in project phoenix by apache.
the class WriteWorkload method getBatches.
private List<Future<Info>> getBatches(DataLoadThreadTime dataLoadThreadTime, Scenario scenario) throws Exception {
RowCalculator rowCalculator = new RowCalculator(getThreadPoolSize(), scenario.getRowCount());
List<Future<Info>> writeBatches = new ArrayList<>();
for (int i = 0; i < getThreadPoolSize(); i++) {
List<Column> phxMetaCols = pUtil.getColumnsFromPhoenix(scenario.getSchemaName(), scenario.getTableNameWithoutSchemaName(), pUtil.getConnection(scenario.getTenantId()));
int threadRowCount = rowCalculator.getNext();
logger.info("Kick off thread (#" + i + ")for upsert with (" + threadRowCount + ") rows.");
Future<Info> write = upsertData(scenario, phxMetaCols, scenario.getTableName(), threadRowCount, dataLoadThreadTime, this.useBatchApi);
writeBatches.add(write);
}
if (writeBatches.isEmpty()) {
throw new PherfException("Holy shit snacks! Throwing up hands in disbelief and exiting. Could not write data for some unknown reason.");
}
return writeBatches;
}
Aggregations