Skip to content

Commit

Permalink
Added votable to the response of read function.
Browse files Browse the repository at this point in the history
  • Loading branch information
aratikakadiya committed Dec 19, 2024
1 parent c7fbcee commit afc0cce
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<GenericRecord> reader = AvroParquetReader.<GenericRecord>builder(inputFile).build()) {
GenericRecord record;

Expand All @@ -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 {
Expand Down Expand Up @@ -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() {
Expand All @@ -185,6 +192,10 @@ public int getRecordCount() {
public int getColumnCount() {
return columnCount;
}

public VOTableDocument getVoTableDocument() {
return voTableDocument;
}
}

}

0 comments on commit afc0cce

Please sign in to comment.