예제 #1
0
 @Test
 public void testReadDoubleMultiFiles() throws Exception {
   String dirPath = "src/test/resources/multi_file_double";
   ArrayList<String> correctAnswer = readAllFiles(dirPath);
   Collections.sort(
       correctAnswer,
       new Comparator<String>() {
         @Override
         public int compare(String o1, String o2) {
           try {
             Double d1 = Double.parseDouble(o1);
             Double d2 = Double.parseDouble(o2);
             return d1.compareTo(d2);
           } catch (NumberFormatException e) {
             e.printStackTrace();
             return 0;
           }
         }
       });
   SortedColumnDFSFile column =
       new SortedColumnDFSFile(qualify(dirPath + "/"), DataType.getType("double"));
   IDictionaryValueEnumerator e = new TableColumnValueEnumerator(column.getReader(), -1);
   ArrayList<String> output = new ArrayList<>();
   while (e.moveNext()) {
     System.out.println(new String(e.current()));
     output.add(new String(e.current()));
   }
   System.out.println(correctAnswer.size());
   assertTrue(correctAnswer.size() == output.size());
   for (int i = 0; i < correctAnswer.size(); i++) {
     assertEquals(correctAnswer.get(i), output.get(i));
   }
 }
예제 #2
0
 @Test
 public void testEmptyDir() throws Exception {
   String dirPath = "src/test/resources/empty_dir";
   new File(dirPath).mkdirs();
   SortedColumnDFSFile column =
       new SortedColumnDFSFile(qualify(dirPath + "/"), DataType.getType("varchar"));
   IDictionaryValueEnumerator e = new TableColumnValueEnumerator(column.getReader(), -1);
   ArrayList<String> output = new ArrayList<>();
   while (e.moveNext()) {
     System.out.println(new String(e.current()));
     output.add(new String(e.current()));
   }
   System.out.println(output.size());
 }
예제 #3
0
 @Test
 public void testReadStringMultiFile() throws Exception {
   String dirPath = "src/test/resources/multi_file_str";
   ArrayList<String> correctAnswer = readAllFiles(dirPath);
   Collections.sort(correctAnswer, new ByteComparator<String>(new StringBytesConverter()));
   SortedColumnDFSFile column =
       new SortedColumnDFSFile(qualify(dirPath + "/"), DataType.getType("varchar"));
   IDictionaryValueEnumerator e = new TableColumnValueEnumerator(column.getReader(), -1);
   ArrayList<String> output = new ArrayList<>();
   while (e.moveNext()) {
     output.add(new String(e.current()));
   }
   System.out.println(correctAnswer.size());
   assertTrue(correctAnswer.size() == output.size());
   for (int i = 0; i < correctAnswer.size(); i++) {
     assertEquals(correctAnswer.get(i), output.get(i));
   }
 }