com.yandex.ydb.jdbc.impl.MappingResultSets Maven / Gradle / Ivy
package com.yandex.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 com.yandex.ydb.ValueProtos;
import com.yandex.ydb.ValueProtos.Type.PrimitiveTypeId;
import com.yandex.ydb.jdbc.exception.YdbRuntimeException;
import com.yandex.ydb.table.result.ResultSetReader;
import com.yandex.ydb.table.result.impl.ProtoValueReaders;
import com.yandex.ydb.table.values.PrimitiveType;
public class MappingResultSets {
private MappingResultSets() {
//
}
@SuppressWarnings("unchecked")
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;
}
static ResultSetReader readerFromList(List