Package cascading.tuple

Examples of cascading.tuple.Tuple


    public int size() {
      return _closure.size();
    }

    public void emit(Tuple result) {
      Tuple ret = new Tuple(((HadoopCoGroupClosure) _closure).getGrouping());
      ret.addAll(result);
      while (ret.size() < _pipeFieldsSum) {
        ret.add(0);
      }
      _results.add(ret);
    }
View Full Code Here


          return it.hasNext();
        }

        @Override
        public Tuple next() {
          return new Tuple(it.next());
        }

        @Override
        public void remove() {
          it.remove();
View Full Code Here

  @Override
  public void operate(FlowProcess flowProcess, FunctionCall fnCall) {
    TupleEntry args = fnCall.getArguments();
    Number n = (Number) args.get(0);
    for (int i = 1; i <= n.intValue(); i++) {
      fnCall.getOutputCollector().add(new Tuple(i));
    }
  }
View Full Code Here

  }

  @Override
  public void complete(FlowProcess flowProcess, AggregatorCall aggregatorCall) {
    int count = (Integer) aggregatorCall.getContext();
    aggregatorCall.getOutputCollector().add(new Tuple(count));
  }
View Full Code Here

import cascalog.CascalogBuffer;

public class OneBuffer extends CascalogBuffer {

  public void operate(FlowProcess flowProcess, BufferCall bufCall) {
    bufCall.getOutputCollector().add(new Tuple(1));
  }
View Full Code Here

      agg.prepare(flowProcess);
    }
  }

  public void operate(FlowProcess fp, FunctionCall fc) {
    Tuple group = fc.getArguments().selectTuple(groupFields);
    Tuple sortArgs = null;
    if (includeSort) {
      if (sortFields != null) {
        sortArgs = fc.getArguments().selectTuple(sortFields);
      } else {
        sortArgs = new Tuple();
      }
    }
    Map<Integer, List<Object>> vals = combined.get(group);
    if (vals == null) {
      vals = new HashMap<Integer, List<Object>>(aggs.size());
      combined.put(group, vals);
    }
    for (int i = 0; i < aggs.size(); i++) {
      try {
        Fields specArgFields = argFields.get(i);
        List<Object> val;
        ParallelAgg agg = aggs.get(i);
        if (specArgFields == null) {
          val = agg.init(new ArrayList<Object>());
        } else {
          Tuple args = fc.getArguments().selectTuple(specArgFields);
          List<Object> toApply = new ArrayList<Object>();
          if (sortArgs != null) {
            toApply.add(Util.tupleToList(sortArgs));
          }
          Util.tupleIntoList(toApply, args);
          val = agg.init(toApply);
        }

        if (vals.get(i) != null) {
          List<Object> existing = vals.get(i);
          val = agg.combine(existing, val);
        }
        vals.put(i, val);
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }

    combined.put(group, vals);

    if (combined.size() >= this.cacheSize) {
      Tuple evict = combined.keySet().iterator().next();
      Map<Integer, List<Object>> removing = combined.remove(evict);
      writeMap(evict, removing, fc);
    }
  }
View Full Code Here

  }

  @Override
  protected void write(Tuple group, List<Object> val, OperationCall opCall) {
    TupleEntryCollector output = ((FunctionCall) opCall).getOutputCollector();
    Tuple t = new Tuple(group);
    for (Object o : val) {
      t.add(o);
    }
    output.add(t);
  }
View Full Code Here

    }
    Object val = vals.get(0);
    try {
      ISeq result_seq = RT.seq(extract_fn.invoke(val));
      while (result_seq != null) {
        Tuple t = Util.coerceToTuple(result_seq.first());
        Tuple emit = new Tuple(group);
        emit.addAll(t);
        output.add(emit);
        result_seq = result_seq.next();
      }
    } catch (Exception e) {
      throw new RuntimeException(e);
View Full Code Here

          public Object next() {
            if (emittedOne) {
              throw new RuntimeException("Shouldn't be accessing outerjoin_first more than once");
            }
            emittedOne = true;
            Tuple t = (Tuple) wrapped.next();
            Tuple ret = new Tuple();
            for (int i = 0; i < t.size(); i++) {
              ret.add(!isEmpty);
            }
            return ret;
          }

          public void remove() {
View Full Code Here

  }

  @Override
  public boolean source(FlowProcess<JobConf> flowProcess,
      SourceCall<Object[], RecordReader> sourceCall) throws IOException {
    Tuple result = new Tuple();

    Object key = sourceCall.getContext()[0];
    Object value = sourceCall.getContext()[1];
    boolean hasNext = sourceCall.getInput().next(key, value);
    if (!hasNext) { return false; }

    // Skip nulls
    if (key == null || value == null) { return true; }

    ImmutableBytesWritable keyWritable = (ImmutableBytesWritable) key;
    Result row = (Result) value;
    result.add(keyWritable);

    for (int i = 0; i < this.familyNames.length; i++) {
      String familyName = this.familyNames[i];
      byte[] familyNameBytes = Bytes.toBytes(familyName);
      Fields fields = this.valueFields[i];
      for (int k = 0; k < fields.size(); k++) {
        String fieldName = (String) fields.get(k);
        byte[] fieldNameBytes = Bytes.toBytes(fieldName);
        byte[] cellValue = row.getValue(familyNameBytes, fieldNameBytes);
        result.add(cellValue != null ? new ImmutableBytesWritable(cellValue) : null);
      }
    }

    sourceCall.getIncomingEntry().setTuple(result);
View Full Code Here

TOP

Related Classes of cascading.tuple.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.