public class TsFileIOWriter extends Object implements AutoCloseable
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
canWrite |
protected List<ChunkGroupMetadata> |
chunkGroupMetadataList |
protected List<ChunkMetadata> |
chunkMetadataList |
protected static TSFileConfig |
config |
protected File |
file |
protected static byte[] |
MAGIC_STRING_BYTES |
protected TsFileOutput |
out |
static byte |
VERSION_NUMBER_BYTE |
| Modifier | Constructor and Description |
|---|---|
protected |
TsFileIOWriter()
empty construct function.
|
|
TsFileIOWriter(File file)
for writing a new tsfile.
|
|
TsFileIOWriter(TsFileOutput output)
for writing a new tsfile.
|
|
TsFileIOWriter(TsFileOutput output,
boolean test)
for test only
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
canWrite() |
void |
close()
close the outputStream or file channel without writing FileMetadata.
|
void |
endChunkGroup()
end chunk and write some log.
|
void |
endCurrentChunk()
end chunk and write some log.
|
void |
endFile()
write TSFileMetaData to output stream and close it.
|
void |
filterChunks(Map<Path,List<Long>> chunkStartTimes)
Remove such ChunkMetadata that its startTime is not in chunkStartTimes
|
Map<String,List<ChunkMetadata>> |
getDeviceChunkMetadataMap() |
Map<String,List<TimeseriesMetadata>> |
getDeviceTimeseriesMetadataMap()
this function is for Upgrade Tool and Split Tool.
|
File |
getFile() |
TsFileOutput |
getIOWriterOut()
this function is only for Test.
|
long |
getMaxPlanIndex() |
long |
getMinPlanIndex() |
long |
getPos()
get the length of normal OutputStream.
|
boolean |
isWritingChunkGroup()
For TsFileReWriteTool / UpgradeTool.
|
void |
mark() |
void |
reset() |
void |
setFile(File file) |
void |
setMaxPlanIndex(long maxPlanIndex) |
void |
setMinPlanIndex(long minPlanIndex) |
int |
startChunkGroup(String deviceId) |
protected void |
startFile() |
void |
startFlushChunk(String measurementId,
CompressionType compressionCodecName,
TSDataType tsDataType,
TSEncoding encodingType,
Statistics<? extends Serializable> statistics,
int dataSize,
int numOfPages,
int mask)
start a ChunkMetaData.
|
void |
truncate(long offset) |
void |
writeBytesToStream(PublicBAOS bytes)
Writes given bytes to output stream.
|
void |
writeChunk(Chunk chunk,
ChunkMetadata chunkMetadata)
Write a whole chunk in another file into this file.
|
void |
writePlanIndices() |
protected static final byte[] MAGIC_STRING_BYTES
public static final byte VERSION_NUMBER_BYTE
protected static final TSFileConfig config
protected TsFileOutput out
protected boolean canWrite
protected File file
protected List<ChunkMetadata> chunkMetadataList
protected List<ChunkGroupMetadata> chunkGroupMetadataList
protected TsFileIOWriter()
public TsFileIOWriter(File file) throws IOException
file - be used to output written dataIOException - if I/O error occurspublic TsFileIOWriter(TsFileOutput output) throws IOException
output - be used to output written dataIOExceptionpublic TsFileIOWriter(TsFileOutput output, boolean test)
public void writeBytesToStream(PublicBAOS bytes) throws IOException
bytes - - data of several pages which has been packedIOException - if an I/O error occurs.protected void startFile()
throws IOException
IOExceptionpublic int startChunkGroup(String deviceId) throws IOException
IOExceptionpublic void endChunkGroup()
throws IOException
IOExceptionpublic boolean isWritingChunkGroup()
public void startFlushChunk(String measurementId, CompressionType compressionCodecName, TSDataType tsDataType, TSEncoding encodingType, Statistics<? extends Serializable> statistics, int dataSize, int numOfPages, int mask) throws IOException
measurementId - - measurementId of this time seriescompressionCodecName - - compression name of this time seriestsDataType - - data typestatistics - - Chunk statisticsdataSize - - the serialized size of all pagesmask - - 0x80 for time chunk, 0x40 for value chunk, 0x00 for common chunkIOException - if I/O error occurspublic void writeChunk(Chunk chunk, ChunkMetadata chunkMetadata) throws IOException
IOExceptionpublic void endCurrentChunk()
public void endFile()
throws IOException
IOException - if I/O error occurspublic long getPos()
throws IOException
IOException - if I/O error occurspublic Map<String,List<ChunkMetadata>> getDeviceChunkMetadataMap()
public boolean canWrite()
public void mark()
throws IOException
IOExceptionpublic void reset()
throws IOException
IOExceptionpublic void close()
throws IOException
close in interface AutoCloseableIOExceptionpublic File getFile()
public void setFile(File file)
public void filterChunks(Map<Path,List<Long>> chunkStartTimes)
public void writePlanIndices()
throws IOException
IOExceptionpublic void truncate(long offset)
throws IOException
IOExceptionpublic TsFileOutput getIOWriterOut()
public Map<String,List<TimeseriesMetadata>> getDeviceTimeseriesMetadataMap()
public long getMinPlanIndex()
public void setMinPlanIndex(long minPlanIndex)
public long getMaxPlanIndex()
public void setMaxPlanIndex(long maxPlanIndex)
Copyright © 2022 The Apache Software Foundation. All rights reserved.