Search in sources :

Example 1 with RecordQueryPlanWithNoChildren

use of com.apple.foundationdb.record.query.plan.plans.RecordQueryPlanWithNoChildren in project fdb-record-layer by FoundationDB.

the class FDBRecordStoreScanLimitTest method getMaximumToScan.

private int getMaximumToScan(QueryPlan<?> plan) throws Exception {
    if (plan instanceof RecordQueryPlanWithNoChildren) {
        try (FDBRecordContext context = openContext()) {
            openSimpleRecordStore(context);
            RecordQueryPlanWithNoChildren planWithNoChildren = (RecordQueryPlanWithNoChildren) plan;
            try (RecordCursorIterator<FDBQueriedRecord<Message>> cursor = recordStore.executeQuery(planWithNoChildren, null, ExecuteProperties.SERIAL_EXECUTE).asIterator()) {
                int maximumToScan = 0;
                while (cursor.hasNext()) {
                    FDBQueriedRecord<Message> record = cursor.next();
                    maximumToScan += record.getStoredRecord().getKeyCount() + (record.getStoredRecord().isVersionedInline() ? 1 : 0);
                }
                return maximumToScan;
            }
        }
    }
    int maximumToScan = 0;
    for (QueryPlan<?> child : plan.getQueryPlanChildren()) {
        maximumToScan += getMaximumToScan(child);
    }
    return maximumToScan;
}
Also used : RecordQueryPlanWithNoChildren(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlanWithNoChildren) FDBQueriedRecord(com.apple.foundationdb.record.provider.foundationdb.FDBQueriedRecord) KeyValueLogMessage(com.apple.foundationdb.record.logging.KeyValueLogMessage) Message(com.google.protobuf.Message) FDBRecordContext(com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext)

Aggregations

KeyValueLogMessage (com.apple.foundationdb.record.logging.KeyValueLogMessage)1 FDBQueriedRecord (com.apple.foundationdb.record.provider.foundationdb.FDBQueriedRecord)1 FDBRecordContext (com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext)1 RecordQueryPlanWithNoChildren (com.apple.foundationdb.record.query.plan.plans.RecordQueryPlanWithNoChildren)1 Message (com.google.protobuf.Message)1