tech.ydb.jdbc.common.MappingResultSets Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ydb-jdbc-driver Show documentation
Show all versions of ydb-jdbc-driver Show documentation
JDBC Driver over YDB Java SDK
package tech.ydb.jdbc.impl;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.google.common.base.Preconditions;
import com.google.protobuf.NullValue;
import tech.ydb.jdbc.exception.YdbRuntimeException;
import tech.ydb.proto.ValueProtos;
import tech.ydb.proto.ValueProtos.Type.PrimitiveTypeId;
import tech.ydb.table.result.ResultSetReader;
import tech.ydb.table.result.impl.ProtoValueReaders;
public class MappingResultSets {
private MappingResultSets() {
//
}
@SuppressWarnings("unchecked")
public static LinkedHashMap stableMap(K key, Object value, Object... kv) {
Preconditions.checkArgument((kv.length & 1) == 0, "KeyValue list must be even");
LinkedHashMap map = new LinkedHashMap<>((kv.length / 2) + 1);
map.put(key, value);
for (int i = 0; i < kv.length; i += 2) {
map.put((K) kv[i], kv[i + 1]);
}
return map;
}
public static ResultSetReader readerFromList(List