-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e64ae0b
commit ceb5a56
Showing
11 changed files
with
805 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
kernel/kernel-api/src/main/java/io/delta/kernel/internal/metrics/SnapshotContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright (2024) The Delta Lake Project Authors. | ||
* | ||
* Licensed 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 io.delta.kernel.internal.metrics; | ||
|
||
import io.delta.kernel.metrics.SnapshotReport; | ||
import java.util.Optional; | ||
|
||
/** Stores the context for a given Snapshot query. Used to generate a {@link SnapshotReport} */ | ||
public class SnapshotContext { | ||
|
||
public static SnapshotContext forLatestSnapshot(String tablePath) { | ||
return new SnapshotContext(tablePath, Optional.empty(), Optional.empty()); | ||
} | ||
|
||
public static SnapshotContext forVersionSnapshot(String tablePath, long version) { | ||
return new SnapshotContext(tablePath, Optional.of(version), Optional.empty()); | ||
} | ||
|
||
public static SnapshotContext forTimestampSnapshot(String tablePath, long timestamp) { | ||
return new SnapshotContext(tablePath, Optional.empty(), Optional.of(timestamp)); | ||
} | ||
|
||
private Optional<Long> version; | ||
private final SnapshotMetrics snapshotMetrics = new SnapshotMetrics(); | ||
private final String tablePath; | ||
private final Optional<Long> providedTimestamp; | ||
|
||
private SnapshotContext( | ||
String tablePath, Optional<Long> version, Optional<Long> providedTimestamp) { | ||
this.tablePath = tablePath; | ||
this.version = version; | ||
this.providedTimestamp = providedTimestamp; | ||
} | ||
|
||
public Optional<Long> getVersion() { | ||
return version; | ||
} | ||
|
||
public SnapshotMetrics getSnapshotMetrics() { | ||
return snapshotMetrics; | ||
} | ||
|
||
public String getTablePath() { | ||
return tablePath; | ||
} | ||
|
||
public Optional<Long> getProvidedTimestamp() { | ||
return providedTimestamp; | ||
} | ||
|
||
public void setVersion(long updatedVersion) { | ||
version = Optional.of(updatedVersion); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
kernel/kernel-api/src/main/java/io/delta/kernel/internal/metrics/SnapshotMetrics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (2024) The Delta Lake Project Authors. | ||
* | ||
* Licensed 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 io.delta.kernel.internal.metrics; | ||
|
||
/** Stores the metrics for an ongoing snapshot creation */ | ||
public class SnapshotMetrics { | ||
|
||
public final Timer timestampToVersionResolutionDuration = new Timer(); | ||
|
||
public final Timer loadProtocolAndMetadataDuration = new Timer(); | ||
} |
84 changes: 84 additions & 0 deletions
84
kernel/kernel-api/src/main/java/io/delta/kernel/internal/metrics/SnapshotReportImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright (2024) The Delta Lake Project Authors. | ||
* | ||
* Licensed 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 io.delta.kernel.internal.metrics; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import io.delta.kernel.metrics.SnapshotMetricsResult; | ||
import io.delta.kernel.metrics.SnapshotReport; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
/** A basic POJO implementation of {@link SnapshotReport} for creating them */ | ||
public class SnapshotReportImpl implements SnapshotReport { | ||
|
||
private final String tablePath; | ||
private final Optional<Long> version; | ||
private final Optional<Long> providedTimestamp; | ||
private final UUID reportUUID; | ||
private final SnapshotMetricsResult snapshotMetrics; | ||
private final Optional<Exception> exception; | ||
|
||
public SnapshotReportImpl( | ||
String tablePath, | ||
Optional<Long> version, | ||
Optional<Long> providedTimestamp, | ||
SnapshotMetrics snapshotMetrics, | ||
Optional<Exception> exception) { | ||
this.tablePath = requireNonNull(tablePath); | ||
this.version = requireNonNull(version); | ||
this.providedTimestamp = requireNonNull(providedTimestamp); | ||
this.snapshotMetrics = | ||
SnapshotMetricsResult.fromSnapshotMetrics(requireNonNull(snapshotMetrics)); | ||
this.exception = requireNonNull(exception); | ||
this.reportUUID = UUID.randomUUID(); | ||
} | ||
|
||
@Override | ||
public String tablePath() { | ||
return tablePath; | ||
} | ||
|
||
@Override | ||
public String operationType() { | ||
return OPERATION_TYPE; | ||
} | ||
|
||
@Override | ||
public Optional<Exception> exception() { | ||
return exception; | ||
} | ||
|
||
@Override | ||
public UUID reportUUID() { | ||
return reportUUID; | ||
} | ||
|
||
@Override | ||
public Optional<Long> version() { | ||
return version; | ||
} | ||
|
||
@Override | ||
public Optional<Long> providedTimestamp() { | ||
return providedTimestamp; | ||
} | ||
|
||
@Override | ||
public SnapshotMetricsResult snapshotMetrics() { | ||
return snapshotMetrics; | ||
} | ||
} |
Oops, something went wrong.