Class LocalTsFileOutput
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.iotdb.tsfile.write.writer.LocalTsFileOutput
-
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,TsFileOutput
public class LocalTsFileOutput extends OutputStream implements TsFileOutput
a TsFileOutput implementation with FileOutputStream. If the file is not existed, it will be created. Otherwise the file will be written from position 0.
-
-
Constructor Summary
Constructors Constructor Description LocalTsFileOutput(FileOutputStream outputStream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()close the output.voidflush()the same withOutputStream.flush().voidforce()Make sure that the data in the buffer is flushed to disklonggetPosition()gets the current position of the Output.voidtruncate(long size)The same withFileChannel.truncate(long).OutputStreamwrapAsStream()convert this TsFileOutput as a outputstream.voidwrite(byte b)Writes 1 byte to this output at the current position.voidwrite(byte[] b)Writesb.lengthbytes from the specified byte array to this output at the current position.voidwrite(byte[] buf, int start, int offset)voidwrite(int b)voidwrite(ByteBuffer b)Writesb.remaining()bytes from the specified byte array to this output at the current position.
-
-
-
Constructor Detail
-
LocalTsFileOutput
public LocalTsFileOutput(FileOutputStream outputStream)
-
-
Method Detail
-
write
public void write(int b) throws IOException- Specified by:
writein classOutputStream- Throws:
IOException
-
write
public void write(byte[] b) throws IOExceptionDescription copied from interface:TsFileOutputWritesb.lengthbytes from the specified byte array to this output at the current position.- Specified by:
writein interfaceTsFileOutput- Overrides:
writein classOutputStream- Parameters:
b- the data.- Throws:
IOException- if an I/O error occurs.
-
write
public void write(byte b) throws IOExceptionDescription copied from interface:TsFileOutputWrites 1 byte to this output at the current position.- Specified by:
writein interfaceTsFileOutput- Parameters:
b- the data.- Throws:
IOException- if an I/O error occurs.
-
write
public void write(byte[] buf, int start, int offset) throws IOException- Overrides:
writein classOutputStream- Throws:
IOException
-
write
public void write(ByteBuffer b) throws IOException
Description copied from interface:TsFileOutputWritesb.remaining()bytes from the specified byte array to this output at the current position.- Specified by:
writein interfaceTsFileOutput- Parameters:
b- the data.- Throws:
IOException- if an I/O error occurs.
-
getPosition
public long getPosition()
Description copied from interface:TsFileOutputgets the current position of the Output. This method is usually used for recording where the data is.
For example, if the Output is a fileOutputStream, then getPosition returns its file position.- Specified by:
getPositionin interfaceTsFileOutput- Returns:
- current position
-
close
public void close() throws IOExceptionDescription copied from interface:TsFileOutputclose the output.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceTsFileOutput- Overrides:
closein classOutputStream- Throws:
IOException- if an I/O error occurs.
-
wrapAsStream
public OutputStream wrapAsStream()
Description copied from interface:TsFileOutputconvert this TsFileOutput as a outputstream.- Specified by:
wrapAsStreamin interfaceTsFileOutput- Returns:
- an output stream whose position is the same with this Output
-
flush
public void flush() throws IOExceptionDescription copied from interface:TsFileOutputthe same withOutputStream.flush().- Specified by:
flushin interfaceFlushable- Specified by:
flushin interfaceTsFileOutput- Overrides:
flushin classOutputStream- Throws:
IOException- if an I/O error occurs.
-
truncate
public void truncate(long size) throws IOExceptionDescription copied from interface:TsFileOutputThe same withFileChannel.truncate(long).- Specified by:
truncatein interfaceTsFileOutput- Parameters:
size- size The new size, a non-negative byte count- Throws:
IOException
-
force
public void force() throws IOExceptionDescription copied from interface:TsFileOutputMake sure that the data in the buffer is flushed to disk- Specified by:
forcein interfaceTsFileOutput- Throws:
IOException
-
-