Package it.unimi.dsi.fastutil.ints

Examples of it.unimi.dsi.fastutil.ints.AbstractIntComparator


            if ( hasCounts ) count = ibs.readGamma() + 1;
            if ( hasPositions ) ibs.skipDeltas( count ); // Skip document positions
          }

          // Sort stably pointers and positions by increasing pointer
          it.unimi.dsi.fastutil.Arrays.quickSort( 0, frequency, new AbstractIntComparator() {
            public int compare( final int i0, final int i1 ) {
              final int t = pointer[ i0 ] - pointer[ i1 ];
              if ( t != 0 ) return t;
              final long u = bitPos[ i0 ] - bitPos[ i1 ]; // We need a stable sort
              return u < 0 ? -1 : u > 0 ? 1 : 0;
            }
          },
          new Swapper() {
            public void swap( final int i0, final int i1 ) {
              final long t = bitPos[ i0 ]; bitPos[ i0 ] = bitPos[ i1 ]; bitPos[ i1 ] = t;
              final int p = pointer[ i0 ]; pointer[ i0 ] = pointer[ i1 ]; pointer[ i1 ] = p;
            }
          } );

          int actualFrequency = frequency;
          // Compute actual frequency for virtual indices
          if ( indexingIsVirtual ) {
            actualFrequency = 1;
            for ( int j = 1; j < frequency; j++ ) if ( pointer[ j ] != pointer[ j - 1 ] ) actualFrequency++;
            if ( ASSERTS ) {
              for ( int j = 1; j < frequency; j++ ) {
                assert pointer[ j ] >= pointer[ j - 1 ];
                assert pointer[ j ] != pointer[ j - 1 ] || bitPos[ j ] > bitPos[ j - 1 ];
              }
            }
          }

          indexWriter.newInvertedList();
          indexWriter.writeFrequency( actualFrequency );

          int currPointer;
          for ( int j = 0; j < frequency; j++ ) {
            ibs.position( bitPos[ j ] );
            obs = indexWriter.newDocumentRecord();
            indexWriter.writeDocumentPointer( obs, currPointer = ibs.readDelta() );
            if ( ASSERTS ) assert currPointer == pointer[ j ];
            if ( hasCounts ) count = ibs.readGamma() + 1;
            if ( hasPositions ) {
              ibs.readDeltas( pos, count );
              for ( int p = 1; p < count; p++ ) pos[ p ] += pos[ p - 1 ] + 1;
            }

            if ( indexingIsVirtual ) {
              while( j < frequency - 1 ) {
                ibs.position( bitPos[ j + 1 ] );
                if ( currPointer != ibs.readDelta() ) break;
                j++;
                if ( hasCounts ) moreCount = ibs.readGamma() + 1;
                if ( hasPositions ) {
                  pos = IntArrays.grow( pos, count + moreCount, count );
                  pos[ count ] = ibs.readDelta();
                  if ( ASSERTS ) assert pos[ count ] > pos[ count - 1 ];
                  for ( int p = 1; p < moreCount; p++ ) pos[ count + p ] = pos[ count + p - 1 ] + 1 + ibs.readDelta();
                }
                count += moreCount;
              }
              if ( maxCount < count ) maxCount = count;
            }

            if ( hasCounts ) indexWriter.writePositionCount( obs, count );
            if ( hasPositions ) indexWriter.writeDocumentPositions( obs, pos, 0, count, -1 );
          }

          frequencies.writeGamma( actualFrequency );
          globCounts.writeLongGamma( bapl.globCount );
        }

        indexWriter.close();
        final Properties properties = indexWriter.properties();
        totPostings += properties.getLong( "postings" );
        properties.setProperty( Index.PropertyKeys.TERMPROCESSOR, ObjectParser.toSpec( termProcessor ) );
        properties.setProperty( Index.PropertyKeys.OCCURRENCES, numOccurrences );
        properties.setProperty( Index.PropertyKeys.MAXDOCSIZE, maxDocSize );
        properties.setProperty( Index.PropertyKeys.SIZE, indexWriter.writtenBits() );
        if ( field != null ) properties.setProperty( Index.PropertyKeys.FIELD, field );
        properties.save( batchBasename + DiskBasedIndex.PROPERTIES_EXTENSION );

        if ( indexingIsRemapped ) {
          // We must permute sizes
          final int[] document = new int[ documentCount ], size = new int[ documentCount ];
          final InputBitStream sizes = new InputBitStream( batchBasename + DiskBasedIndex.SIZES_EXTENSION );
          for ( int i = 0; i < documentCount; i++ ) {
            document[ i ] = sizes.readGamma();
            size[ i ] = sizes.readGamma();
          }
          sizes.close();
         
          it.unimi.dsi.fastutil.Arrays.quickSort( 0, documentCount, new AbstractIntComparator() {
            public int compare( int x, int y ) {
              return document[ x ] - document[ y ];
            }
          }, new Swapper() {
            public void swap( int x, int y ) {
View Full Code Here


      }
    }
   
    int[] termPerm = new int[ termFrequency.length ];
    for( int i = termPerm.length; i-- != 0; ) termPerm[ i ] = i;
    IntArrays.quickSort( termPerm, 0, termPerm.length, new AbstractIntComparator() {
      public int compare( int arg0, int arg1 ) {
        return termFrequency[ arg1 ] - termFrequency[ arg0 ] < 0 ? -1 : termFrequency[ arg1 ] == termFrequency[ arg0 ] ? 0 : 1;
      }
    });
   
    int[] invTermPerm = new int[ termFrequency.length ];
    for( int i = invTermPerm.length; i-- != 0; ) invTermPerm[ termPerm[ i ] ] = i;
   
    int[] nonTermPerm = null, invNonTermPerm = null;
    if ( exact ) {
      nonTermPerm = new int[ termFrequency.length ];
      for( int i = nonTermPerm.length; i-- != 0; ) nonTermPerm[ i ] = i;
      IntArrays.quickSort( nonTermPerm, 0, nonTermPerm.length, new AbstractIntComparator() {
        public int compare( int arg0, int arg1 ) {
          return termFrequency[ arg1 ] - termFrequency[ arg0 ] < 0 ? -1 : termFrequency[ arg1 ] == termFrequency[ arg0 ] ? 0 : 1;
        }
      });
      invNonTermPerm = new int[ nonTermFrequency.length ];
View Full Code Here

        }
      }
      if ( payloadPointers[ i ] != null ) {
        final int p[] = payloadPointers[ i ].elements();
        final Object[] b = payloadContent[ i ].elements();
        Arrays.quickSort( 0, payloadPointers[ i ].size(), new AbstractIntComparator() {
          public int compare( int i0, int i1 ) {
            return p[ i0 ] - p[ i1 ];
          }
        }, new Swapper() {
          public void swap( int i0, int i1 ) {
View Full Code Here

          break;
        }
      assert j < coll.factory().numberOfFields();
    }
    // Sort fields to guarantee that they are correctly numbered
    Arrays.quickSort( 0, nfields, new AbstractIntComparator() {
      public int compare( int x, int y ) {
        return fieldNumber[ x ] - fieldNumber[ y ];
      }}, new Swapper() {
        public void swap( int x, int y ) {
          int t = fieldNumber[ x ]; fieldNumber[ x ] = fieldNumber[ y ]; fieldNumber[ y ] = t;
View Full Code Here

          break;
        }
      assert j < seq.factory().numberOfFields();
    }
    // Sort fields to guarantee that they are correctly numbered
    Arrays.quickSort( 0, nfields, new AbstractIntComparator() {
      public int compare( int x, int y ) {
        return fieldNumber[ x ] - fieldNumber[ y ];
      }}, new Swapper() {
        public void swap( int x, int y ) {
          int t = fieldNumber[ x ]; fieldNumber[ x ] = fieldNumber[ y ]; fieldNumber[ y ] = t;
View Full Code Here

        orderingCompiler.compilePagesIndexOrdering(sortChannels, sortOrders).sort(this);
    }

    public IntComparator createComparator(final List<Integer> sortChannels, final List<SortOrder> sortOrders)
    {
        return new AbstractIntComparator()
        {
            private final PagesIndexComparator comparator = orderingCompiler.compilePagesIndexOrdering(sortChannels, sortOrders).getComparator();

            public int compare(int leftPosition, int rightPosition)
            {
View Full Code Here

        orderingCompiler.compilePagesIndexOrdering(sortChannels, sortOrders).sort(this);
    }

    public IntComparator createComparator(final List<Integer> sortChannels, final List<SortOrder> sortOrders)
    {
        return new AbstractIntComparator()
        {
            private final PagesIndexComparator comparator = orderingCompiler.compilePagesIndexOrdering(sortChannels, sortOrders).getComparator();

            public int compare(int leftPosition, int rightPosition)
            {
View Full Code Here

        orderingCompiler.compilePagesIndexOrdering(sortChannels, sortOrders).sort(this);
    }

    public IntComparator createComparator(final List<Integer> sortChannels, final List<SortOrder> sortOrders)
    {
        return new AbstractIntComparator()
        {
            private final PagesIndexComparator comparator = orderingCompiler.compilePagesIndexOrdering(sortChannels, sortOrders).getComparator();

            public int compare(int leftPosition, int rightPosition)
            {
View Full Code Here

        orderingCompiler.compilePagesIndexOrdering(sortTypes, sortChannels, sortOrders).sort(this);
    }

    public IntComparator createComparator(final List<Type> sortTypes, final List<Integer> sortChannels, final List<SortOrder> sortOrders)
    {
        return new AbstractIntComparator()
        {
            private final PagesIndexComparator comparator = orderingCompiler.compilePagesIndexOrdering(sortTypes, sortChannels, sortOrders).getComparator();

            @Override
            public int compare(int leftPosition, int rightPosition)
View Full Code Here

        orderingCompiler.compilePagesIndexOrdering(sortChannels, sortOrders).sort(this);
    }

    public IntComparator createComparator(final List<Integer> sortChannels, final List<SortOrder> sortOrders)
    {
        return new AbstractIntComparator()
        {
            private final PagesIndexComparator comparator = orderingCompiler.compilePagesIndexOrdering(sortChannels, sortOrders).getComparator();

            public int compare(int leftPosition, int rightPosition)
            {
View Full Code Here

TOP

Related Classes of it.unimi.dsi.fastutil.ints.AbstractIntComparator

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.