@Override public void close() throws IOException { for (ILookupTable usedLookupTable : usedLookupTables) { try { usedLookupTable.close(); } catch (Exception e) { logger.error("error when close lookup table:" + usedLookupTable); } } }
@Override public void close() { try { lookupTable.close(); } catch (IOException e) { logger.error("error when close lookup table", e); } }
private TupleFilter translateDerivedInCompare(CompareTupleFilter compf, Set<TblColRef> collector) { if (compf.getColumn() == null) return compf; TblColRef derived = compf.getColumn(); if (cubeDesc.isExtendedColumn(derived)) { throw new CubeDesc.CannotFilterExtendedColumnException(derived); } if (!cubeDesc.isDerived(derived)) return compf; DeriveInfo hostInfo = cubeDesc.getHostInfo(derived); ILookupTable lookup = cubeDesc.getHostInfo(derived).type == CubeDesc.DeriveType.PK_FK ? null : getLookupStringTableForDerived(derived, hostInfo); Pair<TupleFilter, Boolean> translated = DerivedFilterTranslator.translate(lookup, hostInfo, compf); try { if (lookup != null) { lookup.close(); } } catch (IOException e) { logger.error("error when close lookup table.", e); } TupleFilter translatedFilter = translated.getFirst(); boolean loosened = translated.getSecond(); if (loosened) { collectColumnsRecursively(translatedFilter, collector); } return translatedFilter; }
@Test public void testCheckCacheState() throws Exception { ExtTableSnapshotInfo snapshotInfo = buildSnapshotCache(RandomUtil.randomUUID().toString(), 1000); RocksDBLookupTableCache cache = RocksDBLookupTableCache.getInstance(kylinConfig); ILookupTable cachedLookupTable = cache.getCachedLookupTable(tableDesc, snapshotInfo, false); assertNotNull(cachedLookupTable); cachedLookupTable.close(); ExtTableSnapshotInfoManager.getInstance(kylinConfig).removeSnapshot(snapshotInfo.getTableName(), snapshotInfo.getId()); cache.checkCacheState(); String cacheLocalPath = cache.getSnapshotCachePath(snapshotInfo.getTableName(), snapshotInfo.getId()); // won't cleanup because it is newly created in last 1 hour assertTrue(new File(cacheLocalPath).exists()); // change the volatile value kylinConfig.setProperty("kylin.snapshot.ext.local.cache.check.volatile", "0"); cache.checkCacheState(); // this time it should be removed. assertFalse(new File(cacheLocalPath).exists()); cachedLookupTable = cache.getCachedLookupTable(tableDesc, snapshotInfo, false); assertNull(cachedLookupTable); }
@Test public void testRestoreCacheFromFiles() throws Exception { String snapshotID = RandomUtil.randomUUID().toString(); String snapshotCacheBasePath = RocksDBLookupTableCache.getCacheBasePath(kylinConfig) + File.separator + TABLE_COUNTRY + File.separator + snapshotID; String dbPath = snapshotCacheBasePath + File.separator + "db"; RocksDBLookupBuilder builder = new RocksDBLookupBuilder(tableDesc, new String[] { "COUNTRY" }, dbPath); builder.build(getLookupTableWithRandomData(10000)); String stateFilePath = snapshotCacheBasePath + File.separator + "STATE"; Files.write(CacheState.AVAILABLE.name(), new File(stateFilePath), Charsets.UTF_8); RocksDBLookupTableCache cache = RocksDBLookupTableCache.getInstance(kylinConfig); ExtTableSnapshotInfo snapshotInfo = new ExtTableSnapshotInfo(); snapshotInfo.setTableName(TABLE_COUNTRY); snapshotInfo.setUuid(snapshotID); snapshotInfo.setStorageType(MOCK_EXT_LOOKUP); snapshotInfo.setKeyColumns(new String[] { "COUNTRY" }); ILookupTable lookupTable = cache.getCachedLookupTable(tableDesc, snapshotInfo, false); int rowCnt = 0; for (String[] strings : lookupTable) { rowCnt++; } lookupTable.close(); assertEquals(10000, rowCnt); }
@Override public void close() { try { lookupTable.close(); } catch (IOException e) { logger.error("error when close lookup table", e); } }
@Override public void close() throws IOException { for (ILookupTable usedLookupTable : usedLookupTables) { try { usedLookupTable.close(); } catch (Exception e) { logger.error("error when close lookup table:" + usedLookupTable); } } }
private TupleFilter translateDerivedInCompare(CompareTupleFilter compf, Set<TblColRef> collector) { if (compf.getColumn() == null) return compf; TblColRef derived = compf.getColumn(); if (cubeDesc.isExtendedColumn(derived)) { throw new CubeDesc.CannotFilterExtendedColumnException(derived); } if (!cubeDesc.isDerived(derived)) return compf; DeriveInfo hostInfo = cubeDesc.getHostInfo(derived); ILookupTable lookup = cubeDesc.getHostInfo(derived).type == CubeDesc.DeriveType.PK_FK ? null : getLookupStringTableForDerived(derived, hostInfo); Pair<TupleFilter, Boolean> translated = DerivedFilterTranslator.translate(lookup, hostInfo, compf); try { if (lookup != null) { lookup.close(); } } catch (IOException e) { logger.error("error when close lookup table.", e); } TupleFilter translatedFilter = translated.getFirst(); boolean loosened = translated.getSecond(); if (loosened) { collectColumnsRecursively(translatedFilter, collector); } return translatedFilter; }