/** * Clear the invalid segments from all the datamaps of the table * @param carbonTable * @param segments */ public void clearInvalidSegments(CarbonTable carbonTable, List<Segment> segments) throws IOException { getDefaultDataMap(carbonTable).clear(segments); List<TableDataMap> allDataMap = getAllDataMap(carbonTable); for (TableDataMap dataMap: allDataMap) { dataMap.clear(segments); } }
/** * this methods clears the datamap of table from memory */ public void clearDataMaps(String tableUniqName) { List<TableDataMap> tableIndices = allDataMaps.get(tableUniqName); if (tableIndices != null) { for (TableDataMap tableDataMap : tableIndices) { if (tableDataMap != null) { // clear the segmentMap in BlockletDetailsFetcher,else the Segment will remain in executor // and the query fails as we will check whether the blocklet contains in the index or not tableDataMap.getBlockletDetailsFetcher().clear(); tableDataMap.clear(); } } } allDataMaps.remove(tableUniqName); tablePathMap.remove(tableUniqName); }
/** * After updating table status file clear the dataMap cache for all segmentId's on which * dataMap is being created because flows like merge index file creation involves modification of * segment file and once segment file is modified the cache for that segment need to be cleared * otherwise the old cache will be used which is stale * * @param carbonTable * @param segmentId */ public static void clearBlockDataMapCache(CarbonTable carbonTable, String segmentId) { TableDataMap defaultDataMap = DataMapStoreManager.getInstance().getDefaultDataMap(carbonTable); Segment segment = new Segment(segmentId); List<Segment> segments = new ArrayList<>(); segments.add(segment); LOGGER.info( "clearing cache while updating segment file entry in table status file for segmentId: " + segmentId); defaultDataMap.clear(segments); }
/** * Clear the datamap/datamaps of a table from memory and disk * * @param identifier Table identifier */ public void clearDataMap(AbsoluteTableIdentifier identifier, String dataMapName) { CarbonTable carbonTable = getCarbonTable(identifier); String tableUniqueName = identifier.getCarbonTableIdentifier().getTableUniqueName(); List<TableDataMap> tableIndices = allDataMaps.get(tableUniqueName); if (tableIndices != null) { int i = 0; for (TableDataMap tableDataMap : tableIndices) { if (carbonTable != null && tableDataMap != null && dataMapName .equalsIgnoreCase(tableDataMap.getDataMapSchema().getDataMapName())) { try { DataMapUtil.executeDataMapJobForClearingDataMaps(carbonTable); tableDataMap.clear(); } catch (IOException e) { LOGGER.error("clear dataMap job failed", e); // ignoring the exception } tableDataMap.deleteDatamapData(); tableIndices.remove(i); break; } i++; } allDataMaps.put(tableUniqueName, tableIndices); } }