[HUDI-1446] Support skip bootstrapIndex's init in abstract fs view init (#2520)
Co-authored-by: zhongliang <zhongliang@kuaishou.com> Co-authored-by: Sivabalan Narayanan <sivabala@uber.com>
This commit is contained in:
@@ -64,10 +64,14 @@ public abstract class BootstrapIndex implements Serializable {
|
||||
* @return
|
||||
*/
|
||||
public final boolean useIndex() {
|
||||
boolean validInstantTime = metaClient.getActiveTimeline().getCommitsTimeline().filterCompletedInstants().lastInstant()
|
||||
.map(i -> HoodieTimeline.compareTimestamps(i.getTimestamp(), HoodieTimeline.GREATER_THAN_OR_EQUALS,
|
||||
HoodieTimeline.METADATA_BOOTSTRAP_INSTANT_TS)).orElse(false);
|
||||
return validInstantTime && metaClient.getTableConfig().getBootstrapBasePath().isPresent() && isPresent();
|
||||
if (isPresent()) {
|
||||
boolean validInstantTime = metaClient.getActiveTimeline().getCommitsTimeline().filterCompletedInstants().lastInstant()
|
||||
.map(i -> HoodieTimeline.compareTimestamps(i.getTimestamp(), HoodieTimeline.GREATER_THAN_OR_EQUALS,
|
||||
HoodieTimeline.METADATA_BOOTSTRAP_INSTANT_TS)).orElse(false);
|
||||
return validInstantTime && metaClient.getTableConfig().getBootstrapBasePath().isPresent();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.bootstrap.index;
|
||||
|
||||
import org.apache.hudi.common.table.HoodieTableMetaClient;
|
||||
|
||||
/**
|
||||
* No Op Bootstrap Index , which is a empty implement and not do anything.
|
||||
*/
|
||||
public class NoOpBootstrapIndex extends BootstrapIndex {
|
||||
|
||||
public NoOpBootstrapIndex(HoodieTableMetaClient metaClient) {
|
||||
super(metaClient);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexReader createReader() {
|
||||
throw new RuntimeException("DefaultBootstrapIndex not support create reader!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexWriter createWriter(String sourceBasePath) {
|
||||
throw new RuntimeException("DefaultBootstrapIndex not support create writer!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropIndex() {
|
||||
throw new RuntimeException("DefaultBootstrapIndex not support drop index!");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isPresent() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ package org.apache.hudi.common.table;
|
||||
|
||||
import java.util.Arrays;
|
||||
import org.apache.hudi.common.bootstrap.index.HFileBootstrapIndex;
|
||||
import org.apache.hudi.common.bootstrap.index.NoOpBootstrapIndex;
|
||||
import org.apache.hudi.common.model.HoodieFileFormat;
|
||||
import org.apache.hudi.common.model.HoodieTableType;
|
||||
import org.apache.hudi.common.model.OverwriteWithLatestAvroPayload;
|
||||
@@ -69,6 +70,7 @@ public class HoodieTableConfig implements Serializable {
|
||||
public static final String HOODIE_TIMELINE_LAYOUT_VERSION = "hoodie.timeline.layout.version";
|
||||
public static final String HOODIE_PAYLOAD_CLASS_PROP_NAME = "hoodie.compaction.payload.class";
|
||||
public static final String HOODIE_ARCHIVELOG_FOLDER_PROP_NAME = "hoodie.archivelog.folder";
|
||||
public static final String HOODIE_BOOTSTRAP_INDEX_ENABLE = "hoodie.bootstrap.index.enable";
|
||||
public static final String HOODIE_BOOTSTRAP_INDEX_CLASS_PROP_NAME = "hoodie.bootstrap.index.class";
|
||||
public static final String HOODIE_BOOTSTRAP_BASE_PATH = "hoodie.bootstrap.base.path";
|
||||
|
||||
@@ -77,6 +79,7 @@ public class HoodieTableConfig implements Serializable {
|
||||
public static final HoodieFileFormat DEFAULT_BASE_FILE_FORMAT = HoodieFileFormat.PARQUET;
|
||||
public static final HoodieFileFormat DEFAULT_LOG_FILE_FORMAT = HoodieFileFormat.HOODIE_LOG;
|
||||
public static final String DEFAULT_PAYLOAD_CLASS = OverwriteWithLatestAvroPayload.class.getName();
|
||||
public static final String NO_OP_BOOTSTRAP_INDEX_CLASS = NoOpBootstrapIndex.class.getName();
|
||||
public static final String DEFAULT_BOOTSTRAP_INDEX_CLASS = HFileBootstrapIndex.class.getName();
|
||||
public static final String DEFAULT_ARCHIVELOG_FOLDER = "";
|
||||
|
||||
@@ -146,7 +149,7 @@ public class HoodieTableConfig implements Serializable {
|
||||
}
|
||||
if (properties.containsKey(HOODIE_BOOTSTRAP_BASE_PATH) && !properties.containsKey(HOODIE_BOOTSTRAP_INDEX_CLASS_PROP_NAME)) {
|
||||
// Use the default bootstrap index class.
|
||||
properties.setProperty(HOODIE_BOOTSTRAP_INDEX_CLASS_PROP_NAME, DEFAULT_BOOTSTRAP_INDEX_CLASS);
|
||||
properties.setProperty(HOODIE_BOOTSTRAP_INDEX_CLASS_PROP_NAME, getDefaultBootstrapIndexClass(properties));
|
||||
}
|
||||
properties.store(outputStream, "Properties saved on " + new Date(System.currentTimeMillis()));
|
||||
}
|
||||
@@ -209,7 +212,15 @@ public class HoodieTableConfig implements Serializable {
|
||||
public String getBootstrapIndexClass() {
|
||||
// There could be tables written with payload class from com.uber.hoodie. Need to transparently
|
||||
// change to org.apache.hudi
|
||||
return props.getProperty(HOODIE_BOOTSTRAP_INDEX_CLASS_PROP_NAME, DEFAULT_BOOTSTRAP_INDEX_CLASS);
|
||||
return props.getProperty(HOODIE_BOOTSTRAP_INDEX_CLASS_PROP_NAME, getDefaultBootstrapIndexClass(props));
|
||||
}
|
||||
|
||||
public static String getDefaultBootstrapIndexClass(Properties props) {
|
||||
String defaultClass = DEFAULT_BOOTSTRAP_INDEX_CLASS;
|
||||
if ("false".equalsIgnoreCase(props.getProperty(HOODIE_BOOTSTRAP_INDEX_ENABLE))) {
|
||||
defaultClass = NO_OP_BOOTSTRAP_INDEX_CLASS;
|
||||
}
|
||||
return defaultClass;
|
||||
}
|
||||
|
||||
public Option<String> getBootstrapBasePath() {
|
||||
|
||||
Reference in New Issue
Block a user