/** * returns session property value * * @param key * @return */ private String getSessionPropertyValue(String key) { String value = null; CarbonSessionInfo carbonSessionInfo = ThreadLocalSessionInfo.getCarbonSessionInfo(); if (null != carbonSessionInfo) { SessionParams sessionParams = ThreadLocalSessionInfo.getCarbonSessionInfo().getSessionParams(); if (null != sessionParams) { value = sessionParams.getProperty(key); } } return value; }
public AbstractQueryExecutor(Configuration configuration) { ThreadLocalSessionInfo.setConfigurationToCurrentThread(configuration); queryProperties = new QueryExecutorProperties(); }
public static Configuration getConfiguration() { Configuration conf; Object confObject = ThreadLocalSessionInfo.getOrCreateCarbonSessionInfo() .getNonSerializableExtraInfo().get("carbonConf"); if (confObject == null) { conf = configuration; } else { conf = (Configuration) confObject; } return conf; }
@Override public void run() { ThreadLocalSessionInfo.setConfigurationToCurrentThread(taskAttemptContext .getConfiguration()); try { dataLoadExecutor .execute(loadModel, tempStoreLocations, iterators); } catch (Exception e) { executorService.shutdownNow(); for (CarbonOutputIteratorWrapper iterator : iterators) { iterator.closeWriter(true); } dataLoadExecutor.close(); throw new RuntimeException(e); } finally { ThreadLocalSessionInfo.unsetAll(); } } });
/** * Construct a CarbonReaderBuilder with table path and table name * * @param tablePath table path * @param tableName table name */ CarbonReaderBuilder(String tablePath, String tableName) { this.tablePath = tablePath; this.tableName = tableName; ThreadLocalSessionInfo.setCarbonSessionInfo(new CarbonSessionInfo()); }
@Override public void close(TaskAttemptContext taskAttemptContext) throws InterruptedException { if (!isClosed) { isClosed = true; if (iteratorWrapper != null) { iteratorWrapper.closeWriter(false); } try { future.get(); } catch (ExecutionException e) { LOG.error("Error while loading data", e); throw new InterruptedException(e.getMessage()); } finally { executorService.shutdownNow(); dataLoadExecutor.close(); ThreadLocalSessionInfo.unsetAll(); // clean up the folders and files created locally for data load operation TableProcessingOperations.deleteLocalDataLoadFolderLocation(loadModel, false, false); } LOG.info("Closed writer task " + taskAttemptContext.getTaskAttemptID()); } }
private Object getOperationContext() { // when validate segments is disabled in thread local update it to CarbonTableInputFormat CarbonSessionInfo carbonSessionInfo = ThreadLocalSessionInfo.getCarbonSessionInfo(); if (carbonSessionInfo != null) { return carbonSessionInfo.getThreadParams().getExtraInfo("partition.operationcontext"); } return null; }
public static void setConfigurationToCurrentThread(Configuration configuration) { getOrCreateCarbonSessionInfo().getNonSerializableExtraInfo().put("carbonConf", configuration); }
/** * 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; }
CarbonSessionInfo carbonSessionInfo = ThreadLocalSessionInfo.getCarbonSessionInfo(); if (carbonSessionInfo != null) { String tableUniqueKey = identifier.getDatabaseName() + "." + identifier.getTableName();