org.tarantool.schema.TarantoolIndexMeta Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of connector Show documentation
Show all versions of connector Show documentation
Tarantool client for java
The newest version!
package org.tarantool.schema;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Keeps a space index metadata.
*/
public class TarantoolIndexMeta {
public static final int VINDEX_IID_FIELD_NUMBER = 1;
public static final int VINDEX_NAME_FIELD_NUMBER = 2;
public static final int VINDEX_TYPE_FIELD_NUMBER = 3;
public static final int VINDEX_OPTIONS_FIELD_NUMBER = 4;
public static final int VINDEX_PARTS_FIELD_NUMBER = 5;
public static final int VINDEX_PART_FIELD = 0;
public static final int VINDEX_PART_TYPE = 1;
private final int id;
private final String name;
private final String type;
private final IndexOptions options;
private final List parts;
public TarantoolIndexMeta(int id,
String name,
String type,
IndexOptions options,
List parts) {
this.id = id;
this.name = name;
this.type = type;
this.options = options;
this.parts = parts;
}
public static TarantoolIndexMeta fromTuple(List> tuple) {
Map optionsMap = (Map) tuple.get(VINDEX_OPTIONS_FIELD_NUMBER);
List parts = Collections.emptyList();
List> partsTuple = (List>) tuple.get(VINDEX_PARTS_FIELD_NUMBER);
if (!partsTuple.isEmpty()) {
// simplified index parts as an array
// (when the parts don't use collation and is_nullable options)
if (partsTuple.get(0) instanceof List) {
parts = ((List>) partsTuple)
.stream()
.map(part -> new IndexPart(
(Integer) part.get(VINDEX_PART_FIELD),
(String) part.get(VINDEX_PART_TYPE)
)
)
.collect(Collectors.toList());
} else if (partsTuple.get(0) instanceof Map) {
parts = ((List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy