Skip to content

Commit

Permalink
Add support for "force_map_call" option
Browse files Browse the repository at this point in the history
Closes #459
  • Loading branch information
nickkkccc committed Jan 22, 2024
1 parent 14e051a commit 3d6944e
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.tarantool.driver.api.space.options.crud.OperationWithBatchSizeOptions;
import io.tarantool.driver.api.space.options.crud.OperationWithBucketIdOptions;
import io.tarantool.driver.api.space.options.crud.OperationWithFieldsOptions;
import io.tarantool.driver.api.space.options.crud.OperationWithForceMapCallOptions;
import io.tarantool.driver.api.space.options.crud.OperationWithModeOptions;
import io.tarantool.driver.api.space.options.crud.OperationWithTimeoutOptions;

Expand All @@ -16,5 +17,5 @@
*/
public interface SelectOptions<T extends SelectOptions<T>>
extends OperationWithBucketIdOptions<T>, OperationWithTimeoutOptions<T>, OperationWithFieldsOptions<T>,
OperationWithModeOptions<T>, OperationWithBatchSizeOptions<T> {
OperationWithModeOptions<T>, OperationWithBatchSizeOptions<T>, OperationWithForceMapCallOptions<T> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.tarantool.driver.api.space.options.crud;

import java.util.Optional;

import io.tarantool.driver.api.space.options.Options;
import io.tarantool.driver.api.space.options.Self;
import io.tarantool.driver.api.space.options.crud.enums.ProxyOption;

/**
* Base interface for all operation options that may have a configurable "force_map_call" option.
*
* @author Belonogov Nikolay
*/
public interface OperationWithForceMapCallOptions<T extends OperationWithForceMapCallOptions<T>>
extends Options, Self<T> {

/**
* Sets "force_map_call" option to true. if true then the map call is performed without any optimizations even,
* default value is false.
*
* @return forceMapCall option value.
*/
default T forceMapCall() {
addOption(ProxyOption.FORCE_MAP_CALL, true);
return self();
}

/**
* @return "force_map_call" option value.
*/
default Optional<Boolean> getForceMapCall() {
return getOption(ProxyOption.FORCE_MAP_CALL, Boolean.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public enum ProxyOption {

AFTER("after"),

FIRST("first");
FIRST("first"),

FORCE_MAP_CALL("force_map_call");

private final String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.tarantool.driver.api.space.options.SelectOptions;
import io.tarantool.driver.api.space.TarantoolSpaceOperations;
import io.tarantool.driver.api.space.options.ProxySelectOptions;
import io.tarantool.driver.api.space.options.crud.enums.ProxyOption;
import io.tarantool.driver.api.tuple.DefaultTarantoolTupleFactory;
import io.tarantool.driver.api.tuple.TarantoolTuple;
import io.tarantool.driver.api.tuple.TarantoolTupleFactory;
Expand All @@ -28,6 +29,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* @author Artyom Dubinin
Expand Down Expand Up @@ -174,4 +176,19 @@ public void withModeTest() throws ExecutionException, InterruptedException {
crudSelectOpts = client.eval("return crud_select_opts").get();
assertEquals(Mode.WRITE.value(), ((HashMap<?, ?>) crudSelectOpts.get(0)).get("mode"));
}

@Test
public void withForceMapCallTest() {
TarantoolSpaceOperations<TarantoolTuple, TarantoolResult<TarantoolTuple>> profileSpace =
client.space(TEST_SPACE_NAME);

SelectOptions<ProxySelectOptions> options = ProxySelectOptions.create().forceMapCall();

assertTrue(options.getForceMapCall().isPresent());
assertTrue(options.getForceMapCall().get());

profileSpace.select(Conditions.any(), options).join();
List<?> crudSelectOpts = client.eval("return crud_select_opts").join();
assertEquals(true, ((HashMap<?, ?>) crudSelectOpts.get(0)).get(ProxyOption.FORCE_MAP_CALL.toString()));
}
}

0 comments on commit 3d6944e

Please sign in to comment.