Java Code Examples for org.apache.pig.data.Tuple#equals()
The following examples show how to use
org.apache.pig.data.Tuple#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SetDifference.java From datafu with Apache License 2.0 | 6 votes |
/** * Counts how many elements in the priority queue match the * element at the front of the queue, which should be from the first bag. * * @param pq priority queue * @return number of matches */ public int countMatches(PriorityQueue<Pair> pq) { Pair nextPair = pq.peek(); Tuple data = nextPair.data; // sanity check if (!nextPair.index.equals(0)) { throw new RuntimeException("Expected next bag to have index 0"); } int matches = 0; for (Pair p : pq) { if (data.equals(p.data)) matches++; } // subtract 1 since element matches itself return matches - 1; }
Example 2
Source File: ScorePMML_ElNinoTest.java From Surus with Apache License 2.0 | 5 votes |
@Test public void regressionScoringTest_ElNino_1() throws IOException, SAXException, JAXBException { Schema inputSchema = buildElNinoInputSchema(); // Input/Output Bag Tuple inputTuple = tf.newTuple(); Tuple expected = tf.newTuple(); { // Visit 1, Input: Implicit Signout inputTuple = this.buildElNinoInputEvent("1","1","1","8.96","-140.32","-6.3","-6.4","83.5","27.32","27.57"); // Visit 1, Output expected = this.buildElNinoOutputEvent("1","1","1","8.96","-140.32","-6.3","-6.4","83.5","27.32","27.57",27.384241597858438); } // Initialize Class ScorePMML evalPMML = new ScorePMML(this.regressionElNinoModelPath); Schema outputSchema = evalPMML.outputSchema(inputSchema); Tuple observed = evalPMML.exec(inputTuple); // Test if (expected.equals(observed)) { System.out.println("regressionScoringTest_ElNino_1: PASS"); } else { System.out.println("---------- EPIC FAIL: regressionScoringTest_ElNino_1 ----------"); System.out.println("Expected: " + expected.toString()); System.out.println("Observed: " + observed.toString()); System.out.println("-------- END EPIC FAIL --------"); } assertEquals(expected,observed); }
Example 3
Source File: ScorePMML_AuditTest.java From Surus with Apache License 2.0 | 5 votes |
@Test public void ensembleScoringTest_Audit_1() throws IOException, SAXException, JAXBException { Schema inputSchema = buildAuditInputSchema(); // Input/Output Bag Tuple inputTuple = tf.newTuple(); Tuple expected = tf.newTuple(); { // Visit 1, Input: Implicit Signout inputTuple = this.buildAuditInputEvent(1038288L,45,"Private","Bachelor","Married","Repair",27743.82,"Male",0,55,"UnitedStates",7298,1); // Visit 1, Output expected = this.buildAuditOutputEvent(1038288L,45,"Private","Bachelor","Married","Repair",27743.82,"Male",0,55,"UnitedStates",7298,1,"0"); } // Initialize Class ScorePMML evalPMML = new ScorePMML(this.ensembleAuditModelPath); Schema outputScheam = evalPMML.outputSchema(inputSchema); Tuple observed = evalPMML.exec(inputTuple); // Test if (expected.equals(observed)) { System.out.println("ensembleScoringTest_Audit_1: PASS"); } else { System.out.println("---------- EPIC FAIL: ensembleScoringTest_Audit_1 ----------"); System.out.println("Expected: " + expected.toString()); System.out.println("Observed: " + observed.toString()); System.out.println("-------- END EPIC FAIL --------"); } assertEquals(expected,observed); }
Example 4
Source File: ScorePMML_IrisTest.java From Surus with Apache License 2.0 | 5 votes |
@Test public void treeScoringTest_Iris_1() throws IOException, SAXException, JAXBException { // Build Input Schema Schema inputSchema = buildIrisInputSchema(); // Input/Output Bag Tuple inputTuple = tf.newTuple(); Tuple expected = tf.newTuple(); { // Visit 1, Input: Implicit Signout inputTuple = this.buildIrisInputEvent(5.1,3.5,1.4,0.2,"Iris-setosa"); // Visit 1, Output expected = this.buildIrisOutputEvent("Iris-setosa"); } // Initialize Class ScorePMML evalPMML = new ScorePMML(this.treeIrisModelPath); Schema outputScheam = evalPMML.outputSchema(inputSchema); Tuple observed = evalPMML.exec(inputTuple); // Test if (expected.equals(observed)) { System.out.println("treeScoringTest_Iris_1: PASS"); } else { System.out.println("---------- EPIC FAIL: treeScoringTest_Iris_1 ----------"); System.out.println("Expected: " + expected.toString()); System.out.println("Observed: " + observed.toString()); System.out.println("-------- END EPIC FAIL --------"); } assertEquals(expected,observed); }
Example 5
Source File: ScorePMML_IrisTest.java From Surus with Apache License 2.0 | 5 votes |
@Test public void treeScoringTest_Iris_2() throws IOException, SAXException, JAXBException { // Build Input Schema Schema inputSchema = buildIrisInputSchema(); // Input/Output Bag Tuple inputTuple = tf.newTuple(); Tuple expected = tf.newTuple(); { // Visit 1, Input: Implicit Signout inputTuple = this.buildIrisInputEvent(5.9,3.2,4.8,1.8,"Iris-versicolor"); // Visit 1, Output expected = this.buildIrisOutputEvent("Iris-virginica"); } // Initialize Class ScorePMML evalPMML = new ScorePMML(this.treeIrisModelPath); Schema outputScheam = evalPMML.outputSchema(inputSchema); Tuple observed = evalPMML.exec(inputTuple); // Test if (expected.equals(observed)) { System.out.println("treeScoringTest_Iris_2: PASS"); } else { System.out.println("---------- EPIC FAIL: treeScoringTest_Iris_2 ----------"); System.out.println("Expected: " + expected.toString()); System.out.println("Observed: " + observed.toString()); System.out.println("-------- END EPIC FAIL --------"); } assertEquals(expected,observed); }
Example 6
Source File: ScorePMML_IrisTest.java From Surus with Apache License 2.0 | 5 votes |
@Test public void nnScoringTest_Iris_1() throws IOException, SAXException, JAXBException { // Build Input Schema Schema inputSchema = buildIrisInputSchema(); // Input/Output Bag Tuple inputTuple = tf.newTuple(); Tuple expected = tf.newTuple(); { // Visit 1, Input: Implicit Signout inputTuple = this.buildIrisInputEvent(5.9,3.2,4.8,1.8,"Iris-versicolor"); // Visit 1, Output expected = this.buildIrisOutputEvent("Iris-versicolor"); } // Initialize Class ScorePMML evalPMML = new ScorePMML(this.nnIrisModelPath); Schema outputScheam = evalPMML.outputSchema(inputSchema); Tuple observed = evalPMML.exec(inputTuple); // Test if (expected.equals(observed)) { System.out.println("nnScoringTest_Iris_1: PASS"); } else { System.out.println("---------- EPIC FAIL: nnScoringTest_Iris_1 ----------"); System.out.println("Expected: " + expected.toString()); System.out.println("Observed: " + observed.toString()); System.out.println("-------- END EPIC FAIL --------"); } assertEquals(expected,observed); }
Example 7
Source File: ScorePMML_IrisTest.java From Surus with Apache License 2.0 | 5 votes |
@Test public void rfScoringTest_Iris_1() throws IOException, SAXException, JAXBException { // Build Input Schema Schema inputSchema = buildIrisInputSchema(); // Input/Output Bag Tuple inputTuple = tf.newTuple(); Tuple expected = tf.newTuple(); { // Visit 1, Input: Implicit Signout inputTuple = this.buildIrisInputEvent(5.1,3.5,1.4,0.2,"setosa"); // Visit 1, Output expected = this.buildIrisOutputEvent("setosa","setosa",1.0,0.0,0.0); } // Initialize Class ScorePMML evalPMML = new ScorePMML(this.rfIrisModelPath); Schema outputSchema = evalPMML.outputSchema(inputSchema); Tuple observed = evalPMML.exec(inputTuple); // Test if (expected.equals(observed)) { System.out.println("rfScoringTest_Iris_1: PASS"); } else { System.out.println("---------- EPIC FAIL: rfScoringTest_Iris_1 ----------"); System.out.println("Expected: " + expected.toString()); System.out.println("Observed: " + observed.toString()); System.out.println("-------- END EPIC FAIL --------"); } assertEquals(expected,observed); }