public DataMapSchema getDataMapSchema() { return dataMap.getDataMapSchema(); }
private TableDataMap getTableDataMap(String dataMapName, List<TableDataMap> tableIndices) { TableDataMap dataMap = null; for (TableDataMap tableDataMap : tableIndices) { if (tableDataMap.getDataMapSchema().getDataMapName().equals(dataMapName)) { dataMap = tableDataMap; break; } } return dataMap; }
/** * is datamap exist * @return true if exist, else return false */ public boolean isDataMapExist(String dbName, String tableName, String dmName) { List<TableDataMap> tableDataMaps = allDataMaps.get(dbName + '_' + tableName); if (tableDataMaps != null) { for (TableDataMap dm : tableDataMaps) { if (dm != null && dmName.equalsIgnoreCase(dm.getDataMapSchema().getDataMapName())) { return true; } } } return false; }
public DataMapChooser(CarbonTable carbonTable) throws IOException { this.carbonTable = carbonTable; // read all datamaps for this table and populate CG and FG datamap list List<TableDataMap> visibleDataMaps = DataMapStoreManager.getInstance().getAllVisibleDataMap(carbonTable); Map<String, DataMapStatusDetail> map = DataMapStatusManager.readDataMapStatusMap(); cgDataMaps = new ArrayList<>(visibleDataMaps.size()); fgDataMaps = new ArrayList<>(visibleDataMaps.size()); for (TableDataMap visibleDataMap : visibleDataMaps) { DataMapStatusDetail status = map.get(visibleDataMap.getDataMapSchema().getDataMapName()); if (status != null && status.isEnabled()) { DataMapLevel level = visibleDataMap.getDataMapFactory().getDataMapLevel(); if (level == DataMapLevel.CG) { cgDataMaps.add(visibleDataMap); } else { fgDataMaps.add(visibleDataMap); } } } }
/** * It only gives the visible datamaps */ List<TableDataMap> getAllVisibleDataMap(CarbonTable carbonTable) throws IOException { CarbonSessionInfo sessionInfo = ThreadLocalSessionInfo.getCarbonSessionInfo(); List<TableDataMap> allDataMaps = getAllDataMap(carbonTable); Iterator<TableDataMap> dataMapIterator = allDataMaps.iterator(); while (dataMapIterator.hasNext()) { TableDataMap dataMap = dataMapIterator.next(); String dbName = carbonTable.getDatabaseName(); String tableName = carbonTable.getTableName(); String dmName = dataMap.getDataMapSchema().getDataMapName(); // TODO: need support get the visible status of datamap without sessionInfo in the future if (sessionInfo != null) { boolean isDmVisible = sessionInfo.getSessionParams().getProperty( String.format("%s%s.%s.%s", CarbonCommonConstants.CARBON_DATAMAP_VISIBLE, dbName, tableName, dmName), "true").trim().equalsIgnoreCase("true"); if (!isDmVisible) { LOGGER.warn(String.format("Ignore invisible datamap %s on table %s.%s", dmName, dbName, tableName)); dataMapIterator.remove(); } } else { String message = "Carbon session info is null"; LOGGER.info(message); } } return allDataMaps; }
if (dataMap.getDataMapSchema().getDataMapName().equals(this.dataMapName)) { List<CarbonFile> indexFiles; String dmPath = CarbonTablePath.getDataMapStorePath(tablePath, segmentId, dataMap.getDataMapSchema().getDataMapName()); FileFactory.FileType fileType = FileFactory.getFileType(dmPath); final CarbonFile dirPath = FileFactory.getCarbonFile(dmPath, fileType);
/** * 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); } }
DataMapFactory factoryClass = DataMapStoreManager.getInstance().getDataMapFactoryClass( carbonTable, dataMap.getDataMapSchema()); if (factoryClass.willBecomeStale(operation)) { return false;
/** * register all datamap writer for specified table and segment */ public void registerAllWriter(CarbonTable carbonTable, String segmentId, String taskNo, SegmentProperties segmentProperties) { // clear cache in executor side DataMapStoreManager.getInstance() .clearDataMaps(carbonTable.getCarbonTableIdentifier().getTableUniqueName()); List<TableDataMap> tableIndices; try { tableIndices = DataMapStoreManager.getInstance().getAllDataMap(carbonTable); } catch (IOException e) { LOG.error("Error while retrieving datamaps", e); throw new RuntimeException(e); } if (tableIndices != null) { tblIdentifier = carbonTable.getCarbonTableIdentifier(); for (TableDataMap tableDataMap : tableIndices) { // register it only if it is not lazy datamap, for lazy datamap, user // will rebuild the datamap manually if (!tableDataMap.getDataMapSchema().isLazy()) { DataMapFactory factory = tableDataMap.getDataMapFactory(); register(factory, segmentId, taskNo, segmentProperties); } } } }
try { for (TableDataMap dataMap : DataMapStoreManager.getInstance().getAllDataMap(carbonTable)) { if (dataMap.getDataMapSchema().isIndexDataMap()) { indexDataMaps.add(dataMap);