Package it.unimi.dsi.lang

Examples of it.unimi.dsi.lang.MutableString


  public long getLong( Object o ) {
    CharSequence term = (CharSequence)o;
    try {
      ensureConnection();
      remoteConnection.outputStream.writeByte( RemoteTermMap.GET_NUMBER );
      new MutableString( term ).writeSelfDelimUTF8( (OutputStream)remoteConnection.outputStream );
      remoteConnection.outputStream.flush();
      return remoteConnection.inputStream.readLong();
    }
    catch ( Exception e ) {
      throw new RuntimeException( e );
View Full Code Here


      this.termMap = termMap;
    }
   
    public void run() {
      try {
        final MutableString s = new MutableString();
        int command;
        for ( ;; ) {
          command = inputStream.readByte();
          if ( DEBUG ) LOGGER.debug( "Received remote command: " + command );

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

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

          case RemoteTermMap.HAS_TERMS:
            outputStream.writeBoolean( termMap.list() != null );
View Full Code Here

      curr = new Interval[ n ];
      intervalIterator = new IntervalIterator[ n ];
    }

    public String toString() {
       MutableString res = new MutableString();
       res.append( this.getClass().getName() ).append( "(" ).delete( 0, res.lastIndexOf( '.' ) + 1 );
       for ( int i = 0; i < intervalIterator.length; i++ ) res.append( i > 0 ? "," : "" ).append( intervalIterator[ i ] );
       return res.append( ")" ).toString();
    }
View Full Code Here

      currPos = new int[ n ];
      curr = new int[ n ];
    }

    public String toString() {
       MutableString res = new MutableString();
       res.append( this.getClass().getName() ).append( "(" ).delete( 0, res.lastIndexOf( '.' ) + 1 );
       for ( int i = 0; i < position.length; i++ ) res.append( i > 0 ? "," : "" ).append( IntArrayList.wrap( position[ i ], count[ i ] ) );
       return res.append( ")" ).toString();
    }
View Full Code Here

    this.query = query;
    this.k = k;
  }
 
  public String toString() {
    return new MutableString().append( '(' ).append( query ).append( ")<" ).append( k ).toString();
  }
View Full Code Here

  public void build( final DocumentSequence inputSequence ) throws IOException {
    final DocumentIterator docIt = inputSequence.iterator();
    if ( factory != inputSequence.factory() ) throw new IllegalStateException( "The factory provided by the constructor does not correspond to the factory of the input sequence" );
    final int numberOfFields = factory.numberOfFields();
    WordReader wordReader;
    MutableString word = new MutableString();
    MutableString nonWord = new MutableString();
   
    open( "" );
    for (;;) {
      Document document = docIt.nextDocument();
      if ( document == null ) break;
View Full Code Here

   * @param sep the separator between component queries.
   * @return a string representation for this composite query node.
   */
 
  protected String toString( final String start, final String end, final String sep ) {
    final MutableString s = new MutableString();
    s.append( start );
    for( int i = 0; i < query.length; i++ ) {
      if ( i != 0 ) s.append( sep );
      s.append( query[ i ] );
    }
    s.append( end );
    return s.toString();
  }
View Full Code Here

    final int h = jsapResult.getInt( "h" );
    final String basename = jsapResult.getString( "basename" );
    final PrintStream printStream[] = new PrintStream[ h + 1 ];
    for( int i = 0; i <= h; i++ ) printStream[ i ] = new PrintStream( new FastBufferedOutputStream( new FileOutputStream( basename + "-" + i + DiskBasedIndex.STATS_EXTENSION ) ) );
   
    final MutableString line = new MutableString();
    final FastBufferedReader reader = new FastBufferedReader( new InputStreamReader( System.in ) );
   
    int l, start;
    while( reader.readLine( line ) != null ) {
      if ( line.charAt( 0 ) == '#' ) continue;
      matcher.reset( line );
      l = 0;
      start = 0;
      while( matcher.find() && l <= h ) {
        printStream[ l ].println( line.subSequence( start, matcher.start() ) );
        start = matcher.end();
        l++;
      }
    }
   
View Full Code Here

    int numberOfPartialQueries = queries;
    ProgressLogger pl = new ProgressLogger( LOGGER );
    pl.itemsName = "Klines";
    pl.expectedUpdates = maxDoc / 1000;
    pl.start( "Generating queries..." );
    MutableString line = new MutableString();
    while( reader.readLine( line ) != null && numberOfPartialQueries > 0 ) {
      if ( used[ lineNumber ] ) {
        for ( q = 0; q < queries; q++ )
          if ( coveredForQuery[ q ] < docperquery && docForQuery[ q ][ coveredForQuery[ q ] ] == lineNumber ) {
            split = line.toString().split( " " );
            int nw = split.length;
            words = IntArrays.ensureCapacity( words, nw + 1 );
            for ( i = 0; i < nw; i++ ) words[ i ] = i;
            for ( i = 0; i < Math.min( wordsperdoc, nw ); i++ ) {
              j = i + (int)( ( nw - i ) * Math.random() );
              t = words[ i ]; words[ i ] = words[ j ]; words[ j ] = t;
              query[ q ][ coveredForQuery[ q ] ][ i ] = split[ words[ i ] ];
            }
            coveredForQuery[ q ]++;
            if ( coveredForQuery[ q ] == docperquery ) numberOfPartialQueries--;
          }
      }
      lineNumber++;
      if ( lineNumber % 1000 == 0 ) pl.update();
    }
    pl.done();

    MutableString p[] = new MutableString[ Math.max( queries, wordsperdoc ) ], s = new MutableString();
    for( i = 0; i < p.length; i++ ) p[ i ] = new MutableString();

    for ( q = 0; q < queries; q++ ) {
      for( int d = 0; d < wordsperdoc; d++ ) {
        int last = 0;
        while( last < wordsperdoc && query[ q ][ d ][ last ] != null ) last++;
        p[ d ].replace( '(' ).append( query[ q ][ d ], 0, last, " AND " ).append( ')' );
      }
      System.out.println( s.length( 0 ).append( p, 0, queries, " OR " ) );
    }

    ArrayList<String> l = new ArrayList<String>();
    final String[] emptyArray = new String[ 0 ];
    for ( q = 0; q < queries; q++ ) {
      for( int w = 0; w < wordsperdoc; w++ ) {
        l.clear();
        for( int d = 0; d < wordsperdoc; d++ ) if ( query[ q ][ d ][ w ] != null ) l.add( query[ q ][ d ][ w ] );
        p[ w ].replace( '(' ).append( l.toArray( emptyArray ), " OR " ).append( ')' );
      }
      System.err.println( s.length( 0 ).append( p, 0, wordsperdoc, " AND " ) );
    }

  }
View Full Code Here

      direct[ i ] = new InputBitStream( temp[ i ].buffer() );
      indirect[ i ] = new InputBitStream( tempFile[ i ] );
      if ( bloomFilterPrecision != 0 ) bloomFilter[ i ] = new BloomFilter( globalIndex.numberOfTerms, bloomFilterPrecision );
    }
    int usedIndices;
    MutableString currentTerm = new MutableString();
    Payload payload = null;
    int frequency, globalPointer, localIndex, localPointer, count = -1;

    pl.expectedUpdates = globalIndex.numberOfPostings;
    pl.itemsName = "postings";
    pl.logInterval = logInterval;
    pl.start( "Partitioning index..." );

    for ( int t = 0; t < globalIndex.numberOfTerms; t++ ) {
      terms.readLine( currentTerm );
      indexIterator = indexReader.nextIterator();
      usedIndices = 0;
      frequency = indexIterator.frequency();
     
      for ( int j = 0; j < frequency; j++ ) {
        globalPointer = indexIterator.nextDocument();               
        localIndex = strategy.localIndex( globalPointer )

        if ( localFrequency[ localIndex ] == 0 ) {
          // First time we see a document for this index.
          currentTerm.println( localTerms[ localIndex ] );
          numTerms[ localIndex ]++;
          usedIndex[ usedIndices++ ] = localIndex;
          if ( bloomFilterPrecision != 0 ) bloomFilter[ localIndex ].add( currentTerm );
        }
       
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.