5353import static com .google .common .base .Preconditions .checkState ;
5454import static org .apache .iotdb .calc .execution .operator .source .relational .aggregation .Utils .serializeTimeValueWithNull ;
5555import static org .apache .iotdb .commons .queryengine .plan .relational .type .InternalTypeManager .getTSDataType ;
56- import static org .apache .iotdb .db .queryengine .plan .relational .metadata .fetcher .cache .TableDeviceLastCache .EMPTY_PRIMITIVE_TYPE ;
57- import static org .apache .iotdb .db .queryengine .plan .relational .metadata .fetcher .cache .TableDeviceLastCache .EMPTY_TIME_VALUE_PAIR ;
56+ import static org .apache .iotdb .db .queryengine .plan .relational .metadata .fetcher .cache .TableDeviceLastCache .PLACEHOLDER_EMPTY_COLUMN ;
57+ import static org .apache .iotdb .db .queryengine .plan .relational .metadata .fetcher .cache .TableDeviceLastCache .PLACEHOLDER_NO_VALUE ;
5858
5959/**
6060 * This class is used to execute aggregation table scan when apply {@code canUseLastCacheOptimize()}
@@ -279,7 +279,7 @@ private void buildResultUseLastRowCache() {
279279 TsPrimitiveType tsPrimitiveType =
280280 lastRowCacheResults .get (currentHitCacheIndex ).getRight ()[measurementIdx ];
281281 long lastByTime = lastRowCacheResults .get (currentHitCacheIndex ).getLeft ().getAsLong ();
282- if (tsPrimitiveType == EMPTY_PRIMITIVE_TYPE ) {
282+ if (tsPrimitiveType == PLACEHOLDER_NO_VALUE ) {
283283 // there is no data for this time series
284284 if (aggregator .getStep ().isOutputPartial ()) {
285285 columnBuilder .writeBinary (
@@ -322,7 +322,7 @@ private void buildResultUseLastValuesCache() {
322322 TsPrimitiveType timeLastValue = currentHitResult [currentHitResult .length - 1 ].getValue ();
323323 // when there is no data, no need to append result if the query is GROUP BY or output of
324324 // aggregator is partial (final operator will produce NULL result)
325- if (timeLastValue == EMPTY_PRIMITIVE_TYPE
325+ if (timeLastValue == PLACEHOLDER_NO_VALUE
326326 && (groupingKeySize != 0 || tableAggregators .get (0 ).getStep ().isOutputPartial ())) {
327327 outputDeviceIndex ++;
328328 currentHitCacheIndex ++;
@@ -346,7 +346,7 @@ private void buildResultUseLastValuesCache() {
346346 getNthIdColumnValue (
347347 cachedDeviceEntries .get (currentHitCacheIndex ), aggColumnsIndexArray [columnIdx ]);
348348 if (aggregator .getAccumulator () instanceof LastDescAccumulator ) {
349- if (timeLastValue == EMPTY_PRIMITIVE_TYPE || id == null ) {
349+ if (timeLastValue == PLACEHOLDER_NO_VALUE || id == null ) {
350350 columnBuilder .appendNull ();
351351 } else {
352352 if (aggregator .getStep ().isOutputPartial ()) {
@@ -368,7 +368,7 @@ private void buildResultUseLastValuesCache() {
368368 long lastTime =
369369 lastValuesCacheResults .get (currentHitCacheIndex )[measurementIdx ].getTimestamp ();
370370
371- if (timeLastValue == EMPTY_PRIMITIVE_TYPE || id == null ) {
371+ if (timeLastValue == PLACEHOLDER_NO_VALUE || id == null ) {
372372 if (aggregator .getStep ().isOutputPartial ()) {
373373 columnBuilder .writeBinary (
374374 new Binary (
@@ -399,7 +399,7 @@ private void buildResultUseLastValuesCache() {
399399 cachedDeviceEntries .get (currentHitCacheIndex )
400400 .getAttributeColumnValues ()[aggColumnsIndexArray [columnIdx ]];
401401 if (aggregator .getAccumulator () instanceof LastDescAccumulator ) {
402- if (timeLastValue == EMPTY_PRIMITIVE_TYPE || attribute == null ) {
402+ if (timeLastValue == PLACEHOLDER_NO_VALUE || attribute == null ) {
403403 columnBuilder .appendNull ();
404404 } else {
405405 if (aggregator .getStep ().isOutputPartial ()) {
@@ -420,7 +420,7 @@ private void buildResultUseLastValuesCache() {
420420 lastValuesCacheResults .get (currentHitCacheIndex )[measurementIdx ].getTimestamp ();
421421
422422 // last_by
423- if (timeLastValue == EMPTY_PRIMITIVE_TYPE || attribute == null ) {
423+ if (timeLastValue == PLACEHOLDER_NO_VALUE || attribute == null ) {
424424 if (aggregator .getStep ().isOutputPartial ()) {
425425 columnBuilder .writeBinary (
426426 new Binary (
@@ -448,7 +448,7 @@ private void buildResultUseLastValuesCache() {
448448 case TIME :
449449 if (aggregator .getAccumulator () instanceof LastDescAccumulator ) {
450450 // for last(time) aggregation
451- if (timeLastValue == EMPTY_PRIMITIVE_TYPE ) {
451+ if (timeLastValue == PLACEHOLDER_NO_VALUE ) {
452452 columnBuilder .appendNull ();
453453 } else {
454454 if (aggregator .getStep ().isOutputPartial ()) {
@@ -471,7 +471,7 @@ private void buildResultUseLastValuesCache() {
471471 TsPrimitiveType tsPrimitiveType =
472472 lastValuesCacheResults .get (currentHitCacheIndex )[measurementIdx ].getValue ();
473473
474- if (tsPrimitiveType == EMPTY_PRIMITIVE_TYPE ) {
474+ if (tsPrimitiveType == PLACEHOLDER_NO_VALUE ) {
475475 // there is no data
476476 if (aggregator .getStep ().isOutputPartial ()) {
477477 columnBuilder .writeBinary (
@@ -509,7 +509,7 @@ private void buildResultUseLastValuesCache() {
509509 TsPrimitiveType tsPrimitiveType =
510510 lastValuesCacheResults .get (currentHitCacheIndex )[measurementIdx ].getValue ();
511511
512- if (tsPrimitiveType == EMPTY_PRIMITIVE_TYPE ) {
512+ if (tsPrimitiveType == PLACEHOLDER_NO_VALUE ) {
513513 // there is no data for this time series
514514 columnBuilder .appendNull ();
515515 } else {
@@ -559,7 +559,7 @@ private void updateLastCacheUseLastRowIfPossible() {
559559 new TsPrimitiveType .TsLong (lastAccumulator .getMaxTime ())));
560560 } else {
561561 currentDeviceEntry = deviceEntries .get (currentDeviceIndex );
562- updateTimeValuePairList .add (EMPTY_TIME_VALUE_PAIR );
562+ updateTimeValuePairList .add (PLACEHOLDER_EMPTY_COLUMN );
563563 }
564564 } else {
565565 LastByDescAccumulator lastByAccumulator =
@@ -589,12 +589,12 @@ private void updateLastCacheUseLastRowIfPossible() {
589589 updateMeasurementList .add (schema .getName ());
590590 updateTimeValuePairList .add (
591591 lastByAccumulator .isXNull ()
592- ? new TimeValuePair (lastByTime , EMPTY_PRIMITIVE_TYPE )
592+ ? new TimeValuePair (lastByTime , PLACEHOLDER_NO_VALUE )
593593 : new TimeValuePair (
594594 lastByTime , cloneTsPrimitiveType (lastByAccumulator .getXResult ())));
595595 } else {
596596 updateMeasurementList .add (schema .getName ());
597- updateTimeValuePairList .add (EMPTY_TIME_VALUE_PAIR );
597+ updateTimeValuePairList .add (PLACEHOLDER_EMPTY_COLUMN );
598598 }
599599 break ;
600600 default :
@@ -631,7 +631,7 @@ private void updateLastCacheUseLastValuesIfPossible() {
631631 new TsPrimitiveType .TsLong (lastAccumulator .getMaxTime ())));
632632 } else {
633633 currentDeviceEntry = deviceEntries .get (currentDeviceIndex );
634- updateTimeValuePairList .add (EMPTY_TIME_VALUE_PAIR );
634+ updateTimeValuePairList .add (PLACEHOLDER_EMPTY_COLUMN );
635635 }
636636 }
637637 break ;
@@ -648,7 +648,7 @@ private void updateLastCacheUseLastValuesIfPossible() {
648648 lastAccumulator .getMaxTime (),
649649 cloneTsPrimitiveType (lastAccumulator .getLastValue ())));
650650 } else {
651- updateTimeValuePairList .add (EMPTY_TIME_VALUE_PAIR );
651+ updateTimeValuePairList .add (PLACEHOLDER_EMPTY_COLUMN );
652652 }
653653 break ;
654654 default :
0 commit comments