From 67b0d969672b51dc4c6c8ebf98c02ecc7406380c Mon Sep 17 00:00:00 2001 From: Colin Dellow Date: Sat, 3 Mar 2018 20:57:09 -0500 Subject: [PATCH] float support --- parquet/parquet.cc | 2 +- parquet/parquet_cursor.cc | 12 +++++++++++- parquet/parquet_cursor.h | 8 -------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/parquet/parquet.cc b/parquet/parquet.cc index 6650e94..64a341f 100644 --- a/parquet/parquet.cc +++ b/parquet/parquet.cc @@ -178,6 +178,7 @@ static int parquetColumn( sqlite3_result_int(ctx, rv); break; } + case parquet::Type::FLOAT: case parquet::Type::DOUBLE: { double rv = cursor->getDouble(col); @@ -199,7 +200,6 @@ static int parquetColumn( sqlite3_result_int64(ctx, rv); break; } - case parquet::Type::FLOAT: case parquet::Type::FIXED_LEN_BYTE_ARRAY: default: // Should be impossible to get here as we should have forbidden this at diff --git a/parquet/parquet_cursor.cc b/parquet/parquet_cursor.cc index 875c41a..68fc666 100644 --- a/parquet/parquet_cursor.cc +++ b/parquet/parquet_cursor.cc @@ -86,6 +86,17 @@ void ParquetCursor::ensureColumn(int col) { } break; } + case parquet::Type::FLOAT: + { + parquet::FloatScanner* s = (parquet::FloatScanner*)scanners[col].get(); + float rv = 0; + if(s->NextValue(&rv, &wasNull)) { + colDoubleValues[col] = rv; + } else { + throw std::invalid_argument("unexpectedly lacking a next value"); + } + break; + } case parquet::Type::DOUBLE: { parquet::DoubleScanner* s = (parquet::DoubleScanner*)scanners[col].get(); @@ -157,7 +168,6 @@ void ParquetCursor::ensureColumn(int col) { } break; } - case parquet::Type::FLOAT: case parquet::Type::FIXED_LEN_BYTE_ARRAY: default: // Should be impossible to get here as we should have forbidden this at diff --git a/parquet/parquet_cursor.h b/parquet/parquet_cursor.h index 9e66836..71dd9b8 100644 --- a/parquet/parquet_cursor.h +++ b/parquet/parquet_cursor.h @@ -41,14 +41,6 @@ public: long getInt64(int col); double getDouble(int col); parquet::ByteArray* getByteArray(int col); - - /* - sqlite3_result_double() - sqlite3_result_int() - sqlite3_result_int64() - sqlite3_result_null() - sqlite3_result_text() - */ }; #endif