Loading data-access/servlet/src/main/java/datasets/Cutout.java +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ public interface Cutout public CutResult doFile(String relPathname, int hdunum, Pos pos, Band band, Time time, Pol pol, boolean countNullValues, FitsCard[] extraCards) throws IOException, InterruptedException; ; } data-access/servlet/src/main/java/datasets/CutoutImpl.java +88 −42 Original line number Diff line number Diff line Loading @@ -47,14 +47,6 @@ class CutoutImpl implements Cutout this.settings = settings; } /* public DatasetsImpl(Settings settings, Subsurvey[] subsurveys) { LOGGER.info("trace DatasetsImpl(settings, subsurveys)"); this.settings = settings; this.subsurveys = subsurveys; } */ private String genRegionForVlkbOverlapCmd(Pos pos, Band band) { Loading Loading @@ -182,6 +174,55 @@ class CutoutImpl implements Cutout } private NullValueCount doCountNullValues(String absPathname, int hdunum) throws IOException, InterruptedException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); if(bos == null) throw new AssertionError("byte output stream for bounds was not created, is null"); String[] cmdBounds = new String[3]; cmdBounds[0] = "/usr/local/bin/vlkb"; cmdBounds[1] = "nullvals"; cmdBounds[2] = absPathname; ExecCmd exec = new ExecCmd(); exec.doRun(bos, cmdBounds); LOGGER.info("exec NullVals exitValue: " + exec.exitValue); bos.close(); boolean hasResult = (exec.exitValue == 0); if(hasResult) { String nullValsString = new String(bos.toByteArray()); LOGGER.info("vlkb nullvals: " + nullValsString); if((nullValsString != null) && nullValsString.trim().isEmpty()) { throw new AssertionError("'vlkb nullvals' returned empty string"); } // parse result: '<fill-ratio> <nullvals-count> <tot-count>' String[] splitStr = nullValsString.trim().split("\\s+"); if(splitStr.length != 3) throw new AssertionError("'vlkb nullvals' did not return 3 numbers but: " + nullValsString); NullValueCount nvc = new NullValueCount(); nvc.percent = Double.parseDouble(splitStr[0]); nvc.nullCount = Long.parseLong(splitStr[1]); nvc.totalCount = Long.parseLong(splitStr[2]); return nvc; } else { throw new AssertionError("'vlkb nullvals' exited without results for: " + absPathname); } } public CutResult doFile(String relPathname, int hdunum, Pos pos, Band band, Time time, Pol pol, boolean countNullValues, FitsCard[] extraCards) Loading Loading @@ -210,7 +251,12 @@ class CutoutImpl implements Cutout if(countNullValues) { LOGGER.info("NullValuesCount not implemented when used with Cutout::doStream()"); cutResult.nullValueCount = doCountNullValues(absSubimgPathname, 1); } if(extraCards == null || (extraCards.length < 1)) { LOGGER.info("Adding extraCards to cut-file not implemented when using 'vlkb' exec (implemented in engine vlkbd/AMQP)"); } } else Loading Loading
data-access/servlet/src/main/java/datasets/Cutout.java +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ public interface Cutout public CutResult doFile(String relPathname, int hdunum, Pos pos, Band band, Time time, Pol pol, boolean countNullValues, FitsCard[] extraCards) throws IOException, InterruptedException; ; }
data-access/servlet/src/main/java/datasets/CutoutImpl.java +88 −42 Original line number Diff line number Diff line Loading @@ -47,14 +47,6 @@ class CutoutImpl implements Cutout this.settings = settings; } /* public DatasetsImpl(Settings settings, Subsurvey[] subsurveys) { LOGGER.info("trace DatasetsImpl(settings, subsurveys)"); this.settings = settings; this.subsurveys = subsurveys; } */ private String genRegionForVlkbOverlapCmd(Pos pos, Band band) { Loading Loading @@ -182,6 +174,55 @@ class CutoutImpl implements Cutout } private NullValueCount doCountNullValues(String absPathname, int hdunum) throws IOException, InterruptedException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); if(bos == null) throw new AssertionError("byte output stream for bounds was not created, is null"); String[] cmdBounds = new String[3]; cmdBounds[0] = "/usr/local/bin/vlkb"; cmdBounds[1] = "nullvals"; cmdBounds[2] = absPathname; ExecCmd exec = new ExecCmd(); exec.doRun(bos, cmdBounds); LOGGER.info("exec NullVals exitValue: " + exec.exitValue); bos.close(); boolean hasResult = (exec.exitValue == 0); if(hasResult) { String nullValsString = new String(bos.toByteArray()); LOGGER.info("vlkb nullvals: " + nullValsString); if((nullValsString != null) && nullValsString.trim().isEmpty()) { throw new AssertionError("'vlkb nullvals' returned empty string"); } // parse result: '<fill-ratio> <nullvals-count> <tot-count>' String[] splitStr = nullValsString.trim().split("\\s+"); if(splitStr.length != 3) throw new AssertionError("'vlkb nullvals' did not return 3 numbers but: " + nullValsString); NullValueCount nvc = new NullValueCount(); nvc.percent = Double.parseDouble(splitStr[0]); nvc.nullCount = Long.parseLong(splitStr[1]); nvc.totalCount = Long.parseLong(splitStr[2]); return nvc; } else { throw new AssertionError("'vlkb nullvals' exited without results for: " + absPathname); } } public CutResult doFile(String relPathname, int hdunum, Pos pos, Band band, Time time, Pol pol, boolean countNullValues, FitsCard[] extraCards) Loading Loading @@ -210,7 +251,12 @@ class CutoutImpl implements Cutout if(countNullValues) { LOGGER.info("NullValuesCount not implemented when used with Cutout::doStream()"); cutResult.nullValueCount = doCountNullValues(absSubimgPathname, 1); } if(extraCards == null || (extraCards.length < 1)) { LOGGER.info("Adding extraCards to cut-file not implemented when using 'vlkb' exec (implemented in engine vlkbd/AMQP)"); } } else Loading