-
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.
[Kernel] Add monotonic inCommitTimestamp and read support for inCommi…
…tTimestamp (#3282) ## Description Add read support for inCommitTimestamp and ensure the increasing monotonicity of inCommitTimestamp assuming that there are no conflicts to prepare for the complete inCommitTimestamp support with conflict resolution in Kernel. ## How was this patch tested? Add unit tests to verify that the read of inCommitTimestamp is correct and inCommitTimestamp is monotonic. ## Does this PR introduce _any_ user-facing changes? Yes, user can enable monotonic inCommitTimestamp assuming that there are no conflicts by enabling its property.
- Loading branch information
1 parent
c8e87b4
commit 87f0685
Showing
9 changed files
with
372 additions
and
33 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
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
24 changes: 24 additions & 0 deletions
24
kernel/kernel-api/src/main/java/io/delta/kernel/internal/util/Clock.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 (2023) 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.util; | ||
|
||
/** | ||
* An interface to represent clocks, so that they can be mocked out in unit tests. | ||
*/ | ||
public interface Clock { | ||
/** @return Current system time, in ms. */ | ||
long getTimeMillis(); | ||
} |
39 changes: 39 additions & 0 deletions
39
kernel/kernel-api/src/main/java/io/delta/kernel/internal/util/ManualClock.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,39 @@ | ||
/* | ||
* Copyright (2023) 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.util; | ||
|
||
/** | ||
* A clock whose time can be manually set and modified. | ||
*/ | ||
public class ManualClock implements Clock { | ||
private long timeMillis; | ||
public ManualClock(long timeMillis) { | ||
this.timeMillis = timeMillis; | ||
} | ||
|
||
/** | ||
* @param timeToSet new time (in milliseconds) that the clock should represent | ||
*/ | ||
public synchronized void setTime(long timeToSet) { | ||
this.timeMillis = timeToSet; | ||
this.notifyAll(); | ||
} | ||
|
||
@Override | ||
public long getTimeMillis() { | ||
return timeMillis; | ||
} | ||
} |
Oops, something went wrong.