/** * Clear the datamap/datamaps of a table from memory * * @param identifier Table identifier */ public void clearDataMaps(AbsoluteTableIdentifier identifier) { CarbonTable carbonTable = getCarbonTable(identifier); String tableUniqueName = identifier.getCarbonTableIdentifier().getTableUniqueName(); List<TableDataMap> tableIndices = allDataMaps.get(tableUniqueName); if (tableIndices == null) { String keyUsingTablePath = getKeyUsingTablePath(identifier.getTablePath()); if (keyUsingTablePath != null) { tableUniqueName = keyUsingTablePath; tableIndices = allDataMaps.get(tableUniqueName); } } if (null != carbonTable && tableIndices != null) { try { DataMapUtil.executeDataMapJobForClearingDataMaps(carbonTable); } catch (IOException e) { LOGGER.error("clear dataMap job failed", e); // ignoring the exception } } segmentRefreshMap.remove(identifier.uniqueName()); clearDataMaps(tableUniqueName); allDataMaps.remove(tableUniqueName); tablePathMap.remove(tableUniqueName); }
/** * 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); } }