From 7225a858355fe93e69a326f2800f72e9eebb9ca0 Mon Sep 17 00:00:00 2001 From: Luke Sikina Date: Mon, 1 Jul 2024 16:02:21 -0400 Subject: [PATCH] Revert "[ALS-5755] Switch time series processor to ISO timestamps" This reverts commit 777225577cdb7b1b63734a6de1d2771d5ad22453. --- .../hpds/processing/AbstractProcessor.java | 2 +- .../{timeseries => }/TimeseriesProcessor.java | 28 ++++--------------- .../TimeSeriesConversionService.java | 15 ---------- .../TimeSeriesConversionServiceTest.java | 21 -------------- .../avillach/hpds/service/QueryService.java | 1 - 5 files changed, 7 insertions(+), 60 deletions(-) rename processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/{timeseries => }/TimeseriesProcessor.java (83%) delete mode 100644 processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/timeseries/TimeSeriesConversionService.java delete mode 100644 processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/timeseries/TimeSeriesConversionServiceTest.java diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/AbstractProcessor.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/AbstractProcessor.java index 7a1a5063..8276e3bb 100644 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/AbstractProcessor.java +++ b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/AbstractProcessor.java @@ -672,7 +672,7 @@ protected PhenoCube getCube(String path) { * Useful for federated pic-sure's where there are fewer * guarantees about concept paths. */ - public Optional> nullableGetCube(String path) { + protected Optional> nullableGetCube(String path) { try { return Optional.ofNullable(store.get(path)); } catch (InvalidCacheLoadException | ExecutionException e) { diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/timeseries/TimeseriesProcessor.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/TimeseriesProcessor.java similarity index 83% rename from processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/timeseries/TimeseriesProcessor.java rename to processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/TimeseriesProcessor.java index c0a6b9b0..2eabdf1d 100644 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/timeseries/TimeseriesProcessor.java +++ b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/TimeseriesProcessor.java @@ -1,13 +1,9 @@ -package edu.harvard.hms.dbmi.avillach.hpds.processing.timeseries; +package edu.harvard.hms.dbmi.avillach.hpds.processing; import java.io.FileNotFoundException; import java.io.IOException; import java.util.*; -import edu.harvard.hms.dbmi.avillach.hpds.processing.AbstractProcessor; -import edu.harvard.hms.dbmi.avillach.hpds.processing.AsyncResult; -import edu.harvard.hms.dbmi.avillach.hpds.processing.HpdsProcessor; -import edu.harvard.hms.dbmi.avillach.hpds.processing.QueryProcessor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,16 +36,14 @@ public class TimeseriesProcessor implements HpdsProcessor { private Logger log = LoggerFactory.getLogger(QueryProcessor.class); private AbstractProcessor abstractProcessor; - private final TimeSeriesConversionService conversionService; private final String ID_CUBE_NAME; private final int ID_BATCH_SIZE; private final int CACHE_SIZE; @Autowired - public TimeseriesProcessor(AbstractProcessor abstractProcessor, TimeSeriesConversionService conversionService) { + public TimeseriesProcessor(AbstractProcessor abstractProcessor) { this.abstractProcessor = abstractProcessor; - this.conversionService = conversionService; // todo: handle these via spring annotations CACHE_SIZE = Integer.parseInt(System.getProperty("CACHE_SIZE", "100")); ID_BATCH_SIZE = Integer.parseInt(System.getProperty("ID_BATCH_SIZE", "0")); @@ -121,24 +115,14 @@ private void addDataForConcepts(Collection pathList, Set exporte if (cube.isStringType()) { KeyAndValue keyAndValue = (KeyAndValue) kvObj; // "PATIENT_NUM","CONCEPT_PATH","NVAL_NUM","TVAL_CHAR","TIMESTAMP" - String[] entryData = { - keyAndValue.getKey().toString(), - conceptPath, - "", - keyAndValue.getValue(), - conversionService.toISOString(keyAndValue.getTimestamp()) - }; + String[] entryData = { keyAndValue.getKey().toString(), conceptPath, "", keyAndValue.getValue(), + keyAndValue.getTimestamp().toString() }; dataEntries.add(entryData); } else { // numeric KeyAndValue keyAndValue = (KeyAndValue) kvObj; // "PATIENT_NUM","CONCEPT_PATH","NVAL_NUM","TVAL_CHAR","TIMESTAMP" - String[] entryData = { - keyAndValue.getKey().toString(), - conceptPath, - keyAndValue.getValue().toString(), - "", - conversionService.toISOString(keyAndValue.getTimestamp()) - }; + String[] entryData = { keyAndValue.getKey().toString(), conceptPath, + keyAndValue.getValue().toString(), "", keyAndValue.getTimestamp().toString() }; dataEntries.add(entryData); } //batch exports so we don't take double memory (valuesForKeys + dataEntries could be a lot of data points) diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/timeseries/TimeSeriesConversionService.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/timeseries/TimeSeriesConversionService.java deleted file mode 100644 index 2a9f4ffe..00000000 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/timeseries/TimeSeriesConversionService.java +++ /dev/null @@ -1,15 +0,0 @@ -package edu.harvard.hms.dbmi.avillach.hpds.processing.timeseries; - -import org.springframework.stereotype.Service; - -import java.time.Instant; -import java.time.format.DateTimeFormatter; - -@Service -public class TimeSeriesConversionService { - - public String toISOString(Long unixTimeStamp) { - Instant instant = Instant.ofEpochMilli(unixTimeStamp); - return DateTimeFormatter.ISO_INSTANT.format(instant); - } -} diff --git a/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/timeseries/TimeSeriesConversionServiceTest.java b/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/timeseries/TimeSeriesConversionServiceTest.java deleted file mode 100644 index c09a369c..00000000 --- a/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/timeseries/TimeSeriesConversionServiceTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package edu.harvard.hms.dbmi.avillach.hpds.processing.timeseries; - -import org.junit.Test; - -import java.util.TimeZone; - -import static org.junit.Assert.assertEquals; - - -public class TimeSeriesConversionServiceTest { - - TimeSeriesConversionService subject = new TimeSeriesConversionService(); - - @Test - public void shouldConvertToIsoString() { - String actual = subject.toISOString(0L); - String expected = "1970-01-01T00:00:00Z"; - - assertEquals(expected, actual); - } -} \ No newline at end of file diff --git a/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/QueryService.java b/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/QueryService.java index c1b69c3b..fe120904 100644 --- a/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/QueryService.java +++ b/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/QueryService.java @@ -7,7 +7,6 @@ import java.util.function.Predicate; import java.util.stream.Collectors; -import edu.harvard.hms.dbmi.avillach.hpds.processing.timeseries.TimeseriesProcessor; import edu.harvard.hms.dbmi.avillach.hpds.service.util.QueryDecorator; import org.slf4j.Logger; import org.slf4j.LoggerFactory;