surekhasaharan commented on a change in pull request #6094: Introduce 
SystemSchema tables (#5989)
URL: https://github.com/apache/incubator-druid/pull/6094#discussion_r221765858
 
 

 ##########
 File path: 
sql/src/main/java/org/apache/druid/sql/calcite/schema/SegmentMetadataHolder.java
 ##########
 @@ -0,0 +1,124 @@
+/*
+ * 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.druid.sql.calcite.schema;
+
+import org.apache.druid.sql.calcite.table.RowSignature;
+
+import javax.annotation.Nullable;
+
+public class SegmentMetadataHolder
+{
+  private final Object lock = new Object();
+  private RowSignature rowSignature;
+  private final long isPublished;
+  private final long isAvailable;
+  private final long isRealtime;
+  private long numReplicas;
+  @Nullable
+  private Long numRows;
+
+
+  public SegmentMetadataHolder(
+      @Nullable RowSignature rowSignature,
+      long isPublished,
+      long isAvailable,
+      long isRealtime,
+      long numReplicas,
+      @Nullable Long numRows
+  )
+  {
+    this.rowSignature = rowSignature;
+    this.isPublished = isPublished;
+    this.isAvailable = isAvailable;
+    this.isRealtime = isRealtime;
+    this.numReplicas = numReplicas;
+    this.numRows = numRows;
+  }
+
+
+  public long isPublished()
+  {
+    synchronized (lock) {
+      return isPublished;
+    }
+  }
+
+  public long isAvailable()
+  {
+    synchronized (lock) {
+      return isAvailable;
+    }
+  }
+
+  public long isRealtime()
+  {
+    synchronized (lock) {
+      return isRealtime;
+    }
+  }
+
+  public long getNumReplicas()
+  {
+    synchronized (lock) {
+      return numReplicas;
+    }
+  }
+
+  @Nullable
+  public Long getNumRows()
+  {
+    synchronized (lock) {
+      return numRows;
+    }
+  }
+
+  @Nullable
+  public RowSignature getRowSignature()
+  {
+    synchronized (lock) {
+      return rowSignature;
+    }
+  }
+
+  public void setRowSignature(RowSignature rowSignature)
 
 Review comment:
   Do you mean to remove the setters and always create a new 
`SegmentMetadataHolder` object when any of the member needs update. And replace 
the entry in `segmentMetadataInfo` map in `DruidSchema` every time update is 
required. Is that better then using the `lock`. I wonder if a `ReadWriteLock` 
is better here ?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org

Reply via email to