orc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject orc git commit: ORC-225: Fixed handling longs in CsvReader
Date Thu, 10 Aug 2017 21:37:51 GMT
Repository: orc
Updated Branches:
  refs/heads/master d4c4de3a5 -> cbb12a974


ORC-225: Fixed handling longs in CsvReader

Fixes #150

Signed-off-by: Owen O'Malley <omalley@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/orc/repo
Commit: http://git-wip-us.apache.org/repos/asf/orc/commit/cbb12a97
Tree: http://git-wip-us.apache.org/repos/asf/orc/tree/cbb12a97
Diff: http://git-wip-us.apache.org/repos/asf/orc/diff/cbb12a97

Branch: refs/heads/master
Commit: cbb12a9745f1d1c1989818a0b9c10ce1beccc021
Parents: d4c4de3
Author: Paweł Dąbrowski <pawel.dabrowski@codewise.com>
Authored: Wed Aug 9 11:06:20 2017 +0200
Committer: Owen O'Malley <omalley@apache.org>
Committed: Thu Aug 10 14:36:46 2017 -0700

----------------------------------------------------------------------
 .../org/apache/orc/tools/convert/CsvReader.java  |  2 +-
 .../apache/orc/tools/convert/TestCsvReader.java  | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/orc/blob/cbb12a97/java/tools/src/java/org/apache/orc/tools/convert/CsvReader.java
----------------------------------------------------------------------
diff --git a/java/tools/src/java/org/apache/orc/tools/convert/CsvReader.java b/java/tools/src/java/org/apache/orc/tools/convert/CsvReader.java
index 1afd4bc..a77229a 100644
--- a/java/tools/src/java/org/apache/orc/tools/convert/CsvReader.java
+++ b/java/tools/src/java/org/apache/orc/tools/convert/CsvReader.java
@@ -166,7 +166,7 @@ public class CsvReader implements RecordReader {
         column.isNull[row] = true;
       } else {
         ((LongColumnVector) column).vector[row] =
-            Integer.parseInt(values[offset]);
+            Long.parseLong(values[offset]);
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/orc/blob/cbb12a97/java/tools/src/test/org/apache/orc/tools/convert/TestCsvReader.java
----------------------------------------------------------------------
diff --git a/java/tools/src/test/org/apache/orc/tools/convert/TestCsvReader.java b/java/tools/src/test/org/apache/orc/tools/convert/TestCsvReader.java
index d385725..8943692 100644
--- a/java/tools/src/test/org/apache/orc/tools/convert/TestCsvReader.java
+++ b/java/tools/src/test/org/apache/orc/tools/convert/TestCsvReader.java
@@ -153,4 +153,23 @@ public class TestCsvReader {
     }
     assertEquals(false, reader.nextBatch(batch));
   }
+
+  @Test
+  public void testLargeNumbers() throws Exception {
+    StringReader input = new StringReader(
+            "2147483646,-2147483647,9223372036854775806,-9223372036854775807\n"
+    );
+    TypeDescription schema = TypeDescription.fromString(
+            "struct<a:int,b:int,d:bigint,e:bigint>");
+    RecordReader reader = new CsvReader(input, null, 1, schema, ',', '\'',
+            '\\', 0, "null");
+    VectorizedRowBatch batch = schema.createRowBatch();
+    assertEquals(true, reader.nextBatch(batch));
+    assertEquals(1, batch.size);
+    assertEquals(2147483646, ((LongColumnVector) batch.cols[0]).vector[0]);
+    assertEquals(-2147483647, ((LongColumnVector) batch.cols[1]).vector[0]);
+    assertEquals(9223372036854775806L, ((LongColumnVector) batch.cols[2]).vector[0]);
+    assertEquals(-9223372036854775807L, ((LongColumnVector) batch.cols[3]).vector[0]);
+    assertEquals(false, reader.nextBatch(batch));
+  }
 }


Mime
View raw message