From 878339f5b6f2dd575c5d1062220ab3770c5b454b Mon Sep 17 00:00:00 2001 From: Ben Steffensmeier Date: Thu, 10 Sep 2015 12:37:10 -0500 Subject: [PATCH] Omaha #4707 Do not open pointset netcdf files in memory. Former-commit-id: 0b0c567677a25e45e4940509153f50910983fed2 --- .../res/spring/pointset-netcdf-ingest.xml | 4 ++-- .../pointset/netcdf/PointSetNetcdfDecoder.java | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.pointset.netcdf/res/spring/pointset-netcdf-ingest.xml b/edexOsgi/com.raytheon.uf.edex.plugin.pointset.netcdf/res/spring/pointset-netcdf-ingest.xml index 209560cb5d..9892f2ffa1 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.pointset.netcdf/res/spring/pointset-netcdf-ingest.xml +++ b/edexOsgi/com.raytheon.uf.edex.plugin.pointset.netcdf/res/spring/pointset-netcdf-ingest.xml @@ -31,8 +31,8 @@ - - + + diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.pointset.netcdf/src/com/raytheon/uf/edex/plugin/pointset/netcdf/PointSetNetcdfDecoder.java b/edexOsgi/com.raytheon.uf.edex.plugin.pointset.netcdf/src/com/raytheon/uf/edex/plugin/pointset/netcdf/PointSetNetcdfDecoder.java index 7119f1e020..ab45041530 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.pointset.netcdf/src/com/raytheon/uf/edex/plugin/pointset/netcdf/PointSetNetcdfDecoder.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.pointset.netcdf/src/com/raytheon/uf/edex/plugin/pointset/netcdf/PointSetNetcdfDecoder.java @@ -19,6 +19,7 @@ **/ package com.raytheon.uf.edex.plugin.pointset.netcdf; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.Buffer; @@ -104,7 +105,7 @@ public class PointSetNetcdfDecoder { private ParameterLookup parameterLookup; - public PointSetRecord[] decode(String name, byte[] data) { + public PointSetRecord[] decode(File file) { if (levelFactory == null) { levelFactory = LevelFactory.getInstance(); } @@ -112,25 +113,27 @@ public class PointSetNetcdfDecoder { parameterLookup = ParameterLookup.getInstance(); } try { - NetcdfFile file = NetcdfFile.openInMemory(name, data); + NetcdfFile netcdfFile = NetcdfFile.open(file.getAbsolutePath()); Map locationCache = new HashMap(); List records = new ArrayList<>(); for (ProductDescription description : descriptions .getDescriptions()) { - PointSetRecord record = processDescription(file, description, - locationCache); + PointSetRecord record = processDescription(netcdfFile, + description, locationCache); if (record != null) { records.add(record); } } if (records.isEmpty()) { - logger.warn("No valid pointsets were found in file: {}", name); + logger.warn("No valid pointsets were found in file: {}", + file.getName()); return EMPTY_POINTSET_ARRAY; } else { return records.toArray(EMPTY_POINTSET_ARRAY); } } catch (ParseException | IOException | StorageException e) { - logger.error("Unable to decode pointset from file: {}", name, e); + logger.error("Unable to decode pointset from file: {}", + file.getName(), e); } return EMPTY_POINTSET_ARRAY; }