|
35 | 35 | import com.apple.foundationdb.record.provider.common.StoreTimer;
|
36 | 36 | import com.apple.foundationdb.record.provider.foundationdb.FDBRecordStoreBase;
|
37 | 37 | import com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer;
|
38 |
| -import com.apple.foundationdb.record.query.plan.explain.ExplainPlanVisitor; |
39 | 38 | import com.apple.foundationdb.record.query.plan.cascades.AliasMap;
|
40 | 39 | import com.apple.foundationdb.record.query.plan.cascades.CorrelationIdentifier;
|
41 | 40 | import com.apple.foundationdb.record.query.plan.cascades.Quantifier;
|
|
50 | 49 | import com.apple.foundationdb.record.query.plan.cascades.values.ObjectValue;
|
51 | 50 | import com.apple.foundationdb.record.query.plan.cascades.values.Value;
|
52 | 51 | import com.apple.foundationdb.record.query.plan.cascades.values.translation.TranslationMap;
|
| 52 | +import com.apple.foundationdb.record.query.plan.explain.ExplainPlanVisitor; |
53 | 53 | import com.apple.foundationdb.record.query.plan.serialization.PlanSerialization;
|
54 | 54 | import com.google.auto.service.AutoService;
|
55 | 55 | import com.google.common.collect.ImmutableList;
|
@@ -385,15 +385,18 @@ public PRecordQueryPlan toRecordQueryPlanProto(@Nonnull final PlanSerializationC
|
385 | 385 | @Nonnull
|
386 | 386 | public static RecordQueryStreamingAggregationPlan fromProto(@Nonnull final PlanSerializationContext serializationContext,
|
387 | 387 | @Nonnull final PRecordQueryStreamingAggregationPlan recordQueryStreamingAggregationPlanProto) {
|
388 |
| - return new RecordQueryStreamingAggregationPlan(Quantifier.Physical.fromProto(serializationContext, Objects.requireNonNull(recordQueryStreamingAggregationPlanProto.getInner())), |
389 |
| - PlanSerialization.getFieldOrNull(recordQueryStreamingAggregationPlanProto, |
390 |
| - PRecordQueryStreamingAggregationPlan::hasGroupingKeyValue, |
391 |
| - m -> Value.fromValueProto(serializationContext, m.getGroupingKeyValue())), |
392 |
| - (AggregateValue)Value.fromValueProto(serializationContext, Objects.requireNonNull(recordQueryStreamingAggregationPlanProto.getAggregateValue())), |
393 |
| - CorrelationIdentifier.of(Objects.requireNonNull(recordQueryStreamingAggregationPlanProto.getGroupingKeyAlias())), |
394 |
| - CorrelationIdentifier.of(Objects.requireNonNull(recordQueryStreamingAggregationPlanProto.getAggregateAlias())), |
395 |
| - Value.fromValueProto(serializationContext, Objects.requireNonNull(recordQueryStreamingAggregationPlanProto.getCompleteResultValue())), |
396 |
| - recordQueryStreamingAggregationPlanProto.hasIsCreateDefaultOnEmpty() ? recordQueryStreamingAggregationPlanProto.getIsCreateDefaultOnEmpty() : true); |
| 388 | + // Note: it is important for proper deserialization (at least of things that interact with the serializationContext's cache of |
| 389 | + // referenced values and plans) that we deserialize the values in the same order as they are serialized, or we may |
| 390 | + // not |
| 391 | + final Quantifier.Physical inner = Quantifier.Physical.fromProto(serializationContext, Objects.requireNonNull(recordQueryStreamingAggregationPlanProto.getInner())); |
| 392 | + final AggregateValue aggregateValue = (AggregateValue) Value.fromValueProto(serializationContext, Objects.requireNonNull(recordQueryStreamingAggregationPlanProto.getAggregateValue())); |
| 393 | + @Nullable final Value groupingKeyValue = PlanSerialization.getFieldOrNull(recordQueryStreamingAggregationPlanProto, PRecordQueryStreamingAggregationPlan::hasGroupingKeyValue, |
| 394 | + m -> Value.fromValueProto(serializationContext, m.getGroupingKeyValue())); |
| 395 | + final CorrelationIdentifier groupingKeyAlias = CorrelationIdentifier.of(Objects.requireNonNull(recordQueryStreamingAggregationPlanProto.getGroupingKeyAlias())); |
| 396 | + final CorrelationIdentifier aggregateAlias = CorrelationIdentifier.of(Objects.requireNonNull(recordQueryStreamingAggregationPlanProto.getAggregateAlias())); |
| 397 | + final Value completeResultValue = Value.fromValueProto(serializationContext, Objects.requireNonNull(recordQueryStreamingAggregationPlanProto.getCompleteResultValue())); |
| 398 | + final boolean isCreateDefaultOnEmpty = recordQueryStreamingAggregationPlanProto.hasIsCreateDefaultOnEmpty() ? recordQueryStreamingAggregationPlanProto.getIsCreateDefaultOnEmpty() : true; |
| 399 | + return new RecordQueryStreamingAggregationPlan(inner, groupingKeyValue, aggregateValue, groupingKeyAlias, aggregateAlias, completeResultValue, isCreateDefaultOnEmpty); |
397 | 400 | }
|
398 | 401 |
|
399 | 402 | @Nonnull
|
|
0 commit comments