Examples of TupleFactory


Examples of eu.admire.ogsadai.activity.block.TupleFactory

      // Interface implementation
      public Object call() throws Exception
      {
          Thread.sleep(mInitialSleepDuration);
         
          TupleFactory tf = new SimpleTupleFactory();
          for (int i=0; i<mBlocks; ++i)
          {
            if(i%1000 == 0){
              //Just to see if it's going anywhere
              System.out.println("Writer at iteration " + i + " size of the pipe is " + mPipe.getNumBlocksReadable());
             
              //Flush every so often to prevent OutOfMemory
              mPipe.resetWriter();
            }
              mPipe.write(tf.createTuple());
              Thread.sleep(mIntervalDuration);
          }
        
          mPipe.closeForWriting();
         
View Full Code Here

Examples of kodkod.instance.TupleFactory

   * a mapping from (this.variableUsage().keySet() & Relation) to sets of Tuples.
   * @throws IllegalStateException - this.solver.solve() has not been called or the
   * outcome of the last call was not <code>true</code>.
   */
  public Instance interpret() {
    final TupleFactory f = bounds.universe().factory();
    final Instance instance = new Instance(bounds.universe());
//    System.out.println(varUsage);
    for(Relation r : bounds.relations()) {
      TupleSet lower = bounds.lowerBound(r);
      IntSet indeces = Ints.bestSet(lower.capacity());
      indeces.addAll(lower.indexView());
      IntSet vars = primaryVarUsage.get(r);
      if (vars!=null) {
        int lit = vars.min();
        for(IntIterator iter = bounds.upperBound(r).indexView().iterator(); iter.hasNext();) {
          final int index = iter.next();
          if (!indeces.contains(index) && solver.valueOf(lit++))
            indeces.add(index);
        }
      }
      instance.add(r, f.setOf(r.arity(), indeces));
    }
    return instance;
  }
View Full Code Here

Examples of org.apache.crunch.types.TupleFactory

      PTypeFamily ptf = ptype.getFamily();
      if (cols.length == 1) {
        byFn = new SingleKeyFn(cols[0]);
        keyPType = pt.get(cols[0]);
      } else {
        TupleFactory tf = null;
        switch (cols.length) {
        case 2:
          tf = TupleFactory.PAIR;
          keyPType = ptf.pairs(pt.get(cols[0]), pt.get(cols[1]));
          break;
View Full Code Here

Examples of org.apache.openjpa.persistence.TupleFactory

        } else {
            if (parent.getType().isArray() && q.isMultiselect()) {
                Class<?> componentType = parent.getType().getComponentType();
                if (componentType == Tuple.class) {
                    result = new ResultShape(componentType,
                         new FillStrategy.Factory(new TupleFactory(s), TupleImpl.PUT), false);
                } else {
                    result = new ResultShape(componentType, new FillStrategy.Assign(), true);
                }
            } else {
                result = new ResultShape(type, new FillStrategy.Assign(), true);
View Full Code Here

Examples of org.apache.openjpa.persistence.TupleFactory

               result.nest(getShape(q, result, term));
           }
        } else { // not multiselect
            FillStrategy<?> strategy = new FillStrategy.Assign();
            if (Tuple.class.isAssignableFrom(resultClass)) {
                TupleFactory factory = new TupleFactory(selections.toArray(new TupleElement[selections.size()]));
                strategy = new FillStrategy.Factory<Tuple>(factory,  TupleImpl.PUT);
            }
            result = new ResultShape(resultClass, strategy);
            if (q.getSelectionList() == null) {
                return result;
View Full Code Here

Examples of org.apache.pig.data.TupleFactory

        assertTrue(r==null);
        r = func.exec(t3);
        assertTrue(r==null);
       
        String matchRegex = "^(.+)\\b\\s+is a\\s+\\b(.+)$";
        TupleFactory tupleFactory = TupleFactory.getInstance();
        Tuple te1 = tupleFactory.newTuple(2);
        te1.set(0,"this is a match");
        te1.set(1, matchRegex);
       
        Tuple te2 = tupleFactory.newTuple(2);
        te2.set(0, "no match");
        te2.set(1, matchRegex);
       
        Tuple te3 = tupleFactory.newTuple(2);
        te3.set(0, null);
        te3.set(1, matchRegex);
    
        REGEX_EXTRACT_ALL funce = new REGEX_EXTRACT_ALL();
        Tuple re = funce.exec(te1);
View Full Code Here

Examples of org.apache.pig.data.TupleFactory

        Tuple output = tt.exec(input);
        assertTrue(!(input == output));
        assertEquals(input, output);
       
        TOP top = new TOP();
        TupleFactory tupleFactory = TupleFactory.getInstance();
        BagFactory bagFactory = DefaultBagFactory.getInstance();
        Tuple inputTuple = tupleFactory.newTuple(3);
        DataBag dBag = bagFactory.newDefaultBag();
       
        // set N = 10 i.e retain top 10 tuples
        inputTuple.set(0, 10);
        // compare tuples by field number 1
        inputTuple.set(1, 1);
        // set the data bag containing the tuples
        inputTuple.set(2, dBag);

        // generate tuples of the form (group-1, 1), (group-2, 2) ...
        for (long i = 0; i < 100; i++) {
            Tuple nestedTuple = tupleFactory.newTuple(2);
            nestedTuple.set(0, "group-" + i);
            nestedTuple.set(1, i);
            dBag.add(nestedTuple);
        }
       
        DataBag outBag = top.exec(inputTuple);
        assertEquals(outBag.size(), 10L);
        checkItemsGT(outBag, 1, 89);
       
        // two initial results
        Tuple init1 = (new TOP.Initial()).exec(inputTuple);
        Tuple init2 = (new TOP.Initial()).exec(inputTuple);
        // two intermediate results

        DataBag intermedBag = bagFactory.newDefaultBag();
        intermedBag.add(init1);
        intermedBag.add(init2);
        Tuple intermedInput = tupleFactory.newTuple(intermedBag);
        Tuple intermedOutput1 = (new TOP.Intermed()).exec(intermedInput);
        Tuple intermedOutput2 = (new TOP.Intermed()).exec(intermedInput);
        checkItemsGT((DataBag)intermedOutput1.get(2), 1, 94);

        // final result
        DataBag finalInputBag = bagFactory.newDefaultBag();
        finalInputBag.add(intermedOutput1);
        finalInputBag.add(intermedOutput2);
        Tuple finalInput = tupleFactory.newTuple(finalInputBag);
        outBag = (new TOP.Final()).exec(finalInput);
        assertEquals(outBag.size(), 10L);
        checkItemsGT(outBag, 1, 96);
    }
View Full Code Here

Examples of org.apache.pig.data.TupleFactory

        assertEquals("amy smith", t.get(3));
    }
   
    @Test
    public void testTOKENIZE() throws Exception {
        TupleFactory tf = TupleFactory.getInstance();
        Tuple t1 = tf.newTuple(1);
        t1.set(0, "123 456\"789");
        Tuple t2 = tf.newTuple(1);
        t2.set(0, null);
        Tuple t3 = tf.newTuple(0);
       
        TOKENIZE f = new TOKENIZE();
        DataBag b = f.exec(t1);
        assertTrue(b.size()==3);
        Iterator<Tuple> i = b.iterator();
View Full Code Here

Examples of org.apache.pig.data.TupleFactory

    @Test
    public void testDIFF() throws Exception {
        // Test it in the case with two bags.
        BagFactory bf = BagFactory.getInstance();
        TupleFactory tf = TupleFactory.getInstance();

        DataBag b1 = bf.newDefaultBag();
        DataBag b2 = bf.newDefaultBag();
        for (int i = 0; i < 10; i++) b1.add(tf.newTuple(new Integer(i)));
        for (int i = 0; i < 10; i += 2) b2.add(tf.newTuple(new Integer(i)));
        Tuple t = tf.newTuple(2);
        t.set(0, b1);
        t.set(1, b2);
        DIFF d = new DIFF();
        DataBag result = d.exec(t);

        assertEquals(5, result.size());
        Iterator<Tuple> i = result.iterator();
        int[] values = new int[5];
        for (int j = 0; j < 5; j++) values[j] = (Integer)i.next().get(0);
        Arrays.sort(values);
        for (int j = 1; j < 10; j += 2) assertEquals(j, values[j/2]);

        // Test it in the case of two objects that are equals
        t = tf.newTuple(2);
        t.set(0, new Integer(1));
        t.set(1, new Integer(1));
        result = d.exec(t);
        assertEquals(0, result.size());

        // Test it in the case of two objects that are not equal
        t = tf.newTuple(2);
        t.set(0, new Integer(1));
        t.set(1, new Integer(2));
        result = d.exec(t);
        assertEquals(2, result.size());
    }
View Full Code Here

Examples of org.apache.pig.data.TupleFactory

    if (in == null || in.getPosition() > end) {
      return null;
    }
    Pattern pattern = getPattern();
    Matcher matcher = pattern.matcher("");
    TupleFactory mTupleFactory = DefaultTupleFactory.getInstance();
    String line;
    boolean tryNext = true;
    while (tryNext) {
      if ((line = in.readLine(utf8, recordDel)) == null) {
        break;
      }
      if (line.length() > 0 && line.charAt(line.length() - 1) == '\r')
        line = line.substring(0, line.length() - 1);

      matcher = matcher.reset(line);
      ArrayList<DataByteArray> list = new ArrayList<DataByteArray>();
      if (matcher.find()) {
        tryNext=false;
        for (int i = 1; i <= matcher.groupCount(); i++) {
          list.add(new DataByteArray(matcher.group(i)));
        }
        return mTupleFactory.newTuple(list)
      }
    }


    return null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.