Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Caideyipi committed Nov 29, 2024
1 parent 70c99e4 commit c8e976b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -737,17 +737,38 @@ public void createAlignedTimeSeries(final ICreateAlignedTimeSeriesPlan plan)
regionStatistics.getGlobalMemoryUsage(), regionStatistics.getGlobalSeriesNumber());
}

final boolean withMerge =
plan instanceof CreateAlignedTimeSeriesPlanImpl
&& ((CreateAlignedTimeSeriesPlanImpl) plan).isWithMerge()
|| plan instanceof CreateAlignedTimeSeriesNode
&& ((CreateAlignedTimeSeriesNode) plan).isGeneratedByPipe();
try {
final PartialPath prefixPath = plan.getDevicePath();
final List<String> measurements = plan.getMeasurements();
final List<TSDataType> dataTypes = plan.getDataTypes();
final List<TSEncoding> encodings = plan.getEncodings();
final List<CompressionType> compressors = plan.getCompressors();
final List<String> aliasList = plan.getAliasList();
final List<Map<String, String>> tagsList = plan.getTagsList();
final List<Map<String, String>> attributesList = plan.getAttributesList();
final List<IMeasurementMNode<IMemMNode>> measurementMNodeList;

// Deep copy if with merge
// The original lists may be altered to help distinguish between creation plan
// and update plan
// Here we deeply copy to avoid damaging the original plan node for pipe schema region
// listening queue
List<String> measurements = plan.getMeasurements();
List<TSDataType> dataTypes = plan.getDataTypes();
List<TSEncoding> encodings = plan.getEncodings();
List<CompressionType> compressors = plan.getCompressors();
List<String> aliasList = plan.getAliasList();
List<Map<String, String>> tagsList = plan.getTagsList();
List<Map<String, String>> attributesList = plan.getAttributesList();

if (withMerge) {
measurements = new ArrayList<>(measurements);
dataTypes = new ArrayList<>(dataTypes);
encodings = new ArrayList<>(encodings);
compressors = new ArrayList<>(compressors);
aliasList = Objects.nonNull(aliasList) ? new ArrayList<>(aliasList) : null;
tagsList = Objects.nonNull(tagsList) ? new ArrayList<>(tagsList) : null;
attributesList = Objects.nonNull(attributesList) ? new ArrayList<>(attributesList) : null;
}

for (int i = 0; i < measurements.size(); i++) {
SchemaUtils.checkDataTypeWithEncoding(dataTypes.get(i), encodings.get(i));
}
Expand All @@ -764,10 +785,7 @@ public void createAlignedTimeSeries(final ICreateAlignedTimeSeriesPlan plan)
encodings,
compressors,
aliasList,
plan instanceof CreateAlignedTimeSeriesPlanImpl
&& ((CreateAlignedTimeSeriesPlanImpl) plan).isWithMerge()
|| plan instanceof CreateAlignedTimeSeriesNode
&& ((CreateAlignedTimeSeriesNode) plan).isGeneratedByPipe(),
withMerge,
existingMeasurementIndexes);

// update statistics and schemaDataTypeNumMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;

public class CreateAlignedTimeSeriesPlanImpl implements ICreateAlignedTimeSeriesPlan {

Expand Down Expand Up @@ -178,20 +177,5 @@ public boolean isWithMerge() {

public void setWithMerge(final boolean withMerge) {
this.withMerge = withMerge;
// Deep copy if with merge because when upsert option is set
// The original set may be altered to help distinguish between creation plan
// and update plan
// Here we deeply copy to avoid damaging the original plan node for pipe schema region listening
// queue
if (withMerge) {
measurements = new ArrayList<>(measurements);
dataTypes = new ArrayList<>(dataTypes);
encodings = new ArrayList<>(encodings);
compressors = new ArrayList<>(compressors);
aliasList = Objects.nonNull(aliasList) ? new ArrayList<>(aliasList) : null;
tagsList = Objects.nonNull(tagsList) ? new ArrayList<>(tagsList) : null;
attributesList = Objects.nonNull(attributesList) ? new ArrayList<>(attributesList) : null;
tagOffsets = Objects.nonNull(tagOffsets) ? new ArrayList<>(tagOffsets) : null;
}
}
}

0 comments on commit c8e976b

Please sign in to comment.