Terrier Users :  Terrier Forum terrier.org
General discussion about using/developing applications using Terrier 
Perhaps there are 2 bugs in Terrier BitInBase.java and BitOutputStream.java
Posted by: deeper2 ()
Date: January 02, 2018 07:42AM

I think the following two function should be changed into:
public int writeInterpolativeCode( int data[], int offset, int len, int lo, int hi ) throws IOException {
final int h, m;
int l;

if ( len == 0 ) return 0;
//if ( len == 1 ) return writeMinimalBinary( data[offset] - lo , hi - lo );
if ( len == 1 ) return writeMinimalBinary( data[offset] - lo , hi - lo +1 );//+1
h = len / 2;
m = data[ offset + h ];
//l = writeMinimalBinary( m - ( lo + h) , hi - len + h + 1 - ( lo + h ) );
l = writeMinimalBinary( m - ( lo + h) , hi - len + h + 1 - ( lo + h )+1 );//+1
l += writeInterpolativeCode( data, offset, h, lo, m - 1 );
return l + writeInterpolativeCode( data, offset + h + 1, len - h - 1, m + 1, hi );
}



public void readInterpolativeCoding( int data[], int offset, int len, int lo, int hi ) throws java.io.IOException {
final int h, m;

if ( len == 0 ) return;
if ( len == 1 ) {
//data[ offset ] = readMinimalBinaryZero( hi - lo ) + lo ;
data[ offset ] = readMinimalBinaryZero( hi - lo +1 ) + lo ;//+1
return;
}

h = len / 2;
//m = readMinimalBinaryZero( hi - len + h - ( lo + h ) + 1 ) + lo + h ;
m = readMinimalBinaryZero( hi - len + h + 1 - ( lo + h ) + 1 ) + lo + h ;//+1
data[ offset + h ] = m ;

readInterpolativeCoding( data, offset, h, lo, m - 1 );
readInterpolativeCoding( data, offset + h + 1, len - h - 1, m + 1, hi );
}

Options: ReplyQuote
Re: Perhaps there are 2 bugs in Terrier BitInBase.java and BitOutputStream.java
Posted by: craigm ()
Date: January 03, 2018 12:38PM

Hi.

Thanks for your report. Could you provide a unit test, which would show the problem with the current implementation?

Ideally, this would be prepared as a pull-request submitted through Github?

Thanks

Craig

Options: ReplyQuote


Sorry, only registered users may post in this forum.
This forum powered by Phorum.