Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
/** The {@link BTreeIndexTopoBuilder} for BTree index in Flink. */
public class BTreeIndexTopoBuilder {

public static void buildIndex(
public static boolean buildIndex(
StreamExecutionEnvironment env,
Supplier<BTreeGlobalIndexBuilder> indexBuilderSupplier,
FileStoreTable table,
Expand All @@ -90,12 +90,12 @@ public static void buildIndex(

List<DataSplit> splits = splitByContiguousRowRange(indexBuilder.scan());
if (splits.isEmpty()) {
return;
return false;
}
Map<BinaryRow, Map<Range, List<DataSplit>>> partitionRangeSplits =
groupSplitsByRange(splits);
if (partitionRangeSplits.isEmpty()) {
return;
return false;
}

// 2. Select necessary columns (index field + ROW_ID)
Expand Down Expand Up @@ -160,23 +160,25 @@ public static void buildIndex(
commit(table, allCommitMessages);
}

env.execute("Create btree global index for table: " + table.name());
return true;
}

public static void buildIndex(
public static void buildIndexAndExecute(
StreamExecutionEnvironment env,
FileStoreTable table,
String indexColumn,
PartitionPredicate partitionPredicate,
Options userOptions)
throws Exception {
buildIndex(
if (buildIndex(
env,
() -> new BTreeGlobalIndexBuilder(table),
table,
Collections.singletonList(indexColumn),
partitionPredicate,
userOptions);
userOptions)) {
env.execute("Create btree global index for table: " + table.name());
}
}

protected static DataStream<Committable> executeForPartitionRange(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public String[] call(
// Build global index based on index type
indexType = indexType.toLowerCase().trim();
if ("btree".equals(indexType)) {
BTreeIndexTopoBuilder.buildIndex(
BTreeIndexTopoBuilder.buildIndexAndExecute(
procedureContext.getExecutionEnvironment(),
table,
indexColumn,
Expand Down