rdblue commented on a change in pull request #1825:
URL: https://github.com/apache/iceberg/pull/1825#discussion_r533017757
##########
File path: nessie/src/main/java/org/apache/iceberg/nessie/NessieCatalog.java
##########
@@ -307,6 +313,41 @@ private UpdateableReference loadReference(String
requestedRef) {
}
}
+ private UpdateableReference loadReferenceAtTime(String requestedRef, Instant
timestamp) {
+ try {
+ Reference ref = requestedRef == null ?
client.getTreeApi().getDefaultBranch()
+ : client.getTreeApi().getReferenceByName(requestedRef);
+ if (ref instanceof Hash) {
+ LOGGER.warn("Cannot specify a hash {} and timestamp {} together. " +
+ "The timestamp is redundant and has been ignored", requestedRef,
timestamp);
+ return new UpdateableReference(ref, client.getTreeApi());
+ }
+ // NOTE fetching logs is currently potentially expensive
+ // todo this algorithm doesn't currently handle assign operations. The
resulting hash may
+ // be the hash from the branch that requestedRef was reassigned to at
time 't' rather than the hash
+ // of this ref at time 't' BEFORE reassignment. This logic needs to move
to the server side and will
+ // be done in a follow up commit.
+ List<CommitMeta> ops =
client.getTreeApi().getCommitLog(ref.getName()).getOperations();
+ for (CommitMeta info : ops) {
+ if (info.getCommitTime() != null &&
Instant.ofEpochMilli(info.getCommitTime()).isBefore(timestamp)) {
+ return new
UpdateableReference(ImmutableHash.builder().name(info.getHash()).build(),
client.getTreeApi());
Review comment:
Won't this return the first reference? Is there a guarantee that the
commit log is in reverse order?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]