performance
This commit is contained in:
parent
9d00b0181e
commit
448bb11ad4
13 changed files with 204 additions and 125 deletions
|
|
@ -1,5 +1,7 @@
|
|||
package btools.codec;
|
||||
|
||||
import btools.util.BitCoderContext;
|
||||
|
||||
/**
|
||||
* Container for some re-usable databuffers for the decoder
|
||||
*/
|
||||
|
|
@ -7,6 +9,7 @@ public final class DataBuffers
|
|||
{
|
||||
public byte[] iobuffer;
|
||||
public byte[] tagbuf1 = new byte[256];
|
||||
public BitCoderContext bctx1 = new BitCoderContext( tagbuf1 );
|
||||
public byte[] bbuf1 = new byte[65636];
|
||||
public int[] ibuf1 = new int[4096];
|
||||
public int[] ibuf2 = new int[2048];
|
||||
|
|
|
|||
|
|
@ -135,47 +135,51 @@ public class MicroCache extends ByteDataWriter
|
|||
return n > 0 ? fapos[n - 1] & 0x7fffffff : 0;
|
||||
}
|
||||
|
||||
public final void collect( int threshold )
|
||||
public final int collect( int threshold )
|
||||
{
|
||||
if ( delcount > threshold )
|
||||
if ( delcount <= threshold )
|
||||
{
|
||||
virgin = false;
|
||||
|
||||
int nsize = size - delcount;
|
||||
if ( nsize == 0 )
|
||||
{
|
||||
faid = null;
|
||||
fapos = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
int[] nfaid = new int[nsize];
|
||||
int[] nfapos = new int[nsize];
|
||||
int idx = 0;
|
||||
|
||||
byte[] nab = new byte[ab.length - delbytes];
|
||||
int nab_off = 0;
|
||||
for ( int i = 0; i < size; i++ )
|
||||
{
|
||||
int pos = fapos[i];
|
||||
if ( ( pos & 0x80000000 ) == 0 )
|
||||
{
|
||||
int start = startPos( i );
|
||||
int end = fapos[i];
|
||||
int len = end - start;
|
||||
System.arraycopy( ab, start, nab, nab_off, len );
|
||||
nfaid[idx] = faid[i];
|
||||
nab_off += len;
|
||||
nfapos[idx] = nab_off;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
faid = nfaid;
|
||||
fapos = nfapos;
|
||||
ab = nab;
|
||||
}
|
||||
init( nsize );
|
||||
return 0;
|
||||
}
|
||||
|
||||
virgin = false;
|
||||
|
||||
int nsize = size - delcount;
|
||||
if ( nsize == 0 )
|
||||
{
|
||||
faid = null;
|
||||
fapos = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
int[] nfaid = new int[nsize];
|
||||
int[] nfapos = new int[nsize];
|
||||
int idx = 0;
|
||||
|
||||
byte[] nab = new byte[ab.length - delbytes];
|
||||
int nab_off = 0;
|
||||
for ( int i = 0; i < size; i++ )
|
||||
{
|
||||
int pos = fapos[i];
|
||||
if ( ( pos & 0x80000000 ) == 0 )
|
||||
{
|
||||
int start = startPos( i );
|
||||
int end = fapos[i];
|
||||
int len = end - start;
|
||||
System.arraycopy( ab, start, nab, nab_off, len );
|
||||
nfaid[idx] = faid[i];
|
||||
nab_off += len;
|
||||
nfapos[idx] = nab_off;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
faid = nfaid;
|
||||
fapos = nfapos;
|
||||
ab = nab;
|
||||
}
|
||||
int deleted = delbytes;
|
||||
init( nsize );
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public final void unGhost()
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ public final class MicroCache2 extends MicroCache
|
|||
|
||||
StatCoderContext bc = new StatCoderContext( dataBuffers.iobuffer );
|
||||
|
||||
TagValueCoder wayTagCoder = new TagValueCoder( bc, dataBuffers.tagbuf1, wayValidator );
|
||||
TagValueCoder nodeTagCoder = new TagValueCoder( bc, dataBuffers.tagbuf1, null );
|
||||
TagValueCoder wayTagCoder = new TagValueCoder( bc, dataBuffers, wayValidator );
|
||||
TagValueCoder nodeTagCoder = new TagValueCoder( bc, dataBuffers, null );
|
||||
NoisyDiffCoder nodeIdxDiff = new NoisyDiffCoder( bc );
|
||||
NoisyDiffCoder nodeEleDiff = new NoisyDiffCoder( bc );
|
||||
NoisyDiffCoder extLonDiff = new NoisyDiffCoder(bc);
|
||||
|
|
|
|||
|
|
@ -78,9 +78,9 @@ public final class TagValueCoder
|
|||
this.bc = bc;
|
||||
}
|
||||
|
||||
public TagValueCoder( BitCoderContext bc, byte[] buffer, TagValueValidator validator )
|
||||
public TagValueCoder( BitCoderContext bc, DataBuffers buffers, TagValueValidator validator )
|
||||
{
|
||||
tree = decodeTree( bc, buffer, validator );
|
||||
tree = decodeTree( bc, buffers, validator );
|
||||
this.bc = bc;
|
||||
}
|
||||
|
||||
|
|
@ -89,18 +89,20 @@ public final class TagValueCoder
|
|||
identityMap = new HashMap<TagValueSet, TagValueSet>();
|
||||
}
|
||||
|
||||
private Object decodeTree( BitCoderContext bc, byte[] buffer, TagValueValidator validator )
|
||||
private Object decodeTree( BitCoderContext bc, DataBuffers buffers, TagValueValidator validator )
|
||||
{
|
||||
boolean isNode = bc.decodeBit();
|
||||
if ( isNode )
|
||||
{
|
||||
TreeNode node = new TreeNode();
|
||||
node.child1 = decodeTree( bc, buffer, validator );
|
||||
node.child2 = decodeTree( bc, buffer, validator );
|
||||
node.child1 = decodeTree( bc, buffers, validator );
|
||||
node.child2 = decodeTree( bc, buffers, validator );
|
||||
return node;
|
||||
}
|
||||
|
||||
BitCoderContext ctx = new BitCoderContext( buffer );
|
||||
byte[] buffer = buffers.tagbuf1;
|
||||
BitCoderContext ctx = buffers.bctx1;
|
||||
ctx.reset( buffer );
|
||||
|
||||
int inum = 0;
|
||||
int lastEncodedInum = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue