use of io.prestosql.spi.heuristicindex.IndexClient in project hetu-core by openlookeng.
the class TestIndexCacheLoader method testNoLastModifiedTime.
@Test(expectedExceptions = Exception.class)
public void testNoLastModifiedTime() throws Exception {
IndexClient indexclient = mock(IndexClient.class);
IndexCacheLoader indexCacheLoader = new IndexCacheLoader(indexclient);
IndexCacheKey indexCacheKey = new IndexCacheKey("/path/to/split", 1);
// throw exception to produce "no last modified time file found" behaviour
when(indexclient.getLastModifiedTime((indexCacheKey.getPath()))).thenThrow(Exception.class);
indexCacheLoader.load(indexCacheKey);
}
use of io.prestosql.spi.heuristicindex.IndexClient in project hetu-core by openlookeng.
the class TestIndexCacheLoader method testNoValidIndexFilesFoundException.
@Test(expectedExceptions = Exception.class)
public void testNoValidIndexFilesFoundException() throws Exception {
IndexClient indexclient = mock(IndexClient.class);
IndexCacheLoader indexCacheLoader = new IndexCacheLoader(indexclient);
long lastModifiedTime = 1L;
IndexCacheKey indexCacheKey = new IndexCacheKey("/path/to/split", lastModifiedTime);
when(indexclient.getLastModifiedTime((indexCacheKey.getPath()))).thenReturn(lastModifiedTime);
when(indexclient.readSplitIndex((indexCacheKey.getPath()))).thenThrow(Exception.class);
indexCacheLoader.load(indexCacheKey);
}
use of io.prestosql.spi.heuristicindex.IndexClient in project boostkit-bigdata by kunpengcompute.
the class TestIndexCacheLoader method testNoMatchingLastModifiedTime.
@Test(expectedExceptions = Exception.class)
public void testNoMatchingLastModifiedTime() throws Exception {
IndexClient indexclient = mock(IndexClient.class);
IndexCacheLoader indexCacheLoader = new IndexCacheLoader(indexclient);
IndexCacheKey indexCacheKey = new IndexCacheKey("/path/to/split", 1L);
// return different last modified time to simulate expired index
when(indexclient.getLastModifiedTime((indexCacheKey.getPath()))).thenReturn(2L);
indexCacheLoader.load(indexCacheKey);
}
use of io.prestosql.spi.heuristicindex.IndexClient in project boostkit-bigdata by kunpengcompute.
the class TestIndexCacheLoader method testNoValidIndexFilesFound.
@Test(expectedExceptions = Exception.class)
public void testNoValidIndexFilesFound() throws Exception {
IndexClient indexclient = mock(IndexClient.class);
IndexCacheLoader indexCacheLoader = new IndexCacheLoader(indexclient);
long lastModifiedTime = 1L;
IndexCacheKey indexCacheKey = new IndexCacheKey("/path/to/split", lastModifiedTime);
when(indexclient.getLastModifiedTime((indexCacheKey.getPath()))).thenReturn(lastModifiedTime);
when(indexclient.readSplitIndex((indexCacheKey.getPath()))).thenReturn(Collections.emptyList());
indexCacheLoader.load(indexCacheKey);
}
use of io.prestosql.spi.heuristicindex.IndexClient in project hetu-core by openlookeng.
the class DropIndexTask method execute.
@Override
public ListenableFuture<?> execute(DropIndex statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine, List<Expression> parameters, HeuristicIndexerManager heuristicIndexerManager) {
IndexClient indexClient = heuristicIndexerManager.getIndexClient();
String indexName = statement.getIndexName().toString();
try {
IndexRecord record = indexClient.lookUpIndexRecord(indexName);
// check indexName exist, call heuristic index api to drop index
if (record == null) {
throw new SemanticException(MISSING_INDEX, statement, "Index '%s' does not exist", indexName);
}
QualifiedObjectName fullObjectName = QualifiedObjectName.valueOf(record.qualifiedTable);
Session session = stateMachine.getSession();
accessControl.checkCanDropIndex(session.getRequiredTransactionId(), session.getIdentity(), fullObjectName);
List<String> partitions = Collections.emptyList();
if (statement.getPartitions().isPresent()) {
partitions = HeuristicIndexUtils.extractPartitions(statement.getPartitions().get());
List<String> partitionsInindex = indexClient.lookUpIndexRecord(indexName).partitions;
if (partitionsInindex.isEmpty()) {
throw new SemanticException(MISSING_INDEX, statement, "Index '%s' was not created with explicit partitions. Partial drop by partition is not supported.", indexName);
}
List<String> missingPartitions = new ArrayList<>(partitions);
missingPartitions.removeAll(partitionsInindex);
if (!missingPartitions.isEmpty()) {
throw new SemanticException(MISSING_INDEX, statement, "Index '%s' does not contain partitions: %s", indexName, missingPartitions);
}
}
indexClient.deleteIndex(indexName, partitions);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return immediateFuture(null);
}
Aggregations