Skip to content

Commit

Permalink
Update TarantoolTupleUsage
Browse files Browse the repository at this point in the history
Update TarantoolTupleUsage according to our new documentation policy

Closes #354
  • Loading branch information
iDneprov committed Feb 10, 2023
1 parent 06bcff0 commit c9c9859
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions docs/TarantoolTupleUsage.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,8 @@
# TarantoolTuple usage

You can use TarantoolTuple for creating tuple which can be sent to the Tarantool instance
or can be returned from default "crud" functions.
or can be returned from default [tarantool/crud](https://github.com/tarantool/crud) or box methods.
You can create TarantoolTuple with this factory `TarantoolTupleFactory`.
See an example below:

```java
// Create a mapper factory
DefaultMessagePackMapperFactory mapperFactory = DefaultMessagePackMapperFactory.getInstance();
// Create a tuple factory
TarantoolTupleFactory tupleFactory = new DefaultTarantoolTupleFactory(mapperFactory.defaultComplexTypesMapper());

// Create a tuple from listed values: [1,2.0,'3',4]
TarantoolTuple tarantoolTuple = tupleFactory.create(1, 2.0, "3", new BigDecimal("4"));

Optional<?> object = tarantoolTuple.getObject(0);
Optional<Integer> integer = tarantoolTuple.getObject(0, Integer.class);

// Returned value will have 'double' type (it is used by default).
Optional<?> doubleValue = tarantoolTuple.getObject(1);
// To get 'float' value we must explicitly define the target type.
Optional<?> floatValue = tarantoolTuple.getObject(1, Float.class);

Optional<?> stringValue = tarantoolTuple.getObject(2);

Optional<?> bigDecimalValue = tarantoolTuple.getObject(3);
```
https://github.com/tarantool/cartridge-java/blob/3f14c5dce4fa86f09061585cadd5f30bc70ff8cf/src/test/java/io/tarantool/driver/integration/ProxyTarantoolClientExampleIT.java#L115-L162

0 comments on commit c9c9859

Please sign in to comment.