Class DfsInserter
- java.lang.Object
-
- org.eclipse.jgit.lib.ObjectInserter
-
- org.eclipse.jgit.internal.storage.dfs.DfsInserter
-
public class DfsInserter extends ObjectInserter
Inserts objects into the DFS.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.jgit.lib.ObjectInserter
ObjectInserter.Filter, ObjectInserter.Formatter
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDfsInserter(DfsObjDatabase db)Initialize a new inserter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidflush()Make all inserted objects visible.ObjectIdinsert(int type, byte[] data, int off, int len)Insert a single object into the store, returning its unique name.ObjectIdinsert(int type, long len, InputStream in)Insert a single object into the store, returning its unique name.DfsPackParsernewPackParser(InputStream in)Initialize a parser to read from a pack formatted stream.ObjectReadernewReader()Open a reader for objects that may have been written by this inserter.voidrelease()Release any resources used by this inserter.
-
-
-
Constructor Detail
-
DfsInserter
protected DfsInserter(DfsObjDatabase db)
Initialize a new inserter.- Parameters:
db- database the inserter writes to.
-
-
Method Detail
-
newPackParser
public DfsPackParser newPackParser(InputStream in) throws IOException
Description copied from class:ObjectInserterInitialize a parser to read from a pack formatted stream.- Specified by:
newPackParserin classObjectInserter- Parameters:
in- the input stream. The stream is not closed by the parser, and must instead be closed by the caller once parsing is complete.- Returns:
- the pack parser.
- Throws:
IOException- the parser instance, which can be configured and then used to parse objects into the ObjectDatabase.
-
newReader
public ObjectReader newReader()
Description copied from class:ObjectInserterOpen a reader for objects that may have been written by this inserter.The returned reader allows the calling thread to read back recently inserted objects without first calling
flush()to make them visible to the repository. The returned reader should only be used from the same thread as the inserter. Objects written by this inserter may not be visible tothis.newReader().newReader().- Specified by:
newReaderin classObjectInserter- Returns:
- reader for any object, including an object recently inserted by this inserter since the last flush.
-
insert
public ObjectId insert(int type, byte[] data, int off, int len) throws IOException
Description copied from class:ObjectInserterInsert a single object into the store, returning its unique name.- Overrides:
insertin classObjectInserter- Parameters:
type- type code of the object to store.data- complete content of the object.off- first position withindata.len- number of bytes to copy fromdata.- Returns:
- the name of the object.
- Throws:
IOException- the object could not be stored.
-
insert
public ObjectId insert(int type, long len, InputStream in) throws IOException
Description copied from class:ObjectInserterInsert a single object into the store, returning its unique name.- Specified by:
insertin classObjectInserter- Parameters:
type- type code of the object to store.len- number of bytes to copy fromin.in- stream providing the object content. The caller is responsible for closing the stream.- Returns:
- the name of the object.
- Throws:
IOException- the object could not be stored, or the source stream could not be read.
-
flush
public void flush() throws IOExceptionDescription copied from class:ObjectInserterMake all inserted objects visible.The flush may take some period of time to make the objects available to other threads.
- Specified by:
flushin classObjectInserter- Throws:
IOException- the flush could not be completed; objects inserted thus far are in an indeterminate state.
-
release
public void release()
Description copied from class:ObjectInserterRelease any resources used by this inserter.An inserter that has been released can be used again, but may need to be released after the subsequent usage.
- Specified by:
releasein classObjectInserter
-
-