Class ObjectToPack
- java.lang.Object
-
- org.eclipse.jgit.lib.AnyObjectId
-
- org.eclipse.jgit.lib.ObjectId
-
- org.eclipse.jgit.lib.ObjectIdOwnerMap.Entry
-
- org.eclipse.jgit.transport.PackedObjectInfo
-
- org.eclipse.jgit.internal.storage.pack.ObjectToPack
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<AnyObjectId>
- Direct Known Subclasses:
DfsObjectToPack
,LocalObjectToPack
public class ObjectToPack extends PackedObjectInfo
Per-object state used byPackWriter
.PackWriter
uses this class to track the things it needs to include in the newly generated pack file, and how to efficiently obtain the raw data for each object as they are written to the output stream.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static int
ATTEMPT_DELTA_MASK
private DeltaCache.Ref
cachedDelta
If present, deflated delta instruction stream for this object.private static int
DELTA_ATTEMPTED
private static int
DELTA_SHIFT
private ObjectId
deltaBase
Other object being packed that this will delta against.private static int
DO_NOT_DELTA
private static int
EDGE
private static int
EXT_MASK
private static int
EXT_SHIFT
private int
flags
Bit field, from bit 0 to bit 31: 1 bit: canReuseAsIs 1 bit: deltaAttempted 1 bit: doNotDelta 1 bit: edgeObject 1 bit: unused 3 bits: type 4 bits: subclass flags (if any) -- 20 bits: deltaDepthprivate static int
NON_DELTA_MASK
private static int
NON_EXT_MASK
private int
pathHash
Hash of the object's tree path.private static int
REUSE_AS_IS
private static int
TYPE_SHIFT
-
Constructor Summary
Constructors Constructor Description ObjectToPack(AnyObjectId src, int type)
Construct for the specified object id.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
clearChainLength()
(package private) void
clearDeltaBase()
protected void
clearExtendedFlag(int flag)
Clear an extended flag bit.protected void
clearReuseAsIs()
Forget the reuse information previously stored.(package private) boolean
doNotAttemptDelta()
(package private) int
getCachedSize()
(package private) int
getChainLength()
ObjectToPack
getDeltaBase()
Get delta base object to pack if object is going to be packed in delta representation and delta is specified as object to packObjectId
getDeltaBaseId()
Get delta base object id if object is going to be packed in delta representation(package private) int
getDeltaDepth()
protected int
getExtendedFlags()
Get the extended flags on this object, in the range [0x0, 0xf].(package private) int
getFormat()
(package private) int
getPathHash()
int
getType()
Get the object type.(package private) int
getWeight()
boolean
isDeltaRepresentation()
Whether object is going to be written as delta(package private) boolean
isDoNotDelta()
(package private) boolean
isEdge()
protected boolean
isExtendedFlag(int flag)
Determine if a particular extended flag bit has been set.boolean
isReuseAsIs()
Whether an existing representation was selected to be reused as-is into the pack stream.boolean
isWritten()
Check if object is already written in a pack.(package private) void
markWantWrite()
(package private) DeltaCache.Ref
popCachedDelta()
void
select(StoredObjectRepresentation ref)
Remember a specific representation for reuse at a later time.(package private) void
setCachedDelta(DeltaCache.Ref data)
(package private) void
setCachedSize(int sz)
(package private) void
setChainLength(int len)
(package private) void
setDeltaAttempted(boolean deltaAttempted)
(package private) void
setDeltaBase(ObjectId deltaBase)
Set delta base for the object.(package private) void
setDeltaDepth(int d)
(package private) void
setDoNotDelta()
(package private) void
setEdge()
protected void
setExtendedFlag(int flag)
Set an extended flag bit.protected void
setExtendedFlags(int extFlags)
Set the extended flags used by the subclass.(package private) void
setPathHash(int hc)
(package private) void
setReuseAsIs()
(package private) void
setWeight(int weight)
java.lang.String
toString()
(package private) boolean
wantWrite()
-
Methods inherited from class org.eclipse.jgit.transport.PackedObjectInfo
getCRC, getOffset, setCRC, setOffset, setType
-
Methods inherited from class org.eclipse.jgit.lib.ObjectId
equals, fromRaw, fromRaw, fromRaw, fromRaw, fromString, fromString, isId, toObjectId, toString, zeroId
-
-
-
-
Field Detail
-
REUSE_AS_IS
private static final int REUSE_AS_IS
- See Also:
- Constant Field Values
-
DELTA_ATTEMPTED
private static final int DELTA_ATTEMPTED
- See Also:
- Constant Field Values
-
DO_NOT_DELTA
private static final int DO_NOT_DELTA
- See Also:
- Constant Field Values
-
EDGE
private static final int EDGE
- See Also:
- Constant Field Values
-
ATTEMPT_DELTA_MASK
private static final int ATTEMPT_DELTA_MASK
- See Also:
- Constant Field Values
-
TYPE_SHIFT
private static final int TYPE_SHIFT
- See Also:
- Constant Field Values
-
EXT_SHIFT
private static final int EXT_SHIFT
- See Also:
- Constant Field Values
-
EXT_MASK
private static final int EXT_MASK
- See Also:
- Constant Field Values
-
DELTA_SHIFT
private static final int DELTA_SHIFT
- See Also:
- Constant Field Values
-
NON_EXT_MASK
private static final int NON_EXT_MASK
- See Also:
- Constant Field Values
-
NON_DELTA_MASK
private static final int NON_DELTA_MASK
- See Also:
- Constant Field Values
-
deltaBase
private ObjectId deltaBase
Other object being packed that this will delta against.
-
flags
private int flags
Bit field, from bit 0 to bit 31:- 1 bit: canReuseAsIs
- 1 bit: deltaAttempted
- 1 bit: doNotDelta
- 1 bit: edgeObject
- 1 bit: unused
- 3 bits: type
- 4 bits: subclass flags (if any)
- --
- 20 bits: deltaDepth
-
pathHash
private int pathHash
Hash of the object's tree path.
-
cachedDelta
private DeltaCache.Ref cachedDelta
If present, deflated delta instruction stream for this object.
-
-
Constructor Detail
-
ObjectToPack
public ObjectToPack(AnyObjectId src, int type)
Construct for the specified object id.- Parameters:
src
- object id of object for packingtype
- real type code of the object, not its in-pack type.
-
-
Method Detail
-
getDeltaBaseId
public final ObjectId getDeltaBaseId()
Get delta base object id if object is going to be packed in delta representation- Returns:
- delta base object id if object is going to be packed in delta representation; null otherwise - if going to be packed as a whole object.
-
getDeltaBase
public final ObjectToPack getDeltaBase()
Get delta base object to pack if object is going to be packed in delta representation and delta is specified as object to pack- Returns:
- delta base object to pack if object is going to be packed in delta representation and delta is specified as object to pack; null otherwise - if going to be packed as a whole object or delta base is specified only as id.
-
setDeltaBase
final void setDeltaBase(ObjectId deltaBase)
Set delta base for the object. Delta base set by this method is used byPackWriter
to write object - determines its representation in a created pack.- Parameters:
deltaBase
- delta base object or null if object should be packed as a whole object.
-
setCachedDelta
final void setCachedDelta(DeltaCache.Ref data)
-
popCachedDelta
final DeltaCache.Ref popCachedDelta()
-
clearDeltaBase
final void clearDeltaBase()
-
isDeltaRepresentation
public final boolean isDeltaRepresentation()
Whether object is going to be written as delta- Returns:
- true if object is going to be written as delta; false otherwise.
-
isWritten
public final boolean isWritten()
Check if object is already written in a pack. This information is used to achieve delta-base precedence in a pack file.- Returns:
- true if object is already written; false otherwise.
-
getType
public final int getType()
Get the object type.- Overrides:
getType
in classPackedObjectInfo
- Returns:
- the object type. The default type is OBJ_BAD, which is considered as unknown or invalid type.
-
getDeltaDepth
final int getDeltaDepth()
-
setDeltaDepth
final void setDeltaDepth(int d)
-
getChainLength
final int getChainLength()
-
setChainLength
final void setChainLength(int len)
-
clearChainLength
final void clearChainLength()
-
wantWrite
final boolean wantWrite()
-
markWantWrite
final void markWantWrite()
-
isReuseAsIs
public final boolean isReuseAsIs()
Whether an existing representation was selected to be reused as-is into the pack stream.- Returns:
- true if an existing representation was selected to be reused as-is into the pack stream.
-
setReuseAsIs
final void setReuseAsIs()
-
clearReuseAsIs
protected void clearReuseAsIs()
Forget the reuse information previously stored.Implementations may subclass this method, but they must also invoke the super version with
super.clearReuseAsIs()
to ensure the flag is properly cleared for the writer.
-
isDoNotDelta
final boolean isDoNotDelta()
-
setDoNotDelta
final void setDoNotDelta()
-
isEdge
final boolean isEdge()
-
setEdge
final void setEdge()
-
doNotAttemptDelta
final boolean doNotAttemptDelta()
-
setDeltaAttempted
final void setDeltaAttempted(boolean deltaAttempted)
-
getExtendedFlags
protected final int getExtendedFlags()
Get the extended flags on this object, in the range [0x0, 0xf].- Returns:
- the extended flags on this object, in the range [0x0, 0xf].
-
isExtendedFlag
protected final boolean isExtendedFlag(int flag)
Determine if a particular extended flag bit has been set. This implementation may be faster than callinggetExtendedFlags()
and testing the result.- Parameters:
flag
- the flag mask to test, must be between 0x0 and 0xf.- Returns:
- true if any of the bits matching the mask are non-zero.
-
setExtendedFlag
protected final void setExtendedFlag(int flag)
Set an extended flag bit. This implementation is more efficient than getting the extended flags, adding the bit, and setting them all back.- Parameters:
flag
- the bits to set, must be between 0x0 and 0xf.
-
clearExtendedFlag
protected final void clearExtendedFlag(int flag)
Clear an extended flag bit. This implementation is more efficient than getting the extended flags, removing the bit, and setting them all back.- Parameters:
flag
- the bits to clear, must be between 0x0 and 0xf.
-
setExtendedFlags
protected final void setExtendedFlags(int extFlags)
Set the extended flags used by the subclass. Subclass implementations may store up to 4 bits of information inside of the internal flags field already used by the base ObjectToPack instance.- Parameters:
extFlags
- additional flag bits to store in the flags field. Due to space constraints only values [0x0, 0xf] are permitted.
-
getFormat
final int getFormat()
-
getWeight
final int getWeight()
-
setWeight
final void setWeight(int weight)
-
getPathHash
final int getPathHash()
-
setPathHash
final void setPathHash(int hc)
-
getCachedSize
final int getCachedSize()
-
setCachedSize
final void setCachedSize(int sz)
-
select
public void select(StoredObjectRepresentation ref)
Remember a specific representation for reuse at a later time.Implementers should remember the representation chosen, so it can be reused at a later time.
PackWriter
may invoke this method multiple times for the same object, each time saving the current best representation found.- Parameters:
ref
- the object representation.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classAnyObjectId
-
-