bvaradar commented on code in PR #8452:
URL: https://github.com/apache/hudi/pull/8452#discussion_r1221896891


##########
hudi-common/src/main/java/org/apache/hudi/internal/schema/Types.java:
##########
@@ -523,18 +524,31 @@ public List<Field> fields() {
       return Arrays.asList(fields);
     }
 
-    public Field field(String name) {
+    /**
+     * Case-sensitive get field by name
+     */
+    public synchronized Field fieldByName(String name) {
       if (nameToFields == null) {
         nameToFields = new HashMap<>();
         for (Field field : fields) {
-          nameToFields.put(field.name().toLowerCase(Locale.ROOT), field);
+          nameToFields.put(field.name(), field);
+        }
+      }
+      return nameToFields.get(name);
+    }
+
+    public synchronized Field fieldByNameCaseInsensitive(String name) {
+      if (lowercaseNameToFields == null) {
+        lowercaseNameToFields = new HashMap<>();
+        for (Field field : fields) {
+          lowercaseNameToFields.put(field.name().toLowerCase(Locale.ROOT), 
field);
         }
       }
-      return nameToFields.get(name.toLowerCase(Locale.ROOT));
+      return lowercaseNameToFields.get(name.toLowerCase(Locale.ROOT));
     }
 
     @Override
-    public Field field(int id) {
+    public synchronized Field field(int id) {

Review Comment:
   why did we add synchronized here ? Can we avoid this ? 



##########
hudi-common/src/main/java/org/apache/hudi/internal/schema/Type.java:
##########
@@ -33,17 +37,38 @@ public interface Type extends Serializable {
    * Enums for type names.
    */
   enum TypeID {
-    RECORD, ARRAY, MAP, FIXED, STRING, BINARY,
-    INT, LONG, FLOAT, DOUBLE, DATE, BOOLEAN, TIME, TIMESTAMP, DECIMAL, UUID;
-    private String name;
-
-    TypeID() {
+    RECORD(Types.RecordType.class),
+    ARRAY(List.class),
+    MAP(Map.class),
+    FIXED(ByteBuffer.class),
+    STRING(String.class),
+    BINARY(ByteBuffer.class),
+    INT(Integer.class),
+    LONG(Long.class),
+    FLOAT(Float.class),
+    DOUBLE(Double.class),
+    // TODO How to change this

Review Comment:
   @boneanxs Can you resolve this TODO ? 



##########
hudi-common/src/main/java/org/apache/hudi/internal/schema/utils/Conversions.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.hudi.internal.schema.utils;
+
+import org.apache.hudi.internal.schema.Type;
+import org.apache.hudi.internal.schema.Types;
+
+import java.math.BigDecimal;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.UUID;
+
+public class Conversions {
+
+  private static final OffsetDateTime EPOCH = 
Instant.ofEpochSecond(0).atOffset(ZoneOffset.UTC);
+  private static final LocalDate EPOCH_DAY = EPOCH.toLocalDate();
+
+  private static final HashSet<Type.TypeID> SUPPORTED_PARTITION_TYPES = new 
HashSet<>(
+      Arrays.asList(Type.TypeID.INT,
+          Type.TypeID.LONG,
+          Type.TypeID.BOOLEAN,
+          Type.TypeID.FLOAT,
+          Type.TypeID.DECIMAL,
+          Type.TypeID.DOUBLE,
+          Type.TypeID.UUID,
+          Type.TypeID.DATE,
+          Type.TypeID.STRING));
+
+  public static boolean isSchemaSupportedConversion(Types.RecordType schema) {
+    for (Types.Field field: schema.fields()) {
+      if (!SUPPORTED_PARTITION_TYPES.contains(field.type().typeId())) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  public static Object fromPartitionString(String partitionValue, Type type) {

Review Comment:
   @boneanxs : Since we are defining this mapping in TypeId enum, can we move 
this logic to TypeId class ? 



##########
hudi-common/src/main/java/org/apache/hudi/metadata/AbstractHoodieTableMetadata.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * 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.hudi.metadata;
+
+import org.apache.hudi.common.config.SerializableConfiguration;
+import org.apache.hudi.common.engine.HoodieEngineContext;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.table.HoodieTableConfig;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.util.PartitionPathEncodeUtils;
+import org.apache.hudi.common.util.StringUtils;
+import org.apache.hudi.exception.TableNotFoundException;
+import org.apache.hudi.expression.ArrayData;
+import org.apache.hudi.hadoop.CachingPath;
+import org.apache.hudi.hadoop.SerializablePath;
+import org.apache.hudi.internal.schema.Types;
+import org.apache.hudi.internal.schema.utils.Conversions;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+public abstract class AbstractHoodieTableMetadata implements 
HoodieTableMetadata {
+
+  protected final transient HoodieEngineContext engineContext;
+
+  protected final SerializableConfiguration hadoopConf;
+  protected final SerializablePath dataBasePath;
+
+  protected final boolean hiveStylePartitioningEnabled;
+  protected final boolean urlEncodePartitioningEnabled;
+
+  // TODO get this from HoodieConfig
+  protected final boolean caseSensitive = false;
+
+  public AbstractHoodieTableMetadata(HoodieEngineContext engineContext, 
SerializableConfiguration conf, String dataBasePath) {
+    this.engineContext = engineContext;
+    this.hadoopConf = conf;
+    this.dataBasePath = new SerializablePath(new CachingPath(dataBasePath));
+    FileSystem fs = FSUtils.getFs(dataBasePath, conf.get());
+    Path metaPath = new Path(dataBasePath, 
HoodieTableMetaClient.METAFOLDER_NAME);
+    TableNotFoundException.checkTableValidity(fs, this.dataBasePath.get(), 
metaPath);
+    HoodieTableConfig tableConfig = new HoodieTableConfig(fs, 
metaPath.toString(), null, null);

Review Comment:
   @boneanxs : I think the slowness was due to loadActiveTimelineOnLoad=true 
when constructing HoodieTableMetaClient. If so, can you set it to False and use 
HoodieTableMetaClient. If possible, would prefer to go through 
HoodieTableMetaClient here to keep it similar with HoodieBackedTableMetadata 



-- 
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: commits-unsubscr...@hudi.apache.org

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

Reply via email to