jt2594838 commented on a change in pull request #1169:
URL: https://github.com/apache/incubator-iotdb/pull/1169#discussion_r428414265
##########
File path:
server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
##########
@@ -864,43 +888,78 @@ public void delete(Path path, long timestamp) throws
QueryProcessException {
@Override
public void insert(InsertPlan insertPlan) throws QueryProcessException {
- MNode node = null;
try {
String[] measurementList = insertPlan.getMeasurements();
String deviceId = insertPlan.getDeviceId();
- node = mManager.getDeviceNodeWithAutoCreateAndReadLock(deviceId);
String[] strValues = insertPlan.getValues();
- MeasurementSchema[] schemas = new
MeasurementSchema[measurementList.length];
-
- for (int i = 0; i < measurementList.length; i++) {
- String measurement = measurementList[i];
- if (!node.hasChild(measurement)) {
- if
(!IoTDBDescriptor.getInstance().getConfig().isAutoCreateSchemaEnabled()) {
- throw new PathNotExistException(deviceId + PATH_SEPARATOR +
measurement);
- }
- TSDataType dataType =
TypeInferenceUtils.getPredictedDataType(strValues[i]);
- Path path = new Path(deviceId, measurement);
- internalCreateTimeseries(path.toString(), dataType);
- }
- LeafMNode measurementNode = (LeafMNode) node.getChild(measurement);
- schemas[i] = measurementNode.getSchema();
- // reset measurement to common name instead of alias
- measurementList[i] = measurementNode.getName();
- }
-
- insertPlan.setMeasurements(measurementList);
+ MeasurementSchema[] schemas = getSeriesSchemas(measurementList,
deviceId, strValues);
insertPlan.setSchemas(schemas);
StorageEngine.getInstance().insert(insertPlan);
} catch (StorageEngineException | MetadataException e) {
throw new QueryProcessException(e);
+ }
+ }
+
+ protected MeasurementSchema[] getSeriesSchemas(String[] measurementList,
String deviceId,
+ String[] strValues) throws MetadataException {
+ MeasurementSchema[] schemas = new
MeasurementSchema[measurementList.length];
+
+ MNode node = null;
+ try {
+ node = mManager.getDeviceNodeWithAutoCreateAndReadLock(deviceId);
Review comment:
This is not introduced in this PR and I only rearranged the codes to
reduce the complexity.
I suggest you discuss with him directly or start an issue, but it is really
not the concern of this PR.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]