Examples of TOP


Examples of org.apache.pig.builtin.TOP

  assertEquals("", m.get("k1"), 1);
  assertEquals("", m.get("k2"), 2.0);
  assertEquals("", m.get("k3"), "foo");


        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);
View Full Code Here

Examples of org.apache.pig.piggybank.evaluation.util.Top

public class TestTop extends TestCase {

  @Test
  public void testTop() throws Exception {
    Top top = new Top();
    Tuple inputTuple = DefaultTupleFactory.getInstance().newTuple(3);
    // 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
    DataBag dBag = DefaultBagFactory.getInstance().newDefaultBag();
    inputTuple.set(2, dBag);
    // generate tuples of the form (group-1, 1), (group-2, 2) ...
    for (long i = 0; i < 100; i++) {
      Tuple nestedTuple = DefaultTupleFactory.getInstance().newTuple(2);
      nestedTuple.set(0, "group-" + i);
      nestedTuple.set(1, i);
      dBag.add(nestedTuple);
    }

    DataBag outBag = top.exec(inputTuple);
    super.assertEquals(outBag.size(), 10L);
    Iterator<Tuple> itr = outBag.iterator();
    while (itr.hasNext()) {
      Tuple next = itr.next();
      Long value = (Long) next.get(1);
View Full Code Here

Examples of org.apache.uima.jcas.cas.TOP

      } catch (CASException e1) {
       logAndThrow(e1, jcasView);
      }
    
     // Return eq fs instance if already created
      TOP fs = jcasView.getJfsFromCaddr(addr);
      if (null != fs) {
        fs.jcasType = jcasView.getType(type);
      } else {
        initargs[0] = new Integer(addr);
        initargs[1] = jcasView.getType(type);
View Full Code Here

Examples of org.apache.uima.jcas.cas.TOP

      } catch (CASException e1) {
        logAndThrow(e1, jcasView);
      }

      // Return eq fs instance if already created
      TOP fs = jcasView.getJfsFromCaddr(addr);
      if (null != fs) {
        fs.jcasType = jcasView.getType(type);
      } else {
        initargs[0] = Integer.valueOf(addr);
        initargs[1] = jcasView.getType(type);
View Full Code Here

Examples of org.apache.uima.jcas.cas.TOP

        Annotation a = (Annotation) newFS;
        a.setBegin(matchedAnnotation.getBegin());
        a.setEnd(matchedAnnotation.getEnd());
        stream.addAnnotation(a, match);
      }
      TOP newStructure = null;
      if (newFS instanceof TOP) {
        newStructure = (TOP) newFS;
        fillFeatures(newStructure, features, matchedAnnotation, element, stream);
        newStructure.addToIndexes();
      }
    }
  }
View Full Code Here

Examples of org.apache.uima.jcas.cas.TOP

        Annotation a = (Annotation) newFS;
        a.setBegin(matchedAnnotation.getBegin());
        a.setEnd(matchedAnnotation.getEnd());
        stream.addAnnotation(a, match);
      }
      TOP newStructure = null;
      if (newFS instanceof TOP) {
        newStructure = (TOP) newFS;
        gatherFeatures(newStructure, features, matchedAnnotation, element, match, stream);
        newStructure.addToIndexes();
      }
    }

  }
View Full Code Here

Examples of org.apache.uima.jcas.cas.TOP

        Annotation a = (Annotation) newFS;
        a.setBegin(annotationFS.getBegin());
        a.setEnd(annotationFS.getEnd());
        stream.addAnnotation(a, match);
      }
      TOP newStructure = null;
      if (newFS instanceof TOP) {
        newStructure = (TOP) newFS;
        fillFeatures(newStructure, map, annotationFS, element, rowWhere, stream);
        newStructure.addToIndexes();
      }
    }
  }
View Full Code Here

Examples of org.apache.uima.jcas.cas.TOP

      } catch (CASException e1) {
        logAndThrow(e1, jcasView);
      }

      // Return eq fs instance if already created
      TOP fs = jcasView.getJfsFromCaddr(addr);
      if (null != fs) {
        fs.jcasType = jcasView.getType(type);
      } else {
        initargs[0] = Integer.valueOf(addr);
        initargs[1] = jcasView.getType(type);
View Full Code Here

Examples of org.apache.uima.jcas.cas.TOP

    TypeSystem ts = aList.getCAS().getTypeSystem();
    List<FeatureStructure> data = new ArrayList<FeatureStructure>();
    FSList i = aList;
    while (i instanceof NonEmptyFSList) {
      NonEmptyFSList l = (NonEmptyFSList) i;
      TOP value = l.getHead();
      if (value != null && (type == null || ts.subsumes(type, value.getType()))) {
        data.add(l.getHead());
      }
      i = l.getTail();
    }
View Full Code Here

Examples of org.apache.uima.jcas.cas.TOP

  public void testGetAllFSOfAnnotationType() {
    try {
      JCas cas = getCAS().getJCas();
      cas.setDocumentText(DOCUMENT_TEXT);

      FeatureStructure firstFeatureStructure = new TOP(cas);
      cas.addFsToIndexes(firstFeatureStructure);
      FeatureStructure secondFeatureStructure = new TOP(cas);
      cas.addFsToIndexes(secondFeatureStructure);

      List<FeatureStructure> featureStructures = UIMAUtils.getAllFSofType(TOP.type, cas);

      assertTrue(featureStructures != 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.