This is an automated email from the ASF dual-hosted git repository.

hui pushed a commit to branch lmh/LastPointFetch
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit cb374a922904e96d20f67d7774060e37c48ec301
Author: Minghui Liu <[email protected]>
AuthorDate: Thu May 26 17:18:26 2022 +0800

    add LastPointFetchStatement
---
 .../db/mpp/plan/statement/StatementVisitor.java    |  5 ++
 .../statement/crud/LastPointFetchStatement.java    | 63 ++++++++++++++++++++++
 2 files changed, 68 insertions(+)

diff --git 
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/StatementVisitor.java
 
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/StatementVisitor.java
index 650d15d160..daf1f44b3f 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/StatementVisitor.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/StatementVisitor.java
@@ -25,6 +25,7 @@ import 
org.apache.iotdb.db.mpp.plan.statement.crud.InsertRowsOfOneDeviceStatemen
 import org.apache.iotdb.db.mpp.plan.statement.crud.InsertRowsStatement;
 import org.apache.iotdb.db.mpp.plan.statement.crud.InsertStatement;
 import org.apache.iotdb.db.mpp.plan.statement.crud.InsertTabletStatement;
+import org.apache.iotdb.db.mpp.plan.statement.crud.LastPointFetchStatement;
 import org.apache.iotdb.db.mpp.plan.statement.crud.QueryStatement;
 import 
org.apache.iotdb.db.mpp.plan.statement.metadata.AlterTimeSeriesStatement;
 import org.apache.iotdb.db.mpp.plan.statement.metadata.CountDevicesStatement;
@@ -139,6 +140,10 @@ public abstract class StatementVisitor<R, C> {
     return visitStatement(queryStatement, context);
   }
 
+  public R visitLastPointFetch(LastPointFetchStatement 
lastPointFetchStatement, C context) {
+    return visitStatement(lastPointFetchStatement, context);
+  }
+
   // Insert Statement
   public R visitInsert(InsertStatement insertStatement, C context) {
     return visitStatement(insertStatement, context);
diff --git 
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/crud/LastPointFetchStatement.java
 
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/crud/LastPointFetchStatement.java
new file mode 100644
index 0000000000..06265e5f8e
--- /dev/null
+++ 
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/statement/crud/LastPointFetchStatement.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.mpp.plan.statement.crud;
+
+import org.apache.iotdb.commons.path.PartialPath;
+import org.apache.iotdb.db.metadata.path.MeasurementPath;
+import org.apache.iotdb.db.mpp.plan.statement.Statement;
+import org.apache.iotdb.db.mpp.plan.statement.StatementVisitor;
+
+import java.util.List;
+
+public class LastPointFetchStatement extends Statement {
+
+  private final List<MeasurementPath> selectedPaths;
+
+  // used for fetch data partition
+  private final List<String> storageGroups;
+
+  public LastPointFetchStatement(List<MeasurementPath> selectedPaths, 
List<String> storageGroups) {
+    this.selectedPaths = selectedPaths;
+    this.storageGroups = storageGroups;
+  }
+
+  public List<MeasurementPath> getSelectedPaths() {
+    return selectedPaths;
+  }
+
+  public String getBelongedStorageGroup(String pathName) {
+    for (String storageGroup : storageGroups) {
+      if (pathName.startsWith(storageGroup + ".")) {
+        return storageGroup;
+      }
+    }
+    throw new RuntimeException("No matched storage group. Please check the 
path " + pathName);
+  }
+
+  @Override
+  public List<? extends PartialPath> getPaths() {
+    return selectedPaths;
+  }
+
+  @Override
+  public <R, C> R accept(StatementVisitor<R, C> visitor, C context) {
+    return visitor.visitLastPointFetch(this, context);
+  }
+}

Reply via email to