Github user nickwallen commented on a diff in the pull request:
https://github.com/apache/metron/pull/1190#discussion_r217441386
--- Diff:
metron-platform/metron-indexing/src/main/java/org/apache/metron/indexing/dao/MultiIndexDao.java
---
@@ -282,4 +276,27 @@ public Document getLatest(final String guid, String
sensorType) throws IOExcepti
public List<IndexDao> getIndices() {
return indices;
}
+
+ private Document getDocument(List<DocumentContainer> documentContainers)
throws IOException {
+ Document ret = null;
+ List<String> error = new ArrayList<>();
+ for(DocumentContainer dc : documentContainers) {
+ if(dc.getException().isPresent()) {
+ Throwable e = dc.getException().get();
+ error.add(e.getMessage() + "\n" + ExceptionUtils.getStackTrace(e));
+ }
+ else {
+ if(dc.getDocument().isPresent()) {
+ Document d = dc.getDocument().get();
+ if(ret == null || ret.getTimestamp() < d.getTimestamp()) {
+ ret = d;
+ }
+ }
+ }
+ }
--- End diff --
Do we gain anything from a slight restructuring of your if/else chain that
adds a sanity check?
```
if(dc.getException().isPresent()) {
..
} else if(dc.getDocument.isPresent()) {
..
} else {
throw new IllegalStateException("Expected either document or exception;
got neither");
}
```
---