io.tarantool.driver.core.TarantoolTupleResultImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cartridge-driver Show documentation
Show all versions of cartridge-driver Show documentation
Tarantool Cartridge driver for Tarantool versions 1.10+ based on Netty framework
package io.tarantool.driver.core;
import io.tarantool.driver.api.metadata.TarantoolSpaceMetadata;
import io.tarantool.driver.api.tuple.TarantoolTuple;
import io.tarantool.driver.exceptions.TarantoolTupleConversionException;
import io.tarantool.driver.mappers.converters.value.ArrayValueToTarantoolTupleConverter;
import org.msgpack.core.MessageTypeCastException;
import org.msgpack.value.ArrayValue;
import org.msgpack.value.Value;
import java.util.stream.Collectors;
/**
* Specific TarantoolResult implementation especially for TarantoolTuple input
*
* @author Artyom Dubinin
*/
public class TarantoolTupleResultImpl extends TarantoolResultImpl {
public TarantoolTupleResultImpl(
ArrayValue rawTuples, TarantoolSpaceMetadata metadata,
ArrayValueToTarantoolTupleConverter tupleConverter) {
setItems(rawTuples, metadata, tupleConverter);
}
public TarantoolTupleResultImpl(Value value, ArrayValueToTarantoolTupleConverter tupleConverter) {
setItems(value.asArrayValue(), tupleConverter);
}
private void setItems(
ArrayValue tupleArray, TarantoolSpaceMetadata responseMetadata,
ArrayValueToTarantoolTupleConverter tupleConverter) {
this.tuples = tupleArray.list().stream()
.map(v -> {
try {
return tupleConverter.fromValue(v.asArrayValue(), responseMetadata);
} catch (MessageTypeCastException e) {
throw new TarantoolTupleConversionException(v, e);
}
})
.collect(Collectors.toList());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy