Examples of Distinct


Examples of org.apache.pig.builtin.Distinct

    @Test
    public void testDistinctIsNullSafe() throws Exception {
        DataBag empty = bagFactory.newDefaultBag();
        Tuple tupleOfNull = tupleFactory.newTuple(1);
        Tuple tupleOfEmpty = tupleFactory.newTuple(empty);
        assertEquals(empty, new Distinct().exec(tupleOfNull));
        assertEquals(tupleOfEmpty, new Distinct.Initial().exec(tupleOfNull));
        assertEquals(tupleOfEmpty, new Distinct.Intermediate().exec(tupleOfNull));
        assertEquals(empty, new Distinct.Final().exec(tupleOfNull));
    }
View Full Code Here

Examples of org.apache.pig.builtin.Distinct

            inp[i] = i/2;
            inp[i+1] = i/2;
        }

        DataBag inputBag = Util.createBagOfOneColumn(inp);
        EvalFunc<DataBag> distinct = new Distinct();
        DataBag result = distinct.exec(tupleFactory.newTuple(inputBag));

        Integer[] exp = new Integer[inputSize/2];
        for (int j = 0; j < inputSize/2; ++j) {
            exp[j] = j;
        }
View Full Code Here

Examples of org.apache.pig.builtin.Distinct

    @Test
    public void testDistinctIsNullSafe() throws Exception {
        DataBag empty = bagFactory.newDefaultBag();
        Tuple tupleOfNull = tupleFactory.newTuple(1);
        Tuple tupleOfEmpty = tupleFactory.newTuple(empty);
        assertEquals(empty, new Distinct().exec(tupleOfNull));
        assertEquals(tupleOfEmpty, new Distinct.Initial().exec(tupleOfNull));
        assertEquals(tupleOfEmpty, new Distinct.Intermediate().exec(tupleOfNull));
        assertEquals(empty, new Distinct.Final().exec(tupleOfNull));
    }
View Full Code Here

Examples of org.apache.pig.builtin.Distinct

            inp[i] = i/2;
            inp[i+1] = i/2;
        }

        DataBag inputBag = Util.createBagOfOneColumn(inp);
        EvalFunc<DataBag> distinct = new Distinct();
        DataBag result = distinct.exec(tupleFactory.newTuple(inputBag));

        Integer[] exp = new Integer[inputSize/2];
        for(int j = 0; j < inputSize/2; ++j) {
            exp[j] = j;
        }
View Full Code Here

Examples of org.apache.pig.builtin.Distinct

            inp[i] = i/2;
            inp[i+1] = i/2;
        }

        DataBag inputBag = Util.createBagOfOneColumn(inp);
        EvalFunc<DataBag> distinct = new Distinct();
        DataBag result = distinct.exec(tupleFactory.newTuple(inputBag));

        Integer[] exp = new Integer[inputSize/2];
        for(int j = 0; j < inputSize/2; ++j) {
            exp[j] = j;
        }
View Full Code Here

Examples of org.apache.pig.builtin.Distinct

            inp[i] = i/2;
            inp[i+1] = i/2;
        }

        DataBag inputBag = Util.createBagOfOneColumn(inp);
        EvalFunc<DataBag> distinct = new Distinct();
        DataBag result = distinct.exec(tupleFactory.newTuple(inputBag));

        Integer[] exp = new Integer[inputSize/2];
        for(int j = 0; j < inputSize/2; ++j) {
            exp[j] = j;
        }
View Full Code Here

Examples of org.apache.pig.builtin.Distinct

            inp[i] = i/2;
            inp[i+1] = i/2;
        }

        DataBag inputBag = Util.createBagOfOneColumn(inp);
        EvalFunc<DataBag> distinct = new Distinct();
        DataBag result = distinct.exec(tupleFactory.newTuple(inputBag));

        Integer[] exp = new Integer[inputSize/2];
        for(int j = 0; j < inputSize/2; ++j) {
            exp[j] = j;
        }
View Full Code Here

Examples of org.openrdf.query.algebra.Distinct

      }

      result = new Projection(result, projElemList);

      // Filter the duplicates from these projected bindings
      result = new Distinct(result);
    }

    // Create BNodeGenerator's for all anonymous variables
    Map<Var, ExtensionElem> extElemMap = new HashMap<Var, ExtensionElem>();

    for (Var var : constructVars) {
      if (var.isAnonymous() && !extElemMap.containsKey(var)) {
        ValueExpr valueExpr = null;

        if (var.hasValue()) {
          valueExpr = new ValueConstant(var.getValue());
        }
        else if (explicit) {
          // only generate bnodes in case of an explicit constructor
          valueExpr = new BNodeGenerator();
        }

        if (valueExpr != null) {
          extElemMap.put(var, new ExtensionElem(valueExpr, var.getName()));
        }
      }
    }

    if (!extElemMap.isEmpty()) {
      result = new Extension(result, extElemMap.values());
    }

    // Create a Projection for each StatementPattern in the constructor
    List<ProjectionElemList> projections = new ArrayList<ProjectionElemList>();

    for (StatementPattern sp : statementPatterns) {
      ProjectionElemList projElemList = new ProjectionElemList();

      projElemList.addElement(new ProjectionElem(sp.getSubjectVar().getName(), "subject"));
      projElemList.addElement(new ProjectionElem(sp.getPredicateVar().getName(), "predicate"));
      projElemList.addElement(new ProjectionElem(sp.getObjectVar().getName(), "object"));

      projections.add(projElemList);
    }

    if (projections.size() == 1) {
      result = new Projection(result, projections.get(0));

      // Note: no need to apply the second duplicate elimination step if
      // there's just one projection
    }
    else if (projections.size() > 1) {
      result = new MultiProjection(result, projections);

      if (distinct) {
        // Add another distinct to filter duplicate statements
        result = new Distinct(result);
      }
    }
    else {
      // Empty constructor
      result = new EmptySet();
View Full Code Here

Examples of org.openrdf.query.algebra.Distinct

    TupleExpr rightArg = (TupleExpr)node.getRightArg().jjtAccept(this, null);

    TupleExpr result = new Union(leftArg, rightArg);

    if (node.isDistinct()) {
      result = new Distinct(result);
    }

    return result;
  }
View Full Code Here

Examples of org.openrdf.query.algebra.Distinct

    TupleExpr rightArg = (TupleExpr)node.getRightArg().jjtAccept(this, null);

    TupleExpr result = new Union(leftArg, rightArg);

    if (node.isDistinct()) {
      result = new Distinct(result);
    }

    return result;
  }
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.