vinishjail97 commented on code in PR #935:
URL: https://github.com/apache/incubator-xtable/pull/935#discussion_r4252200179
##########
xtable-api/src/main/java/org/apache/xtable/model/sync/SyncResult.java:
##########
@@ -50,6 +50,18 @@ public class SyncResult {
// The sync status for each catalog.
@Builder.Default List<CatalogSyncStatus> catalogSyncStatusList =
Collections.emptyList();
+ /**
+ * Returns the error message of the table format sync of the given result,
or null when the sync
+ * reported no error details.
+ */
+ public static String getErrorMessage(SyncResult syncResult) {
Review Comment:
Done in 2df63f60, `getErrorMessage()` is now an instance method.
##########
xtable-core/src/main/java/org/apache/xtable/index/Index.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.xtable.index;
+
+import org.apache.spark.sql.Dataset;
+import org.apache.spark.sql.Row;
+
+/**
+ * An index over a table that maps the values of a column to the rows that
hold them, so an engine
+ * can find those rows without a full table scan or join.
+ *
+ * @param <T> The table type of the source format (for example an Iceberg
{@code Table})
+ */
+public interface Index<T> {
+ /**
+ * Checks whether the index of the given column exists.
+ *
+ * @param columnName The indexed column
+ * @return true when a build of the index has completed
+ */
+ boolean doesIndexExist(String columnName);
+
+ /**
+ * Brings the indexes of the configured columns up to date with the current
state of the table.
+ * The indexed columns are part of the index configuration, not of the sync.
+ *
+ * @param table The table to index
+ */
+ void syncIndex(T table);
+
+ /**
+ * Looks up the given keys in the index of a column.
+ *
+ * @param table The table the index belongs to
+ * @param keys The values to look up, in the column named {@code columnName}
+ * @param columnName The indexed column
+ * @return the matches of the keys. The schema of the result depends on the
type of the index.
+ */
+ Dataset<Row> lookup(T table, Dataset<Row> keys, String columnName);
Review Comment:
Makes sense, split in 2df63f60 along the lines of Lucene's IndexWriter and
IndexReader. `IndexWriter` (`syncIndex`) has no Spark types, and
`HudiBackedSecondaryIndexWriter` takes only a Hadoop `Configuration`.
`IndexReader<T, K, R>` (`doesIndexExist`, `lookup`) takes the key and result
types as parameters, so the interface does not depend on Spark either;
`HudiBackedSecondaryIndexReader` is the Spark implementation with
`Dataset<Row>`. At runtime the sync still commits through Hudi's Spark engine,
because Hudi's Java engine cannot build the secondary index yet
(apache/hudi#20244, plus an NPE on Java secondary index updates that still
needs an issue). Once those are fixed, the sync can move to the Java engine
without an API change.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]