// We don't paginate this call. So we should make sure the number of reads is tolerable.
// TODO: Think about paginating this call.
private Map<Locator, ColumnList<Long>> getColumnsFromDB(List<Locator> locators, ColumnFamily<Locator, Long> CF,
                                                            Range range) {
        if (range.getStart() > range.getStop()) {
            throw new RuntimeException(String.format("Invalid rollup range: ", range.toString()));
        }
        boolean isBatch = locators.size() != 1;
        final Map<Locator, ColumnList<Long>> columns = new HashMap<Locator, ColumnList<Long>>();
        final RangeBuilder rangeBuilder = new RangeBuilder().setStart(range.getStart()).setEnd(range.getStop());
        Timer.Context ctx = isBatch ? Instrumentation.getBatchReadTimerContext(CF) : Instrumentation.getReadTimerContext(CF);
        try {
            // We don't paginate this call. So we should make sure the number of reads is tolerable.
            // TODO: Think about paginating this call.
            OperationResult<Rows<Locator, Long>> query = keyspace
                    .prepareQuery(CF)
                    .getKeySlice(locators)
                    .withColumnRange(rangeBuilder.build())
                    .execute();
            for (Row<Locator, Long> row : query.getResult()) {
                columns.put(row.getKey(), row.getColumns());
            }
        } catch (ConnectionException e) {
            if (e instanceof NotFoundException) { // TODO: Not really sure what happens when one of the keys is not found.
                Instrumentation.markNotFound(CF);
            } else {
                if (isBatch) { Instrumentation.markBatchReadError(e); }
                else { Instrumentation.markReadError(e); }
            }
            log.warn((isBatch ? "Batch " : "") + " read query failed for column family " + CF.getName(), e);
        } finally {
            ctx.stop();
        }
        return columns;
    }
Timer.Context ctx = isBatch ? Instrumentation.getBatchReadTimerContext(CF) : Instrumentation.getReadTimerContext(CF);
try {
// We don't paginate this call. So we should make sure the number of reads is tolerable.
// TODO: Think about paginating this call.
OperationResult<Rows<Locator, Long>> query = keyspace
.prepareQuery(CF)
private Map<Locator, ColumnList<Long>> getColumnsFromDB(List<Locator> locators, ColumnFamily<Locator, Long> CF,
Range range) {
if (range.getStart() > range.getStop()) {
throw new RuntimeException(String.format("Invalid rollup range: ", range.toString()));
}
boolean isBatch = locators.size() != 1;
final Map<Locator, ColumnList<Long>> columns = new HashMap<Locator, ColumnList<Long>>();
final RangeBuilder rangeBuilder = new RangeBuilder().setStart(range.getStart()).setEnd(range.getStop());
Timer.Context ctx = isBatch ? Instrumentation.getBatchReadTimerContext(CF) : Instrumentation.getReadTimerContext(CF);
try {
// We don't paginate this call. So we should make sure the number of reads is tolerable.
// TODO: Think about paginating this call.
OperationResult<Rows<Locator, Long>> query = keyspace
.prepareQuery(CF)
.getKeySlice(locators)
.withColumnRange(rangeBuilder.build())
.execute();
for (Row<Locator, Long> row : query.getResult()) {
columns.put(row.getKey(), row.getColumns());
}
} catch (ConnectionException e) {
if (e instanceof NotFoundException) { // TODO: Not really sure what happens when one of the keys is not found.
private Map<Locator, ColumnList<Long>> getColumnsFromDB(List<Locator> locators, ColumnFamily<Locator, Long> CF,
Range range) {
if (range.getStart() > range.getStop()) {
throw new RuntimeException(String.format("Invalid rollup range: ", range.toString()));
}
boolean isBatch = locators.size() != 1;
final Map<Locator, ColumnList<Long>> columns = new HashMap<Locator, ColumnList<Long>>();
final RangeBuilder rangeBuilder = new RangeBuilder().setStart(range.getStart()).setEnd(range.getStop());
Timer.Context ctx = isBatch ? Instrumentation.getBatchReadTimerContext(CF) : Instrumentation.getReadTimerContext(CF);
try {
// We don't paginate this call. So we should make sure the number of reads is tolerable.
// TODO: Think about paginating this call.
OperationResult<Rows<Locator, Long>> query = keyspace
.prepareQuery(CF)
.getKeySlice(locators)
.withColumnRange(rangeBuilder.build())
.execute();
for (Row<Locator, Long> row : query.getResult()) {
columns.put(row.getKey(), row.getColumns());
}
} catch (ConnectionException e) {
if (e instanceof NotFoundException) { // TODO: Not really sure what happens when one of the keys is not found.
Instrumentation.markNotFound(CF);
} else {
if (isBatch) { Instrumentation.markBatchReadError(e); }
else { Instrumentation.markReadError(e); }
}
log.warn((isBatch ? "Batch " : "") + " read query failed for column family " + CF.getName(), e);
} finally {
ctx.stop();
}
return columns;