Class QueryResourceManager
- java.lang.Object
-
- org.apache.iotdb.db.query.control.QueryResourceManager
-
public class QueryResourceManager extends java.lang.ObjectQueryResourceManager manages resource (file streams) used by each query job, and assign Ids to the jobs. During the life cycle of a query, the following methods must be called in strict order:1. assignQueryId - get an Id for the new query.
2. getQueryDataSource - open files for the job or reuse existing readers.
3. endQueryForGivenJob - release the resource used by this job.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description longassignCompactionQueryId()Register a query id for compaction.longassignQueryId(boolean isDataQuery)Register a new query.voidendQuery(long queryId)Whenever the jdbc request is closed normally or abnormally, this method must be invoked.static QueryResourceManagergetInstance()QueryDataSourcegetQueryDataSource(org.apache.iotdb.commons.path.PartialPath selectedPath, QueryContext context, org.apache.iotdb.tsfile.read.filter.basic.Filter timeFilter, boolean ascending)QueryFileManagergetQueryFileManager()voidinitQueryDataSourceCache(java.util.Map<DataRegion,java.util.List<org.apache.iotdb.commons.path.PartialPath>> processorToSeriesMap, QueryContext context, org.apache.iotdb.tsfile.read.filter.basic.Filter timeFilter)The method is called in mergeLock() when executing query.voidregisterTempExternalSortFile(long queryId, IExternalSortFileDeserializer deserializer)register temporary file generated by external sort for resource release.voidwriteQueryFileInfo()
-
-
-
Method Detail
-
getInstance
public static QueryResourceManager getInstance()
-
assignQueryId
public long assignQueryId(boolean isDataQuery)
Register a new query. When a query request is created firstly, this method must be invoked.
-
assignCompactionQueryId
public long assignCompactionQueryId()
Register a query id for compaction. The name of the compaction thread is 'pool-x-IoTDB-Compaction-xx', xx in which is usually an integer from 0 to MAXCOMPACTION_THREAD_NUM. We use the following rules to define query id for compaction:
queryId = xx + Long.MIN_VALUE
-
registerTempExternalSortFile
public void registerTempExternalSortFile(long queryId, IExternalSortFileDeserializer deserializer)register temporary file generated by external sort for resource release.- Parameters:
queryId- query job iddeserializer- deserializer of temporary file in external sort.
-
initQueryDataSourceCache
public void initQueryDataSourceCache(java.util.Map<DataRegion,java.util.List<org.apache.iotdb.commons.path.PartialPath>> processorToSeriesMap, QueryContext context, org.apache.iotdb.tsfile.read.filter.basic.Filter timeFilter) throws QueryProcessException
The method is called in mergeLock() when executing query. This method will get all the QueryDataSource needed for this query and put them in the cachedQueryDataSourcesMap.- Parameters:
processorToSeriesMap- Key: processor of the virtual storage group. Value: selected series under the virtual storage group- Throws:
QueryProcessException
-
getQueryDataSource
public QueryDataSource getQueryDataSource(org.apache.iotdb.commons.path.PartialPath selectedPath, QueryContext context, org.apache.iotdb.tsfile.read.filter.basic.Filter timeFilter, boolean ascending) throws StorageEngineException, QueryProcessException
- Parameters:
selectedPath- MeasurementPath or AlignedPath, even if it contains only one sub sensor of an aligned device, it should be AlignedPath instead of MeasurementPath- Throws:
StorageEngineExceptionQueryProcessException
-
endQuery
public void endQuery(long queryId) throws StorageEngineExceptionWhenever the jdbc request is closed normally or abnormally, this method must be invoked. All query tokens created by this jdbc request must be cleared.- Throws:
StorageEngineException
-
writeQueryFileInfo
public void writeQueryFileInfo()
-
getQueryFileManager
public QueryFileManager getQueryFileManager()
-
-