@ -176,6 +176,67 @@ public class ReftableTest {
assertEquals ( expBytes , table . length ) ;
assertEquals ( expBytes , table . length ) ;
}
}
@Test
public void hasObjMapRefs ( ) throws IOException {
ArrayList < Ref > refs = new ArrayList < > ( ) ;
refs . add ( ref ( MASTER , 1 ) ) ;
byte [ ] table = write ( refs ) ;
ReftableReader t = read ( table ) ;
assertTrue ( t . hasObjectMap ( ) ) ;
}
@Test
public void hasObjMapRefsSmallTable ( ) throws IOException {
ArrayList < Ref > refs = new ArrayList < > ( ) ;
ReftableConfig cfg = new ReftableConfig ( ) ;
cfg . setIndexObjects ( false ) ;
refs . add ( ref ( MASTER , 1 ) ) ;
byte [ ] table = write ( refs ) ;
ReftableReader t = read ( table ) ;
assertTrue ( t . hasObjectMap ( ) ) ;
}
@Test
public void hasObjLogs ( ) throws IOException {
PersonIdent who = new PersonIdent ( "Log" , "Ger" , 1500079709 , - 8 * 60 ) ;
String msg = "test" ;
ReftableConfig cfg = new ReftableConfig ( ) ;
cfg . setIndexObjects ( false ) ;
ByteArrayOutputStream buffer = new ByteArrayOutputStream ( ) ;
ReftableWriter writer = new ReftableWriter ( buffer )
. setMinUpdateIndex ( 1 )
. setConfig ( cfg )
. setMaxUpdateIndex ( 1 )
. begin ( ) ;
writer . writeLog ( "master" , 1 , who , ObjectId . zeroId ( ) , id ( 1 ) , msg ) ;
writer . finish ( ) ;
byte [ ] table = buffer . toByteArray ( ) ;
ReftableReader t = read ( table ) ;
assertTrue ( t . hasObjectMap ( ) ) ;
}
@Test
public void hasObjMapRefsNoIndexObjects ( ) throws IOException {
ArrayList < Ref > refs = new ArrayList < > ( ) ;
ReftableConfig cfg = new ReftableConfig ( ) ;
cfg . setIndexObjects ( false ) ;
cfg . setRefBlockSize ( 256 ) ;
cfg . setAlignBlocks ( true ) ;
// Fill up 5 blocks.
int N = 256 * 5 / 25 ;
for ( int i = 0 ; i < N ; i + + ) {
refs . add ( ref ( String . format ( "%02d/xxxxxxxxxx" , i ) , i ) ) ;
}
byte [ ] table = write ( refs , cfg ) ;
ReftableReader t = read ( table ) ;
assertFalse ( t . hasObjectMap ( ) ) ;
}
@Test
@Test
public void oneIdRef ( ) throws IOException {
public void oneIdRef ( ) throws IOException {
Ref exp = ref ( MASTER , 1 ) ;
Ref exp = ref ( MASTER , 1 ) ;
@ -936,8 +997,13 @@ public class ReftableTest {
}
}
private byte [ ] write ( Collection < Ref > refs ) throws IOException {
private byte [ ] write ( Collection < Ref > refs ) throws IOException {
return write ( refs , new ReftableConfig ( ) ) ;
}
private byte [ ] write ( Collection < Ref > refs , ReftableConfig cfg ) throws IOException {
ByteArrayOutputStream buffer = new ByteArrayOutputStream ( ) ;
ByteArrayOutputStream buffer = new ByteArrayOutputStream ( ) ;
stats = new ReftableWriter ( buffer )
stats = new ReftableWriter ( buffer )
. setConfig ( cfg )
. begin ( )
. begin ( )
. sortAndWriteRefs ( refs )
. sortAndWriteRefs ( refs )
. finish ( )
. finish ( )