org.eclipse.jgit.storage.dfs
Class DfsPackDescription

java.lang.Object
  extended by org.eclipse.jgit.storage.dfs.DfsPackDescription
All Implemented Interfaces:
Comparable<DfsPackDescription>

public class DfsPackDescription
extends Object
implements Comparable<DfsPackDescription>

Description of a DFS stored pack/index file.

Implementors may extend this class and add additional data members.

Instances of this class are cached with the DfsPackFile, and should not be modified once initialized and presented to the JGit DFS library.


Constructor Summary
DfsPackDescription(DfsRepositoryDescription repoDesc, String name)
          Initialize a description by pack name and repository.
 
Method Summary
 DfsPackDescription clearPackStats()
          Discard the pack statistics, if it was populated.
 int compareTo(DfsPackDescription b)
          Sort packs according to the optimal lookup ordering.
 boolean equals(Object b)
           
 long getDeltaCount()
           
 String getFileName(PackExt ext)
           
 long getFileSize(PackExt ext)
           
 long getLastModified()
           
 long getObjectCount()
           
 DfsObjDatabase.PackSource getPackSource()
           
 PackWriter.Statistics getPackStats()
           
 DfsRepositoryDescription getRepositoryDescription()
           
 Set<ObjectId> getTips()
           
 int hashCode()
           
 DfsPackDescription setDeltaCount(long cnt)
           
 DfsPackDescription setFileSize(PackExt ext, long bytes)
           
 DfsPackDescription setLastModified(long timeMillis)
           
 DfsPackDescription setObjectCount(long cnt)
           
 DfsPackDescription setPackSource(DfsObjDatabase.PackSource source)
           
 DfsPackDescription setTips(Set<ObjectId> tips)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DfsPackDescription

public DfsPackDescription(DfsRepositoryDescription repoDesc,
                          String name)
Initialize a description by pack name and repository.

The corresponding index file is assumed to exist. If this is not true implementors must extend the class and override getFileName(PackExt).

Callers should also try to fill in other fields if they are reasonably free to access at the time this instance is being initialized.

Parameters:
name - name of the pack file. Must end with ".pack".
repoDesc - description of the repo containing the pack file.
Method Detail

getRepositoryDescription

public DfsRepositoryDescription getRepositoryDescription()
Returns:
description of the repository.

getFileName

public String getFileName(PackExt ext)
Parameters:
ext - the file extension
Returns:
name of the file.

getPackSource

public DfsObjDatabase.PackSource getPackSource()
Returns:
the source of the pack.

setPackSource

public DfsPackDescription setPackSource(DfsObjDatabase.PackSource source)
Parameters:
source - the source of the pack.
Returns:
this

getLastModified

public long getLastModified()
Returns:
time the pack was created, in milliseconds.

setLastModified

public DfsPackDescription setLastModified(long timeMillis)
Parameters:
timeMillis - time the pack was created, in milliseconds. 0 if not known.
Returns:
this

setFileSize

public DfsPackDescription setFileSize(PackExt ext,
                                      long bytes)
Parameters:
ext - the file extension.
bytes - size of the file in bytes. If 0 the file is not known and will be determined on first read.
Returns:
this

getFileSize

public long getFileSize(PackExt ext)
Parameters:
ext - the file extension.
Returns:
size of the file, in bytes. If 0 the file size is not yet known.

getObjectCount

public long getObjectCount()
Returns:
number of objects in the pack.

setObjectCount

public DfsPackDescription setObjectCount(long cnt)
Parameters:
cnt - number of objects in the pack.
Returns:
this

getDeltaCount

public long getDeltaCount()
Returns:
number of delta compressed objects in the pack.

setDeltaCount

public DfsPackDescription setDeltaCount(long cnt)
Parameters:
cnt - number of delta compressed objects in the pack.
Returns:
this

getTips

public Set<ObjectId> getTips()
Returns:
the tips that created this pack, if known.

setTips

public DfsPackDescription setTips(Set<ObjectId> tips)
Parameters:
tips - the tips of the pack, null if it has no known tips.
Returns:
this

getPackStats

public PackWriter.Statistics getPackStats()
Returns:
statistics from PackWriter, if the pack was built with it. Generally this is only available for packs created by DfsGarbageCollector or DfsPackCompactor, and only when the pack is being committed to the repository.

clearPackStats

public DfsPackDescription clearPackStats()
Discard the pack statistics, if it was populated.

Returns:
this

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object b)
Overrides:
equals in class Object

compareTo

public int compareTo(DfsPackDescription b)
Sort packs according to the optimal lookup ordering.

This method tries to position packs in the order readers should examine them when looking for objects by SHA-1. The default tries to sort packs with more recent modification dates before older packs, and packs with fewer objects before packs with more objects.

Specified by:
compareTo in interface Comparable<DfsPackDescription>
Parameters:
b - the other pack.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All Rights Reserved.