Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
package io.oxia.client.api;

import io.oxia.client.api.exceptions.UnexpectedVersionIdException;
import io.oxia.client.api.options.DeleteOption;
import io.oxia.client.api.options.DeleteRangeOption;
import io.oxia.client.api.options.GetOption;
import io.oxia.client.api.options.GetSequenceUpdatesOption;
import io.oxia.client.api.options.ListOption;
import io.oxia.client.api.options.PutOption;
import io.oxia.client.api.options.RangeScanOption;
import java.io.Closeable;
import java.util.List;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
package io.oxia.client.api;

import io.oxia.client.api.exceptions.UnexpectedVersionIdException;
import io.oxia.client.api.options.DeleteOption;
import io.oxia.client.api.options.DeleteRangeOption;
import io.oxia.client.api.options.GetOption;
import io.oxia.client.api.options.GetSequenceUpdatesOption;
import io.oxia.client.api.options.ListOption;
import io.oxia.client.api.options.PutOption;
import io.oxia.client.api.options.RangeScanOption;
import java.io.Closeable;
import java.util.List;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.oxia.client.api;
package io.oxia.client.api.options;

import io.oxia.client.api.options.defs.OptionPartitionKey;
import io.oxia.client.api.options.defs.OptionVersionId;

/** Options for deleting a record. */
public sealed interface DeleteOption permits OptionPartitionKey, OptionVersionId {
public interface DeleteOption {

/**
* Conditional delete will only succeed if the record's version matches the supplied versionId.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.oxia.client.api;
package io.oxia.client.api.options;

import io.oxia.client.api.options.defs.OptionPartitionKey;

/** Options for deleting a range of records. */
public sealed interface DeleteRangeOption permits OptionPartitionKey {
public interface DeleteRangeOption {

/**
* PartitionKey overrides the partition routing with the specified `partitionKey` instead of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.oxia.client.api;
package io.oxia.client.api.options;

import io.oxia.client.api.options.defs.OptionComparisonType;
import io.oxia.client.api.options.defs.OptionIncludeValue;
import io.oxia.client.api.options.defs.OptionPartitionKey;
import io.oxia.client.api.options.defs.OptionSecondaryIndexName;

/** Options for getting a record. */
public sealed interface GetOption
permits OptionComparisonType, OptionIncludeValue, OptionPartitionKey, OptionSecondaryIndexName {
public interface GetOption {

/** ComparisonEqual sets the Get() operation to compare the stored key for equality. */
GetOption ComparisonEqual = new OptionComparisonType(OptionComparisonType.ComparisonType.Equal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.oxia.client.api;
package io.oxia.client.api.options;

import io.oxia.client.api.options.defs.OptionPartitionKey;

/** Options for getting sequence updates. */
public sealed interface GetSequenceUpdatesOption permits OptionPartitionKey {
public interface GetSequenceUpdatesOption {

/**
* PartitionKey overrides the partition routing with the specified `partitionKey` instead of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.oxia.client.api;
package io.oxia.client.api.options;

import io.oxia.client.api.options.defs.OptionPartitionKey;
import io.oxia.client.api.options.defs.OptionSecondaryIndexName;

/** Options for listing records. */
public sealed interface ListOption permits OptionPartitionKey, OptionSecondaryIndexName {
public interface ListOption {

/**
* PartitionKey overrides the partition routing with the specified `partitionKey` instead of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.oxia.client.api;
package io.oxia.client.api.options;

import io.oxia.client.api.SyncOxiaClient;
import io.oxia.client.api.options.defs.OptionEphemeral;
import io.oxia.client.api.options.defs.OptionPartitionKey;
import io.oxia.client.api.options.defs.OptionSecondaryIndex;
import io.oxia.client.api.options.defs.OptionSequenceKeysDeltas;
import io.oxia.client.api.options.defs.OptionVersionId;
import java.util.List;
import java.util.Set;

Expand All @@ -23,12 +29,7 @@
* operation in a data store. These options allow fine-grained control over conditions,
* partitioning, indexing, and key management associated with the operation.
*/
public sealed interface PutOption
permits OptionEphemeral,
OptionPartitionKey,
OptionSecondaryIndex,
OptionSequenceKeysDeltas,
OptionVersionId {
public interface PutOption {

/**
* Specifies that the operation should only proceed if the record does not already exist. This
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.oxia.client.api;
package io.oxia.client.api.options;

import io.oxia.client.api.options.defs.OptionPartitionKey;
import io.oxia.client.api.options.defs.OptionSecondaryIndexName;

/**
* RangeScanOption is a sealed interface that represents options for controlling range scan
* operations. It allows specifying additional preferences such as the partition key or secondary
* index name.
*/
public sealed interface RangeScanOption permits OptionPartitionKey, OptionSecondaryIndexName {
public interface RangeScanOption {

/**
* PartitionKey overrides the partition routing with the specified `partitionKey` instead of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.oxia.client.api;
package io.oxia.client.api.options.defs;

import io.oxia.client.api.options.GetOption;

/**
* @hidden
*/
public record OptionComparisonType(ComparisonType comparisonType) implements GetOption {

/**
* @hidden
*/
public enum ComparisonType {
Equal,
Floor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.oxia.client.api;
package io.oxia.client.api.options.defs;

import io.oxia.client.api.options.PutOption;

/**
* @hidden
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.oxia.client.api;
package io.oxia.client.api.options.defs;

import io.oxia.client.api.options.GetOption;

/**
* @hidden
*/
public record OptionIncludeValue(boolean includeValue) implements GetOption {}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.oxia.client.api;
package io.oxia.client.api.options.defs;

import io.oxia.client.api.options.DeleteOption;
import io.oxia.client.api.options.DeleteRangeOption;
import io.oxia.client.api.options.GetOption;
import io.oxia.client.api.options.GetSequenceUpdatesOption;
import io.oxia.client.api.options.ListOption;
import io.oxia.client.api.options.PutOption;
import io.oxia.client.api.options.RangeScanOption;

/**
* @hidden
*/
public record OptionPartitionKey(String partitionKey)
implements DeleteRangeOption,
GetOption,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.oxia.client.api;
package io.oxia.client.api.options.defs;

import io.oxia.client.api.options.PutOption;

/**
* @hidden
*/
public record OptionSecondaryIndex(String indexName, String secondaryKey) implements PutOption {}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.oxia.client.api;
package io.oxia.client.api.options.defs;

import io.oxia.client.api.options.GetOption;
import io.oxia.client.api.options.ListOption;
import io.oxia.client.api.options.RangeScanOption;

/**
* @hidden
*/
public record OptionSecondaryIndexName(String secondaryIndexName)
implements ListOption, RangeScanOption, GetOption {}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.oxia.client.api;
package io.oxia.client.api.options.defs;

import io.oxia.client.api.options.PutOption;
import java.util.List;

/**
* @hidden
*/
public record OptionSequenceKeysDeltas(List<Long> sequenceKeysDeltas) implements PutOption {
public OptionSequenceKeysDeltas {
if (sequenceKeysDeltas.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.oxia.client.api;
package io.oxia.client.api.options.defs;

import io.oxia.client.api.Version;
import io.oxia.client.api.options.DeleteOption;
import io.oxia.client.api.options.PutOption;

/**
* @hidden
*/
public sealed interface OptionVersionId extends PutOption, DeleteOption
permits OptionVersionId.OptionRecordDoesNotExist, OptionVersionId.OptionVersionIdEqual {

long versionId();

/**
* @hidden
*/
record OptionVersionIdEqual(long versionId) implements OptionVersionId {
public OptionVersionIdEqual {
if (versionId < 0) {
Expand All @@ -28,6 +38,9 @@ record OptionVersionIdEqual(long versionId) implements OptionVersionId {
}
}

/**
* @hidden
*/
record OptionRecordDoesNotExist() implements OptionVersionId {
@Override
public long versionId() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright © 2022-2025 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.
*/

/** The definitions for options that can be passed to the Oxia client operations. */
package io.oxia.client.api.options;
18 changes: 9 additions & 9 deletions client-it/src/test/java/io/oxia/client/it/OxiaClientIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
package io.oxia.client.it;

import static io.oxia.client.api.PutOption.IfRecordDoesNotExist;
import static io.oxia.client.api.PutOption.IfVersionIdEquals;
import static io.oxia.client.api.options.PutOption.IfRecordDoesNotExist;
import static io.oxia.client.api.options.PutOption.IfVersionIdEquals;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.concurrent.CompletableFuture.allOf;
import static java.util.function.Function.identity;
Expand All @@ -34,23 +34,23 @@
import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader;
import io.opentelemetry.semconv.ResourceAttributes;
import io.oxia.client.api.AsyncOxiaClient;
import io.oxia.client.api.DeleteOption;
import io.oxia.client.api.DeleteRangeOption;
import io.oxia.client.api.GetOption;
import io.oxia.client.api.GetResult;
import io.oxia.client.api.GetSequenceUpdatesOption;
import io.oxia.client.api.ListOption;
import io.oxia.client.api.Notification;
import io.oxia.client.api.Notification.KeyCreated;
import io.oxia.client.api.Notification.KeyDeleted;
import io.oxia.client.api.Notification.KeyModified;
import io.oxia.client.api.OxiaClientBuilder;
import io.oxia.client.api.PutOption;
import io.oxia.client.api.PutResult;
import io.oxia.client.api.RangeScanOption;
import io.oxia.client.api.SyncOxiaClient;
import io.oxia.client.api.exceptions.KeyAlreadyExistsException;
import io.oxia.client.api.exceptions.UnexpectedVersionIdException;
import io.oxia.client.api.options.DeleteOption;
import io.oxia.client.api.options.DeleteRangeOption;
import io.oxia.client.api.options.GetOption;
import io.oxia.client.api.options.GetSequenceUpdatesOption;
import io.oxia.client.api.options.ListOption;
import io.oxia.client.api.options.PutOption;
import io.oxia.client.api.options.RangeScanOption;
import io.oxia.testcontainers.OxiaContainer;
import java.util.ArrayList;
import java.util.Collections;
Expand Down
14 changes: 7 additions & 7 deletions client/src/main/java/io/oxia/client/AsyncOxiaClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
import io.oxia.client.api.AsyncOxiaClient;
import io.oxia.client.api.DeleteOption;
import io.oxia.client.api.DeleteRangeOption;
import io.oxia.client.api.GetOption;
import io.oxia.client.api.GetResult;
import io.oxia.client.api.GetSequenceUpdatesOption;
import io.oxia.client.api.ListOption;
import io.oxia.client.api.Notification;
import io.oxia.client.api.PutOption;
import io.oxia.client.api.PutResult;
import io.oxia.client.api.RangeScanConsumer;
import io.oxia.client.api.RangeScanOption;
import io.oxia.client.api.options.DeleteOption;
import io.oxia.client.api.options.DeleteRangeOption;
import io.oxia.client.api.options.GetOption;
import io.oxia.client.api.options.GetSequenceUpdatesOption;
import io.oxia.client.api.options.ListOption;
import io.oxia.client.api.options.PutOption;
import io.oxia.client.api.options.RangeScanOption;
import io.oxia.client.batch.BatchManager;
import io.oxia.client.batch.Operation.ReadOperation.GetOperation;
import io.oxia.client.batch.Operation.WriteOperation.DeleteOperation;
Expand Down
Loading