siddharthteotia commented on a change in pull request #4983: Make PQL case 
insensitive
URL: https://github.com/apache/incubator-pinot/pull/4983#discussion_r367135859
 
 

 ##########
 File path: 
pinot-common/src/main/java/org/apache/pinot/common/utils/helix/TableCache.java
 ##########
 @@ -0,0 +1,189 @@
+/**
+ * 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.pinot.common.utils.helix;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import org.I0Itec.zkclient.IZkChildListener;
+import org.I0Itec.zkclient.IZkDataListener;
+import org.apache.helix.AccessOption;
+import org.apache.helix.ZNRecord;
+import org.apache.helix.store.HelixPropertyListener;
+import org.apache.helix.store.zk.ZkHelixPropertyStore;
+import org.apache.pinot.common.config.TableConfig;
+import org.apache.pinot.common.config.TableNameBuilder;
+import org.apache.pinot.common.utils.SchemaUtils;
+import org.apache.pinot.spi.data.FieldSpec;
+import org.apache.pinot.spi.data.Schema;
+
+
+public class TableCache {
+  private static final String PROPERTYSTORE_SCHEMAS_PREFIX = "/SCHEMAS";
+  private static final String PROPERTYSTORE_TABLE_CONFIGS_PREFIX = 
"/CONFIGS/TABLE";
+
+  private ZkHelixPropertyStore<ZNRecord> _propertyStore;
+  TableConfigChangeListener _tableConfigChangeListener;
+  SchemaChangeListener _schemaChangeListener;
+
+  public TableCache(ZkHelixPropertyStore<ZNRecord> propertyStore) {
+    _propertyStore = propertyStore;
+    _schemaChangeListener = new SchemaChangeListener();
+    _schemaChangeListener.refresh();
+    _tableConfigChangeListener = new TableConfigChangeListener();
+    _tableConfigChangeListener.refresh();
+  }
+
+  public String getActualTableName(String tableName) {
+    return 
_tableConfigChangeListener._tableNameMap.getOrDefault(tableName.toLowerCase(), 
tableName);
+  }
+
+  public String getActualColumnName(String tableName, String columnName) {
+    String schemaName = 
_tableConfigChangeListener._table2SchemaConfigMap.get(tableName.toLowerCase());
+    if (schemaName != null) {
+      return _schemaChangeListener.getColumnName(schemaName, columnName);
+    }
+    return columnName;
+  }
+
+  class TableConfigChangeListener implements IZkChildListener, IZkDataListener 
{
+
+    Map<String, TableConfig> _tableConfigMap = new ConcurrentHashMap<>();
 
 Review comment:
   To _schemaMap as also mentioned in this comment 
https://github.com/apache/incubator-pinot/pull/4983#discussion_r366688484

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to