@ -53,7 +53,7 @@ public class InMemoryRepository extends DfsRepository {
static final AtomicInteger packId = new AtomicInteger ( ) ;
static final AtomicInteger packId = new AtomicInteger ( ) ;
private final Dfs ObjDatabase objdb ;
private final Mem ObjDatabase objdb ;
private final RefDatabase refdb ;
private final RefDatabase refdb ;
private String gitwebDescription ;
private String gitwebDescription ;
private boolean performsAtomicTransactions = true ;
private boolean performsAtomicTransactions = true ;
@ -75,7 +75,7 @@ public class InMemoryRepository extends DfsRepository {
}
}
@Override
@Override
public Dfs ObjDatabase getObjectDatabase ( ) {
public Mem ObjDatabase getObjectDatabase ( ) {
return objdb ;
return objdb ;
}
}
@ -106,13 +106,23 @@ public class InMemoryRepository extends DfsRepository {
gitwebDescription = d ;
gitwebDescription = d ;
}
}
private class MemObjDatabase extends DfsObjDatabase {
/** DfsObjDatabase used by InMemoryRepository. */
public class MemObjDatabase extends DfsObjDatabase {
private List < DfsPackDescription > packs = new ArrayList < > ( ) ;
private List < DfsPackDescription > packs = new ArrayList < > ( ) ;
private int blockSize ;
MemObjDatabase ( DfsRepository repo ) {
MemObjDatabase ( DfsRepository repo ) {
super ( repo , new DfsReaderOptions ( ) ) ;
super ( repo , new DfsReaderOptions ( ) ) ;
}
}
/ * *
* @param blockSize
* force a different block size for testing .
* /
public void setReadableChannelBlockSizeForTest ( int blockSize ) {
this . blockSize = blockSize ;
}
@Override
@Override
protected synchronized List < DfsPackDescription > listPacks ( ) {
protected synchronized List < DfsPackDescription > listPacks ( ) {
return packs ;
return packs ;
@ -152,7 +162,7 @@ public class InMemoryRepository extends DfsRepository {
byte [ ] file = memPack . fileMap . get ( ext ) ;
byte [ ] file = memPack . fileMap . get ( ext ) ;
if ( file = = null )
if ( file = = null )
throw new FileNotFoundException ( desc . getFileName ( ext ) ) ;
throw new FileNotFoundException ( desc . getFileName ( ext ) ) ;
return new ByteArrayReadableChannel ( file ) ;
return new ByteArrayReadableChannel ( file , blockSize ) ;
}
}
@Override
@Override
@ -216,13 +226,13 @@ public class InMemoryRepository extends DfsRepository {
private static class ByteArrayReadableChannel implements ReadableChannel {
private static class ByteArrayReadableChannel implements ReadableChannel {
private final byte [ ] data ;
private final byte [ ] data ;
private final int blockSize ;
private int position ;
private int position ;
private boolean open = true ;
private boolean open = true ;
ByteArrayReadableChannel ( byte [ ] buf ) {
ByteArrayReadableChannel ( byte [ ] buf , int blockSize ) {
data = buf ;
data = buf ;
this . blockSize = blockSize ;
}
}
@Override
@Override
@ -262,7 +272,7 @@ public class InMemoryRepository extends DfsRepository {
@Override
@Override
public int blockSize ( ) {
public int blockSize ( ) {
return 0 ;
return blockSize ;
}
}
@Override
@Override