You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "danny0405 (via GitHub)" <gi...@apache.org> on 2023/08/29 03:12:18 UTC
[GitHub] [hudi] danny0405 opened a new pull request, #9565: [HUDI-6725] Support efficient completion time queries on the timeline
danny0405 opened a new pull request, #9565:
URL: https://github.com/apache/hudi/pull/9565
### Change Logs
Add a tool to query completion time efficiently on both active & archived timeline.
### Impact
none
### Risk level (write none, low medium or high below)
none
### Documentation Update
_Describe any necessary documentation update if there is any new feature, config, or user-facing change_
- _The config description must be updated if new configs are added or the default value of the configs are changed_
- _Any new feature or user-facing change requires updating the Hudi website. Please create a Jira ticket, attach the
ticket number here and follow the [instruction](https://hudi.apache.org/contribute/developer-setup#website) to make
changes to the website._
### Contributor's checklist
- [ ] Read through [contributor's guide](https://hudi.apache.org/contribute/how-to-contribute)
- [ ] Change Logs and Impact were stated clearly
- [ ] Adequate tests were added if applicable
- [ ] CI passed
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] hudi-bot commented on pull request #9565: [HUDI-6725] Support efficient completion time queries on the timeline
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #9565:
URL: https://github.com/apache/hudi/pull/9565#issuecomment-1696945772
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19531",
"triggerID" : "a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e Azure: [FAILURE](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19531)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] hudi-bot commented on pull request #9565: [HUDI-6725] Support efficient completion time queries on the timeline
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #9565:
URL: https://github.com/apache/hudi/pull/9565#issuecomment-1700646379
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19531",
"triggerID" : "a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e",
"triggerType" : "PUSH"
}, {
"hash" : "040d9781c208ca8837cbad14d6a443a5a5bef58b",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "040d9781c208ca8837cbad14d6a443a5a5bef58b",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e Azure: [FAILURE](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19531)
* 040d9781c208ca8837cbad14d6a443a5a5bef58b UNKNOWN
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] hudi-bot commented on pull request #9565: [HUDI-6725] Support efficient completion time queries on the timeline
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #9565:
URL: https://github.com/apache/hudi/pull/9565#issuecomment-1696734657
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19531",
"triggerID" : "a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e Azure: [PENDING](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19531)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] danny0405 commented on a diff in pull request #9565: [HUDI-6725] Support efficient completion time queries on the timeline
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on code in PR #9565:
URL: https://github.com/apache/hudi/pull/9565#discussion_r1308148250
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/timeline/CompletionTimeQueryView.java:
##########
@@ -0,0 +1,149 @@
+/*
+ * 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.hudi.client.timeline;
+
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.timeline.HoodieArchivedTimeline;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.common.util.Option;
+
+import org.apache.avro.generic.GenericRecord;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.apache.hudi.common.table.timeline.HoodieArchivedTimeline.COMPLETION_TIME_ARCHIVED_META_FIELD;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.EQUALS;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.GREATER_THAN;
+
+/**
+ * Query view for instant completion time.
+ */
+public class CompletionTimeQueryView implements AutoCloseable {
+ private final HoodieTableMetaClient metaClient;
+
+ /**
+ * Mapping from instant start time -> completion time.
+ * Should be thread-safe data structure.
+ */
+ private final Map<String, String> startToCompletionInstantTimeMap;
+
+ /**
+ * The start instant time to eagerly load from, by default load last 3 days of completed instants.
+ */
+ private final String startInstant;
+
+ /**
+ * The first instant on the active timeline, used for query optimization.
+ */
+ private final String firstInstantOnActiveTimeline;
+
+ /**
+ * The constructor.
+ *
+ * @param metaClient The table meta client.
+ * @param startInstant The earliest instant time to eagerly load from, by default load last 3 days of completed instants.
+ */
+ public CompletionTimeQueryView(HoodieTableMetaClient metaClient, String startInstant) {
+ this.metaClient = metaClient;
+ this.startToCompletionInstantTimeMap = new ConcurrentHashMap<>();
+ this.startInstant = startInstant;
+ this.firstInstantOnActiveTimeline = metaClient.getActiveTimeline().firstInstant().map(HoodieInstant::getTimestamp).orElse("");
+ load();
+ }
+
+ /**
+ * Queries the instant completion time with given start time.
+ *
+ * @param startTime The start time.
+ *
+ * @return The completion time if the instant finished or empty if it is still pending.
+ */
+ public Option<String> getCompletionTime(String startTime) {
+ String completionTime = this.startToCompletionInstantTimeMap.get(startTime);
+ if (completionTime != null) {
+ return Option.of(completionTime);
+ }
+ if (HoodieTimeline.compareTimestamps(startTime, GREATER_THAN, this.firstInstantOnActiveTimeline)) {
+ // the instant is still pending
+ return Option.empty();
+ }
+ // the 'startTime' should be out of the eager loading range, switch to a lazy loading.
+ // This operation is resource costly.
+ HoodieArchivedTimeline.loadInstants(metaClient,
+ new EQTsFilter(startTime),
Review Comment:
Might switch to point-query API on parquet if we have that.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] danny0405 commented on a diff in pull request #9565: [HUDI-6725] Support efficient completion time queries on the timeline
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on code in PR #9565:
URL: https://github.com/apache/hudi/pull/9565#discussion_r1311262489
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/timeline/CompletionTimeQueryView.java:
##########
@@ -0,0 +1,149 @@
+/*
+ * 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.hudi.client.timeline;
+
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.timeline.HoodieArchivedTimeline;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.common.util.Option;
+
+import org.apache.avro.generic.GenericRecord;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.apache.hudi.common.table.timeline.HoodieArchivedTimeline.COMPLETION_TIME_ARCHIVED_META_FIELD;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.EQUALS;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.GREATER_THAN;
+
+/**
+ * Query view for instant completion time.
+ */
+public class CompletionTimeQueryView implements AutoCloseable {
+ private final HoodieTableMetaClient metaClient;
+
+ /**
+ * Mapping from instant start time -> completion time.
+ * Should be thread-safe data structure.
+ */
+ private final Map<String, String> startToCompletionInstantTimeMap;
+
+ /**
+ * The start instant time to eagerly load from, by default load last 3 days of completed instants.
+ */
+ private final String startInstant;
+
+ /**
+ * The first instant on the active timeline, used for query optimization.
+ */
+ private final String firstInstantOnActiveTimeline;
+
+ /**
+ * The constructor.
+ *
+ * @param metaClient The table meta client.
+ * @param startInstant The earliest instant time to eagerly load from, by default load last 3 days of completed instants.
+ */
+ public CompletionTimeQueryView(HoodieTableMetaClient metaClient, String startInstant) {
+ this.metaClient = metaClient;
+ this.startToCompletionInstantTimeMap = new ConcurrentHashMap<>();
+ this.startInstant = startInstant;
+ this.firstInstantOnActiveTimeline = metaClient.getActiveTimeline().firstInstant().map(HoodieInstant::getTimestamp).orElse("");
+ load();
+ }
+
+ /**
+ * Queries the instant completion time with given start time.
+ *
+ * @param startTime The start time.
+ *
+ * @return The completion time if the instant finished or empty if it is still pending.
+ */
+ public Option<String> getCompletionTime(String startTime) {
+ String completionTime = this.startToCompletionInstantTimeMap.get(startTime);
+ if (completionTime != null) {
+ return Option.of(completionTime);
+ }
+ if (HoodieTimeline.compareTimestamps(startTime, GREATER_THAN, this.firstInstantOnActiveTimeline)) {
+ // the instant is still pending
+ return Option.empty();
+ }
+ // the 'startTime' should be out of the eager loading range, switch to a lazy loading.
+ // This operation is resource costly.
+ HoodieArchivedTimeline.loadInstants(metaClient,
+ new EQTsFilter(startTime),
+ HoodieArchivedTimeline.LoadMode.SLIM,
+ r -> true,
+ this::readCompletionTime);
+ return Option.ofNullable(this.startToCompletionInstantTimeMap.get(startTime));
+ }
+
+ /**
+ * This is method to read instant completion time.
+ * This would also update 'startToCompletionInstantTimeMap' map with start time/completion time pairs.
+ * Only instants starts from 'startInstant' (inclusive) are considered.
+ */
+ private void load() {
+ // load active instants first.
+ this.metaClient.getActiveTimeline()
+ .filterCompletedInstants().getInstantsAsStream()
+ .forEach(instant -> setCompletionTime(instant.getTimestamp(), instant.getStateTransitionTime()));
+ // then load the archived instants.
+ HoodieArchivedTimeline.loadInstants(metaClient,
+ new HoodieArchivedTimeline.StartTsFilter(this.startInstant),
+ HoodieArchivedTimeline.LoadMode.SLIM,
Review Comment:
Yeah, here we only want to fetch the start time and completion time for each transaction.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] danny0405 commented on a diff in pull request #9565: [HUDI-6725] Support efficient completion time queries on the timeline
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on code in PR #9565:
URL: https://github.com/apache/hudi/pull/9565#discussion_r1311261556
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/timeline/CompletionTimeQueryView.java:
##########
@@ -0,0 +1,149 @@
+/*
+ * 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.hudi.client.timeline;
+
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.timeline.HoodieArchivedTimeline;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.common.util.Option;
+
+import org.apache.avro.generic.GenericRecord;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.apache.hudi.common.table.timeline.HoodieArchivedTimeline.COMPLETION_TIME_ARCHIVED_META_FIELD;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.EQUALS;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.GREATER_THAN;
+
+/**
+ * Query view for instant completion time.
+ */
+public class CompletionTimeQueryView implements AutoCloseable {
+ private final HoodieTableMetaClient metaClient;
+
+ /**
+ * Mapping from instant start time -> completion time.
+ * Should be thread-safe data structure.
+ */
+ private final Map<String, String> startToCompletionInstantTimeMap;
+
+ /**
+ * The start instant time to eagerly load from, by default load last 3 days of completed instants.
+ */
+ private final String startInstant;
+
+ /**
+ * The first instant on the active timeline, used for query optimization.
+ */
+ private final String firstInstantOnActiveTimeline;
+
+ /**
+ * The constructor.
+ *
+ * @param metaClient The table meta client.
+ * @param startInstant The earliest instant time to eagerly load from, by default load last 3 days of completed instants.
+ */
+ public CompletionTimeQueryView(HoodieTableMetaClient metaClient, String startInstant) {
+ this.metaClient = metaClient;
+ this.startToCompletionInstantTimeMap = new ConcurrentHashMap<>();
+ this.startInstant = startInstant;
+ this.firstInstantOnActiveTimeline = metaClient.getActiveTimeline().firstInstant().map(HoodieInstant::getTimestamp).orElse("");
+ load();
+ }
+
+ /**
+ * Queries the instant completion time with given start time.
+ *
+ * @param startTime The start time.
+ *
+ * @return The completion time if the instant finished or empty if it is still pending.
+ */
+ public Option<String> getCompletionTime(String startTime) {
+ String completionTime = this.startToCompletionInstantTimeMap.get(startTime);
+ if (completionTime != null) {
+ return Option.of(completionTime);
+ }
+ if (HoodieTimeline.compareTimestamps(startTime, GREATER_THAN, this.firstInstantOnActiveTimeline)) {
+ // the instant is still pending
+ return Option.empty();
+ }
+ // the 'startTime' should be out of the eager loading range, switch to a lazy loading.
+ // This operation is resource costly.
+ HoodieArchivedTimeline.loadInstants(metaClient,
+ new EQTsFilter(startTime),
+ HoodieArchivedTimeline.LoadMode.SLIM,
+ r -> true,
+ this::readCompletionTime);
+ return Option.ofNullable(this.startToCompletionInstantTimeMap.get(startTime));
+ }
+
+ /**
+ * This is method to read instant completion time.
+ * This would also update 'startToCompletionInstantTimeMap' map with start time/completion time pairs.
+ * Only instants starts from 'startInstant' (inclusive) are considered.
+ */
+ private void load() {
+ // load active instants first.
+ this.metaClient.getActiveTimeline()
+ .filterCompletedInstants().getInstantsAsStream()
+ .forEach(instant -> setCompletionTime(instant.getTimestamp(), instant.getStateTransitionTime()));
+ // then load the archived instants.
+ HoodieArchivedTimeline.loadInstants(metaClient,
+ new HoodieArchivedTimeline.StartTsFilter(this.startInstant),
+ HoodieArchivedTimeline.LoadMode.SLIM,
+ r -> true,
+ this::readCompletionTime);
+ }
+
+ private void readCompletionTime(String instantTime, GenericRecord record) {
+ final String completionTime = record.get(COMPLETION_TIME_ARCHIVED_META_FIELD).toString();
Review Comment:
yeah, always in the record, based on the query schema, completion time is a must-have field.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] hudi-bot commented on pull request #9565: [HUDI-6725] Support efficient completion time queries on the timeline
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #9565:
URL: https://github.com/apache/hudi/pull/9565#issuecomment-1696729681
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e UNKNOWN
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] danny0405 commented on a diff in pull request #9565: [HUDI-6725] Support efficient completion time queries on the timeline
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on code in PR #9565:
URL: https://github.com/apache/hudi/pull/9565#discussion_r1311264365
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/timeline/CompletionTimeQueryView.java:
##########
@@ -0,0 +1,149 @@
+/*
+ * 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.hudi.client.timeline;
+
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.timeline.HoodieArchivedTimeline;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.common.util.Option;
+
+import org.apache.avro.generic.GenericRecord;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.apache.hudi.common.table.timeline.HoodieArchivedTimeline.COMPLETION_TIME_ARCHIVED_META_FIELD;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.EQUALS;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.GREATER_THAN;
+
+/**
+ * Query view for instant completion time.
+ */
+public class CompletionTimeQueryView implements AutoCloseable {
+ private final HoodieTableMetaClient metaClient;
+
+ /**
+ * Mapping from instant start time -> completion time.
+ * Should be thread-safe data structure.
+ */
+ private final Map<String, String> startToCompletionInstantTimeMap;
+
+ /**
+ * The start instant time to eagerly load from, by default load last 3 days of completed instants.
Review Comment:
Probably in the following-up PR, for this patch, we can firstly expose it as a consructor param.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] hudi-bot commented on pull request #9565: [HUDI-6725] Support efficient completion time queries on the timeline
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #9565:
URL: https://github.com/apache/hudi/pull/9565#issuecomment-1703979688
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19531",
"triggerID" : "a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e",
"triggerType" : "PUSH"
}, {
"hash" : "040d9781c208ca8837cbad14d6a443a5a5bef58b",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19574",
"triggerID" : "040d9781c208ca8837cbad14d6a443a5a5bef58b",
"triggerType" : "PUSH"
}, {
"hash" : "3c3356c9a296cc9f1bce2e507944b07256b2ea01",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19633",
"triggerID" : "3c3356c9a296cc9f1bce2e507944b07256b2ea01",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 040d9781c208ca8837cbad14d6a443a5a5bef58b Azure: [FAILURE](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19574)
* 3c3356c9a296cc9f1bce2e507944b07256b2ea01 Azure: [PENDING](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19633)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] hudi-bot commented on pull request #9565: [HUDI-6725] Support efficient completion time queries on the timeline
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #9565:
URL: https://github.com/apache/hudi/pull/9565#issuecomment-1700661729
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19531",
"triggerID" : "a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e",
"triggerType" : "PUSH"
}, {
"hash" : "040d9781c208ca8837cbad14d6a443a5a5bef58b",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19574",
"triggerID" : "040d9781c208ca8837cbad14d6a443a5a5bef58b",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e Azure: [FAILURE](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19531)
* 040d9781c208ca8837cbad14d6a443a5a5bef58b Azure: [PENDING](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19574)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] codope commented on a diff in pull request #9565: [HUDI-6725] Support efficient completion time queries on the timeline
Posted by "codope (via GitHub)" <gi...@apache.org>.
codope commented on code in PR #9565:
URL: https://github.com/apache/hudi/pull/9565#discussion_r1312937243
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/timeline/CompletionTimeQueryView.java:
##########
@@ -0,0 +1,149 @@
+/*
+ * 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.hudi.client.timeline;
+
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.timeline.HoodieArchivedTimeline;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.common.util.Option;
+
+import org.apache.avro.generic.GenericRecord;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.apache.hudi.common.table.timeline.HoodieArchivedTimeline.COMPLETION_TIME_ARCHIVED_META_FIELD;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.EQUALS;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.GREATER_THAN;
+
+/**
+ * Query view for instant completion time.
+ */
+public class CompletionTimeQueryView implements AutoCloseable {
+ private final HoodieTableMetaClient metaClient;
+
+ /**
+ * Mapping from instant start time -> completion time.
+ * Should be thread-safe data structure.
+ */
+ private final Map<String, String> startToCompletionInstantTimeMap;
+
+ /**
+ * The start instant time to eagerly load from, by default load last 3 days of completed instants.
Review Comment:
Please file a followup JIRA.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] codope commented on a diff in pull request #9565: [HUDI-6725] Support efficient completion time queries on the timeline
Posted by "codope (via GitHub)" <gi...@apache.org>.
codope commented on code in PR #9565:
URL: https://github.com/apache/hudi/pull/9565#discussion_r1312942443
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/timeline/CompletionTimeQueryView.java:
##########
@@ -0,0 +1,149 @@
+/*
+ * 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.hudi.client.timeline;
+
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.timeline.HoodieArchivedTimeline;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.common.util.Option;
+
+import org.apache.avro.generic.GenericRecord;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.apache.hudi.common.table.timeline.HoodieArchivedTimeline.COMPLETION_TIME_ARCHIVED_META_FIELD;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.EQUALS;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.GREATER_THAN;
+
+/**
+ * Query view for instant completion time.
+ */
+public class CompletionTimeQueryView implements AutoCloseable {
+ private final HoodieTableMetaClient metaClient;
+
+ /**
+ * Mapping from instant start time -> completion time.
+ * Should be thread-safe data structure.
+ */
+ private final Map<String, String> startToCompletionInstantTimeMap;
+
+ /**
+ * The start instant time to eagerly load from, by default load last N days of completed instants.
+ */
+ private final String startInstant;
+
+ /**
+ * The first instant on the active timeline, used for query optimization.
+ */
+ private final String firstInstantOnActiveTimeline;
+
+ /**
+ * The constructor.
+ *
+ * @param metaClient The table meta client.
+ * @param startInstant The earliest instant time to eagerly load from, by default load last 3 days of completed instants.
Review Comment:
Need to match or infer from archival frequency.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] hudi-bot commented on pull request #9565: [HUDI-6725] Support efficient completion time queries on the timeline
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #9565:
URL: https://github.com/apache/hudi/pull/9565#issuecomment-1704003374
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19531",
"triggerID" : "a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e",
"triggerType" : "PUSH"
}, {
"hash" : "040d9781c208ca8837cbad14d6a443a5a5bef58b",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19574",
"triggerID" : "040d9781c208ca8837cbad14d6a443a5a5bef58b",
"triggerType" : "PUSH"
}, {
"hash" : "3c3356c9a296cc9f1bce2e507944b07256b2ea01",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19633",
"triggerID" : "3c3356c9a296cc9f1bce2e507944b07256b2ea01",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 3c3356c9a296cc9f1bce2e507944b07256b2ea01 Azure: [FAILURE](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19633)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] hudi-bot commented on pull request #9565: [HUDI-6725] Support efficient completion time queries on the timeline
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #9565:
URL: https://github.com/apache/hudi/pull/9565#issuecomment-1700990713
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19531",
"triggerID" : "a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e",
"triggerType" : "PUSH"
}, {
"hash" : "040d9781c208ca8837cbad14d6a443a5a5bef58b",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19574",
"triggerID" : "040d9781c208ca8837cbad14d6a443a5a5bef58b",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 040d9781c208ca8837cbad14d6a443a5a5bef58b Azure: [FAILURE](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19574)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] danny0405 commented on a diff in pull request #9565: [HUDI-6725] Support efficient completion time queries on the timeline
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on code in PR #9565:
URL: https://github.com/apache/hudi/pull/9565#discussion_r1311266196
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/timeline/CompletionTimeQueryView.java:
##########
@@ -0,0 +1,149 @@
+/*
+ * 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.hudi.client.timeline;
+
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.timeline.HoodieArchivedTimeline;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.common.util.Option;
+
+import org.apache.avro.generic.GenericRecord;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.apache.hudi.common.table.timeline.HoodieArchivedTimeline.COMPLETION_TIME_ARCHIVED_META_FIELD;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.EQUALS;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.GREATER_THAN;
+
+/**
+ * Query view for instant completion time.
+ */
+public class CompletionTimeQueryView implements AutoCloseable {
+ private final HoodieTableMetaClient metaClient;
+
+ /**
+ * Mapping from instant start time -> completion time.
+ * Should be thread-safe data structure.
+ */
+ private final Map<String, String> startToCompletionInstantTimeMap;
+
+ /**
+ * The start instant time to eagerly load from, by default load last 3 days of completed instants.
+ */
+ private final String startInstant;
+
+ /**
+ * The first instant on the active timeline, used for query optimization.
+ */
+ private final String firstInstantOnActiveTimeline;
+
+ /**
+ * The constructor.
+ *
+ * @param metaClient The table meta client.
+ * @param startInstant The earliest instant time to eagerly load from, by default load last 3 days of completed instants.
+ */
+ public CompletionTimeQueryView(HoodieTableMetaClient metaClient, String startInstant) {
+ this.metaClient = metaClient;
+ this.startToCompletionInstantTimeMap = new ConcurrentHashMap<>();
+ this.startInstant = startInstant;
+ this.firstInstantOnActiveTimeline = metaClient.getActiveTimeline().firstInstant().map(HoodieInstant::getTimestamp).orElse("");
+ load();
+ }
+
+ /**
+ * Queries the instant completion time with given start time.
+ *
+ * @param startTime The start time.
+ *
+ * @return The completion time if the instant finished or empty if it is still pending.
+ */
+ public Option<String> getCompletionTime(String startTime) {
+ String completionTime = this.startToCompletionInstantTimeMap.get(startTime);
+ if (completionTime != null) {
+ return Option.of(completionTime);
+ }
+ if (HoodieTimeline.compareTimestamps(startTime, GREATER_THAN, this.firstInstantOnActiveTimeline)) {
Review Comment:
> Not following this logic. If startTime > firstInstantOnActiveTimeline, it doesn't mean that instant is still pending right.
It means it is pending, because in the `#load` method, we already put all the completed instants of the active timeline into the map, if the map does not contain the startTime as a key, then it means the instant is pending.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] codope commented on a diff in pull request #9565: [HUDI-6725] Support efficient completion time queries on the timeline
Posted by "codope (via GitHub)" <gi...@apache.org>.
codope commented on code in PR #9565:
URL: https://github.com/apache/hudi/pull/9565#discussion_r1311099826
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/timeline/CompletionTimeQueryView.java:
##########
@@ -0,0 +1,149 @@
+/*
+ * 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.hudi.client.timeline;
+
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.timeline.HoodieArchivedTimeline;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.common.util.Option;
+
+import org.apache.avro.generic.GenericRecord;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.apache.hudi.common.table.timeline.HoodieArchivedTimeline.COMPLETION_TIME_ARCHIVED_META_FIELD;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.EQUALS;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.GREATER_THAN;
+
+/**
+ * Query view for instant completion time.
+ */
+public class CompletionTimeQueryView implements AutoCloseable {
+ private final HoodieTableMetaClient metaClient;
+
+ /**
+ * Mapping from instant start time -> completion time.
+ * Should be thread-safe data structure.
+ */
+ private final Map<String, String> startToCompletionInstantTimeMap;
+
+ /**
+ * The start instant time to eagerly load from, by default load last 3 days of completed instants.
+ */
+ private final String startInstant;
+
+ /**
+ * The first instant on the active timeline, used for query optimization.
+ */
+ private final String firstInstantOnActiveTimeline;
+
+ /**
+ * The constructor.
+ *
+ * @param metaClient The table meta client.
+ * @param startInstant The earliest instant time to eagerly load from, by default load last 3 days of completed instants.
+ */
+ public CompletionTimeQueryView(HoodieTableMetaClient metaClient, String startInstant) {
+ this.metaClient = metaClient;
+ this.startToCompletionInstantTimeMap = new ConcurrentHashMap<>();
+ this.startInstant = startInstant;
+ this.firstInstantOnActiveTimeline = metaClient.getActiveTimeline().firstInstant().map(HoodieInstant::getTimestamp).orElse("");
+ load();
+ }
+
+ /**
+ * Queries the instant completion time with given start time.
+ *
+ * @param startTime The start time.
+ *
+ * @return The completion time if the instant finished or empty if it is still pending.
+ */
+ public Option<String> getCompletionTime(String startTime) {
+ String completionTime = this.startToCompletionInstantTimeMap.get(startTime);
+ if (completionTime != null) {
+ return Option.of(completionTime);
+ }
+ if (HoodieTimeline.compareTimestamps(startTime, GREATER_THAN, this.firstInstantOnActiveTimeline)) {
+ // the instant is still pending
+ return Option.empty();
+ }
+ // the 'startTime' should be out of the eager loading range, switch to a lazy loading.
+ // This operation is resource costly.
+ HoodieArchivedTimeline.loadInstants(metaClient,
+ new EQTsFilter(startTime),
+ HoodieArchivedTimeline.LoadMode.SLIM,
+ r -> true,
+ this::readCompletionTime);
+ return Option.ofNullable(this.startToCompletionInstantTimeMap.get(startTime));
+ }
+
+ /**
+ * This is method to read instant completion time.
+ * This would also update 'startToCompletionInstantTimeMap' map with start time/completion time pairs.
+ * Only instants starts from 'startInstant' (inclusive) are considered.
+ */
+ private void load() {
+ // load active instants first.
+ this.metaClient.getActiveTimeline()
+ .filterCompletedInstants().getInstantsAsStream()
+ .forEach(instant -> setCompletionTime(instant.getTimestamp(), instant.getStateTransitionTime()));
+ // then load the archived instants.
+ HoodieArchivedTimeline.loadInstants(metaClient,
+ new HoodieArchivedTimeline.StartTsFilter(this.startInstant),
+ HoodieArchivedTimeline.LoadMode.SLIM,
+ r -> true,
+ this::readCompletionTime);
+ }
+
+ private void readCompletionTime(String instantTime, GenericRecord record) {
+ final String completionTime = record.get(COMPLETION_TIME_ARCHIVED_META_FIELD).toString();
+ setCompletionTime(instantTime, completionTime);
+ }
+
+ private void setCompletionTime(String instantTime, String completionTime) {
+ this.startToCompletionInstantTimeMap.putIfAbsent(instantTime, completionTime);
+ }
+
+ @Override
+ public void close() throws Exception {
+ this.startToCompletionInstantTimeMap.clear();
+ }
+
+ // -------------------------------------------------------------------------
+ // Inner class
+ // -------------------------------------------------------------------------
+
+ /**
+ * A time based filter with equality of specified timestamp.
+ */
+ public static class EQTsFilter extends HoodieArchivedTimeline.TimeRangeFilter {
Review Comment:
Rename to `EqualTImestampsFilter`? Full name makes it more readable.
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/timeline/CompletionTimeQueryView.java:
##########
@@ -0,0 +1,149 @@
+/*
+ * 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.hudi.client.timeline;
+
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.timeline.HoodieArchivedTimeline;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.common.util.Option;
+
+import org.apache.avro.generic.GenericRecord;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.apache.hudi.common.table.timeline.HoodieArchivedTimeline.COMPLETION_TIME_ARCHIVED_META_FIELD;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.EQUALS;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.GREATER_THAN;
+
+/**
+ * Query view for instant completion time.
+ */
+public class CompletionTimeQueryView implements AutoCloseable {
+ private final HoodieTableMetaClient metaClient;
+
+ /**
+ * Mapping from instant start time -> completion time.
+ * Should be thread-safe data structure.
+ */
+ private final Map<String, String> startToCompletionInstantTimeMap;
+
+ /**
+ * The start instant time to eagerly load from, by default load last 3 days of completed instants.
Review Comment:
Is there some internal config to control last N days of completed instants?
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/timeline/CompletionTimeQueryView.java:
##########
@@ -0,0 +1,149 @@
+/*
+ * 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.hudi.client.timeline;
+
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.timeline.HoodieArchivedTimeline;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.common.util.Option;
+
+import org.apache.avro.generic.GenericRecord;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.apache.hudi.common.table.timeline.HoodieArchivedTimeline.COMPLETION_TIME_ARCHIVED_META_FIELD;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.EQUALS;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.GREATER_THAN;
+
+/**
+ * Query view for instant completion time.
+ */
+public class CompletionTimeQueryView implements AutoCloseable {
+ private final HoodieTableMetaClient metaClient;
+
+ /**
+ * Mapping from instant start time -> completion time.
+ * Should be thread-safe data structure.
+ */
+ private final Map<String, String> startToCompletionInstantTimeMap;
+
+ /**
+ * The start instant time to eagerly load from, by default load last 3 days of completed instants.
+ */
+ private final String startInstant;
+
+ /**
+ * The first instant on the active timeline, used for query optimization.
+ */
+ private final String firstInstantOnActiveTimeline;
+
+ /**
+ * The constructor.
+ *
+ * @param metaClient The table meta client.
+ * @param startInstant The earliest instant time to eagerly load from, by default load last 3 days of completed instants.
+ */
+ public CompletionTimeQueryView(HoodieTableMetaClient metaClient, String startInstant) {
+ this.metaClient = metaClient;
+ this.startToCompletionInstantTimeMap = new ConcurrentHashMap<>();
+ this.startInstant = startInstant;
+ this.firstInstantOnActiveTimeline = metaClient.getActiveTimeline().firstInstant().map(HoodieInstant::getTimestamp).orElse("");
+ load();
+ }
+
+ /**
+ * Queries the instant completion time with given start time.
+ *
+ * @param startTime The start time.
+ *
+ * @return The completion time if the instant finished or empty if it is still pending.
+ */
+ public Option<String> getCompletionTime(String startTime) {
+ String completionTime = this.startToCompletionInstantTimeMap.get(startTime);
+ if (completionTime != null) {
+ return Option.of(completionTime);
+ }
+ if (HoodieTimeline.compareTimestamps(startTime, GREATER_THAN, this.firstInstantOnActiveTimeline)) {
+ // the instant is still pending
+ return Option.empty();
+ }
+ // the 'startTime' should be out of the eager loading range, switch to a lazy loading.
+ // This operation is resource costly.
+ HoodieArchivedTimeline.loadInstants(metaClient,
+ new EQTsFilter(startTime),
+ HoodieArchivedTimeline.LoadMode.SLIM,
+ r -> true,
+ this::readCompletionTime);
+ return Option.ofNullable(this.startToCompletionInstantTimeMap.get(startTime));
+ }
+
+ /**
+ * This is method to read instant completion time.
+ * This would also update 'startToCompletionInstantTimeMap' map with start time/completion time pairs.
+ * Only instants starts from 'startInstant' (inclusive) are considered.
+ */
+ private void load() {
+ // load active instants first.
+ this.metaClient.getActiveTimeline()
+ .filterCompletedInstants().getInstantsAsStream()
+ .forEach(instant -> setCompletionTime(instant.getTimestamp(), instant.getStateTransitionTime()));
+ // then load the archived instants.
+ HoodieArchivedTimeline.loadInstants(metaClient,
+ new HoodieArchivedTimeline.StartTsFilter(this.startInstant),
+ HoodieArchivedTimeline.LoadMode.SLIM,
Review Comment:
`SLIM` mode is sufficient? We don't need any metadata?
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/timeline/CompletionTimeQueryView.java:
##########
@@ -0,0 +1,149 @@
+/*
+ * 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.hudi.client.timeline;
+
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.timeline.HoodieArchivedTimeline;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.common.util.Option;
+
+import org.apache.avro.generic.GenericRecord;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.apache.hudi.common.table.timeline.HoodieArchivedTimeline.COMPLETION_TIME_ARCHIVED_META_FIELD;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.EQUALS;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.GREATER_THAN;
+
+/**
+ * Query view for instant completion time.
+ */
+public class CompletionTimeQueryView implements AutoCloseable {
+ private final HoodieTableMetaClient metaClient;
+
+ /**
+ * Mapping from instant start time -> completion time.
+ * Should be thread-safe data structure.
+ */
+ private final Map<String, String> startToCompletionInstantTimeMap;
+
+ /**
+ * The start instant time to eagerly load from, by default load last 3 days of completed instants.
+ */
+ private final String startInstant;
+
+ /**
+ * The first instant on the active timeline, used for query optimization.
+ */
+ private final String firstInstantOnActiveTimeline;
+
+ /**
+ * The constructor.
+ *
+ * @param metaClient The table meta client.
+ * @param startInstant The earliest instant time to eagerly load from, by default load last 3 days of completed instants.
+ */
+ public CompletionTimeQueryView(HoodieTableMetaClient metaClient, String startInstant) {
+ this.metaClient = metaClient;
+ this.startToCompletionInstantTimeMap = new ConcurrentHashMap<>();
+ this.startInstant = startInstant;
+ this.firstInstantOnActiveTimeline = metaClient.getActiveTimeline().firstInstant().map(HoodieInstant::getTimestamp).orElse("");
+ load();
+ }
+
+ /**
+ * Queries the instant completion time with given start time.
+ *
+ * @param startTime The start time.
+ *
+ * @return The completion time if the instant finished or empty if it is still pending.
+ */
+ public Option<String> getCompletionTime(String startTime) {
+ String completionTime = this.startToCompletionInstantTimeMap.get(startTime);
+ if (completionTime != null) {
+ return Option.of(completionTime);
+ }
+ if (HoodieTimeline.compareTimestamps(startTime, GREATER_THAN, this.firstInstantOnActiveTimeline)) {
Review Comment:
Not following this logic. If startTime > firstInstantOnActiveTimeline, it doesn't mean that instant is still pending right. Probably i'm missing something. Can you please explain with this example? Let's say firstInstantOnActiveTimeline has start time t0 and completion time t1. Another instant that has startTime t2 and completionTime t3. Here t2 > t0 but it is still completed.
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/timeline/CompletionTimeQueryView.java:
##########
@@ -0,0 +1,149 @@
+/*
+ * 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.hudi.client.timeline;
+
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.timeline.HoodieArchivedTimeline;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.table.timeline.HoodieTimeline;
+import org.apache.hudi.common.util.Option;
+
+import org.apache.avro.generic.GenericRecord;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.apache.hudi.common.table.timeline.HoodieArchivedTimeline.COMPLETION_TIME_ARCHIVED_META_FIELD;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.EQUALS;
+import static org.apache.hudi.common.table.timeline.HoodieTimeline.GREATER_THAN;
+
+/**
+ * Query view for instant completion time.
+ */
+public class CompletionTimeQueryView implements AutoCloseable {
+ private final HoodieTableMetaClient metaClient;
+
+ /**
+ * Mapping from instant start time -> completion time.
+ * Should be thread-safe data structure.
+ */
+ private final Map<String, String> startToCompletionInstantTimeMap;
+
+ /**
+ * The start instant time to eagerly load from, by default load last 3 days of completed instants.
+ */
+ private final String startInstant;
+
+ /**
+ * The first instant on the active timeline, used for query optimization.
+ */
+ private final String firstInstantOnActiveTimeline;
+
+ /**
+ * The constructor.
+ *
+ * @param metaClient The table meta client.
+ * @param startInstant The earliest instant time to eagerly load from, by default load last 3 days of completed instants.
+ */
+ public CompletionTimeQueryView(HoodieTableMetaClient metaClient, String startInstant) {
+ this.metaClient = metaClient;
+ this.startToCompletionInstantTimeMap = new ConcurrentHashMap<>();
+ this.startInstant = startInstant;
+ this.firstInstantOnActiveTimeline = metaClient.getActiveTimeline().firstInstant().map(HoodieInstant::getTimestamp).orElse("");
+ load();
+ }
+
+ /**
+ * Queries the instant completion time with given start time.
+ *
+ * @param startTime The start time.
+ *
+ * @return The completion time if the instant finished or empty if it is still pending.
+ */
+ public Option<String> getCompletionTime(String startTime) {
+ String completionTime = this.startToCompletionInstantTimeMap.get(startTime);
+ if (completionTime != null) {
+ return Option.of(completionTime);
+ }
+ if (HoodieTimeline.compareTimestamps(startTime, GREATER_THAN, this.firstInstantOnActiveTimeline)) {
+ // the instant is still pending
+ return Option.empty();
+ }
+ // the 'startTime' should be out of the eager loading range, switch to a lazy loading.
+ // This operation is resource costly.
+ HoodieArchivedTimeline.loadInstants(metaClient,
+ new EQTsFilter(startTime),
+ HoodieArchivedTimeline.LoadMode.SLIM,
+ r -> true,
+ this::readCompletionTime);
+ return Option.ofNullable(this.startToCompletionInstantTimeMap.get(startTime));
+ }
+
+ /**
+ * This is method to read instant completion time.
+ * This would also update 'startToCompletionInstantTimeMap' map with start time/completion time pairs.
+ * Only instants starts from 'startInstant' (inclusive) are considered.
+ */
+ private void load() {
+ // load active instants first.
+ this.metaClient.getActiveTimeline()
+ .filterCompletedInstants().getInstantsAsStream()
+ .forEach(instant -> setCompletionTime(instant.getTimestamp(), instant.getStateTransitionTime()));
+ // then load the archived instants.
+ HoodieArchivedTimeline.loadInstants(metaClient,
+ new HoodieArchivedTimeline.StartTsFilter(this.startInstant),
+ HoodieArchivedTimeline.LoadMode.SLIM,
+ r -> true,
+ this::readCompletionTime);
+ }
+
+ private void readCompletionTime(String instantTime, GenericRecord record) {
+ final String completionTime = record.get(COMPLETION_TIME_ARCHIVED_META_FIELD).toString();
Review Comment:
Will `COMPLETION_TIME_ARCHIVED_META_FIELD` be always present in the `record`? Do we need some validation like it must be greater tahn `insantTime`?
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] hudi-bot commented on pull request #9565: [HUDI-6725] Support efficient completion time queries on the timeline
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #9565:
URL: https://github.com/apache/hudi/pull/9565#issuecomment-1703978712
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19531",
"triggerID" : "a6763dd79b81e4abb7ce4dd925e7dd8f318cca0e",
"triggerType" : "PUSH"
}, {
"hash" : "040d9781c208ca8837cbad14d6a443a5a5bef58b",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19574",
"triggerID" : "040d9781c208ca8837cbad14d6a443a5a5bef58b",
"triggerType" : "PUSH"
}, {
"hash" : "3c3356c9a296cc9f1bce2e507944b07256b2ea01",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "3c3356c9a296cc9f1bce2e507944b07256b2ea01",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 040d9781c208ca8837cbad14d6a443a5a5bef58b Azure: [FAILURE](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=19574)
* 3c3356c9a296cc9f1bce2e507944b07256b2ea01 UNKNOWN
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [hudi] danny0405 merged pull request #9565: [HUDI-6725] Support efficient completion time queries on the timeline
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 merged PR #9565:
URL: https://github.com/apache/hudi/pull/9565
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org