io.tarantool.driver.core.metadata.SpacesTarantoolMetadataContainer 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.metadata;
import io.tarantool.driver.api.TarantoolResult;
import io.tarantool.driver.api.metadata.TarantoolIndexMetadata;
import io.tarantool.driver.api.metadata.TarantoolMetadataContainer;
import io.tarantool.driver.api.metadata.TarantoolSpaceMetadata;
import java.util.HashMap;
import java.util.Map;
/**
* Contains spaces and indexes metadata information retrieved from the system spaces
*
* @author Alexey Kuzin
*/
public class SpacesTarantoolMetadataContainer implements TarantoolMetadataContainer {
private final Map spaceMetadataByName = new HashMap<>();
private final Map spaceMetadataById = new HashMap<>();
private final Map> indexMetadataBySpaceName = new HashMap<>();
public SpacesTarantoolMetadataContainer(
TarantoolResult spacesCollection,
TarantoolResult indexesCollection) {
spacesCollection.forEach(meta -> {
spaceMetadataByName.put(meta.getSpaceName(), meta);
spaceMetadataById.put(meta.getSpaceId(), meta);
});
indexesCollection.forEach(meta -> {
String spaceName = spaceMetadataById.get(meta.getSpaceId()).getSpaceName();
indexMetadataBySpaceName.putIfAbsent(spaceName, new HashMap<>());
indexMetadataBySpaceName.get(spaceName).put(meta.getIndexName(), meta);
});
}
@Override
public Map getSpaceMetadataByName() {
return spaceMetadataByName;
}
@Override
public Map> getIndexMetadataBySpaceName() {
return indexMetadataBySpaceName;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy