@ -108,6 +108,7 @@ public class ReftableWriter {
private long minUpdateIndex ;
private long maxUpdateIndex ;
private OutputStream outputStream ;
private ReftableOutputStream out ;
private ObjectIdSubclassMap < RefList > obj2ref ;
@ -136,7 +137,20 @@ public class ReftableWriter {
* configuration for the writer .
* /
public ReftableWriter ( ReftableConfig cfg ) {
this ( cfg , null ) ;
}
/ * *
* Initialize a writer with a configuration .
*
* @param cfg
* configuration for the writer
* @param os
* output stream . Do not supply a stream to begin ( ) on this writer .
* /
public ReftableWriter ( ReftableConfig cfg , @Nullable OutputStream os ) {
config = cfg ;
outputStream = os ;
}
/ * *
@ -183,16 +197,32 @@ public class ReftableWriter {
}
/ * *
* Begin writing the reftable .
* Begin writing the reftable . Should be called only once .
*
* @param os
* stream to write the table to . Caller is responsible for
* closing the stream after invoking { @link # finish ( ) } .
* @return { @code this }
* @throws java . io . IOException
* if reftable header cannot be written .
* /
public ReftableWriter begin ( OutputStream os ) throws IOException {
public ReftableWriter begin ( OutputStream os ) {
if ( outputStream ! = null ) {
throw new IllegalStateException ( "begin() called twice." ) ; //$NON-NLS-1$
}
outputStream = os ;
return begin ( ) ;
}
/ * *
* Begin writing the reftable . Should be called only once . Call this
* if a stream was passed to the constructor .
*
* @return { @code this }
* /
public ReftableWriter begin ( ) {
if ( out ! = null ) {
throw new IllegalStateException ( "begin() called twice." ) ; //$NON-NLS-1$
}
refBlockSize = config . getRefBlockSize ( ) ;
logBlockSize = config . getLogBlockSize ( ) ;
restartInterval = config . getRestartInterval ( ) ;
@ -212,7 +242,7 @@ public class ReftableWriter {
restartInterval = refBlockSize < ( 60 < < 10 ) ? 16 : 64 ;
}
out = new ReftableOutputStream ( os , refBlockSize , alignBlocks ) ;
out = new ReftableOutputStream ( outputStream , refBlockSize , alignBlocks ) ;
refs = new Section ( REF_BLOCK_TYPE ) ;
if ( indexObjects ) {
obj2ref = new ObjectIdSubclassMap < > ( ) ;