public class ObjectToPack extends PackedObjectInfo
PackWriter
.
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.
Modifier and Type | Field and 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: deltaDepth
|
private 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 and Description |
---|
ObjectToPack(AnyObjectId src,
int type)
Construct for the specified object id.
|
Modifier and Type | Method and 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 pack
|
ObjectId |
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() |
getCRC, getOffset, setCRC, setOffset, setType
equals, fromRaw, fromRaw, fromRaw, fromRaw, fromString, fromString, isId, toObjectId, toString, zeroId
private static final int REUSE_AS_IS
private static final int DELTA_ATTEMPTED
private static final int DO_NOT_DELTA
private static final int EDGE
private static final int ATTEMPT_DELTA_MASK
private static final int TYPE_SHIFT
private static final int EXT_SHIFT
private static final int EXT_MASK
private static final int DELTA_SHIFT
private static final int NON_EXT_MASK
private static final int NON_DELTA_MASK
private ObjectId deltaBase
private int flags
private int pathHash
private DeltaCache.Ref cachedDelta
public ObjectToPack(AnyObjectId src, int type)
src
- object id of object for packingtype
- real type code of the object, not its in-pack type.public final ObjectId getDeltaBaseId()
public final ObjectToPack getDeltaBase()
final void setDeltaBase(ObjectId deltaBase)
PackWriter
to write object - determines its representation
in a created pack.deltaBase
- delta base object or null if object should be packed as a
whole object.final void setCachedDelta(DeltaCache.Ref data)
final DeltaCache.Ref popCachedDelta()
final void clearDeltaBase()
public final boolean isDeltaRepresentation()
public final boolean isWritten()
public final int getType()
getType
in class PackedObjectInfo
final int getDeltaDepth()
final void setDeltaDepth(int d)
final int getChainLength()
final void setChainLength(int len)
final void clearChainLength()
final boolean wantWrite()
final void markWantWrite()
public final boolean isReuseAsIs()
final void setReuseAsIs()
protected void clearReuseAsIs()
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.
final boolean isDoNotDelta()
final void setDoNotDelta()
final boolean isEdge()
final void setEdge()
final boolean doNotAttemptDelta()
final void setDeltaAttempted(boolean deltaAttempted)
protected final int getExtendedFlags()
protected final boolean isExtendedFlag(int flag)
getExtendedFlags()
and testing the result.flag
- the flag mask to test, must be between 0x0 and 0xf.protected final void setExtendedFlag(int flag)
flag
- the bits to set, must be between 0x0 and 0xf.protected final void clearExtendedFlag(int flag)
flag
- the bits to clear, must be between 0x0 and 0xf.protected final void setExtendedFlags(int extFlags)
extFlags
- additional flag bits to store in the flags field. Due to space
constraints only values [0x0, 0xf] are permitted.final int getFormat()
final int getWeight()
final void setWeight(int weight)
final int getPathHash()
final void setPathHash(int hc)
final int getCachedSize()
final void setCachedSize(int sz)
public void select(StoredObjectRepresentation ref)
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.
ref
- the object representation.public java.lang.String toString()
toString
in class AnyObjectId