You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hx...@apache.org on 2021/03/19 05:26:04 UTC
[iotdb] branch master updated: [IOTDB-1234] fix ImportCsv tool
cannot parse empty string (#2857)
This is an automated email from the ASF dual-hosted git repository.
hxd pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new a8b01f1 [IOTDB-1234] fix ImportCsv tool cannot parse empty string (#2857)
a8b01f1 is described below
commit a8b01f1d0c1184bb48c82e721c9346c540aa960a
Author: HelKim <30...@users.noreply.github.com>
AuthorDate: Fri Mar 19 13:25:43 2021 +0800
[IOTDB-1234] fix ImportCsv tool cannot parse empty string (#2857)
* [IOTDB-1234] fix ImportCsv tool cannot parse empty string
---
.../org/apache/iotdb/db/service/TSServiceImpl.java | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
index 031b2bc..4e99e90 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
@@ -1278,9 +1278,8 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
try {
plan.setDeviceId(new PartialPath(req.getDeviceIds().get(i)));
plan.setTime(req.getTimestamps().get(i));
- plan.setMeasurements(req.getMeasurementsList().get(i).toArray(new String[0]));
+ addMeasurementAndValue(plan, req.getMeasurementsList().get(i), req.getValuesList().get(i));
plan.setDataTypes(new TSDataType[plan.getMeasurements().length]);
- plan.setValues(req.getValuesList().get(i).toArray(new Object[0]));
plan.setNeedInferType(true);
TSStatus status = checkAuthority(plan, req.getSessionId());
if (status != null) {
@@ -1304,6 +1303,24 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
allCheckSuccess, tsStatus, insertRowsPlan.getResults(), req.deviceIds.size());
}
+ private void addMeasurementAndValue(
+ InsertRowPlan insertRowPlan, List<String> measurements, List<String> values) {
+ List<String> newMeasurements = new ArrayList<>(measurements.size());
+ List<Object> newValues = new ArrayList<>(values.size());
+
+ for (int i = 0; i < measurements.size(); ++i) {
+ String value = values.get(i);
+ if (value.isEmpty()) {
+ continue;
+ }
+ newMeasurements.add(measurements.get(i));
+ newValues.add(value);
+ }
+
+ insertRowPlan.setValues(newValues.toArray(new Object[0]));
+ insertRowPlan.setMeasurements(newMeasurements.toArray(new String[0]));
+ }
+
@Override
public TSStatus testInsertTablet(TSInsertTabletReq req) {
LOGGER.debug("Test insert batch request receive.");