Java Code Examples for org.apache.spark.rdd.RDD#toLocalIterator()
The following examples show how to use
org.apache.spark.rdd.RDD#toLocalIterator() .
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: MLContextTest.java From systemds with Apache License 2.0 | 5 votes |
@Test public void testOutputRDDStringIJVDML() { System.out.println("MLContextTest - output RDD String IJV DML"); String s = "M = matrix('1 2 3 4', rows=2, cols=2);"; Script script = dml(s).out("M"); MLResults results = ml.execute(script); RDD<String> rddStringIJV = results.getRDDStringIJV("M"); Iterator<String> iterator = rddStringIJV.toLocalIterator(); Assert.assertEquals("1 1 1.0", iterator.next()); Assert.assertEquals("1 2 2.0", iterator.next()); Assert.assertEquals("2 1 3.0", iterator.next()); Assert.assertEquals("2 2 4.0", iterator.next()); }
Example 2
Source File: MLContextTest.java From systemds with Apache License 2.0 | 5 votes |
@Test public void testOutputRDDStringCSVDenseDML() { System.out.println("MLContextTest - output RDD String CSV Dense DML"); String s = "M = matrix('1 2 3 4', rows=2, cols=2); print(toString(M));"; Script script = dml(s).out("M"); MLResults results = ml.execute(script); RDD<String> rddStringCSV = results.getRDDStringCSV("M"); Iterator<String> iterator = rddStringCSV.toLocalIterator(); Assert.assertEquals("1.0,2.0", iterator.next()); Assert.assertEquals("3.0,4.0", iterator.next()); }
Example 3
Source File: MLContextTest.java From systemds with Apache License 2.0 | 5 votes |
@Test public void testOutputRDDStringCSVSparseDML() { System.out.println("MLContextTest - output RDD String CSV Sparse DML"); String s = "M = matrix(0, rows=10, cols=10); M[1,1]=1; M[1,2]=2; M[2,1]=3; M[2,2]=4; print(toString(M));"; Script script = dml(s).out("M"); MLResults results = ml.execute(script); RDD<String> rddStringCSV = results.getRDDStringCSV("M"); Iterator<String> iterator = rddStringCSV.toLocalIterator(); Assert.assertEquals("1.0,2.0", iterator.next()); Assert.assertEquals("3.0,4.0", iterator.next()); }
Example 4
Source File: MLContextTest.java From systemds with Apache License 2.0 | 5 votes |
@Test public void testOutputMatrixObjectDML() { System.out.println("MLContextTest - output matrix object DML"); String s = "M = matrix('1 2 3 4', rows=2, cols=2);"; MatrixObject mo = ml.execute(dml(s).out("M")).getMatrixObject("M"); RDD<String> rddStringCSV = MLContextConversionUtil.matrixObjectToRDDStringCSV(mo); Iterator<String> iterator = rddStringCSV.toLocalIterator(); Assert.assertEquals("1.0,2.0", iterator.next()); Assert.assertEquals("3.0,4.0", iterator.next()); }
Example 5
Source File: MLContextTest.java From systemds with Apache License 2.0 | 5 votes |
@Test public void testOutputRDDStringCSVFromMatrixDML() { System.out.println("MLContextTest - output RDD String CSV from matrix DML"); String s = "M = matrix('1 2 3 4', rows=1, cols=4);"; Script script = dml(s).out("M"); RDD<String> rddStringCSV = ml.execute(script).getMatrix("M").toRDDStringCSV(); Iterator<String> iterator = rddStringCSV.toLocalIterator(); Assert.assertEquals("1.0,2.0,3.0,4.0", iterator.next()); }
Example 6
Source File: MLContextTest.java From systemds with Apache License 2.0 | 5 votes |
@Test public void testOutputRDDStringIJVDML() { System.out.println("MLContextTest - output RDD String IJV DML"); String s = "M = matrix('1 2 3 4', rows=2, cols=2);"; Script script = dml(s).out("M"); MLResults results = ml.execute(script); RDD<String> rddStringIJV = results.getRDDStringIJV("M"); Iterator<String> iterator = rddStringIJV.toLocalIterator(); Assert.assertEquals("1 1 1.0", iterator.next()); Assert.assertEquals("1 2 2.0", iterator.next()); Assert.assertEquals("2 1 3.0", iterator.next()); Assert.assertEquals("2 2 4.0", iterator.next()); }
Example 7
Source File: MLContextTest.java From systemds with Apache License 2.0 | 5 votes |
@Test public void testOutputRDDStringCSVDenseDML() { System.out.println("MLContextTest - output RDD String CSV Dense DML"); String s = "M = matrix('1 2 3 4', rows=2, cols=2); print(toString(M));"; Script script = dml(s).out("M"); MLResults results = ml.execute(script); RDD<String> rddStringCSV = results.getRDDStringCSV("M"); Iterator<String> iterator = rddStringCSV.toLocalIterator(); Assert.assertEquals("1.0,2.0", iterator.next()); Assert.assertEquals("3.0,4.0", iterator.next()); }
Example 8
Source File: MLContextTest.java From systemds with Apache License 2.0 | 5 votes |
@Test public void testOutputRDDStringCSVSparseDML() { System.out.println("MLContextTest - output RDD String CSV Sparse DML"); String s = "M = matrix(0, rows=10, cols=10); M[1,1]=1; M[1,2]=2; M[2,1]=3; M[2,2]=4; print(toString(M));"; Script script = dml(s).out("M"); MLResults results = ml.execute(script); RDD<String> rddStringCSV = results.getRDDStringCSV("M"); Iterator<String> iterator = rddStringCSV.toLocalIterator(); Assert.assertEquals("1.0,2.0", iterator.next()); Assert.assertEquals("3.0,4.0", iterator.next()); }
Example 9
Source File: MLContextTest.java From systemds with Apache License 2.0 | 5 votes |
@Test public void testOutputMatrixObjectDML() { System.out.println("MLContextTest - output matrix object DML"); String s = "M = matrix('1 2 3 4', rows=2, cols=2);"; MatrixObject mo = ml.execute(dml(s).out("M")).getMatrixObject("M"); RDD<String> rddStringCSV = MLContextConversionUtil.matrixObjectToRDDStringCSV(mo); Iterator<String> iterator = rddStringCSV.toLocalIterator(); Assert.assertEquals("1.0,2.0", iterator.next()); Assert.assertEquals("3.0,4.0", iterator.next()); }
Example 10
Source File: MLContextTest.java From systemds with Apache License 2.0 | 5 votes |
@Test public void testOutputRDDStringCSVFromMatrixDML() { System.out.println("MLContextTest - output RDD String CSV from matrix DML"); String s = "M = matrix('1 2 3 4', rows=1, cols=4);"; Script script = dml(s).out("M"); RDD<String> rddStringCSV = ml.execute(script).getMatrix("M").toRDDStringCSV(); Iterator<String> iterator = rddStringCSV.toLocalIterator(); Assert.assertEquals("1.0,2.0,3.0,4.0", iterator.next()); }