Skip to content

Commit

Permalink
[core] Add Table.indexManifestFileReader (apache#4068)
Browse files Browse the repository at this point in the history
  • Loading branch information
JingsongLi authored Aug 27, 2024
1 parent db77eec commit d373a86
Show file tree
Hide file tree
Showing 15 changed files with 87 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ protected ManifestList.Factory manifestListFactory(boolean forWrite) {
forWrite ? writeManifestCache : readManifestCache);
}

protected IndexManifestFile.Factory indexManifestFileFactory() {
@Override
public IndexManifestFile.Factory indexManifestFileFactory() {
return new IndexManifestFile.Factory(
fileIO,
options.manifestFormat(),
Expand Down
3 changes: 3 additions & 0 deletions paimon-core/src/main/java/org/apache/paimon/FileStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.apache.paimon.fs.Path;
import org.apache.paimon.index.IndexFileHandler;
import org.apache.paimon.manifest.IndexManifestFile;
import org.apache.paimon.manifest.ManifestCacheFilter;
import org.apache.paimon.manifest.ManifestFile;
import org.apache.paimon.manifest.ManifestList;
Expand Down Expand Up @@ -70,6 +71,8 @@ public interface FileStore<T> {

ManifestFile.Factory manifestFileFactory();

IndexManifestFile.Factory indexManifestFileFactory();

IndexFileHandler newIndexFileHandler();

StatsFileHandler newStatsFileHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.apache.paimon.index;

import org.apache.paimon.annotation.Public;
import org.apache.paimon.deletionvectors.DeletionVectorsIndexFile;
import org.apache.paimon.types.ArrayType;
import org.apache.paimon.types.BigIntType;
Expand All @@ -34,7 +35,12 @@

import static org.apache.paimon.utils.SerializationUtils.newStringType;

/** Metadata of index file. */
/**
* Metadata of index file.
*
* @since 0.9.0
*/
@Public
public class IndexFileMeta {

public static final RowType SCHEMA =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.apache.paimon.manifest;

import org.apache.paimon.annotation.Public;
import org.apache.paimon.data.BinaryRow;
import org.apache.paimon.index.IndexFileMeta;
import org.apache.paimon.types.ArrayType;
Expand All @@ -34,7 +35,12 @@
import static org.apache.paimon.utils.SerializationUtils.newBytesType;
import static org.apache.paimon.utils.SerializationUtils.newStringType;

/** Manifest entry for index file. */
/**
* Manifest entry for index file.
*
* @since 0.9.0
*/
@Public
public class IndexManifestEntry {

public static final RowType SCHEMA =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.paimon.catalog.Identifier;
import org.apache.paimon.fs.Path;
import org.apache.paimon.index.IndexFileHandler;
import org.apache.paimon.manifest.IndexManifestFile;
import org.apache.paimon.manifest.ManifestCacheFilter;
import org.apache.paimon.manifest.ManifestFile;
import org.apache.paimon.manifest.ManifestList;
Expand Down Expand Up @@ -106,6 +107,11 @@ public ManifestFile.Factory manifestFileFactory() {
return wrapped.manifestFileFactory();
}

@Override
public IndexManifestFile.Factory indexManifestFileFactory() {
return wrapped.indexManifestFileFactory();
}

@Override
public IndexFileHandler newIndexFileHandler() {
return wrapped.newIndexFileHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.apache.paimon.FileStore;
import org.apache.paimon.catalog.Identifier;
import org.apache.paimon.manifest.IndexManifestEntry;
import org.apache.paimon.manifest.ManifestCacheFilter;
import org.apache.paimon.manifest.ManifestEntry;
import org.apache.paimon.manifest.ManifestFileMeta;
Expand Down Expand Up @@ -104,6 +105,11 @@ public SimpleFileReader<ManifestEntry> manifestFileReader() {
return wrapped.manifestFileReader();
}

@Override
public SimpleFileReader<IndexManifestEntry> indexManifestFileReader() {
return wrapped.indexManifestFileReader();
}

@Override
public FileStoreTable copy(TableSchema newTableSchema) {
return new PrivilegedFileStoreTable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.paimon.consumer.ConsumerManager;
import org.apache.paimon.fs.FileIO;
import org.apache.paimon.fs.Path;
import org.apache.paimon.manifest.IndexManifestEntry;
import org.apache.paimon.manifest.ManifestEntry;
import org.apache.paimon.manifest.ManifestFileMeta;
import org.apache.paimon.metastore.AddPartitionCommitCallback;
Expand Down Expand Up @@ -138,6 +139,11 @@ public SimpleFileReader<ManifestEntry> manifestFileReader() {
return store().manifestFileFactory().create();
}

@Override
public SimpleFileReader<IndexManifestEntry> indexManifestFileReader() {
return store().indexManifestFileFactory().create();
}

@Override
public String name() {
return identifier().getObjectName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.paimon.data.BinaryRow;
import org.apache.paimon.data.InternalRow;
import org.apache.paimon.disk.IOManager;
import org.apache.paimon.manifest.IndexManifestEntry;
import org.apache.paimon.manifest.ManifestEntry;
import org.apache.paimon.manifest.ManifestFileMeta;
import org.apache.paimon.manifest.PartitionEntry;
Expand Down Expand Up @@ -86,6 +87,11 @@ public SimpleFileReader<ManifestEntry> manifestFileReader() {
return wrapped.manifestFileReader();
}

@Override
public SimpleFileReader<IndexManifestEntry> indexManifestFileReader() {
return wrapped.indexManifestFileReader();
}

@Override
public FileStoreTable copy(TableSchema newTableSchema) {
return new FallbackReadFileStoreTable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.paimon.Snapshot;
import org.apache.paimon.annotation.Public;
import org.apache.paimon.catalog.Identifier;
import org.apache.paimon.manifest.IndexManifestEntry;
import org.apache.paimon.manifest.ManifestEntry;
import org.apache.paimon.manifest.ManifestFileMeta;
import org.apache.paimon.stats.Statistics;
Expand Down Expand Up @@ -235,6 +236,11 @@ default SimpleFileReader<ManifestEntry> manifestFileReader() {
throw new UnsupportedOperationException();
}

@Override
default SimpleFileReader<IndexManifestEntry> indexManifestFileReader() {
throw new UnsupportedOperationException();
}

@Override
default void rollbackTo(long snapshotId) {
throw new UnsupportedOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.paimon.table;

import org.apache.paimon.Snapshot;
import org.apache.paimon.manifest.IndexManifestEntry;
import org.apache.paimon.manifest.ManifestEntry;
import org.apache.paimon.manifest.ManifestFileMeta;
import org.apache.paimon.stats.Statistics;
Expand Down Expand Up @@ -140,6 +141,14 @@ default SimpleFileReader<ManifestEntry> manifestFileReader() {
this.getClass().getSimpleName()));
}

@Override
default SimpleFileReader<IndexManifestEntry> indexManifestFileReader() {
throw new UnsupportedOperationException(
String.format(
"Readonly Table %s does not support indexManifestFileReader.",
this.getClass().getSimpleName()));
}

@Override
default void rollbackTo(long snapshotId) {
throw new UnsupportedOperationException(
Expand Down
5 changes: 5 additions & 0 deletions paimon-core/src/main/java/org/apache/paimon/table/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.paimon.Snapshot;
import org.apache.paimon.annotation.Experimental;
import org.apache.paimon.annotation.Public;
import org.apache.paimon.manifest.IndexManifestEntry;
import org.apache.paimon.manifest.ManifestEntry;
import org.apache.paimon.manifest.ManifestFileMeta;
import org.apache.paimon.stats.Statistics;
Expand Down Expand Up @@ -94,6 +95,10 @@ default String fullName() {
@Experimental
SimpleFileReader<ManifestEntry> manifestFileReader();

/** Reader to read index manifest entry from index manifest file. */
@Experimental
SimpleFileReader<IndexManifestEntry> indexManifestFileReader();

/** Rollback table's state to a specific snapshot. */
@Experimental
void rollbackTo(long snapshotId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.paimon.disk.IOManager;
import org.apache.paimon.fs.FileIO;
import org.apache.paimon.fs.Path;
import org.apache.paimon.manifest.IndexManifestEntry;
import org.apache.paimon.manifest.ManifestEntry;
import org.apache.paimon.manifest.ManifestFileMeta;
import org.apache.paimon.manifest.PartitionEntry;
Expand Down Expand Up @@ -124,6 +125,11 @@ public SimpleFileReader<ManifestEntry> manifestFileReader() {
return wrapped.manifestFileReader();
}

@Override
public SimpleFileReader<IndexManifestEntry> indexManifestFileReader() {
return wrapped.indexManifestFileReader();
}

@Override
public String name() {
return wrapped.name() + SYSTEM_TABLE_SPLITTER + AUDIT_LOG;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.paimon.fs.Path;
import org.apache.paimon.io.DataFileMeta;
import org.apache.paimon.io.DataFileMetaSerializer;
import org.apache.paimon.manifest.IndexManifestEntry;
import org.apache.paimon.manifest.ManifestEntry;
import org.apache.paimon.manifest.ManifestFileMeta;
import org.apache.paimon.predicate.Predicate;
Expand Down Expand Up @@ -128,6 +129,11 @@ public SimpleFileReader<ManifestEntry> manifestFileReader() {
return wrapped.manifestFileReader();
}

@Override
public SimpleFileReader<IndexManifestEntry> indexManifestFileReader() {
return wrapped.indexManifestFileReader();
}

@Override
public Path location() {
return wrapped.location();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.paimon.fs.Path;
import org.apache.paimon.io.DataFileMeta;
import org.apache.paimon.io.DataFileMetaSerializer;
import org.apache.paimon.manifest.IndexManifestEntry;
import org.apache.paimon.manifest.ManifestEntry;
import org.apache.paimon.manifest.ManifestFileMeta;
import org.apache.paimon.predicate.Predicate;
Expand Down Expand Up @@ -115,6 +116,11 @@ public SimpleFileReader<ManifestEntry> manifestFileReader() {
return wrapped.manifestFileReader();
}

@Override
public SimpleFileReader<IndexManifestEntry> indexManifestFileReader() {
return wrapped.indexManifestFileReader();
}

@Override
public Path location() {
return wrapped.location();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.paimon.Snapshot;
import org.apache.paimon.fs.FileIO;
import org.apache.paimon.fs.Path;
import org.apache.paimon.manifest.IndexManifestEntry;
import org.apache.paimon.manifest.ManifestEntry;
import org.apache.paimon.manifest.ManifestFileMeta;
import org.apache.paimon.operation.DefaultValueAssigner;
Expand Down Expand Up @@ -85,6 +86,11 @@ public SimpleFileReader<ManifestEntry> manifestFileReader() {
return wrapped.manifestFileReader();
}

@Override
public SimpleFileReader<IndexManifestEntry> indexManifestFileReader() {
return wrapped.indexManifestFileReader();
}

@Override
public String name() {
return wrapped.name() + SYSTEM_TABLE_SPLITTER + READ_OPTIMIZED;
Expand Down

0 comments on commit d373a86

Please sign in to comment.