Examples of Swapper


Examples of cern.colt.Swapper

  if (splitFrom < 0 || splitTo >= splitters.length) throw new IllegalArgumentException();
  if (splitIndexes.length < splitters.length) throw new IllegalArgumentException();

  // this one knows how to swap two row indexes (a,b)
  final int[] g = rowIndexes;
  Swapper swapper = new Swapper() {
    public void swap(int b, int c) {
      int tmp = g[b]; g[b] = g[c]; g[c] = tmp;
    }
  };
 
View Full Code Here

Examples of cern.colt.Swapper

  if (splitFrom < 0 || splitTo >= splitters.length) throw new IllegalArgumentException();
  if (splitIndexes.length < splitters.length) throw new IllegalArgumentException();

  // this one knows how to swap two row indexes (a,b)
  final int[] g = rowIndexes;
  Swapper swapper = new Swapper() {
    public void swap(int b, int c) {
      int tmp = g[b]; g[b] = g[c]; g[c] = tmp;
    }
  };
 
View Full Code Here

Examples of cern.colt.Swapper

  if (splitFrom < 0 || splitTo >= splitters.length) throw new IllegalArgumentException();
  if (splitIndexes.length < splitters.length) throw new IllegalArgumentException();

  // this one knows how to swap two row indexes (a,b)
  final int[] g = rowIndexes;
  Swapper swapper = new Swapper() {
    public void swap(int b, int c) {
      int tmp = g[b]; g[b] = g[c]; g[c] = tmp;
    }
  };
 
View Full Code Here

Examples of cern.colt.Swapper

  if (splitFrom < 0 || splitTo >= splitters.length) throw new IllegalArgumentException();
  if (splitIndexes.length < splitters.length) throw new IllegalArgumentException();

  // this one knows how to swap two row indexes (a,b)
  final int[] g = rowIndexes;
  Swapper swapper = new Swapper() {
    public void swap(int b, int c) {
      int tmp = g[b]; g[b] = g[c]; g[c] = tmp;
    }
  };
 
View Full Code Here

Examples of it.unimi.dsi.fastutil.Swapper

              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 ) {
              int t = document[ x ];
              document[ x ] = document[ y ];
              document[ y ] = t;
              t = size[ x ];
View Full Code Here

Examples of it.unimi.dsi.fastutil.Swapper

        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 ) {
            final int t = p[ i0 ];
            p[ i0 ] = p[ i1 ];
            p[ i1 ] = t;
            final Object o = b[ i0 ];
View Full Code Here

Examples of it.unimi.dsi.fastutil.Swapper

    }
    // 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;
          t = arrayIndex[ x ]; arrayIndex[ x ] = arrayIndex[ y ]; arrayIndex[ y ] = t;
          String q = fieldName[ x ]; fieldName[ x ] = fieldName[ y ]; fieldName[ y ] = q;
        }} );
View Full Code Here

Examples of it.unimi.dsi.fastutil.Swapper

    }
    // 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;
          t = arrayIndex[ x ]; arrayIndex[ x ] = arrayIndex[ y ]; arrayIndex[ y ] = t;
          String q = fieldName[ x ]; fieldName[ x ] = fieldName[ y ]; fieldName[ y ] = q;
        }} );
View Full Code Here

Examples of org.apache.mahout.math.Swapper

        permute(A.viewColumn(j), indexes, doubleWork);
      }
      return A;
    }

    Swapper swapper = new Swapper() {
      public void swap(int a, int b) {
        A.viewRow(a).swap(A.viewRow(b));
      }
    };
View Full Code Here

Examples of org.apache.mahout.math.Swapper

    IntComparator comp = new IntComparator() {
      public int compare(int a, int b) {
        return Property.get(names, a).compareTo(Property.get(names, b));
      }
    };
    Swapper swapper = new Swapper() {
      public void swap(int a, int b) {
        String tmp = names.get(a);
        names.set(a, names.get(b));
        names.set(b, tmp);
        tmp = values.get(a);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.