flush(), and never
inserts loose objects.
| Modifier and Type | Class and Description |
|---|---|
| private class | PackInserter.
Stream that writes to a pack file. |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private Inflater | |
| private boolean | |
| private int | |
| private final ObjectDirectory | |
| private static final int | INDEX_VERSION
Always produce version 2 indexes, to get CRC data. |
| private List | |
| private ObjectIdOwnerMap | |
| private PackInserter. | |
| private PackConfig | |
| private boolean | |
| private File |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private long | |
| private void | |
| public void | checkExisting(boolean
if check)false, will write out possibly-duplicate objects
without first checking whether they exist in the repo; default
is true.Whether to check if objects exist in the repo |
| private void | |
| public void | close()
Implements abstract org. Implements java. Closes this resource, relinquishing any underlying resources. |
| private ObjectId | |
| private ObjectId | |
| public void | flush()
Implements abstract org. Make all inserted objects visible. |
| pack-priv int | |
| private static File | |
| private Inflater | |
| public ObjectId | insert(int
type code of the object to store. type, byte[] complete content of the object. data, int first position within off, int data.number of bytes to copy from len)data.Overrides org. Insert a single object into the store, returning its unique name. |
| public ObjectId | insert(int
type code of the object to store. type, long number of bytes to copy from len, InputStream in.stream providing the object content. The caller is responsible
for closing the stream. in)Implements abstract org. Insert a single object into the store, returning its unique name. |
| 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. Initialize a parser to read from a pack formatted stream. |
| public ObjectReader | newReader()
Implements abstract org. Open a reader for objects that may have been written by this inserter. |
| public void | setCompressionLevel(int
compression level for zlib deflater. compression)Set compression level for zlib deflater. |
| private static int | |
| private static void |
| cachedInflater | back to summary |
|---|---|
| private Inflater cachedInflater | |
| checkExisting | back to summary |
|---|---|
| private boolean checkExisting | |
| compression | back to summary |
|---|---|
| private int compression | |
| db | back to summary |
|---|---|
| private final ObjectDirectory db | |
| INDEX_VERSION | back to summary |
|---|---|
| private static final int INDEX_VERSION Always produce version 2 indexes, to get CRC data. | |
| objectList | back to summary |
|---|---|
| private List<PackedObjectInfo> objectList | |
| objectMap | back to summary |
|---|---|
| private ObjectIdOwnerMap<PackedObjectInfo> objectMap | |
| packOut | back to summary |
|---|---|
| private PackInserter. | |
| pconfig | back to summary |
|---|---|
| private PackConfig pconfig | |
| rollback | back to summary |
|---|---|
| private boolean rollback | |
| tmpPack | back to summary |
|---|---|
| private File tmpPack | |
| PackInserter | back to summary |
|---|---|
| pack-priv PackInserter(ObjectDirectory db) | |
| beginObject | back to summary |
|---|---|
| private long beginObject(int type, long len) throws IOException | |
| beginPack | back to summary |
|---|---|
| private void beginPack() throws IOException | |
| checkExisting | back to summary |
|---|---|
| public void checkExisting(boolean check) Whether to check if objects exist in the repo
| |
| clear | back to summary |
|---|---|
| private void clear() | |
| close | back to summary |
|---|---|
| public void close() Implements abstract org. Implements java. Doc from org. Closes this resource, relinquishing any underlying resources.
This method is invoked automatically on objects managed by the
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.
| |
| computeName | back to summary |
|---|---|
| private ObjectId computeName(List<PackedObjectInfo> list) | |
| endObject | back to summary |
|---|---|
| private ObjectId endObject(ObjectId id, long offset) | |
| flush | back to summary |
|---|---|
| public void flush() throws IOException Implements abstract org. Doc from org. Make all inserted objects visible. The flush may take some period of time to make the objects available to other threads.
| |
| getBufferSize | back to summary |
|---|---|
| pack-priv int getBufferSize() | |
| idxFor | back to summary |
|---|---|
| private static File idxFor(File packFile) | |
| inflater | back to summary |
|---|---|
| private Inflater inflater() | |
| insert | back to summary |
|---|---|
| public ObjectId insert(int type, byte[] data, int off, int len) throws IOException Overrides org. Doc from org. Insert a single object into the store, returning its unique name.
| |
| insert | back to summary |
|---|---|
| public ObjectId insert(int type, long len, InputStream in) throws IOException Implements abstract org. Doc from org. Insert a single object into the store, returning its unique name.
| |
| newPackParser | back to summary |
|---|---|
| public PackParser newPackParser(InputStream in) Implements abstract org. Doc from org. Initialize a parser to read from a pack formatted stream.
| |
| newReader | back to summary |
|---|---|
| public ObjectReader newReader() Implements abstract org. Doc from org. 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
The returned reader should return this inserter instance from
Behavior is undefined if an insert method is called on the inserter in the
middle of reading from an
| |
| setCompressionLevel | back to summary |
|---|---|
| public void setCompressionLevel(int compression) Set compression level for zlib deflater.
| |
| writePackHeader | back to summary |
|---|---|
| private static int writePackHeader(byte[] buf, int objectCount) | |
| writePackIndex | back to summary |
|---|---|
| private static void writePackIndex(File idx, byte[] packHash, List<PackedObjectInfo> list) throws IOException | |
Backed by two views of the same open file descriptor: a random-access file, and an output stream. Seeking in the file causes subsequent writes to the output stream to occur wherever the file pointer is pointing, so we need to take care to always seek to the end of the file before writing a new object.
Callers should always use seek(long) to seek, rather than reaching
into the file member. As long as this contract is followed, calls to write(byte[], int, int) are guaranteed to write at the end of the file,
even if there have been intermediate seeks.
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| pack-priv final DeflaterOutputStream | |
| pack-priv final CRC32 | |
| private final Deflater | |
| private final RandomAccessFile | |
| pack-priv final byte[] | |
| private final CountingOutputStream |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| public void | close()
Overrides java. Implements java. Closes this output stream and releases any system resources associated with this stream. |
| private int | |
| pack-priv byte[] | |
| pack-priv long | |
| pack-priv byte[] | |
| pack-priv void | |
| private int | |
| public void | write(int
the b)byte.Implements abstract java. Writes the specified byte to this output stream. |
| public void | write(byte[]
the data. data, int the start offset in the data. off, int the number of bytes to write. len)Overrides java. Writes |
| atEnd | back to summary |
|---|---|
| private boolean atEnd | |
| compress | back to summary |
|---|---|
| pack-priv final DeflaterOutputStream compress | |
| crc32 | back to summary |
|---|---|
| pack-priv final CRC32 crc32 | |
| deflater | back to summary |
|---|---|
| private final Deflater deflater | |
| file | back to summary |
|---|---|
| private final RandomAccessFile file | |
| hdrBuf | back to summary |
|---|---|
| pack-priv final byte[] hdrBuf | |
| out | back to summary |
|---|---|
| private final CountingOutputStream out | |
| PackStream | back to summary |
|---|---|
| pack-priv PackStream(File pack) throws IOException | |
| beginObject | back to summary |
|---|---|
| pack-priv void beginObject(int objectType, long length) throws IOException | |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this output stream and releases any system resources
associated with this stream. The general contract of
| |
| encodeTypeSize | back to summary |
|---|---|
| private int encodeTypeSize(int type, long rawLength) | |
| finishPack | back to summary |
|---|---|
| pack-priv byte[] finishPack() throws IOException | |
| getOffset | back to summary |
|---|---|
| pack-priv long getOffset() | |
| inflate | back to summary |
|---|---|
| pack-priv byte[] inflate(long filePos, int len) throws IOException, DataFormatException | |
| seek | back to summary |
|---|---|
| pack-priv void seek(long offset) throws IOException | |
| setInput | back to summary |
|---|---|
| private int setInput(long filePos, Inflater inf, byte[] buf) throws IOException | |
| write | back to summary |
|---|---|
| public void write(int b) throws IOException Implements abstract java. Doc from java. Writes the specified byte to this output stream. The general
contract for
| |
| write | back to summary |
|---|---|
| public void write(byte[] data, int off, int len) throws IOException Overrides java. Doc from java. Writes
If
If
| |
| Modifier and Type | Class and Description |
|---|---|
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private final ObjectReader |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements abstract org. Implements java. Closes this resource, relinquishing any underlying resources. |
| public ObjectInserter | getCreatedFromInserter()
Overrides org. Get the |
| public Set | getShallowCommits()
Implements abstract org. Returns IDs for those commits which should be considered as shallow. |
| private byte[] | |
| public ObjectReader | newReader()
Implements abstract org. Construct a new reader from the same data. |
| public ObjectLoader | open(AnyObjectId
identity of the object to open. objectId, int hint about the type of object being requested, e.g.
typeHint)org.;
OBJ_ANY if the object type is not known, or does not
matter to the caller.Implements abstract org. Open an object from this database. |
| public Collection | resolve(AbbreviatedObjectId
abbreviated id to resolve to a complete identity. The
abbreviation must have a length of at least 2. id)Implements abstract org. Resolve an abbreviated ObjectId to its full form. |
| ctx | back to summary |
|---|---|
| private final ObjectReader ctx | |
| Reader | back to summary |
|---|---|
| private Reader() | |
| close | back to summary |
|---|---|
| public void close() Implements abstract org. Implements java. Doc from org. Closes this resource, relinquishing any underlying resources.
This method is invoked automatically on objects managed by the
Release any resources used by this reader. A reader that has been released can be used again, but may need to be released after the subsequent usage.
| |
| getCreatedFromInserter | back to summary |
|---|---|
| public ObjectInserter getCreatedFromInserter() Overrides org. Doc from org. Get the
| |
| getShallowCommits | back to summary |
|---|---|
| public Set Implements abstract org. Doc from org. Returns IDs for those commits which should be considered as shallow.
| |
| inflate | back to summary |
|---|---|
| private byte[] inflate(PackedObjectInfo obj, long zpos, int sz) throws IOException, CorruptObjectException | |
| newReader | back to summary |
|---|---|
| public ObjectReader newReader() Implements abstract org. Doc from org. Construct a new reader from the same data. Applications can use this method to build a new reader from the same data source, but for an different thread.
| |
| open | back to summary |
|---|---|
| public ObjectLoader open(AnyObjectId objectId, int typeHint) throws MissingObjectException, IncorrectObjectTypeException, IOException Implements abstract org. Doc from org. Open an object from this database.
| |
| resolve | back to summary |
|---|---|
| public Collection Implements abstract org. Doc from org. Resolve an abbreviated ObjectId to its full form. This method searches for an ObjectId that begins with the abbreviation, and returns at least some matching candidates. If the returned collection is empty, no objects start with this abbreviation. The abbreviation doesn't belong to this repository, or the repository lacks the necessary objects to complete it. If the collection contains exactly one member, the abbreviation is (currently) unique within this database. There is a reasonably high probability that the returned id is what was previously abbreviated. If the collection contains 2 or more members, the abbreviation is not unique. In this case the implementation is only required to return at least 2 candidates to signal the abbreviation has conflicts. User friendly implementations should return as many candidates as reasonably possible, as the caller may be able to disambiguate further based on context. However since databases can be very large (e.g. 10 million objects) returning 625,000 candidates for the abbreviation "0" is simply unreasonable, so implementors should draw the line at around 256 matches.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final long | |
| private final long | |
| private final int |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public byte[] | getCachedBytes()
Implements abstract org. Obtain a reference to the (possibly cached) bytes of this object. |
| public long | |
| public int | |
| public ObjectStream | openStream()
Implements abstract org. Obtain an input stream to read this object's data. |
| pos | back to summary |
|---|---|
| private final long pos | |
| size | back to summary |
|---|---|
| private final long size | |
| type | back to summary |
|---|---|
| private final int type | |
| StreamLoader | back to summary |
|---|---|
| pack-priv StreamLoader(int type, long size, long pos) | |
| getCachedBytes | back to summary |
|---|---|
| public byte[] getCachedBytes() throws LargeObjectException Implements abstract org. Doc from org. Obtain a reference to the (possibly cached) bytes of this object. This method offers direct access to the internal caches, potentially saving on data copies between the internal cache and higher level code. Callers who receive this reference must not modify its contents. Changes (if made) will affect the cache but not the repository itself.
| |
| getSize | back to summary |
|---|---|
| public long getSize() Implements abstract org. Doc from org. Get size of object in bytes
| |
| getType | back to summary |
|---|---|
| public int getType() Implements abstract org. Doc from org. Get Git in pack object type
| |
| openStream | back to summary |
|---|---|
| public ObjectStream openStream() throws MissingObjectException, IOException Implements abstract org. Doc from org. Obtain an input stream to read this object's data.
| |