You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2021/11/26 01:49:46 UTC

[GitHub] [iotdb] cornmonster commented on a change in pull request #4388: [IOTDB-2010] fix incomplete show timeseries result

cornmonster commented on a change in pull request #4388:
URL: https://github.com/apache/iotdb/pull/4388#discussion_r757183875



##########
File path: cluster/src/main/java/org/apache/iotdb/cluster/server/handlers/caller/ShowTimeSeriesHandler.java
##########
@@ -0,0 +1,133 @@
+/*
+ * 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.cluster.server.handlers.caller;
+
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.exception.metadata.MetadataException;
+import org.apache.iotdb.db.metadata.path.PartialPath;
+import org.apache.iotdb.db.query.dataset.ShowTimeSeriesResult;
+
+import org.apache.thrift.async.AsyncMethodCallback;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+/** Handler for getting the schemas from each data group concurrently. */
+public class ShowTimeSeriesHandler implements AsyncMethodCallback<List<ShowTimeSeriesResult>> {
+
+  private static class ShowTimeSeriesResultComparator implements Comparator<ShowTimeSeriesResult> {
+
+    @Override
+    public int compare(ShowTimeSeriesResult o1, ShowTimeSeriesResult o2) {
+      if (o1 == null && o2 == null) {
+        return 0;
+      } else if (o1 == null) {
+        return -1;
+      } else if (o2 == null) {
+        return 1;
+      }
+      return o1.getName().compareTo(o2.getName());
+    }
+  }
+
+  private static final Logger logger = LoggerFactory.getLogger(ShowTimeSeriesHandler.class);
+
+  /** String representation of a partial path for logging */
+  private final String path;
+
+  private final CountDownLatch countDownLatch;
+  private final long startTimeInMs;
+
+  private final Map<String, ShowTimeSeriesResult> timeSeriesNameToResult = new HashMap<>();

Review comment:
       `onComplete` and `onError` are decorated with keyword `synchronized`. Thus this handler should be thread-safe.




-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org