use of io.prestosql.testing.NoOpIndexClient in project hetu-core by openlookeng.
the class TestIndexCacheRemoval method testExpiredCacheIndices.
@Test
public void testExpiredCacheIndices() throws Exception {
synchronized (this) {
HiveSplit testHiveSplit;
testHiveSplit = mock(HiveSplit.class);
when(testHiveSplit.getPath()).thenReturn(testPath);
when(testHiveSplit.getLastModifiedTime()).thenReturn(testLastModifiedTime);
IndexMetadata indexMetadata = mock(IndexMetadata.class);
when(indexMetadata.getLastModifiedTime()).thenReturn(testLastModifiedTime);
Index index = mock(Index.class);
when(indexMetadata.getIndex()).then(new Returns(index));
when(index.getMemoryUsage()).thenReturn(new DataSize(1, KILOBYTE).toBytes());
List<IndexMetadata> expectedIndices = new LinkedList<>();
expectedIndices.add(indexMetadata);
IndexCacheLoader indexCacheLoader = mock(IndexCacheLoader.class);
when(indexCacheLoader.load(any())).then(new Returns(expectedIndices));
IndexCache indexCache = new IndexCache(indexCacheLoader, loadDelay, new NoOpIndexClient());
List<IndexMetadata> actualSplitIndex = indexCache.getIndices(catalog, table, testHiveSplit, effectivePredicate, testPartitions);
assertEquals(actualSplitIndex.size(), 0);
Thread.sleep(loadDelay + 2000);
actualSplitIndex = indexCache.getIndices(catalog, table, testHiveSplit, effectivePredicate, testPartitions);
assertEquals(actualSplitIndex.size(), numberOfIndexTypes);
// now the index is in the cache, but changing the lastmodified date of the split should invalidate it
when(testHiveSplit.getLastModifiedTime()).thenReturn(testLastModifiedTime + 1);
actualSplitIndex = indexCache.getIndices(catalog, table, testHiveSplit, effectivePredicate, testPartitions);
assertEquals(actualSplitIndex.size(), 0);
}
}
use of io.prestosql.testing.NoOpIndexClient in project boostkit-bigdata by kunpengcompute.
the class TestIndexCacheFetch method testIndexCacheThrowsExecutionException.
@Test
public void testIndexCacheThrowsExecutionException() throws Exception {
synchronized (this) {
HiveSplit testHiveSplit;
testHiveSplit = mock(HiveSplit.class);
when(testHiveSplit.getPath()).thenReturn(testPath);
when(testHiveSplit.getLastModifiedTime()).thenReturn(testLastModifiedTime);
IndexMetadata indexMetadata = mock(IndexMetadata.class);
when(indexMetadata.getLastModifiedTime()).thenReturn(testLastModifiedTime);
List<IndexMetadata> expectedIndices = new LinkedList<>();
expectedIndices.add(indexMetadata);
IndexCacheLoader indexCacheLoader = mock(IndexCacheLoader.class);
when(indexCacheLoader.load(any())).thenThrow(ExecutionException.class);
IndexCache indexCache = new IndexCache(indexCacheLoader, loadDelay, new NoOpIndexClient());
List<IndexMetadata> actualSplitIndex = indexCache.getIndices(catalog, table, testHiveSplit, effectivePredicate, testPartitions);
assertEquals(actualSplitIndex.size(), 0);
Thread.sleep(loadDelay + 2000);
actualSplitIndex = indexCache.getIndices(catalog, table, testHiveSplit, effectivePredicate, testPartitions);
assertEquals(actualSplitIndex.size(), 0);
}
}
use of io.prestosql.testing.NoOpIndexClient in project boostkit-bigdata by kunpengcompute.
the class TestIndexCachePartition method testIndexCacheWithPartitions.
@Test
public void testIndexCacheWithPartitions() throws Exception {
synchronized (this) {
HiveSplit testHiveSplit;
testHiveSplit = mock(HiveSplit.class);
when(testHiveSplit.getPath()).thenReturn(testPath);
when(testHiveSplit.getLastModifiedTime()).thenReturn(testLastModifiedTime);
HiveColumnHandle partitionColumnHandle;
TupleDomain<HiveColumnHandle> effectivePredicateForPartition;
partitionColumnHandle = mock(HiveColumnHandle.class);
// partition column should be filtered out this should never get called
when(partitionColumnHandle.getName()).thenThrow(Exception.class);
effectivePredicateForPartition = TupleDomain.withColumnDomains(ImmutableMap.of(testColumnHandle, domain, partitionColumnHandle, domain));
List<HiveColumnHandle> partitionColumns = ImmutableList.of(partitionColumnHandle);
IndexMetadata indexMetadata = mock(IndexMetadata.class);
when(indexMetadata.getLastModifiedTime()).thenReturn(testLastModifiedTime);
Index index = mock(Index.class);
when(indexMetadata.getIndex()).then(new Returns(index));
when(index.getMemoryUsage()).thenReturn(new DataSize(1, KILOBYTE).toBytes());
List<IndexMetadata> expectedIndices = new LinkedList<>();
expectedIndices.add(indexMetadata);
IndexCacheLoader indexCacheLoader = mock(IndexCacheLoader.class);
when(indexCacheLoader.load(any())).then(new Returns(expectedIndices));
IndexCache indexCache = new IndexCache(indexCacheLoader, loadDelay, new NoOpIndexClient());
List<IndexMetadata> actualSplitIndex = indexCache.getIndices(catalog, table, testHiveSplit, effectivePredicateForPartition, partitionColumns);
assertEquals(actualSplitIndex.size(), 0);
Thread.sleep(loadDelay + 2000);
actualSplitIndex = indexCache.getIndices(catalog, table, testHiveSplit, effectivePredicateForPartition, partitionColumns);
assertEquals(actualSplitIndex.size(), numberOfIndexTypes);
}
}
use of io.prestosql.testing.NoOpIndexClient in project hetu-core by openlookeng.
the class TestIndexCacheFetch method testIndexCacheGetIndices.
@Test
public void testIndexCacheGetIndices() throws Exception {
synchronized (this) {
HiveSplit testHiveSplit;
testHiveSplit = mock(HiveSplit.class);
when(testHiveSplit.getPath()).thenReturn(testPath);
when(testHiveSplit.getLastModifiedTime()).thenReturn(testLastModifiedTime);
IndexMetadata indexMetadata = mock(IndexMetadata.class);
when(indexMetadata.getLastModifiedTime()).thenReturn(testLastModifiedTime);
Index index = mock(Index.class);
when(indexMetadata.getIndex()).then(new Returns(index));
when(index.getMemoryUsage()).thenReturn(new DataSize(1, KILOBYTE).toBytes());
List<IndexMetadata> expectedIndices = new LinkedList<>();
expectedIndices.add(indexMetadata);
IndexCacheLoader indexCacheLoader = mock(IndexCacheLoader.class);
when(indexCacheLoader.load(any())).then(new Returns(expectedIndices));
IndexCache indexCache = new IndexCache(indexCacheLoader, new NoOpIndexClient());
List<IndexMetadata> actualSplitIndex = indexCache.getIndices(catalog, table, testHiveSplit, effectivePredicate, testPartitions);
assertEquals(actualSplitIndex.size(), 0);
Thread.sleep(loadDelay + 2000);
actualSplitIndex = indexCache.getIndices(catalog, table, testHiveSplit, effectivePredicate, testPartitions);
assertEquals(actualSplitIndex.size(), numberOfIndexTypes);
assertEquals(actualSplitIndex.get(0), expectedIndices.get(0));
}
}
use of io.prestosql.testing.NoOpIndexClient in project hetu-core by openlookeng.
the class TestIndexCachePartition method testIndexCacheWithPartitions.
@Test
public void testIndexCacheWithPartitions() throws Exception {
synchronized (this) {
HiveSplit testHiveSplit;
testHiveSplit = mock(HiveSplit.class);
when(testHiveSplit.getPath()).thenReturn(testPath);
when(testHiveSplit.getLastModifiedTime()).thenReturn(testLastModifiedTime);
HiveColumnHandle partitionColumnHandle;
TupleDomain<HiveColumnHandle> effectivePredicateForPartition;
partitionColumnHandle = mock(HiveColumnHandle.class);
// partition column should be filtered out this should never get called
when(partitionColumnHandle.getName()).thenThrow(Exception.class);
effectivePredicateForPartition = TupleDomain.withColumnDomains(ImmutableMap.of(testColumnHandle, domain, partitionColumnHandle, domain));
List<HiveColumnHandle> partitionColumns = ImmutableList.of(partitionColumnHandle);
IndexMetadata indexMetadata = mock(IndexMetadata.class);
when(indexMetadata.getLastModifiedTime()).thenReturn(testLastModifiedTime);
Index index = mock(Index.class);
when(indexMetadata.getIndex()).then(new Returns(index));
when(index.getMemoryUsage()).thenReturn(new DataSize(1, KILOBYTE).toBytes());
List<IndexMetadata> expectedIndices = new LinkedList<>();
expectedIndices.add(indexMetadata);
IndexCacheLoader indexCacheLoader = mock(IndexCacheLoader.class);
when(indexCacheLoader.load(any())).then(new Returns(expectedIndices));
IndexCache indexCache = new IndexCache(indexCacheLoader, loadDelay, new NoOpIndexClient());
List<IndexMetadata> actualSplitIndex = indexCache.getIndices(catalog, table, testHiveSplit, effectivePredicateForPartition, partitionColumns);
assertEquals(actualSplitIndex.size(), 0);
Thread.sleep(loadDelay + 2000);
actualSplitIndex = indexCache.getIndices(catalog, table, testHiveSplit, effectivePredicateForPartition, partitionColumns);
assertEquals(actualSplitIndex.size(), numberOfIndexTypes);
}
}
Aggregations