Package it.unimi.dsi.mg4j.util

Examples of it.unimi.dsi.mg4j.util.SemiExternalOffsetList


    if ( payload == null && randomAccess ) {
      int offsetStep = queryProperties != null && queryProperties.get( UriKeys.OFFSETSTEP ) != null ? Integer.parseInt( queryProperties.get( UriKeys.OFFSETSTEP ) ) : DEFAULT_OFFSET_STEP;
     
      if ( offsetStep < 0 ) { // Memory-mapped
        offsetStep  = -offsetStep;
        offsets = LongLists.synchronize( new SemiExternalOffsetList(
            new InputBitStream( ByteBufferInputStream.map( new FileInputStream( basename + DiskBasedIndex.OFFSETS_EXTENSION ).getChannel(), MapMode.READ_ONLY ) ),
            offsetStep, numberOfTerms + 1 ) );
      }
      else {
        offsets = offsetStep == 0?
            DiskBasedIndex.readOffsets( basename + DiskBasedIndex.OFFSETS_EXTENSION, numberOfTerms ) :
              LongLists.synchronize( new SemiExternalOffsetList( new InputBitStream( basename + DiskBasedIndex.OFFSETS_EXTENSION, 1024 ), offsetStep, numberOfTerms + 1 ) );
      }
      if ( offsets.size() != numberOfTerms + 1 ) throw new IllegalStateException( "The length of the offset list (" + offsets.size() + ") is not equal to the number of terms plus one (" + numberOfTerms + " + 1)" );
    }
    else offsets = null;
   
View Full Code Here


    public void testSemiExternalOffsetListGammaCoding() throws IOException {

    long[] offsets = { 10, 300, 450, 650, 1000, 1290, 1699 };
    LongList listOffsets = new LongArrayList( offsets );

    SemiExternalOffsetList list = new SemiExternalOffsetList( buildInputStream( listOffsets ), 1, listOffsets.size() );
    for ( int i = 0; i < offsets.length; ++i ) {
      assertEquals( ( "test failed for index: " + i ), offsets[ i ], list.getLong( i ) );
    }

    list = new SemiExternalOffsetList( buildInputStream( listOffsets ), 2, listOffsets.size() );
    for ( int i = 0; i < offsets.length; ++i ) {
      assertEquals( ( "test failed for index: " + i ), offsets[ i ], list.getLong( i ) );
    }

    list = new SemiExternalOffsetList( buildInputStream( listOffsets ), 4, listOffsets.size() );
    for ( int i = 0; i < offsets.length; ++i ) {
      assertEquals( ( "test failed for index: " + i ), offsets[ i ], list.getLong( i ) );
    }

    list = new SemiExternalOffsetList( buildInputStream( listOffsets ), 7, listOffsets.size() );
    for ( int i = 0; i < offsets.length; ++i ) {
      assertEquals( ( "test failed for index: " + i ), offsets[ i ], list.getLong( i ) );
    }
   
    list = new SemiExternalOffsetList( buildInputStream( listOffsets ), 8, listOffsets.size() );
    for ( int i = 0; i < offsets.length; ++i ) {
      assertEquals( ( "test failed for index: " + i ), offsets[ i ], list.getLong( i ) );
    }
    }
View Full Code Here

    public void testEmptySemiExternalOffsetListGammaCoding() throws IOException {

    long[] offsets = {  };
    LongList listOffsets = new LongArrayList( offsets );

    new SemiExternalOffsetList( buildInputStream( listOffsets ), 1, listOffsets.size() );
    assertTrue( true );
    }
View Full Code Here

TOP

Related Classes of it.unimi.dsi.mg4j.util.SemiExternalOffsetList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.