Package it.unimi.dsi.lang

Examples of it.unimi.dsi.lang.MutableString


     
      final File sizesFile = new File( this.inputBasename[ i ] + DiskBasedIndex.SIZES_EXTENSION );
      writeSizes &= sizesFile.exists();
      someSizes |= sizesFile.exists();

      term[ i ] = new MutableString();
      termReader[ i ] = new FastBufferedReader( new InputStreamReader( new FileInputStream( this.inputBasename[ i ] + DiskBasedIndex.TERMS_EXTENSION ), "UTF-8" ) );
      if ( termReader[ i ].readLine( term[ i ] ) != null ) termQueue.enqueue( i ); // If the term list is nonempty, we enqueue it
    }

    if ( writeGlobCounts != someGlobCounts ) LOGGER.warn"Some (but not all) global-counts file missing" );
View Full Code Here


    final OutputBitStream frequencies = new OutputBitStream( outputBasename + DiskBasedIndex.FREQUENCIES_EXTENSION );
    // To write the new term list
    final PrintWriter termFile = new PrintWriter( new BufferedWriter( new OutputStreamWriter( new FileOutputStream( outputBasename + DiskBasedIndex.TERMS_EXTENSION ), "UTF-8" ), bufferSize ) );
   
    // The current term
    MutableString currTerm;
   
    // Total number of pointers and occurrences
    long numPointers = 0;
   
    pl.expectedUpdates = writeGlobCounts ? numberOfOccurrences : -1;
    pl.itemsName = writeGlobCounts ? "occurrences" : "terms";
    pl.logInterval = logInterval;
    pl.start( "Combining lists..." );

    int totalFrequency, numTerms = 0, numUsedIndices, k;
    long totalGlobCount = 0;
    predictedSize = -1;
    predictedLengthNumBits = -1;
   
    // Discard first zero from offsets
    if ( p != 0 ) for( InputBitStream ibs: offsets ) ibs.readGamma();
   
    // TODO: use the front of the queue?
    while( ! termQueue.isEmpty() ) {
      numUsedIndices = 0;
      // We read a new word from the queue, copy it and write it to the term file
      currTerm = term[ k = usedIndex[ numUsedIndices++ ] = termQueue.first() ].copy();
     
      if ( DEBUG ) System.err.println( "Merging term " + currTerm );
     
      currTerm.println( termFile );
      if ( termReader[ k ].readLine( term[ k ] ) == null ) termQueue.dequeue();
      else termQueue.changed();
     
      // Then, we extract all equal words from the queue, accumulating the set of indices in inIndex and currIndex
      while( ! termQueue.isEmpty() && term[ termQueue.first() ].equals( currTerm ) ) {
View Full Code Here

    if ( index < 0 || index >= numberOfFields() )
      throw new IndexOutOfBoundsException( Integer.toString( index ) );
  }

  public String toString() {
    final MutableString res = new MutableString();
    res.append( getClass().getName() );
    res.append( '[' );
    for ( int field = 0; field < numberOfFields(); field++ )
      res.append( ' ' ).append( fieldName( field ) ).append( ':' ).append( fieldType( field ).name() );
    return res.append( " ]" ).toString();
  }
View Full Code Here

                // TODO: this is a bit radical
                resultItem.title = resultItem.uri = titleList.get( resultItem.doc );
              }
              else {
                resultItem.title = "Document #" +  resultItem.doc;
                resultItem.uri = new MutableString( "./Item?doc=" ).append( resultItem.doc ).append( "&m=" ).append( urlEncodedMimeType );
              }
             
              MutableString text = new MutableString();
              for( Iterator<Index> j = indexMap.values().iterator(); j.hasNext(); ) {
                final Index index = j.next();
                selectedInterval = dsi.info.get( index );
                if ( selectedInterval != null )
                  text.append( "<p>" ).append( index.field ).append( ": " ).append( Arrays.asList( selectedInterval ) );
                LOGGER.debug( index.field + ": " + ( selectedInterval == null ? null : Arrays.asList( selectedInterval ) ) );
              }
              resultItem.text = text;
            }
          }
View Full Code Here

        Object field = document.content( f );
        if ( seq.factory().fieldType( f ) == FieldType.TEXT ) {
          Reader reader = (Reader)field;
          WordReader wr = document.wordReader( f );
          wr.setReader( reader );
          MutableString word = new MutableString();
          MutableString nonWord = new MutableString();
            while ( wr.next( word, nonWord ) ) System.out.println( word.toString() + nonWord.toString() );
        } else System.out.println( field );
      }
      doc++;
    }
  }
View Full Code Here

    this.leftMargin = leftMargin;
    this.rightMargin = rightMargin;
  }

  public String toString() {
    return new MutableString().append( '(' ).append( minuend ).append( leftMargin == 0 && rightMargin == 0 ? " - " : " - [[" + leftMargin + ":" + rightMargin + "]] " ).append( subtrahend ).append( ')' ).toString();
  }
View Full Code Here

  public Prefix( final CharSequence prefix ) {
    this.prefix = prefix;
  }
 
  public String toString() {
    return new MutableString().append( prefix ).append( '*' ).toString();
  }
View Full Code Here

          ensureConnection();
          remoteConnection.outputStream.writeByte( RemotePrefixMap.GET_PREFIX );
          remoteConnection.outputStream.writeInt( interval.left );
          remoteConnection.outputStream.writeInt( interval.right );
          remoteConnection.outputStream.flush();
          return new MutableString().readSelfDelimUTF8( (InputStream)remoteConnection.inputStream );
        }
        catch ( Exception e ) {
            throw new RuntimeException( e );
        }
      }
View Full Code Here

      public Interval get( Object o ) {
        CharSequence prefix = (CharSequence)o;
        try {
          ensureConnection();
          remoteConnection.outputStream.writeByte( RemotePrefixMap.GET_INTERVAL );
          new MutableString( prefix ).writeSelfDelimUTF8( (OutputStream)remoteConnection.outputStream );
          remoteConnection.outputStream.flush();
          return Interval.valueOf( remoteConnection.inputStream.readInt(), remoteConnection.inputStream.readInt() );
        }
        catch ( Exception e ) {
          throw new RuntimeException( e );
View Full Code Here

      this.prefixMap = prefixMap;
    }
   
    public void run() {
      try {
        final MutableString s = new MutableString();
        int command;
        Interval interval;

        for ( ;; ) {
          command = inputStream.readByte();
          if ( DEBUG ) LOGGER.debug( "Received remote command: " + command );

          switch ( command ) {
          case RemoteTermMap.GET_NUMBER:
            outputStream.writeLong( prefixMap.getLong( s.readSelfDelimUTF8( (InputStream)inputStream ) ) );
            outputStream.flush();
            break;

          case RemoteTermMap.GET_TERM:
            new MutableString( prefixMap.list().get( inputStream.readInt() ) ).writeSelfDelimUTF8( (OutputStream)outputStream );
            outputStream.flush();
            break;

          case RemoteTermMap.HAS_TERMS:
            outputStream.writeBoolean( prefixMap.list() != null );
            outputStream.flush();
            break;

          case RemotePrefixMap.GET_INTERVAL:
            interval = prefixMap.rangeMap().get( s.readSelfDelimUTF8( (InputStream)inputStream ) );
            outputStream.writeInt( interval.left );
            outputStream.writeInt( interval.right );
            outputStream.flush();
            break;

          case RemotePrefixMap.GET_PREFIX:
            new MutableString( prefixMap.prefixMap().get( Interval.valueOf( inputStream.readInt(), inputStream.readInt() ) ) ).writeSelfDelimUTF8( (OutputStream)outputStream );
            outputStream.flush();
            break;

          case RemotePrefixMap.HAS_PREFIXES:
            outputStream.writeBoolean( prefixMap.prefixMap() != null );
View Full Code Here

TOP

Related Classes of it.unimi.dsi.lang.MutableString

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.