Top Description Fields Constructors Methods
org.eclipse.jgit.internal.storage.pack

public Class ObjectToPack

extends PackedObjectInfo
Class Inheritance
Known Direct Subclasses
org.eclipse.jgit.internal.storage.dfs.DfsObjectToPack, org.eclipse.jgit.internal.storage.file.LocalObjectToPack
Imports
org.eclipse.jgit.lib.AnyObjectId, .Constants, .ObjectId, org.eclipse.jgit.transport.PackedObjectInfo

Per-object state used by org.eclipse.jgit.internal.storage.pack.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.

Field Summary

Modifier and TypeField and Description
private static final int
private DeltaCache.Ref
cachedDelta

If present, deflated delta instruction stream for this object.

private static final int
private static final int
private ObjectId
deltaBase

Other object being packed that this will delta against.

private static final int
private static final int
private static final int
private static final int
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 final int
private static final int
private int
pathHash

Hash of the object's tree path.

private static final int
private static final int

Constructor Summary

AccessConstructor and Description
public
ObjectToPack(AnyObjectId
object id of object for packing
src
,
int
real type code of the object, not its in-pack type.
type
)

Construct for the specified object id.

Method Summary

Modifier and TypeMethod and Description
pack-priv final void
pack-priv final void
protected final void
clearExtendedFlag(int
the bits to clear, must be between 0x0 and 0xf.
flag
)

Clear an extended flag bit.

protected void
clearReuseAsIs()

Forget the reuse information previously stored.

pack-priv final boolean
pack-priv final int
pack-priv final int
public final ObjectToPack

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

public final ObjectId

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.
getDeltaBaseId
()

Get delta base object id if object is going to be packed in delta representation

pack-priv final int
protected final int

Returns:

the extended flags on this object, in the range [0x0, 0xf].
getExtendedFlags
()

Get the extended flags on this object, in the range [0x0, 0xf].

pack-priv final int
pack-priv final int
public final int
pack-priv final int
public final boolean

Returns:

true if object is going to be written as delta; false otherwise.
isDeltaRepresentation
()

Whether object is going to be written as delta

pack-priv final boolean
pack-priv final boolean
protected final boolean

Returns:

true if any of the bits matching the mask are non-zero.
isExtendedFlag
(int
the flag mask to test, must be between 0x0 and 0xf.
flag
)

Determine if a particular extended flag bit has been set.

public final boolean

Returns:

true if an existing representation was selected to be reused as-is into the pack stream.
isReuseAsIs
()

Whether an existing representation was selected to be reused as-is into the pack stream.

public final boolean

Returns:

true if object is already written; false otherwise.
isWritten
()

Check if object is already written in a pack.

pack-priv final void
pack-priv final DeltaCache.Ref
public void
select(StoredObjectRepresentation
the object representation.
ref
)

Remember a specific representation for reuse at a later time.

pack-priv final void
pack-priv final void
setCachedSize(int sz)

pack-priv final void
setChainLength(int len)

pack-priv final void
setDeltaAttempted(boolean deltaAttempted)

pack-priv final void
setDeltaBase(ObjectId
delta base object or null if object should be packed as a whole object.
deltaBase
)

Set delta base for the object.

pack-priv final void
pack-priv final void
pack-priv final void
protected final void
setExtendedFlag(int
the bits to set, must be between 0x0 and 0xf.
flag
)

Set an extended flag bit.

protected final void
setExtendedFlags(int
additional flag bits to store in the flags field. Due to space constraints only values [0x0, 0xf] are permitted.
extFlags
)

Set the extended flags used by the subclass.

pack-priv final void
setPathHash(int hc)

pack-priv final void
pack-priv final void
setWeight(int weight)

public String
toString()

Overrides org.eclipse.jgit.lib.AnyObjectId.toString.

Returns a string representation of the object.

pack-priv final boolean
Inherited from org.eclipse.jgit.transport.PackedObjectInfo:
getCRCgetFullSizegetOffsetsetCRCsetFullSizesetOffsetsetType

Field Detail

ATTEMPT_DELTA_MASKback to summary
private static final int ATTEMPT_DELTA_MASK
cachedDeltaback to summary
private DeltaCache.Ref cachedDelta

If present, deflated delta instruction stream for this object.

DELTA_ATTEMPTEDback to summary
private static final int DELTA_ATTEMPTED
DELTA_SHIFTback to summary
private static final int DELTA_SHIFT
deltaBaseback to summary
private ObjectId deltaBase

Other object being packed that this will delta against.

DO_NOT_DELTAback to summary
private static final int DO_NOT_DELTA
EDGEback to summary
private static final int EDGE
EXT_MASKback to summary
private static final int EXT_MASK
EXT_SHIFTback to summary
private static final int EXT_SHIFT
flagsback to summary
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
NON_DELTA_MASKback to summary
private static final int NON_DELTA_MASK
NON_EXT_MASKback to summary
private static final int NON_EXT_MASK
pathHashback to summary
private int pathHash

Hash of the object's tree path.

REUSE_AS_ISback to summary
private static final int REUSE_AS_IS
TYPE_SHIFTback to summary
private static final int TYPE_SHIFT

Constructor Detail

ObjectToPackback to summary
public ObjectToPack(AnyObjectId src, int type)

Construct for the specified object id.

Parameters
src:AnyObjectId

object id of object for packing

type:int

real type code of the object, not its in-pack type.

Method Detail

clearChainLengthback to summary
pack-priv final void clearChainLength()
clearDeltaBaseback to summary
pack-priv final void clearDeltaBase()
clearExtendedFlagback to summary
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:int

the bits to clear, must be between 0x0 and 0xf.

clearReuseAsIsback to summary
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.

doNotAttemptDeltaback to summary
pack-priv final boolean doNotAttemptDelta()
getCachedSizeback to summary
pack-priv final int getCachedSize()
getChainLengthback to summary
pack-priv final int getChainLength()
getDeltaBaseback to summary
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:ObjectToPack

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.

getDeltaBaseIdback to summary
public final ObjectId getDeltaBaseId()

Get delta base object id if object is going to be packed in delta representation

Returns:ObjectId

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.

getDeltaDepthback to summary
pack-priv final int getDeltaDepth()
getExtendedFlagsback to summary
protected final int getExtendedFlags()

Get the extended flags on this object, in the range [0x0, 0xf].

Returns:int

the extended flags on this object, in the range [0x0, 0xf].

getFormatback to summary
pack-priv final int getFormat()
getPathHashback to summary
pack-priv final int getPathHash()
getTypeback to summary
public final int getType()

Overrides org.eclipse.jgit.transport.PackedObjectInfo.getType.

Doc from org.eclipse.jgit.transport.PackedObjectInfo.getType.

Get the object type.

Returns:int

the object type. The default type is OBJ_BAD, which is considered as unknown or invalid type.

Annotations
@Override
getWeightback to summary
pack-priv final int getWeight()
isDeltaRepresentationback to summary
public final boolean isDeltaRepresentation()

Whether object is going to be written as delta

Returns:boolean

true if object is going to be written as delta; false otherwise.

isDoNotDeltaback to summary
pack-priv final boolean isDoNotDelta()
isEdgeback to summary
pack-priv final boolean isEdge()
isExtendedFlagback to summary
protected final boolean isExtendedFlag(int flag)

Determine if a particular extended flag bit has been set. This implementation may be faster than calling getExtendedFlags() and testing the result.

Parameters
flag:int

the flag mask to test, must be between 0x0 and 0xf.

Returns:boolean

true if any of the bits matching the mask are non-zero.

isReuseAsIsback to summary
public final boolean isReuseAsIs()

Whether an existing representation was selected to be reused as-is into the pack stream.

Returns:boolean

true if an existing representation was selected to be reused as-is into the pack stream.

isWrittenback to summary
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:boolean

true if object is already written; false otherwise.

markWantWriteback to summary
pack-priv final void markWantWrite()
popCachedDeltaback to summary
pack-priv final DeltaCache.Ref popCachedDelta()
selectback to summary
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. org.eclipse.jgit.internal.storage.pack.PackWriter may invoke this method multiple times for the same object, each time saving the current best representation found.

Parameters
ref:StoredObjectRepresentation

the object representation.

setCachedDeltaback to summary
pack-priv final void setCachedDelta(DeltaCache.Ref data)
setCachedSizeback to summary
pack-priv final void setCachedSize(int sz)
setChainLengthback to summary
pack-priv final void setChainLength(int len)
setDeltaAttemptedback to summary
pack-priv final void setDeltaAttempted(boolean deltaAttempted)
setDeltaBaseback to summary
pack-priv final void setDeltaBase(ObjectId deltaBase)

Set delta base for the object. Delta base set by this method is used by PackWriter to write object - determines its representation in a created pack.

Parameters
deltaBase:ObjectId

delta base object or null if object should be packed as a whole object.

setDeltaDepthback to summary
pack-priv final void setDeltaDepth(int d)
setDoNotDeltaback to summary
pack-priv final void setDoNotDelta()
setEdgeback to summary
pack-priv final void setEdge()
setExtendedFlagback to summary
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:int

the bits to set, must be between 0x0 and 0xf.

setExtendedFlagsback to summary
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:int

additional flag bits to store in the flags field. Due to space constraints only values [0x0, 0xf] are permitted.

setPathHashback to summary
pack-priv final void setPathHash(int hc)
setReuseAsIsback to summary
pack-priv final void setReuseAsIs()
setWeightback to summary
pack-priv final void setWeight(int weight)
toStringback to summary
public String toString()

Overrides org.eclipse.jgit.lib.AnyObjectId.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@SuppressWarnings:nls
@Override
wantWriteback to summary
pack-priv final boolean wantWrite()