Package com.ebay.erl.mobius.core.model

Examples of com.ebay.erl.mobius.core.model.Tuple


    @Override
    public List<TupleToBuffer> fill()
    {
      while ( this.buffer.size()<this.bufferSize && this.currentReadTuples<totalTuples )
      {         
        Tuple t = new Tuple();
        try
        {
          t.readFields(this.reader);
          t.setSchema(this.schema)
        }
        catch (IOException e)
        {
          throw new RuntimeException("Cannot deserialize tuples from underline file:"+source.toString(), e);
        }       
View Full Code Here


 

  @Override
  public void consume(Tuple tuple)
  {
    Tuple t = new Tuple();
    for( int i=0;i<this.inputs.length;i++ )
    {
      String outName  = this.outputSchema[i];
      String inName  = this.inputs[i].getInputColumnName();
      t.insert(outName, tuple.get(inName));
    }
   
    if( this.temp==null )
      this.temp = new BigTupleList(new Tuple(), this.reporter);
   
    this.temp.add(t);
  }
View Full Code Here

    // the <code>temp</code> is sorted, so
    // we just iterate it over and check if
    // the previous tuple is different than
    // the current tuple or not.
   
    Tuple previous = null;
   
    CloseableIterator<Tuple> it = this.temp.iterator();
    while( it.hasNext() )
    {
      Tuple current = it.next();
     
      if( previous==null || previous.compareTo(current)!=0 )
      { 
        // a different tuple comes, add the result
        this.output(current);
View Full Code Here

  @Override
  public BigTupleList getResult()
  {
    long uniqueCounts = 0L;
   
    Tuple previous = null;
   
    CloseableIterator<Tuple> it = this.temp.iterator();
    while( it.hasNext() )
    {
      Tuple current = it.next();
     
      if( previous==null || previous.compareTo(current)!=0 )
      { 
        // a different tuple comes, add the result
        uniqueCounts++;
      }     
      previous = current;
    }
    it.close();
   
    Tuple result = new Tuple();
    result.put(this.getOutputSchema()[0], uniqueCounts);
    this.output(result);
   
    return super.getResult();
  }
View Full Code Here

    Tuple[] tuples = this.maxHeap.toArray(new Tuple[this.maxHeap.size()]);
    Arrays.sort(tuples, this.getComparator());
   
    for( int i=tuples.length-1;i>=0;i-- )
    {
      Tuple currentTuple = tuples[i];
      Tuple t = new Tuple();
      for( int j=0;j<this.getOutputSchema().length;j++ )   
      {
        String inName  = this.inputs[j].getInputColumnName();
        String outName  = this.getOutputSchema()[j];
       
        t.insert(outName, currentTuple.get(inName));
      }
      result.add(t);
    }
    return result;
  }
View Full Code Here

    {
      if( this.sorters==null)
      {
        // user doesn't specified sorters nor customized comparator,
        // use the default comparator (Tuple).
        comp = new Tuple();
      }
      else
      {
        // user has specified sorters, create a comparator that
        // use sorters to compare.
View Full Code Here

   */
  public final Tuple getNoMatchResult(Object nullReplacement)
  {
    if( this.noMatchRow==null )
    {
      Tuple temp = new Tuple();
      for( String aColumn:this.getOutputSchema() )
      {
        if( nullReplacement==null )
        {
          temp.putNull(aColumn);
        }
        else
        {
          temp.insert(aColumn, nullReplacement);
        }
      }
      this.noMatchRow = Tuple.immutable(temp);
    }
    return noMatchRow;
View Full Code Here

    // a BigTupleList, let the BigTupleList
    // perform the sorting, and extract the
    // medium value in the getComputedResult()
    // method.
    Object newValue = tuple.get(this.inputColumnName);   
    Tuple t = new Tuple();
    t.insert(this.inputColumnName, newValue);
    if( this.temp==null)
      this.temp = this.newBigTupleList();
   
    this.temp.add(t);
  }
View Full Code Here

  public Tuple getComputedResult()
  {
    CloseableIterator<Tuple> it = this.temp.iterator();   
    long mediumIdx  = this.temp.size()/2;
    long counts    = 0L;
    Tuple result  = null;
    while( it.hasNext() )
    {
      Tuple t = it.next();
      if( counts<mediumIdx )
      {
        counts++;
      }
      else
View Full Code Here

      // reading elements from one split
      long readElement = 0;
      while (reader.next(key, value))
      {
        collector.clear();
        Tuple tuple = mapper.parse(key, value);
       
        readElement++;
        if (readElement> (((long)numSamples)*((long)proportion)) )
        {
          // a split might be very big (ex: a large gz file),
          // so we just need to read the
          break;
        }
       
        if (r.nextDouble() <= freq)
        {
          if (samples.size() < numSamples)
          {
            mapper.joinmap(key, value, collector, Reporter.NULL);
            // joinmap function might generate more than one output key
            // per <code>key</code> input.
            for( Tuple t:collector.getOutKey() )
            {
              Tuple mt = Tuple.merge(tuple, t);
              DataJoinKey nkey = this.getKey(mt, sorters, datasetID, mapper, job);
              samples.add(nkey);
            }
          }
          else
          {
            // When exceeding the maximum number of samples, replace
            // a random element with this one, then adjust the
            // frequency to reflect the possibility of existing
            // elements being pushed out
           
            mapper.joinmap(key, value, collector, Reporter.NULL);
            for( Tuple t:collector.getOutKey() )
            {
              int ind = r.nextInt(numSamples);
              if (ind != numSamples)
              {
                Tuple mt = Tuple.merge(tuple, t);
                DataJoinKey nkey = this.getKey(mt, sorters, datasetID, mapper, job);
                samples.set(ind, nkey);
              }
            }
           
View Full Code Here

TOP

Related Classes of com.ebay.erl.mobius.core.model.Tuple

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.