Top Description Inners Fields Constructors Methods
org.eclipse.jgit.internal.storage.file

pack-priv Class ObjectDirectoryInserter

extends ObjectInserter
Class Inheritance
Imports
java.io.EOFException, .File, .FileOutputStream, .FilterOutputStream, .IOException, .InputStream, .OutputStream, java.nio.channels.Channels, java.text.MessageFormat, java.util.zip.Deflater, .DeflaterOutputStream, org.eclipse.jgit.errors.ObjectWritingException, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.lib.Config, .Constants, .ObjectId, .ObjectInserter, .ObjectReader, org.eclipse.jgit.transport.PackParser, org.eclipse.jgit.util.FileUtils, .IO, org.eclipse.jgit.util.sha1.SHA1

Creates loose objects in a ObjectDirectory.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final WriteConfig
private final FileObjectDatabase
private Deflater

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract org.eclipse.jgit.lib.ObjectInserter.close.

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

pack-priv DeflaterOutputStream
public void
flush()

Implements abstract org.eclipse.jgit.lib.ObjectInserter.flush.

Make all inserted objects visible.

public ObjectId
insert(int
type code of the object to store.
type
,
byte[]
complete content of the object.
data
,
int
first position within data.
off
,
int
number of bytes to copy from data.
len
)

Overrides org.eclipse.jgit.lib.ObjectInserter.insert.

Insert a single object into the store, returning its unique name.

private ObjectId

Returns:

ObjectId the name of the object
insert
(int
object type
type
,
byte[]
object data
data
,
int
first position within @{code data}
off
,
int
length number of bytes to copy
len
,
boolean
whether to insert a duplicate if an object with this id already exists
createDuplicate
)

Insert a loose object into the database.

public ObjectId
insert(int
type code of the object to store.
type
,
long
number of bytes to copy from in.
len
,
InputStream
stream providing the object content. The caller is responsible for closing the stream.
is
)

Implements abstract org.eclipse.jgit.lib.ObjectInserter.insert.

Insert a single object into the store, returning its unique name.

pack-priv ObjectId

Returns:

ObjectId the name of the object
insert
(int
object type
type
,
long
number of bytes to copy
len
,
InputStream
input stream
is
,
boolean
whether to insert a duplicate if an object with this id already exists
createDuplicate
)

Insert a loose object into the database.

private ObjectId
insertOneObject(File tmp, ObjectId id, boolean createDuplicate)

public PackParser
newPackParser(InputStream
the input stream. The stream is not closed by the parser, and must instead be closed by the caller once parsing is complete.
in
)

Implements abstract org.eclipse.jgit.lib.ObjectInserter.newPackParser.

Initialize a parser to read from a pack formatted stream.

public ObjectReader
newReader()

Implements abstract org.eclipse.jgit.lib.ObjectInserter.newReader.

Open a reader for objects that may have been written by this inserter.

pack-priv File
private static EOFException
shortInput(long missing)

private File
toTemp(final SHA1 md, final int type, long len, final InputStream is)

private File
toTemp(final int type, final byte[] buf, final int pos, final int len)

pack-priv void
writeHeader(OutputStream out, int type, long len)

Inherited from org.eclipse.jgit.lib.ObjectInserter:
bufferdigestidForidForidForidForinsertinsertinsertinsert

Field Detail

configback to summary
private final WriteConfig config
dbback to summary
private final FileObjectDatabase db
deflateback to summary
private Deflater deflate

Constructor Detail

ObjectDirectoryInserterback to summary
pack-priv ObjectDirectoryInserter(FileObjectDatabase dest, Config cfg)

Method Detail

closeback to summary
public void close()

Implements abstract org.eclipse.jgit.lib.ObjectInserter.close.

Implements java.lang.AutoCloseable.close.

Doc from org.eclipse.jgit.lib.ObjectInserter.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

Release 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.

Annotations
@Override
compressback to summary
pack-priv DeflaterOutputStream compress(OutputStream out)
flushback to summary
public void flush() throws IOException

Implements abstract org.eclipse.jgit.lib.ObjectInserter.flush.

Doc from org.eclipse.jgit.lib.ObjectInserter.flush.

Make all inserted objects visible.

The flush may take some period of time to make the objects available to other threads.

Annotations
@Override
Exceptions
IOException:
the flush could not be completed; objects inserted thus far are in an indeterminate state.
insertback to summary
public ObjectId insert(int type, byte[] data, int off, int len) throws IOException

Overrides org.eclipse.jgit.lib.ObjectInserter.insert.

Doc from org.eclipse.jgit.lib.ObjectInserter.insert.

Insert a single object into the store, returning its unique name.

Parameters
type:int

type code of the object to store.

data:byte[]

complete content of the object.

off:int

first position within data.

len:int

number of bytes to copy from data.

Returns:ObjectId

the name of the object.

Annotations
@Override
Exceptions
IOException:
the object could not be stored.
insertback to summary
private ObjectId insert(int type, byte[] data, int off, int len, boolean createDuplicate) throws IOException

Insert a loose object into the database. If createDuplicate is true, write the loose object even if we already have it in the loose or packed ODB.

Parameters
type:int

object type

data:byte[]

object data

off:int

first position within @{code data}

len:int

length number of bytes to copy

createDuplicate:boolean

whether to insert a duplicate if an object with this id already exists

Returns:ObjectId

ObjectId the name of the object

Exceptions
IOException:
if an IO error occurred
insertback to summary
public ObjectId insert(int type, long len, InputStream is) throws IOException

Implements abstract org.eclipse.jgit.lib.ObjectInserter.insert.

Doc from org.eclipse.jgit.lib.ObjectInserter.insert.

Insert a single object into the store, returning its unique name.

Parameters
type:int

type code of the object to store.

len:long

number of bytes to copy from in.

is:InputStream

stream providing the object content. The caller is responsible for closing the stream.

Returns:ObjectId

the name of the object.

Annotations
@Override
Exceptions
IOException:
the object could not be stored, or the source stream could not be read.
insertback to summary
pack-priv ObjectId insert(int type, long len, InputStream is, boolean createDuplicate) throws IOException

Insert a loose object into the database. If createDuplicate is true, write the loose object even if we already have it in the loose or packed ODB.

Parameters
type:int

object type

len:long

number of bytes to copy

is:InputStream

input stream

createDuplicate:boolean

whether to insert a duplicate if an object with this id already exists

Returns:ObjectId

ObjectId the name of the object

Exceptions
IOException:
if an IO error occurred
insertOneObjectback to summary
private ObjectId insertOneObject(File tmp, ObjectId id, boolean createDuplicate) throws IOException
newPackParserback to summary
public PackParser newPackParser(InputStream in) throws IOException

Implements abstract org.eclipse.jgit.lib.ObjectInserter.newPackParser.

Doc from org.eclipse.jgit.lib.ObjectInserter.newPackParser.

Initialize a parser to read from a pack formatted stream.

Parameters
in:InputStream

the input stream. The stream is not closed by the parser, and must instead be closed by the caller once parsing is complete.

Returns:PackParser

the pack parser.

Annotations
@Override
Exceptions
IOException:
the parser instance, which can be configured and then used to parse objects into the ObjectDatabase.
newReaderback to summary
public ObjectReader newReader()

Implements abstract org.eclipse.jgit.lib.ObjectInserter.newReader.

Doc from org.eclipse.jgit.lib.ObjectInserter.newReader.

Open 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 to this.newReader().newReader().

The returned reader should return this inserter instance from ObjectReader#getCreatedFromInserter().

Behavior is undefined if an insert method is called on the inserter in the middle of reading from an ObjectStream opened from this reader. For example, reading the remainder of the object may fail, or newly written data may even be corrupted. Interleaving whole object reads (including streaming reads) with inserts is fine, just not interleaving streaming partial object reads with inserts.

Returns:ObjectReader

reader for any object, including an object recently inserted by this inserter since the last flush.

Annotations
@Override
newTempFileback to summary
pack-priv File newTempFile() throws IOException
shortInputback to summary
private static EOFException shortInput(long missing)
toTempback to summary
private File toTemp(final SHA1 md, final int type, long len, final InputStream is) throws IOException
toTempback to summary
private File toTemp(final int type, final byte[] buf, final int pos, final int len) throws IOException
writeHeaderback to summary
pack-priv void writeHeader(OutputStream out, int type, long len) throws IOException
org.eclipse.jgit.internal.storage.file back to summary

private Class ObjectDirectoryInserter.SHA1OutputStream

extends FilterOutputStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final SHA1
Inherited from java.io.FilterOutputStream:
out

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
write(int
the byte.
b
)

Overrides java.io.FilterOutputStream.write.

Writes the specified byte to this output stream.

public void
write(byte[]
the data.
in
,
int
the start offset in the data.
p
,
int
the number of bytes to write.
n
)

Overrides java.io.FilterOutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.

Inherited from java.io.FilterOutputStream:
closeflushwrite

Field Detail

mdback to summary
private final SHA1 md

Constructor Detail

SHA1OutputStreamback to summary
pack-priv SHA1OutputStream(OutputStream out, SHA1 md)

Method Detail

writeback to summary
public void write(int b) throws IOException

Overrides java.io.FilterOutputStream.write.

Doc from java.io.FilterOutputStream.write.

Writes the specified byte to this output stream.

The write method of FilterOutputStream calls the write method of its underlying output stream, that is, it performs out.write(b).

Implements the abstract write method of OutputStream.

Parameters
b:int

the byte.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
writeback to summary
public void write(byte[] in, int p, int n) throws IOException

Overrides java.io.FilterOutputStream.write.

Doc from java.io.FilterOutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.

Parameters
in:byte[]

the data.

p:int

the start offset in the data.

n:int

the number of bytes to write.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.