Class TsFileProcessor
- java.lang.Object
-
- org.apache.iotdb.db.engine.storagegroup.TsFileProcessor
-
public class TsFileProcessor extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description TsFileProcessor(java.lang.String storageGroupName, StorageGroupInfo storageGroupInfo, TsFileResource tsFileResource, CloseFileListener closeUnsealedTsFileProcessor, DataRegion.UpdateEndTimeCallBack updateLatestFlushTimeCallback, boolean sequence, org.apache.iotdb.tsfile.write.writer.RestorableTsFileIOWriter writer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCloseFileListener(CloseFileListener listener)voidaddCloseFileListeners(java.util.Collection<CloseFileListener> listeners)voidaddFlushListener(FlushListener listener)voidaddFlushListeners(java.util.Collection<FlushListener> listeners)booleanalreadyMarkedClosing()voidasyncFlush()put the working memtable into flushing list and set the working memtable to nullvoidclose()close this tsfilevoiddeleteDataInMemory(Deletion deletion, java.util.Set<org.apache.iotdb.commons.path.PartialPath> devicePaths)Delete data which belongs to the timeseries `deviceId.measurementId` and the timestamp of which <= 'timestamp' in the deletion.voidflushOneMemTable()Take the first MemTable from the flushingMemTables and flush it.java.util.concurrent.ConcurrentLinkedDeque<IMemTable>getFlushingMemTable()intgetFlushingMemTableSize()longgetLastWorkMemtableFlushTime()java.lang.StringgetStorageGroupName()longgetTimeRangeId()TsFileProcessorInfogetTsFileProcessorInfo()TsFileResourcegetTsFileResource()IMemTablegetWorkMemTable()longgetWorkMemTableCreatedTime()Return Long.MAX_VALUE if workMemTable is nulllonggetWorkMemTableRamCost()voidinsert(InsertRowNode insertRowNode)insert data in an InsertRowNode into the workingMemtable.voidinsert(InsertRowPlan insertRowPlan)insert data in an InsertRowPlan into the workingMemtable.voidinsertTablet(InsertTabletNode insertTabletNode, int start, int end, org.apache.iotdb.common.rpc.thrift.TSStatus[] results)insert batch data of insertTabletPlan into the workingMemtable.voidinsertTablet(InsertTabletPlan insertTabletPlan, int start, int end, org.apache.iotdb.common.rpc.thrift.TSStatus[] results)insert batch data of insertTabletPlan into the workingMemtable.booleanisManagedByFlushManager()booleanisMemtableNotNull()sync methodbooleanisSequence()voidputMemTableBackAndClose()release resource of a memtablevoidquery(java.util.List<org.apache.iotdb.commons.path.PartialPath> seriesPaths, QueryContext context, java.util.List<TsFileResource> tsfileResourcesForQuery)get the chunk(s) in the memtable (one from work memtable and the other ones in flushing memtables and then compact them into one TimeValuePairSorter).voidsetManagedByFlushManager(boolean managedByFlushManager)voidsetTimeRangeId(long timeRangeId)voidsetTsFileProcessorInfo(TsFileProcessorInfo tsFileProcessorInfo)voidsetWorkMemTableShouldFlush()booleanshouldClose()booleanshouldFlush()voidsubmitAFlushTask()voidsyncFlush()TODO if the flushing thread is too fast, the tmpMemTable.wait() may never wakeup Tips: I am trying to solve this issue by checking whether the table exist before wait()
-
-
-
Constructor Detail
-
TsFileProcessor
public TsFileProcessor(java.lang.String storageGroupName, StorageGroupInfo storageGroupInfo, TsFileResource tsFileResource, CloseFileListener closeUnsealedTsFileProcessor, DataRegion.UpdateEndTimeCallBack updateLatestFlushTimeCallback, boolean sequence, org.apache.iotdb.tsfile.write.writer.RestorableTsFileIOWriter writer)
-
-
Method Detail
-
insert
public void insert(InsertRowPlan insertRowPlan) throws WriteProcessException
insert data in an InsertRowPlan into the workingMemtable.- Parameters:
insertRowPlan- physical plan of insertion- Throws:
WriteProcessException
-
insert
public void insert(InsertRowNode insertRowNode) throws WriteProcessException
insert data in an InsertRowNode into the workingMemtable.- Parameters:
insertRowNode- physical plan of insertion- Throws:
WriteProcessException
-
insertTablet
public void insertTablet(InsertTabletPlan insertTabletPlan, int start, int end, org.apache.iotdb.common.rpc.thrift.TSStatus[] results) throws WriteProcessException
insert batch data of insertTabletPlan into the workingMemtable. The rows to be inserted are in the range [start, end). Null value in each column values will be replaced by the subsequent non-null value, e.g., {1, null, 3, null, 5} will be {1, 3, 5, null, 5}- Parameters:
insertTabletPlan- insert a tablet of a devicestart- start index of rows to be inserted in insertTabletPlanend- end index of rows to be inserted in insertTabletPlanresults- result array- Throws:
WriteProcessException
-
insertTablet
public void insertTablet(InsertTabletNode insertTabletNode, int start, int end, org.apache.iotdb.common.rpc.thrift.TSStatus[] results) throws WriteProcessException
insert batch data of insertTabletPlan into the workingMemtable. The rows to be inserted are in the range [start, end). Null value in each column values will be replaced by the subsequent non-null value, e.g., {1, null, 3, null, 5} will be {1, 3, 5, null, 5}- Parameters:
insertTabletNode- insert a tablet of a devicestart- start index of rows to be inserted in insertTabletPlanend- end index of rows to be inserted in insertTabletPlanresults- result array- Throws:
WriteProcessException
-
deleteDataInMemory
public void deleteDataInMemory(Deletion deletion, java.util.Set<org.apache.iotdb.commons.path.PartialPath> devicePaths)
Delete data which belongs to the timeseries `deviceId.measurementId` and the timestamp of which <= 'timestamp' in the deletion.
Delete data in both working MemTable and flushing MemTables.
-
getTsFileResource
public TsFileResource getTsFileResource()
-
shouldFlush
public boolean shouldFlush()
-
shouldClose
public boolean shouldClose()
-
syncFlush
public void syncFlush() throws java.io.IOExceptionTODO if the flushing thread is too fast, the tmpMemTable.wait() may never wakeup Tips: I am trying to solve this issue by checking whether the table exist before wait()- Throws:
java.io.IOException
-
asyncFlush
public void asyncFlush()
put the working memtable into flushing list and set the working memtable to null
-
flushOneMemTable
public void flushOneMemTable()
Take the first MemTable from the flushingMemTables and flush it. Called by a flush thread of the flush manager pool
-
isManagedByFlushManager
public boolean isManagedByFlushManager()
-
setManagedByFlushManager
public void setManagedByFlushManager(boolean managedByFlushManager)
-
isMemtableNotNull
public boolean isMemtableNotNull()
sync method
-
close
public void close() throws TsFileProcessorExceptionclose this tsfile- Throws:
TsFileProcessorException
-
getFlushingMemTableSize
public int getFlushingMemTableSize()
-
getStorageGroupName
public java.lang.String getStorageGroupName()
-
query
public void query(java.util.List<org.apache.iotdb.commons.path.PartialPath> seriesPaths, QueryContext context, java.util.List<TsFileResource> tsfileResourcesForQuery) throws java.io.IOExceptionget the chunk(s) in the memtable (one from work memtable and the other ones in flushing memtables and then compact them into one TimeValuePairSorter). Then get the related ChunkMetadata of data on disk.- Parameters:
seriesPaths- selected paths- Throws:
java.io.IOException
-
getTimeRangeId
public long getTimeRangeId()
-
setTimeRangeId
public void setTimeRangeId(long timeRangeId)
-
putMemTableBackAndClose
public void putMemTableBackAndClose() throws TsFileProcessorExceptionrelease resource of a memtable- Throws:
TsFileProcessorException
-
getTsFileProcessorInfo
public TsFileProcessorInfo getTsFileProcessorInfo()
-
setTsFileProcessorInfo
public void setTsFileProcessorInfo(TsFileProcessorInfo tsFileProcessorInfo)
-
getWorkMemTableRamCost
public long getWorkMemTableRamCost()
-
getWorkMemTableCreatedTime
public long getWorkMemTableCreatedTime()
Return Long.MAX_VALUE if workMemTable is null
-
getLastWorkMemtableFlushTime
public long getLastWorkMemtableFlushTime()
-
isSequence
public boolean isSequence()
-
setWorkMemTableShouldFlush
public void setWorkMemTableShouldFlush()
-
addFlushListener
public void addFlushListener(FlushListener listener)
-
addCloseFileListener
public void addCloseFileListener(CloseFileListener listener)
-
addFlushListeners
public void addFlushListeners(java.util.Collection<FlushListener> listeners)
-
addCloseFileListeners
public void addCloseFileListeners(java.util.Collection<CloseFileListener> listeners)
-
submitAFlushTask
public void submitAFlushTask()
-
alreadyMarkedClosing
public boolean alreadyMarkedClosing()
-
getWorkMemTable
public IMemTable getWorkMemTable()
-
getFlushingMemTable
public java.util.concurrent.ConcurrentLinkedDeque<IMemTable> getFlushingMemTable()
-
-