This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new c6be49b04 [core] Revert branchs in TagsTable (#3350)
c6be49b04 is described below
commit c6be49b04dc30e97ab1aea7fd2714c126959058b
Author: Jingsong Lee <[email protected]>
AuthorDate: Mon May 20 18:21:15 2024 +0800
[core] Revert branchs in TagsTable (#3350)
---
.../org/apache/paimon/table/system/TagsTable.java | 35 ++++------------------
.../apache/paimon/table/system/TagsTableTest.java | 35 ++--------------------
2 files changed, 8 insertions(+), 62 deletions(-)
diff --git
a/paimon-core/src/main/java/org/apache/paimon/table/system/TagsTable.java
b/paimon-core/src/main/java/org/apache/paimon/table/system/TagsTable.java
index 5a179cfc1..0c1c4aa29 100644
--- a/paimon-core/src/main/java/org/apache/paimon/table/system/TagsTable.java
+++ b/paimon-core/src/main/java/org/apache/paimon/table/system/TagsTable.java
@@ -18,7 +18,6 @@
package org.apache.paimon.table.system;
-import org.apache.paimon.CoreOptions;
import org.apache.paimon.data.BinaryString;
import org.apache.paimon.data.GenericRow;
import org.apache.paimon.data.InternalRow;
@@ -26,11 +25,8 @@ import org.apache.paimon.data.Timestamp;
import org.apache.paimon.disk.IOManager;
import org.apache.paimon.fs.FileIO;
import org.apache.paimon.fs.Path;
-import org.apache.paimon.options.Options;
import org.apache.paimon.predicate.Predicate;
import org.apache.paimon.reader.RecordReader;
-import org.apache.paimon.table.FileStoreTable;
-import org.apache.paimon.table.FileStoreTableFactory;
import org.apache.paimon.table.ReadonlyTable;
import org.apache.paimon.table.Table;
import org.apache.paimon.table.source.InnerTableRead;
@@ -52,10 +48,8 @@ import org.apache.paimon.utils.TagManager;
import org.apache.paimon.shade.guava30.com.google.common.collect.Iterators;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
@@ -80,10 +74,9 @@ public class TagsTable implements ReadonlyTable {
new DataField(2, "schema_id", new
BigIntType(false)),
new DataField(3, "commit_time", new
TimestampType(false, 3)),
new DataField(4, "record_count", new
BigIntType(true)),
- new DataField(5, "branches",
SerializationUtils.newStringType(true)),
- new DataField(6, "create_time", new
TimestampType(true, 3)),
+ new DataField(5, "create_time", new
TimestampType(true, 3)),
new DataField(
- 7, "time_retained",
SerializationUtils.newStringType(true))));
+ 6, "time_retained",
SerializationUtils.newStringType(true))));
private final FileIO fileIO;
private final Path location;
@@ -140,6 +133,7 @@ public class TagsTable implements ReadonlyTable {
}
private static class TagsSplit implements Split {
+
private static final long serialVersionUID = 1L;
private final long rowCount;
@@ -205,28 +199,14 @@ public class TagsTable implements ReadonlyTable {
throw new IllegalArgumentException("Unsupported split: " +
split.getClass());
}
Path location = ((TagsSplit) split).location;
- Options options = new Options();
- options.set(CoreOptions.PATH, location.toUri().toString());
- FileStoreTable table = FileStoreTableFactory.create(fileIO,
options);
- List<Pair<Tag, String>> tags = table.tagManager().tagObjects();
+ List<Pair<Tag, String>> tags = new TagManager(fileIO,
location).tagObjects();
Map<String, Tag> nameToSnapshot = new LinkedHashMap<>();
for (Pair<Tag, String> tag : tags) {
nameToSnapshot.put(tag.getValue(), tag.getKey());
}
- Map<String, List<String>> tagBranches = new HashMap<>();
- table.branchManager()
- .branches()
- .forEach(
- branch ->
- tagBranches
- .computeIfAbsent(
- branch.getCreatedFromTag(),
- key -> new ArrayList<>())
- .add(branch.getBranchName()));
Iterator<InternalRow> rows =
- Iterators.transform(
- nameToSnapshot.entrySet().iterator(), tag ->
toRow(tag, tagBranches));
+ Iterators.transform(nameToSnapshot.entrySet().iterator(),
this::toRow);
if (projection != null) {
rows =
Iterators.transform(
@@ -235,17 +215,14 @@ public class TagsTable implements ReadonlyTable {
return new IteratorRecordReader<>(rows);
}
- private InternalRow toRow(
- Map.Entry<String, Tag> snapshot, Map<String, List<String>>
tagBranches) {
+ private InternalRow toRow(Map.Entry<String, Tag> snapshot) {
Tag tag = snapshot.getValue();
- List<String> branches = tagBranches.get(snapshot.getKey());
return GenericRow.of(
BinaryString.fromString(snapshot.getKey()),
tag.id(),
tag.schemaId(),
Timestamp.fromLocalDateTime(DateTimeUtils.toLocalDateTime(tag.timeMillis())),
tag.totalRecordCount(),
- BinaryString.fromString(branches == null ? "[]" :
branches.toString()),
Optional.ofNullable(tag.getTagCreateTime())
.map(Timestamp::fromLocalDateTime)
.orElse(null),
diff --git
a/paimon-core/src/test/java/org/apache/paimon/table/system/TagsTableTest.java
b/paimon-core/src/test/java/org/apache/paimon/table/system/TagsTableTest.java
index a1b7770c5..99c38df01 100644
---
a/paimon-core/src/test/java/org/apache/paimon/table/system/TagsTableTest.java
+++
b/paimon-core/src/test/java/org/apache/paimon/table/system/TagsTableTest.java
@@ -26,7 +26,6 @@ import org.apache.paimon.data.Timestamp;
import org.apache.paimon.manifest.ManifestCommittable;
import org.apache.paimon.schema.Schema;
import org.apache.paimon.table.FileStoreTable;
-import org.apache.paimon.table.Table;
import org.apache.paimon.table.TableTestBase;
import org.apache.paimon.table.sink.TableCommitImpl;
import org.apache.paimon.tag.Tag;
@@ -40,10 +39,7 @@ import org.junit.jupiter.api.Test;
import java.time.LocalDateTime;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
-import java.util.function.Function;
import static org.assertj.core.api.Assertions.assertThat;
@@ -87,38 +83,12 @@ class TagsTableTest extends TableTestBase {
@Test
void testTagsTable() throws Exception {
- List<InternalRow> expectRow =
- getExceptedResult(
- key -> {
- return new ArrayList<>();
- });
+ List<InternalRow> expectRow = getExceptedResult();
List<InternalRow> result = read(tagsTable);
assertThat(result).containsExactlyElementsOf(expectRow);
}
- @Test
- void testTagBranchesTable() throws Exception {
- Table table = catalog.getTable(identifier(tableName));
- table.createBranch("2023-07-17-branch1", "2023-07-17");
- table.createBranch("2023-07-18-branch1", "2023-07-18");
- table.createBranch("2023-07-18-branch2", "2023-07-18");
- List<InternalRow> expectRow =
- getExceptedResult(
- tag -> {
- if (tag.equals("2023-07-17")) {
- return
Collections.singletonList("2023-07-17-branch1");
- } else if (tag.equals("2023-07-18")) {
- return Arrays.asList("2023-07-18-branch1",
"2023-07-18-branch2");
- } else {
- return new ArrayList<>();
- }
- });
- List<InternalRow> result = read(tagsTable);
- assertThat(result).containsExactlyElementsOf(expectRow);
- }
-
- private List<InternalRow> getExceptedResult(
- Function<String, List<String>> tagBranchesFunction) {
+ private List<InternalRow> getExceptedResult() {
List<InternalRow> internalRows = new ArrayList<>();
for (Pair<Tag, String> snapshot : tagManager.tagObjects()) {
Tag tag = snapshot.getKey();
@@ -131,7 +101,6 @@ class TagsTableTest extends TableTestBase {
Timestamp.fromLocalDateTime(
DateTimeUtils.toLocalDateTime(tag.timeMillis())),
tag.totalRecordCount(),
-
BinaryString.fromString(tagBranchesFunction.apply(tagName).toString()),
tag.getTagCreateTime() == null
? null
:
Timestamp.fromLocalDateTime(tag.getTagCreateTime()),