proof of concept delta-rd5

This commit is contained in:
Arndt Brenschede 2019-09-10 00:18:03 +02:00
parent a69fb1c99a
commit 8c15a1d16f
2 changed files with 29 additions and 14 deletions

View file

@ -91,6 +91,7 @@ public final class MicroCache2 extends MicroCache
if ( featureId == 13 ) if ( featureId == 13 )
{ {
fapos[n] = aboffset; fapos[n] = aboffset;
validBits[ n >> 5 ] |= 1 << n; // mark dummy-node valid
continue; // empty node escape (delta files only) continue; // empty node escape (delta files only)
} }
while( featureId != 0 ) while( featureId != 0 )

View file

@ -30,8 +30,10 @@ final public class Rd5DiffTool
int nodesTotal = 0; int nodesTotal = 0;
int nodesDiff = 0; int nodesDiff = 0;
int diffedTiles = 0;
long bytesDiff = 0L; long bytesDiff = 0L;
long diffedTileSize = 0L;
PhysicalFile pf1 = null; PhysicalFile pf1 = null;
PhysicalFile pf2 = null; PhysicalFile pf2 = null;
@ -67,11 +69,6 @@ final public class Rd5DiffTool
nodesTotal += mc2.getSize(); nodesTotal += mc2.getSize();
if ( latIdx == 15 )
{
// System.out.println( "hier!" );
}
if ( mc.getSize() > 0 ) if ( mc.getSize() > 0 )
{ {
int len = mc.encodeMicroCache( abBuf1 ); int len = mc.encodeMicroCache( abBuf1 );
@ -80,20 +77,37 @@ final public class Rd5DiffTool
bytesDiff += len; bytesDiff += len;
nodesDiff += mc.getSize(); nodesDiff += mc.getSize();
diffedTiles++;
diffedTileSize += mc2.size();
// cross-check the encoding: re-instantiate the cache // cross-check the encoding: decode again
MicroCache mcCheck = new MicroCache2( new StatCoderContext( bytes ), new DataBuffers( null ), lonIdxDiv, latIdxDiv, div, null, null ); MicroCache mcCheck = new MicroCache2( new StatCoderContext( bytes ), new DataBuffers( null ), lonIdxDiv, latIdxDiv, div, null, null );
// ..and check if still the same // due to link-order ambiguity, for decoded we can only compare node-count and datasize
if ( mc.size() != mcCheck.size() ) if ( mc.size() != mcCheck.size() )
{ {
// mc.compareWith finds link-ordering differences, throw new IllegalArgumentException( "re-decoded data-size mismatch!" );
// so we compare only if there's also a size missmatch... }
if ( mc.getSize() != mcCheck.getSize() )
String diffMessage = mc.compareWith( mcCheck );
if ( diffMessage != null )
{ {
throw new RuntimeException( "files differ: " + diffMessage ); throw new IllegalArgumentException( "re-decoded node-count mismatch!" );
}
// .... so re-encode again
int len2 = mcCheck.encodeMicroCache( abBuf1 );
byte[] bytes2 = new byte[len2];
System.arraycopy( abBuf1, 0, bytes2, 0, len2 );
// and here we can compare byte-by-byte
if ( len != len2 )
{
throw new IllegalArgumentException( "decoded size mismatch!" );
}
for( int i=0; i<len; i++ )
{
if ( bytes[i] != bytes2[i] )
{
throw new IllegalArgumentException( "decoded data mismatch at i=" + i );
} }
} }
} }
@ -101,7 +115,7 @@ final public class Rd5DiffTool
} }
} }
} }
System.out.println( "nodesTotal=" + nodesTotal + " nodesDiff=" + nodesDiff + " bytesDiff=" + bytesDiff ); System.out.println( "nodesTotal=" + nodesTotal + " nodesDiff=" + nodesDiff + " bytesDiff=" + bytesDiff + " diffedTiles=" + diffedTiles + " diffedTileSize=" + diffedTileSize );
} }
finally finally
{ {