Search in sources :

Example 1 with BTreeIndex

use of io.hetu.core.plugin.heuristicindex.index.btree.BTreeIndex in project hetu-core by openlookeng.

the class HeuristicIndexClient method readPartitionIndex.

@Override
public List<IndexMetadata> readPartitionIndex(String path) throws IOException {
    Path indexKeyPath = Paths.get(path);
    Path absolutePath = Paths.get(this.root.toString(), path);
    String tableName = indexKeyPath.subpath(0, 1).toString();
    String column = indexKeyPath.subpath(1, 2).toString();
    List<IndexMetadata> result = new ArrayList<>();
    if (fs.exists(absolutePath)) {
        List<Path> paths = fs.walk(absolutePath).filter(p -> !fs.isDirectory(p)).collect(Collectors.toList());
        for (Path filePath : paths) {
            BTreeIndex index = new BTreeIndex();
            InputStream inputStream = fs.newInputStream(filePath);
            index.deserialize(inputStream);
            IndexMetadata indexMetadata = new IndexMetadata(index, tableName, new String[] { column }, root.toString(), filePath.toString(), 0L, 0L);
            result.add(indexMetadata);
        }
        return result;
    } else {
        LOG.debug("File path doesn't exists" + absolutePath);
        return ImmutableList.of();
    }
}
Also used : Path(java.nio.file.Path) HetuMetastore(io.prestosql.spi.metastore.HetuMetastore) Logger(io.airlift.log.Logger) HetuFileSystemClient(io.prestosql.spi.filesystem.HetuFileSystemClient) ArchiveEntry(org.apache.commons.compress.archivers.ArchiveEntry) TarArchiveInputStream(org.apache.commons.compress.archivers.tar.TarArchiveInputStream) IndexConstants(io.hetu.core.heuristicindex.util.IndexConstants) FileBasedLock(io.prestosql.spi.filesystem.FileBasedLock) ArrayList(java.util.ArrayList) BTreeIndex(io.hetu.core.plugin.heuristicindex.index.btree.BTreeIndex) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) ImmutableList(com.google.common.collect.ImmutableList) CloseShieldInputStream(org.apache.commons.io.input.CloseShieldInputStream) IndexClient(io.prestosql.spi.heuristicindex.IndexClient) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) LinkedList(java.util.LinkedList) IndexRecord(io.prestosql.spi.heuristicindex.IndexRecord) Path(java.nio.file.Path) ImmutableMap(com.google.common.collect.ImmutableMap) FileSystemException(java.nio.file.FileSystemException) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) Pair(io.prestosql.spi.heuristicindex.Pair) UncheckedIOException(java.io.UncheckedIOException) AtomicLong(java.util.concurrent.atomic.AtomicLong) List(java.util.List) Lock(java.util.concurrent.locks.Lock) Stream(java.util.stream.Stream) Paths(java.nio.file.Paths) CreateIndexMetadata(io.prestosql.spi.connector.CreateIndexMetadata) IndexMetadata(io.prestosql.spi.heuristicindex.IndexMetadata) Index(io.prestosql.spi.heuristicindex.Index) Collections(java.util.Collections) SecurePathWhiteList(io.hetu.core.common.util.SecurePathWhiteList) InputStream(java.io.InputStream) BTreeIndex(io.hetu.core.plugin.heuristicindex.index.btree.BTreeIndex) TarArchiveInputStream(org.apache.commons.compress.archivers.tar.TarArchiveInputStream) CloseShieldInputStream(org.apache.commons.io.input.CloseShieldInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) CreateIndexMetadata(io.prestosql.spi.connector.CreateIndexMetadata) IndexMetadata(io.prestosql.spi.heuristicindex.IndexMetadata)

Aggregations

Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Logger (io.airlift.log.Logger)1 SecurePathWhiteList (io.hetu.core.common.util.SecurePathWhiteList)1 IndexConstants (io.hetu.core.heuristicindex.util.IndexConstants)1 BTreeIndex (io.hetu.core.plugin.heuristicindex.index.btree.BTreeIndex)1 CreateIndexMetadata (io.prestosql.spi.connector.CreateIndexMetadata)1 FileBasedLock (io.prestosql.spi.filesystem.FileBasedLock)1 HetuFileSystemClient (io.prestosql.spi.filesystem.HetuFileSystemClient)1 Index (io.prestosql.spi.heuristicindex.Index)1 IndexClient (io.prestosql.spi.heuristicindex.IndexClient)1 IndexMetadata (io.prestosql.spi.heuristicindex.IndexMetadata)1 IndexRecord (io.prestosql.spi.heuristicindex.IndexRecord)1 Pair (io.prestosql.spi.heuristicindex.Pair)1 HetuMetastore (io.prestosql.spi.metastore.HetuMetastore)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 UncheckedIOException (java.io.UncheckedIOException)1 FileSystemException (java.nio.file.FileSystemException)1