[ 
https://issues.apache.org/jira/browse/HUDI-2268?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17398746#comment-17398746
 ] 

ASF GitHub Bot commented on HUDI-2268:
--------------------------------------

nsivabalan commented on a change in pull request #3470:
URL: https://github.com/apache/hudi/pull/3470#discussion_r688607735



##########
File path: 
hudi-common/src/main/java/org/apache/hudi/common/util/MarkerUtils.java
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.common.util;
+
+import org.apache.hudi.common.config.SerializableConfiguration;
+import org.apache.hudi.common.engine.HoodieEngineContext;
+import org.apache.hudi.common.util.collection.ImmutablePair;
+import org.apache.hudi.exception.HoodieIOException;
+
+import org.apache.hadoop.fs.FSDataInputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+import static org.apache.hudi.common.util.FileIOUtils.closeQuietly;
+
+/**
+ * A utility class for marker related operations.
+ */
+public class MarkerUtils {
+  public static final String MARKERS_FILENAME_PREFIX = "MARKERS";
+  public static final String MARKER_TYPE_FILENAME = MARKERS_FILENAME_PREFIX + 
".type";
+  private static final Logger LOG = LogManager.getLogger(MarkerUtils.class);
+
+  /**
+   * Reads the marker type from `MARKERS.type` file.
+   *
+   * @param fileSystem file system to use.
+   * @param markerDir  marker directory.
+   * @return the marker type in String, or empty if the marker type file does 
not exist.
+   */
+  public static Option<String> readMarkerType(FileSystem fileSystem, String 
markerDir) {
+    Path markerTypeFilePath = new Path(markerDir, MARKER_TYPE_FILENAME);
+    FSDataInputStream fsDataInputStream = null;
+    String content = null;
+    try {
+      if (!fileSystem.exists(markerTypeFilePath)) {
+        return Option.empty();
+      }
+      fsDataInputStream = fileSystem.open(markerTypeFilePath);
+      content = FileIOUtils.readAsUTFString(fsDataInputStream);
+    } catch (IOException e) {
+      throw new HoodieIOException("Cannot read marker type file " + 
markerTypeFilePath.toString()
+          + "; " + e.getMessage(), e);
+    } finally {
+      closeQuietly(fsDataInputStream);
+    }
+
+    if (content != null) {
+      return Option.of(content);
+    }
+    return Option.empty();
+  }
+
+  /**
+   * Deletes `MARKERS.type` file.
+   *
+   * @param fileSystem file system to use.
+   * @param markerDir  marker directory.
+   */
+  public static void deleteMarkerTypeFile(FileSystem fileSystem, String 
markerDir) {
+    Path markerTypeFilePath = new Path(markerDir, MARKER_TYPE_FILENAME);
+    try {
+      fileSystem.delete(markerTypeFilePath, false);
+    } catch (IOException e) {
+      throw new HoodieIOException("Cannot delete marker type file " + 
markerTypeFilePath.toString()
+          + "; " + e.getMessage(), e);
+    }
+  }
+
+  /**
+   * Reads files containing the markers written by timeline-server-based 
marker mechanism.
+   *
+   * @param markerDir   marker directory.
+   * @param fileSystem  file system to use.
+   * @param context     instance of {@link HoodieEngineContext} to use
+   * @param parallelism parallelism to use
+   * @return A {@code Map} of file name to the set of markers stored in the 
file.
+   */
+  public static Map<String, Set<String>> 
readTimelineServerBasedMarkersFromFileSystem(

Review comment:
       I assume this is same as MarkerDirState.syncMarkersFromFileSystem() 

##########
File path: 
hudi-timeline-service/src/main/java/org/apache/hudi/timeline/service/handlers/marker/MarkerDirState.java
##########
@@ -270,9 +272,11 @@ private void syncMarkersFromFileSystem() {
     try {
       if (fileSystem.exists(dirPath)) {
         FileStatus[] fileStatuses = fileSystem.listStatus(dirPath);
+        Predicate<String> prefixFilter = pathStr -> 
pathStr.contains(MARKERS_FILENAME_PREFIX);

Review comment:
       Is it possible to re-use 
MarkerUtils.readTimelineServerBasedMarkersFromFileSystem() ? 




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


> Upgrade hoodie table to 0.9.0
> -----------------------------
>
>                 Key: HUDI-2268
>                 URL: https://issues.apache.org/jira/browse/HUDI-2268
>             Project: Apache Hudi
>          Issue Type: Sub-task
>          Components: Usability
>            Reporter: sivabalan narayanan
>            Assignee: sivabalan narayanan
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 0.9.0
>
>
> Wrt upgrading/downgrading hoodie.properties, here is what we can go. 
> Add a new table version, 2. 
> Add an upgrade step:
> before every write operation. 
>      Check if existing hoodie.props is in an older version. If yes, perform 
> upgrade step to version2 (either from 0 to 2 or from 1 to 2). This 
> essentially means that we need to add new properties pertaining to sql dml to 
> hoodie.properties. 
> Things to watch out for:
> for some operations, not all props might be set by the user. So, we might 
> need to throw an exception. (record key field, partition path field, key gen 
> prop, precombine field). 
> We need to fetch latest table schema since the incoming df could have partial 
> cols.
>  
> Downgrade step: 
> hoodie.properties will have some additional properties. Should not cause any 
> harm. All we need to do is to downgrade the table version to target version 
> and not touch any of the props. 
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to