Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [Unreleased]
- Remove config request timeout as default parameter in crud client
- Add details for the case of space metadata fetching failure ([#200](https://github.com/tarantool/cartridge-java/issues/200))
- Add metadataFormatIsEmpty in TarantoolTuple
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to change this entry too

- Close public access to TarantoolResult*Impl ([#326](https://github.com/tarantool/cartridge-java/issues/326))
- Split retrying into more detailed modules ([#341](https://github.com/tarantool/cartridge-java/issues/341))
- Add deep copy instead of shallow copy in default message pack mapper ([#166](https://github.com/tarantool/cartridge-java/issues/166))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
* @author Alexey Kuzin
*/
public interface TarantoolTuple extends Iterable<TarantoolField>, Packable {
/**
* Check whether this tuple includes information about space format
*
* @return true if we can obtain the tuple fields by names
*/
boolean hasMetadata();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are going to use different types (TarantoolTuple and TarantoolTupleWithMetadata). do we really need this method then? It is a public API, we need to carefully think before changing it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll break compatibility anyway. So I don't see a big problem to have hasMetadata now and then remove it. I want to sync springdata and cartridge-java as soon as possible, because we've already been being late


/**
* Get a tuple field by its position
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ public TarantoolTupleImpl(ArrayValue value, MessagePackMapper mapper, TarantoolS
}
}

@Override
public boolean hasMetadata() {
return spaceMetadata == null || spaceMetadata.getSpaceFormatMetadata() == null ||
spaceMetadata.getSpaceFormatMetadata().isEmpty();
}

@Override
public Optional<TarantoolField> getField(int fieldPosition) {
Assert.state(fieldPosition >= 0, "Field position starts with 0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import io.tarantool.driver.mappers.TarantoolTupleResultMapperFactory;
import io.tarantool.driver.mappers.TarantoolTupleResultMapperFactoryImpl;
import io.tarantool.driver.mappers.factories.DefaultMessagePackMapperFactory;
import io.tarantool.driver.mappers.factories.ResultMapperFactoryFactoryImpl;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
Expand Down Expand Up @@ -404,7 +404,19 @@ public void callForTarantoolResultTest() throws Exception {
).get();

assertTrue(result.size() >= 3);
assertEquals(1605, result.get(0).getInteger("year"));
TarantoolTuple tuple = result.get(0);
assertFalse(tuple.hasMetadata());
assertEquals(1605, tuple.getInteger("year"));

result = client.call(
"user_function_complex_query",
Collections.singletonList(1000),
defaultMapper,
factory.withSingleValueArrayToTarantoolTupleResultMapper(defaultMapper, null)
).get();
assertTrue(result.size() >= 3);
tuple = result.get(0);
assertTrue(tuple.hasMetadata());
}

@Test
Expand Down