Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Cool counts" #110

Merged
merged 3 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,5 @@ public enum ResultType {
* is suitable to time series analysis and/or loading into another
* instance of HPDS.
*/
DATAFRAME_TIMESERIES,

/**
* Count number of patients and number of available concept paths. Useful for federated networks
* where not every concept path in a query is guaranteed to be in a specific portal
*/
PATIENT_AND_CONCEPT_COUNT
DATAFRAME_TIMESERIES
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<PhenoCube<?>> nullableGetCube(String path) {
protected Optional<PhenoCube<?>> nullableGetCube(String path) {
try {
return Optional.ofNullable(store.get(path));
} catch (InvalidCacheLoadException | ExecutionException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,20 +229,4 @@ public Map<String, Object> runVariantCount(Query query) {
}
return response;
}

public PatientAndConceptCount runPatientAndConceptCount(Query incomingQuery) {
log.info("Starting Patient and Concept Count query {}", incomingQuery.getPicSureId());
log.info("Calculating available concepts");
long concepts = incomingQuery.getFields().stream()
.map(abstractProcessor::nullableGetCube)
.filter(Optional::isPresent)
.count();
log.info("Calculating patient counts");
int patients = runCounts(incomingQuery);
PatientAndConceptCount patientAndConceptCount = new PatientAndConceptCount();
patientAndConceptCount.setConceptCount(concepts);
patientAndConceptCount.setPatientCount(patients);
log.info("Completed Patient and Concept Count query {}", incomingQuery.getPicSureId());
return patientAndConceptCount;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +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 java.util.stream.Collectors;

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;

Expand Down Expand Up @@ -41,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"));
Expand Down Expand Up @@ -95,7 +88,6 @@ private void exportTimeData(Query query, AsyncResult result, TreeSet<Integer> id
//get a list of all fields mentioned in the query; export all data associated with any included field
List<String> pathList = new LinkedList<String>();
pathList.addAll(query.getAnyRecordOf());
pathList.addAll(query.getAnyRecordOfMulti().stream().flatMap(Collection::stream).collect(Collectors.toList()));
pathList.addAll(query.getFields());
pathList.addAll(query.getRequiredFields());
pathList.addAll(query.getCategoryFilters().keySet());
Expand Down Expand Up @@ -123,24 +115,14 @@ private void addDataForConcepts(Collection<String> pathList, Set<String> exporte
if (cube.isStringType()) {
KeyAndValue<String> 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<Double> 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)
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,6 @@ private Response submitQueryAndWaitForCompletion(QueryRequest resultRequest) thr
case COUNT:
return queryOkResponse(countProcessor.runCounts(incomingQuery), incomingQuery).build();

case PATIENT_AND_CONCEPT_COUNT:
return queryOkResponse(countProcessor.runPatientAndConceptCount(incomingQuery), incomingQuery).build();

default:
// no valid type
return Response.status(Status.BAD_REQUEST).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading