@ -72,7 +72,6 @@ import org.eclipse.jgit.internal.storage.file.PackBitmapIndex;
import org.eclipse.jgit.internal.storage.file.PackIndex ;
import org.eclipse.jgit.internal.storage.file.PackIndex ;
import org.eclipse.jgit.internal.storage.file.PackReverseIndex ;
import org.eclipse.jgit.internal.storage.file.PackReverseIndex ;
import org.eclipse.jgit.internal.storage.pack.BinaryDelta ;
import org.eclipse.jgit.internal.storage.pack.BinaryDelta ;
import org.eclipse.jgit.internal.storage.pack.PackExt ;
import org.eclipse.jgit.internal.storage.pack.PackOutputStream ;
import org.eclipse.jgit.internal.storage.pack.PackOutputStream ;
import org.eclipse.jgit.internal.storage.pack.StoredObjectRepresentation ;
import org.eclipse.jgit.internal.storage.pack.StoredObjectRepresentation ;
import org.eclipse.jgit.lib.AbbreviatedObjectId ;
import org.eclipse.jgit.lib.AbbreviatedObjectId ;
@ -89,8 +88,8 @@ import org.eclipse.jgit.util.LongList;
* objects are similar .
* objects are similar .
* /
* /
public final class DfsPackFile extends BlockBasedFile {
public final class DfsPackFile extends BlockBasedFile {
final DfsStreamKey idxKey = new DfsStreamKey ( ) ;
final DfsStreamKey idxKey ;
final DfsStreamKey reverseIdxKey = new DfsStreamKey ( ) ;
final DfsStreamKey reverseIdxKey ;
DfsStreamKey bitmapKey ;
DfsStreamKey bitmapKey ;
/ * *
/ * *
@ -125,11 +124,11 @@ public final class DfsPackFile extends BlockBasedFile {
* cache that owns the pack data .
* cache that owns the pack data .
* @param desc
* @param desc
* description of the pack within the DFS .
* description of the pack within the DFS .
* @param key
* interned key used to identify blocks in the block cache .
* /
* /
DfsPackFile ( DfsBlockCache cache , DfsPackDescription desc , DfsStreamKey key ) {
DfsPackFile ( DfsBlockCache cache , DfsPackDescription desc ) {
super ( cache , key , desc , PACK ) ;
super ( cache , desc , PACK ) ;
idxKey = desc . getStreamKey ( INDEX ) ;
reverseIdxKey = idxKey . derive ( "r" ) ; //$NON-NLS-1$
length = desc . getFileSize ( PACK ) ;
length = desc . getFileSize ( PACK ) ;
if ( length < = 0 )
if ( length < = 0 )
length = - 1 ;
length = - 1 ;
@ -137,7 +136,7 @@ public final class DfsPackFile extends BlockBasedFile {
/** @return description that was originally used to configure this pack file. */
/** @return description that was originally used to configure this pack file. */
public DfsPackDescription getPackDescription ( ) {
public DfsPackDescription getPackDescription ( ) {
return packD esc;
return d esc;
}
}
/ * *
/ * *
@ -148,11 +147,6 @@ public final class DfsPackFile extends BlockBasedFile {
return idxref ! = null & & idxref . has ( ) ;
return idxref ! = null & & idxref . has ( ) ;
}
}
/** @return bytes cached in memory for this pack, excluding the index. */
public long getCachedSize ( ) {
return key . cachedSize . get ( ) ;
}
void setPackIndex ( PackIndex idx ) {
void setPackIndex ( PackIndex idx ) {
long objCnt = idx . getObjectCount ( ) ;
long objCnt = idx . getObjectCount ( ) ;
int recSize = Constants . OBJECT_ID_LENGTH + 8 ;
int recSize = Constants . OBJECT_ID_LENGTH + 8 ;
@ -200,7 +194,7 @@ public final class DfsPackFile extends BlockBasedFile {
try {
try {
ctx . stats . readIdx + + ;
ctx . stats . readIdx + + ;
long start = System . nanoTime ( ) ;
long start = System . nanoTime ( ) ;
ReadableChannel rc = ctx . db . openFile ( packD esc, INDEX ) ;
ReadableChannel rc = ctx . db . openFile ( d esc, INDEX ) ;
try {
try {
InputStream in = Channels . newInputStream ( rc ) ;
InputStream in = Channels . newInputStream ( rc ) ;
int wantSize = 8192 ;
int wantSize = 8192 ;
@ -219,14 +213,14 @@ public final class DfsPackFile extends BlockBasedFile {
invalid = true ;
invalid = true ;
IOException e2 = new IOException ( MessageFormat . format (
IOException e2 = new IOException ( MessageFormat . format (
DfsText . get ( ) . shortReadOfIndex ,
DfsText . get ( ) . shortReadOfIndex ,
packD esc. getFileName ( INDEX ) ) ) ;
d esc. getFileName ( INDEX ) ) ) ;
e2 . initCause ( e ) ;
e2 . initCause ( e ) ;
throw e2 ;
throw e2 ;
} catch ( IOException e ) {
} catch ( IOException e ) {
invalid = true ;
invalid = true ;
IOException e2 = new IOException ( MessageFormat . format (
IOException e2 = new IOException ( MessageFormat . format (
DfsText . get ( ) . cannotReadIndex ,
DfsText . get ( ) . cannotReadIndex ,
packD esc. getFileName ( INDEX ) ) ) ;
d esc. getFileName ( INDEX ) ) ) ;
e2 . initCause ( e ) ;
e2 . initCause ( e ) ;
throw e2 ;
throw e2 ;
}
}
@ -237,7 +231,7 @@ public final class DfsPackFile extends BlockBasedFile {
}
}
final boolean isGarbage ( ) {
final boolean isGarbage ( ) {
return packD esc. getPackSource ( ) = = UNREACHABLE_GARBAGE ;
return d esc. getPackSource ( ) = = UNREACHABLE_GARBAGE ;
}
}
PackBitmapIndex getBitmapIndex ( DfsReader ctx ) throws IOException {
PackBitmapIndex getBitmapIndex ( DfsReader ctx ) throws IOException {
@ -250,7 +244,7 @@ public final class DfsPackFile extends BlockBasedFile {
return idx ;
return idx ;
}
}
if ( ! packD esc. hasFileExt ( PackExt . BITMAP_INDEX ) )
if ( ! d esc. hasFileExt ( BITMAP_INDEX ) )
return null ;
return null ;
synchronized ( initLock ) {
synchronized ( initLock ) {
@ -261,14 +255,14 @@ public final class DfsPackFile extends BlockBasedFile {
return idx ;
return idx ;
}
}
if ( bitmapKey = = null ) {
if ( bitmapKey = = null ) {
bitmapKey = new DfsStreamKey ( ) ;
bitmapKey = desc . getStreamKey ( BITMAP_INDEX ) ;
}
}
long size ;
long size ;
PackBitmapIndex idx ;
PackBitmapIndex idx ;
try {
try {
ctx . stats . readBitmap + + ;
ctx . stats . readBitmap + + ;
long start = System . nanoTime ( ) ;
long start = System . nanoTime ( ) ;
ReadableChannel rc = ctx . db . openFile ( packD esc, BITMAP_INDEX ) ;
ReadableChannel rc = ctx . db . openFile ( d esc, BITMAP_INDEX ) ;
try {
try {
InputStream in = Channels . newInputStream ( rc ) ;
InputStream in = Channels . newInputStream ( rc ) ;
int wantSize = 8192 ;
int wantSize = 8192 ;
@ -289,13 +283,13 @@ public final class DfsPackFile extends BlockBasedFile {
} catch ( EOFException e ) {
} catch ( EOFException e ) {
IOException e2 = new IOException ( MessageFormat . format (
IOException e2 = new IOException ( MessageFormat . format (
DfsText . get ( ) . shortReadOfIndex ,
DfsText . get ( ) . shortReadOfIndex ,
packD esc. getFileName ( BITMAP_INDEX ) ) ) ;
d esc. getFileName ( BITMAP_INDEX ) ) ) ;
e2 . initCause ( e ) ;
e2 . initCause ( e ) ;
throw e2 ;
throw e2 ;
} catch ( IOException e ) {
} catch ( IOException e ) {
IOException e2 = new IOException ( MessageFormat . format (
IOException e2 = new IOException ( MessageFormat . format (
DfsText . get ( ) . cannotReadIndex ,
DfsText . get ( ) . cannotReadIndex ,
packD esc. getFileName ( BITMAP_INDEX ) ) ) ;
d esc. getFileName ( BITMAP_INDEX ) ) ) ;
e2 . initCause ( e ) ;
e2 . initCause ( e ) ;
throw e2 ;
throw e2 ;
}
}
@ -377,7 +371,6 @@ public final class DfsPackFile extends BlockBasedFile {
/** Release all memory used by this DfsPackFile instance. */
/** Release all memory used by this DfsPackFile instance. */
public void close ( ) {
public void close ( ) {
cache . remove ( this ) ;
index = null ;
index = null ;
reverseIndex = null ;
reverseIndex = null ;
}
}
@ -445,7 +438,7 @@ public final class DfsPackFile extends BlockBasedFile {
} else {
} else {
b = cache . get ( key , alignToBlock ( position ) ) ;
b = cache . get ( key , alignToBlock ( position ) ) ;
if ( b = = null ) {
if ( b = = null ) {
rc = ctx . db . openFile ( packD esc, PACK ) ;
rc = ctx . db . openFile ( d esc, PACK ) ;
int sz = ctx . getOptions ( ) . getStreamPackBufferSize ( ) ;
int sz = ctx . getOptions ( ) . getStreamPackBufferSize ( ) ;
if ( sz > 0 ) {
if ( sz > 0 ) {
rc . setReadAheadBytes ( sz ) ;
rc . setReadAheadBytes ( sz ) ;
@ -469,7 +462,7 @@ public final class DfsPackFile extends BlockBasedFile {
private long copyPackBypassCache ( PackOutputStream out , DfsReader ctx )
private long copyPackBypassCache ( PackOutputStream out , DfsReader ctx )
throws IOException {
throws IOException {
try ( ReadableChannel rc = ctx . db . openFile ( packD esc, PACK ) ) {
try ( ReadableChannel rc = ctx . db . openFile ( d esc, PACK ) ) {
ByteBuffer buf = newCopyBuffer ( out , rc ) ;
ByteBuffer buf = newCopyBuffer ( out , rc ) ;
if ( ctx . getOptions ( ) . getStreamPackBufferSize ( ) > 0 )
if ( ctx . getOptions ( ) . getStreamPackBufferSize ( ) > 0 )
rc . setReadAheadBytes ( ctx . getOptions ( ) . getStreamPackBufferSize ( ) ) ;
rc . setReadAheadBytes ( ctx . getOptions ( ) . getStreamPackBufferSize ( ) ) ;