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

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


    {
      Byte datasetID = values.nextDatasetID ();
      Iterator<Tuple> valuesToBeOutput = values.next();
      while( valuesToBeOutput.hasNext() )
      {
        Tuple outTuple = new Tuple();
       
        Tuple aTuple = valuesToBeOutput.next();
        aTuple.setSchema(this.getSchemaByDatasetID(datasetID));
       
        // make the column output ordering the same as
        // the <code>_projections</code> ordering.
        for( Projectable aFunc:this._projections)
        {
          String name = ((Column)aFunc).getInputColumnName();         
          outTuple.insert(name, aTuple.get(name));
        }       
        output.collect(NullWritable.get(), outTuple);
      }
    }
  }
View Full Code Here


 
  public void write(Tuple tuple)
    throws IOException
  {
   
    Tuple value = new Tuple();
    for( String aValueColumn:valueColumns )
    {
      value.insert(aValueColumn, tuple.get(aValueColumn));
    }
   
    if( mapOnly )
    {
      if( this.tupleCriteria!=null && !this.tupleCriteria.accept(value, this.conf))
      {
        return;
      }
     
      output.collect(NullWritable.get(), value);
    }
    else
    {
      Tuple key = new Tuple();
      for( String aKeyColumn:keyColumns )
      {
        key.insert(aKeyColumn, tuple.get(aKeyColumn));
      }
     
      if( this.tupleCriteria!=null && !this.tupleCriteria.accept(value, this.conf))
      {
        return;
View Full Code Here

        key.setSchema(this.getKeySchemaByDatasetID(datasetID));
      }
     
      Iterator<Tuple> tuples = values.next ();
     
      Tuple combinedValue = new Tuple();
     
      long progress = 0L;
      while( tuples.hasNext() )
      {
        Tuple aTuple = tuples.next();
        if( ++progress % 3000 ==0 )
        {
          reporter.progress();
        }       
        aTuple.setSchema(this.getValueSchemaByDatasetID(datasetID));
       
        for( Projectable p:this.dsToFuncsMapping.get(datasetID) )
        {
          if( p instanceof GroupFunction )
          {
            ((GroupFunction) p).consume(aTuple);
          }
          else
          {
            ExtendFunction func    = (ExtendFunction)p;
            Tuple computedResult   = func.getResult(aTuple);
           
            String name = func.getInputColumns()[0].getInputColumnName();           
            combinedValue.insert(name, computedResult.get(0));
          }
        }
      }
     
      for( Projectable p:this.dsToFuncsMapping.get(datasetID) )
      {
        if( p instanceof GroupFunction )
        {
          BigTupleList aggregatedResult = ((GroupFunction)p).getResult();
          if( aggregatedResult.size() ==1 )
          {
            Tuple aggResult = aggregatedResult.getFirst();
            String name = p.getInputColumns()[0].getInputColumnName();
            combinedValue.insert(name, aggResult.get(0));
          }
          else if( aggregatedResult.size()>1 )
            throw new IllegalArgumentException(p.toString()+" is a group function that generates " +
                "more than one rows ("+aggregatedResult.size()+") per key, so it is not combinable.");
        }
View Full Code Here

   */
  @Override
  public Tuple parse(LongWritable inkey, Text invalue)
      throws IllegalFormatException, IOException
  {   
    Tuple tuple    = Tuple.valueOf(invalue, this.schema, this.delimiter);   
    return tuple;
  }
View Full Code Here

  {
    Dataset ds = this.createDummyDataset("ds", new String[]{"COLUMN"});
   
    BigDecimal expected = BigDecimal.valueOf(Double.MAX_VALUE).add(BigDecimal.valueOf(Double.MAX_VALUE));
   
    Tuple t = new Tuple();
    t.put("COLUMN", Double.MAX_VALUE);
   
    Sum func = new Sum(new Column(ds, "COLUMN"));
    func.reset();
    func.consume(t);
    func.consume(t);
View Full Code Here

    throws IOException
  {
    Dataset ds = this.createDummyDataset("ds", new String[]{"COLUMN"});
    BigDecimal expected = BigDecimal.valueOf(-5D);
   
    Tuple t1 = new Tuple();
    t1.put("column", 10D);
   
    Tuple t2 = new Tuple();
    t2.put("column", Double.MIN_VALUE);
   
    Tuple t3 = new Tuple();
    t3.put("column", Math.abs(Double.MIN_VALUE));
   
    Tuple t4 = new Tuple();
    t4.put("column", -15D);
   
    Sum func = new Sum(new Column(ds, "COLUMN"));
    func.reset();
   
    func.consume(t1);
View Full Code Here

 
  @Test
  public void testSerDe()
    throws IOException
  {
    Tuple t1 = new Tuple();
    t1.put("k1", "v1");
   
    Tuple t2 = new Tuple();
    t2.put("k2", "v2");
   
    DataJoinKey k1 = new DataJoinKey(Byte.valueOf("1"), t1);
    DataJoinKey k2 = new DataJoinKey(Byte.valueOf("1"), t2);
   
    ByteArrayOutputStream b1 = new ByteArrayOutputStream();
View Full Code Here

      {     
        BigTupleList temp = new BigTupleList(reporter);
        Iterator<Tuple> it1 = dataset1.iterator();
        while( it1.hasNext() )
        {
          Tuple rowFromDS1 = it1.next();
         
          Iterator<Tuple> it2 = dataset2.iterator();
          while( it2.hasNext() )
          {
            Tuple merged = Tuple.merge(rowFromDS1, it2.next());
            temp.add(merged);
          }
          close(it2);
        }
        close(it1);
View Full Code Here

    List<Tuple> tuples    = new ArrayList<Tuple>();
    StringBuffer trueAnswer = new StringBuffer();
    final int max = 50;
    for( int i=0;i<max;i++)
    {
      Tuple t = new Tuple();
      t.put("ID", i);
      tuples.add(t);
     
      trueAnswer.append(i);
      if( i<max-1)
      {
View Full Code Here

   
    Array a1 = new Array();
    a1.add(1);
    a1.add(2);
    a1.add(3);   
    Tuple t1 = new Tuple();
    t1.put("C1", new ResultWrapper(a1));   
    tuples.add(t1);
   
    Tuple t2 = new Tuple();
    t2.put("C1", 4);
    tuples.add(t2);
   
    Array a2 = new Array();
    a2.add(5);   
    Tuple t3 = new Tuple();
    t3.put("C1", a2);
    tuples.add(t3);
   
   
    Dataset ds = this.createDummyDataset("test", new String[]{"C1"});
    Concate func = new Concate(new Column(ds, "C1"));
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.