Skip to content

org.apache.iceberg.util.SnapshotUtil#snapshotIdAsOfTime could make use of binary search if org.apache.iceberg.Table#history is guaranteed to be ordered #3891

Closed
@findinpath

Description

@findinpath

Currently the SnapshotUtil is going over all the history entries of a table (with O(n) complexity).

    Long snapshotId = null;
    for (HistoryEntry logEntry : table.history()) {
      if (logEntry.timestampMillis() <= timestampMillis) {
        snapshotId = logEntry.snapshotId();
      }
    }

In case that the org.apache.iceberg.Table#history would be guaranteed to be ordered, a binary search algorithm could be used instead (O(log n) complexity).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions