public CarbonSessionInfo() { this.sessionParams = new SessionParams(); this.threadParams = new SessionParams(); }
/** * This method will be used to add a new property * * @param key * @return properties value */ public SessionParams addProperty(String key, String value) throws InvalidConfigurationException { boolean isValidConf = validateKeyValue(key, value); if (isValidConf) { if (key.equals(CarbonLoadOptionConstants.CARBON_OPTIONS_BAD_RECORDS_ACTION)) { value = value.toUpperCase(); } LOGGER.info( "The key " + key + " with value " + value + " added in the session param"); sProps.put(key, value); } return this; }
CarbonInputFormat.setValidateSegmentsToAccess( conf, Boolean.valueOf(carbonSessionInfo.getThreadParams().getProperty( validateInputSegmentsKey, "true"))); String queryOnPreAggStreamingKey = CarbonCommonConstantsInternal.QUERY_ON_PRE_AGG_STREAMING + tableUniqueKey; boolean queryOnPreAggStreaming = Boolean.valueOf(carbonSessionInfo.getThreadParams() .getProperty(queryOnPreAggStreamingKey, "false")); String inputSegmentsKey = CarbonCommonConstants.CARBON_INPUT_SEGMENTS + tableUniqueKey; CarbonInputFormat.setValidateSegmentsToAccess(conf, Boolean.valueOf(carbonSessionInfo.getThreadParams() .getProperty(validateInputSegmentsKey, "true"))); CarbonInputFormat.setQuerySegment( conf, carbonSessionInfo.getThreadParams().getProperty( inputSegmentsKey, CarbonProperties.getInstance().getProperty(inputSegmentsKey, "*"))); if (queryOnPreAggStreaming) { CarbonInputFormat.setAccessStreamingSegments(conf, true); carbonSessionInfo.getThreadParams().removeProperty(queryOnPreAggStreamingKey); carbonSessionInfo.getThreadParams().removeProperty(inputSegmentsKey); carbonSessionInfo.getThreadParams().removeProperty(validateInputSegmentsKey);
/** * 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; }
public CarbonSessionInfo clone() throws CloneNotSupportedException { super.clone(); CarbonSessionInfo newObj = new CarbonSessionInfo(); newObj.setSessionParams(sessionParams.clone()); newObj.setThreadParams(threadParams.clone()); for (Map.Entry<String, Object> entry : getNonSerializableExtraInfo().entrySet()) { newObj.getNonSerializableExtraInfo().put(entry.getKey(), entry.getValue()); } return newObj; }
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; }
/** * 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 SessionParams clone() throws CloneNotSupportedException { super.clone(); SessionParams newObj = new SessionParams(); newObj.addedProps.putAll(this.addedProps); newObj.sProps.putAll(this.sProps); newObj.extraInfo.putAll(this.extraInfo); return newObj; } }
public static synchronized CarbonSessionInfo getOrCreateCarbonSessionInfo() { CarbonSessionInfo info = threadLocal.get(); if (info == null || info.getSessionParams() == null) { info = new CarbonSessionInfo(); info.setSessionParams(new SessionParams()); threadLocal.set(info); } return info; }