Github user nickwallen commented on a diff in the pull request:
https://github.com/apache/metron/pull/1190#discussion_r222420697
--- 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 --
Hmm. Interesting. I don't really understand what happens in that else
condition then.
The OCD side of me wants to make sure I understand this to ensure there is
not a pre-existing bug. But at the same time I can't fault you for this. All
you did was refactor this code out into a method.
It seems that a `DocumentContainer` should either have an exception
(`dc.getException().isPresent()`) or it should have a document
(`dc.getDocument.isPresent()`). We would hit the else when neither of those
are the case. So under what conditions would a `DocumentContainer` have
neither of those?
I guess a `null` Document or null Throwable is added to the
`DocumentContainer`? I hope this is what we expect to happen.
```
if(dc.getException().isPresent()) {
..
} else if(dc.getDocument.isPresent()) {
..
} else {
// when does this occur? what do we expect to happen?
}
```
---