Search in sources :

Example 1 with RowCalculator

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);
}
Also used : RowCalculator(org.apache.phoenix.pherf.util.RowCalculator)

Example 2 with RowCalculator

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;
}
Also used : PherfException(org.apache.phoenix.pherf.exception.PherfException) Column(org.apache.phoenix.pherf.configuration.Column) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) RowCalculator(org.apache.phoenix.pherf.util.RowCalculator)

Aggregations

RowCalculator (org.apache.phoenix.pherf.util.RowCalculator)2 ArrayList (java.util.ArrayList)1 Future (java.util.concurrent.Future)1 Column (org.apache.phoenix.pherf.configuration.Column)1 PherfException (org.apache.phoenix.pherf.exception.PherfException)1