-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added get() with floor/ceiling/lower/higher comparison (#159)
* Added get() with floor/ceiling/lower/higher comparison * Fixed test
- Loading branch information
Showing
20 changed files
with
489 additions
and
29 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
47 changes: 47 additions & 0 deletions
47
client-api/src/main/java/io/streamnative/oxia/client/api/GetOption.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,47 @@ | ||
/* | ||
* Copyright © 2022-2024 StreamNative Inc. | ||
* | ||
* 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.streamnative.oxia.client.api; | ||
|
||
public sealed interface GetOption permits OptionComparisonType { | ||
|
||
/** ComparisonEqual sets the Get() operation to compare the stored key for equality. */ | ||
GetOption ComparisonEqual = new OptionComparisonType(OptionComparisonType.ComparisonType.Equal); | ||
|
||
/** | ||
* ComparisonFloor option will make the get operation to search for the record whose key is the | ||
* highest key <= to the supplied key. | ||
*/ | ||
GetOption ComparisonFloor = new OptionComparisonType(OptionComparisonType.ComparisonType.Floor); | ||
|
||
/** | ||
* ComparisonCeiling option will make the get operation to search for the record whose key is the | ||
* lowest key >= to the supplied key. | ||
*/ | ||
GetOption ComparisonCeiling = | ||
new OptionComparisonType(OptionComparisonType.ComparisonType.Ceiling); | ||
|
||
/** | ||
* ComparisonLower option will make the get operation to search for the record whose key is | ||
* strictly < to the supplied key. | ||
*/ | ||
GetOption ComparisonLower = new OptionComparisonType(OptionComparisonType.ComparisonType.Lower); | ||
|
||
/** | ||
* ComparisonHigher option will make the get operation to search for the record whose key is | ||
* strictly > to the supplied key. | ||
*/ | ||
GetOption ComparisonHigher = new OptionComparisonType(OptionComparisonType.ComparisonType.Higher); | ||
} |
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
31 changes: 31 additions & 0 deletions
31
client-api/src/main/java/io/streamnative/oxia/client/api/OptionComparisonType.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,31 @@ | ||
/* | ||
* Copyright © 2022-2024 StreamNative Inc. | ||
* | ||
* 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.streamnative.oxia.client.api; | ||
|
||
public record OptionComparisonType(ComparisonType comparisonType) implements GetOption { | ||
|
||
public enum ComparisonType { | ||
Equal, | ||
Floor, | ||
Ceiling, | ||
Lower, | ||
Higher, | ||
} | ||
|
||
public ComparisonType getComparisonType() { | ||
return comparisonType; | ||
} | ||
} |
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
Oops, something went wrong.