io.tarantool.driver.mappers.TarantoolTupleResultMapperFactory Maven / Gradle / Ivy
Show all versions of cartridge-driver Show documentation
package io.tarantool.driver.mappers;
import io.tarantool.driver.api.MultiValueCallResult;
import io.tarantool.driver.api.SingleValueCallResult;
import io.tarantool.driver.api.TarantoolResult;
import io.tarantool.driver.api.metadata.TarantoolSpaceMetadata;
import io.tarantool.driver.api.tuple.TarantoolTuple;
/**
* Provides factory that creates result mappers for parsing {@code TarantoolResult} from various
* structures
*
* @author Artyom Dubinin
*/
public interface TarantoolTupleResultMapperFactory {
/**
* Mapper parses result from a list of tuples.
* Use this mapper for handling containers with {@link TarantoolTuple} inside.
* The IProto method results by default contain lists of tuples.
* This mapper can be used at the inner level by other mapper factories that are handling higher-level containers.
*
* input: array of tuples with MessagePack values inside ([t1, t2, ...])
*
* mapper result: {@code TarantoolResult}
*
* Returned TarantoolResult doesn't store metadata, and you can't get field by field name
*
* @param messagePackMapper MessagePack-to-entity converter for tuples
* @return mapper that parses list of arrays to {@code TarantoolResult}
*/
TarantoolResultMapper withArrayValueToTarantoolTupleResultConverter(
MessagePackMapper messagePackMapper);
/**
* Mapper parses result from a list of tuples.
* Use this mapper for handling containers with {@link TarantoolTuple} inside.
* The IProto method results by default contain lists of tuples.
* This mapper can be used at the inner level by other mapper factories that are handling higher-level containers.
*
* input: array of tuples with MessagePack values inside ([t1, t2, ...])
*
* mapper result: {@code TarantoolResult}
*
* For example, it can be used to parse result from IPROTO_SELECT
*
* @param messagePackMapper MessagePack-to-entity converter for tuples
* @param spaceMetadata space metadata to parse values by their names
* @return mapper that parses list of arrays to {@code TarantoolResult}
*/
TarantoolResultMapper withArrayValueToTarantoolTupleResultConverter(
MessagePackMapper messagePackMapper, TarantoolSpaceMetadata spaceMetadata);
/**
* Mapper parses result from a map with list of tuples and metadata.
* Use this mapper for handling containers with {@link TarantoolTuple} inside.
* The crud method results by default contain map with list of tuples and metadata.
* This mapper can be used at the inner level by other mapper factories that are handling higher-level containers.
*
* input: map with metadata and array of tuples with MessagePack values inside ([t1, t2, ...])
*
* mapper result: {@code TarantoolResult}
*
* Returned TarantoolResult doesn't store metadata, and you can't get field by field name
*
* @param messagePackMapper MessagePack-to-entity converter for tuples
* @return mapper that parses map to {@code TarantoolResult}
*/
TarantoolResultMapper withRowsMetadataToTarantoolTupleResultConverter(
MessagePackMapper messagePackMapper);
/**
* Mapper parses result from a map with list of tuples and metadata.
* Use this mapper for handling containers with {@link TarantoolTuple} inside.
* The crud method results by default contain map with list of tuples and metadata.
* This mapper can be used at the inner level by other mapper factories that are handling higher-level containers.
*
* input: map with metadata and array of tuples with MessagePack values inside ([t1, t2, ...])
*
* mapper result: {@code TarantoolResult}
*
*
* @param messagePackMapper MessagePack-to-entity converter for tuples
* @param spaceMetadata space metadata to parse values by their names
* @return mapper that parses map to {@code TarantoolResult}
*/
TarantoolResultMapper withRowsMetadataToTarantoolTupleResultConverter(
MessagePackMapper messagePackMapper, TarantoolSpaceMetadata spaceMetadata);
/**
* Mapper for single the stored Lua function call result in the form return result, err
* with a list of tuples as a result.
* For example, this form of the result is used for some return from lua function like box.space.select
*
* input: [x, y, ...], MessagePack array from a Lua function multi-return response
*
* where x
is a data structure with an array of tuples inside ([t1, t2, ...]) and y
* can be interpreted as an error structure if it is not empty and there are no more arguments after
* y
`
*
* mapper result: converted value of x
to {@code TarantoolResult}
*
* Mapper result and the inner contents depend on the parameters or the passed converters.
*
* @param messagePackMapper MessagePack-to-entity converter for tuples
* @param spaceMetadata space metadata to parse values by their names
* @return default mapper for single value call result with a list of tuples
*/
CallResultMapper, SingleValueCallResult>>
withSingleValueArrayToTarantoolTupleResultMapper(
MessagePackMapper messagePackMapper, TarantoolSpaceMetadata spaceMetadata);
/**
* Mapper for single the stored Lua function call result in the form return result, err
* with a list of tuples as a result.
* For example, this form of the result is used for some return from lua function like crud.select
*
* input: [x, y, ...], MessagePack array from a Lua function multi-return response
*
* where x
map with metadata and array of tuples with MessagePack values inside ([t1, t2, ...])
*
* mapper result: converted value of x
to {@code TarantoolResult}
*
*
* @param messagePackMapper MessagePack-to-entity converter for tuples
* @param spaceMetadata space metadata to parse values by their names
* @return mapper for single value call result with a list of tuples
*/
CallResultMapper, SingleValueCallResult>>
withSingleValueRowsMetadataToTarantoolTupleResultMapper(
MessagePackMapper messagePackMapper, TarantoolSpaceMetadata spaceMetadata);
/**
* Mapper for the stored Lua function call result, interpreted in a way that each returned item is a tuple.
* Use this factory for handling proxy function call results which return tuples as a multi-return result.
*
* input: [x, y, z, ...], MessagePack array from a Lua function multi-return response
*
* where x, y, z
are some MessagePack values, each one representing a Tarantool tuple
*
* mapper result: {@code TarantoolResult} converted from [x, y, z, ...]
*
* Mapper result and its inner contents depend on the parameters or the passed converters.
*
* @param messagePackMapper MessagePack-to-entity converter for tuples
* @param spaceMetadata space metadata to parse values by their names
* @return mapper for multi value call result as a list of tuples
*/
CallResultMapper<
TarantoolResult,
MultiValueCallResult>>
withMultiValueArrayToTarantoolTupleResultMapper(
MessagePackMapper messagePackMapper, TarantoolSpaceMetadata spaceMetadata);
}