From afc0ccee7314872144cd6a4e517c732ae851a429 Mon Sep 17 00:00:00 2001 From: Arati Kakadiya Date: Wed, 18 Dec 2024 17:47:29 -0800 Subject: [PATCH] Added votable to the response of read function. --- .../cadc/dali/tables/parquet/ParquetReader.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/cadc-dali/src/main/java/ca/nrc/cadc/dali/tables/parquet/ParquetReader.java b/cadc-dali/src/main/java/ca/nrc/cadc/dali/tables/parquet/ParquetReader.java index ab8635d5..4f3831c6 100644 --- a/cadc-dali/src/main/java/ca/nrc/cadc/dali/tables/parquet/ParquetReader.java +++ b/cadc-dali/src/main/java/ca/nrc/cadc/dali/tables/parquet/ParquetReader.java @@ -9,6 +9,8 @@ import java.util.HashMap; import java.util.Map; +import ca.nrc.cadc.dali.tables.votable.VOTableDocument; +import ca.nrc.cadc.dali.tables.votable.VOTableReader; import org.apache.avro.generic.GenericRecord; import org.apache.log4j.Logger; @@ -37,9 +39,12 @@ public TableShape read(InputStream inputStream) throws IOException { MessageType schema = metadata.getFileMetaData().getSchema(); columnCount = schema.getFieldCount(); - String votable = metadata.getFileMetaData().getKeyValueMetaData().get("votable"); + String votable = metadata.getFileMetaData().getKeyValueMetaData().get("IVOA.VOTable-Parquet.content"); log.debug("VOTable: " + votable); + VOTableReader voTableReader = new VOTableReader(); + VOTableDocument voTableDocument = voTableReader.read(votable); + try (org.apache.parquet.hadoop.ParquetReader reader = AvroParquetReader.builder(inputFile).build()) { GenericRecord record; @@ -63,7 +68,7 @@ public TableShape read(InputStream inputStream) throws IOException { if (recordCount == 0) { throw new RuntimeException("NO Records Read"); } - return new TableShape(recordCount, columnCount); + return new TableShape(recordCount, columnCount, voTableDocument); } private static InputFile getInputFile(InputStream inputStream) throws IOException { @@ -172,10 +177,12 @@ public void close() throws IOException { public static class TableShape { int recordCount; int columnCount; + VOTableDocument voTableDocument; - public TableShape(int recordCount, int columnCount) { + public TableShape(int recordCount, int columnCount, VOTableDocument voTableDocument) { this.recordCount = recordCount; this.columnCount = columnCount; + this.voTableDocument = voTableDocument; } public int getRecordCount() { @@ -185,6 +192,10 @@ public int getRecordCount() { public int getColumnCount() { return columnCount; } + + public VOTableDocument getVoTableDocument() { + return voTableDocument; + } } }