Skip to content

Commit

Permalink
Add floor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zymap committed May 23, 2024
1 parent 9a3dc7c commit 1d4801f
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import static io.streamnative.oxia.client.api.PutOption.IfRecordDoesNotExist;
import static io.streamnative.oxia.client.api.PutOption.IfVersionIdEquals;
import static io.streamnative.oxia.client.api.PutOption.PartitionKey;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.concurrent.CompletableFuture.allOf;
import static java.util.function.Function.identity;
Expand Down Expand Up @@ -229,6 +230,32 @@ void test() throws Exception {
.isEqualTo(24);
}

@Test
public void getFloorValue() throws Exception {

@Cleanup
SyncOxiaClient client = OxiaClientBuilder.create(oxia.getServiceAddress()).syncClient();

GetResult gr = client.get("a", Set.of(GetOption.ComparisonFloor));
assertThat(gr).isNull();

PutResult pr = client.put("a", "0".getBytes(), Set.of(PartitionKey("a"), PutOption.SequenceKeysDeltas(List.of(1L))));
System.out.println(pr.key());
gr = client.get("a", Set.of(GetOption.PartitionKey("a"), GetOption.ComparisonFloor));

pr = client.put("a", "0".getBytes(), Set.of(PartitionKey("a"), PutOption.SequenceKeysDeltas(List.of(1L))));
System.out.println(pr.key());


gr = client.get(pr.key(), Set.of(GetOption.PartitionKey("a"), GetOption.ComparisonFloor));
System.out.println(gr.getKey());

gr = client.get("a-00000000000000000000", Set.of(GetOption.PartitionKey("a"), GetOption.ComparisonFloor));
System.out.println("final key");
System.out.println(gr.getKey());

}

@Test
public void testGetFloorCeilingWithPartitionKey() throws Exception {
@Cleanup
Expand Down Expand Up @@ -268,6 +295,15 @@ public void testGetFloorCeilingWithPartitionKey() throws Exception {
} else {
System.out.println("ComparisionHigher null");
}

client.put("a", "0".getBytes(), Set.of(PutOption.PartitionKey("a")));
gr = client.get("a", Set.of(GetOption.PartitionKey("a"), GetOption.ComparisonFloor));
if (gr != null) {
System.out.println(gr.getKey());
} else {
System.out.println("ComparisionFloor null");
}

}

@Test
Expand Down

0 comments on commit 1d4801f

Please sign in to comment.