You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "tsreaper (via GitHub)" <gi...@apache.org> on 2023/11/21 08:14:45 UTC

[PR] [core] Introduce read-optimized system table [incubator-paimon]

tsreaper opened a new pull request, #2359:
URL: https://github.com/apache/incubator-paimon/pull/2359

   ### Purpose
   
   OLAP systems have high demands on reading efficiency. This PR introduces a new system table called the "read-optimized table". This table is optimized for reading by avoiding merging files.
   
   For primary key tables, this system table only scans files on top level. For append only tables, as all files can be read without merging, this system table does nothing special.
   
   ### Tests
   
   * `PrimaryKeyFileStoreTableTest#testReadOptimizedTable`.
   * `CatalogTableITCase#testReadOptimizedTable`.
   
   ### API and Format
   
   No.
   
   ### Documentation
   
   Yes. Document is also updated.
   


-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [core] Introduce read-optimized system table [incubator-paimon]

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #2359:
URL: https://github.com/apache/incubator-paimon/pull/2359#discussion_r1400183943


##########
paimon-core/src/main/java/org/apache/paimon/table/system/ReadOptimizedTable.java:
##########
@@ -0,0 +1,153 @@
+/*
+ * 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.paimon.table.system;
+
+import org.apache.paimon.CoreOptions;
+import org.apache.paimon.fs.FileIO;
+import org.apache.paimon.fs.Path;
+import org.apache.paimon.operation.DefaultValueAssigner;
+import org.apache.paimon.table.AbstractFileStoreTable;
+import org.apache.paimon.table.DataTable;
+import org.apache.paimon.table.FileStoreTable;
+import org.apache.paimon.table.ReadonlyTable;
+import org.apache.paimon.table.Table;
+import org.apache.paimon.table.source.InnerStreamTableScan;
+import org.apache.paimon.table.source.InnerStreamTableScanImpl;
+import org.apache.paimon.table.source.InnerTableRead;
+import org.apache.paimon.table.source.InnerTableScan;
+import org.apache.paimon.table.source.InnerTableScanImpl;
+import org.apache.paimon.table.source.snapshot.SnapshotReader;
+import org.apache.paimon.types.RowType;
+import org.apache.paimon.utils.SnapshotManager;
+import org.apache.paimon.utils.TagManager;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.apache.paimon.catalog.Catalog.SYSTEM_TABLE_SPLITTER;
+
+/**
+ * A {@link Table} optimized for reading by avoiding merging files.
+ *
+ * <ul>
+ *   <li>For primary key tables, this system table only scans files on top level.
+ *   <li>For append only tables, as all files can be read without merging, this system table does
+ *       nothing special.
+ * </ul>
+ */
+public class ReadOptimizedTable implements DataTable, ReadonlyTable {
+
+    public static final String READ_OPTIMIZED = "ro";
+
+    private final AbstractFileStoreTable dataTable;
+
+    public ReadOptimizedTable(FileStoreTable dataTable) {
+        this.dataTable = (AbstractFileStoreTable) dataTable;
+    }
+
+    @Override
+    public String name() {
+        return dataTable.name() + SYSTEM_TABLE_SPLITTER + READ_OPTIMIZED;
+    }
+
+    @Override
+    public RowType rowType() {
+        return dataTable.rowType();
+    }
+
+    @Override
+    public List<String> partitionKeys() {
+        return dataTable.partitionKeys();
+    }
+
+    @Override
+    public Map<String, String> options() {
+        return dataTable.options();
+    }
+
+    @Override
+    public List<String> primaryKeys() {
+        return dataTable.primaryKeys();
+    }
+
+    @Override
+    public SnapshotReader newSnapshotReader() {
+        if (dataTable.schema().primaryKeys().size() > 0) {
+            return dataTable
+                    .newSnapshotReader()
+                    .withLevelFilter(level -> level == coreOptions().numLevels() - 1);

Review Comment:
   we can just read max level in a split. not just table max level.
   
   you can add test for this.



-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [core] Introduce read-optimized system table [incubator-paimon]

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi merged PR #2359:
URL: https://github.com/apache/incubator-paimon/pull/2359


-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [core] Introduce read-optimized system table [incubator-paimon]

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #2359:
URL: https://github.com/apache/incubator-paimon/pull/2359#discussion_r1400181872


##########
docs/content/how-to/system-tables.md:
##########
@@ -130,6 +130,22 @@ SELECT * FROM MyTable$audit_log;
 */
 ```
 
+### Read-optimized Table

Review Comment:
   modify documentation in `Read Performance` too



-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org