use of com.apple.foundationdb.record.query.predicates.ValuePickerValue in project fdb-record-layer by FoundationDB.
the class FDBSelectorPlanTest method testPlanValues.
@DualPlannerTest
void testPlanValues() throws Throwable {
complexQuerySetup(NO_HOOK);
RecordQuery query1 = RecordQuery.newBuilder().setRecordType("MySimpleRecord").build();
RecordQuery query2 = RecordQuery.newBuilder().setRecordType("MySimpleRecord").setFilter(Query.field("num_value_2").equalsValue(1)).build();
RecordQueryPlan plan = RecordQuerySelectorPlan.from(plan(query1, query2), List.of(50, 50));
List<? extends Value> resultValues = plan.getResultValues();
assertThat(resultValues.size(), is(1));
ValuePickerValue value = (ValuePickerValue) resultValues.get(0);
List<Value> subValues = ImmutableList.copyOf(value.getChildren());
assertThat(subValues.size(), is(2));
assertThat(subValues.get(0), is(plan.getQuantifiers().get(0).getFlowedValues().get(0)));
assertThat(subValues.get(1), is(plan.getQuantifiers().get(1).getFlowedValues().get(0)));
}
use of com.apple.foundationdb.record.query.predicates.ValuePickerValue in project fdb-record-layer by FoundationDB.
the class RecordQueryChooserPlanBase method calculateChildrenValues.
/**
* This utility calculates the list of values that are returned by the plan. The plan returns a list of
* {@link ValuePickerValue} that each represent the values returned by one of the child plans.
* Each {@link ValuePickerValue} holds a "selected index" that determines which of the sub-values it references, so
* that, in all, when the same "selected index" is chosen for all picker value, one would get back a consistent set
* of values, representing one of the child plans for this plan.
*
* @return list of {@link ValuePickerValue} representing all the values from all the sub plans
*/
private List<? extends Value> calculateChildrenValues() {
// Store all values in a multimap, indexed by the ordinal of the value in the returned list
// Each list represents all the i'th Value from each of the sub plans
ImmutableListMultimap.Builder<Integer, Value> mapBuilder = ImmutableListMultimap.builder();
quantifiers.forEach(quantifier -> {
List<? extends Value> values = quantifier.getFlowedValues();
for (int i = 0; i < values.size(); i++) {
mapBuilder.put(i, values.get(i));
}
});
ImmutableListMultimap<Integer, ? extends Value> valuesMap = mapBuilder.build();
ImmutableList.Builder<ValuePickerValue> resultBuilder = ImmutableList.builder();
for (int i = 0; i < valuesMap.keySet().size(); i++) {
ImmutableList<? extends Value> subValues = valuesMap.get(i);
// For now, fix all the picker values to return the first sub value
resultBuilder.add(new ValuePickerValue(0, subValues));
}
return resultBuilder.build();
}
Aggregations