(
Map<Comparable, Doc> model, String fromField, String toField)
| 431 | } |
| 432 | |
| 433 | @SuppressWarnings({"rawtypes"}) |
| 434 | Map<Comparable, Set<Comparable>> createJoinMap( |
| 435 | Map<Comparable, Doc> model, String fromField, String toField) { |
| 436 | Map<Comparable, Set<Comparable>> id_to_id = new HashMap<>(); |
| 437 | |
| 438 | Map<Comparable, List<Comparable>> value_to_id = invertField(model, toField); |
| 439 | |
| 440 | for (Comparable fromId : model.keySet()) { |
| 441 | Doc doc = model.get(fromId); |
| 442 | List<Comparable> vals = doc.getValues(fromField); |
| 443 | if (vals == null) continue; |
| 444 | for (Comparable val : vals) { |
| 445 | List<Comparable> toIds = value_to_id.get(val); |
| 446 | if (toIds == null) continue; |
| 447 | Set<Comparable> ids = id_to_id.get(fromId); |
| 448 | if (ids == null) { |
| 449 | ids = new HashSet<>(); |
| 450 | id_to_id.put(fromId, ids); |
| 451 | } |
| 452 | for (Comparable toId : toIds) ids.add(toId); |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | return id_to_id; |
| 457 | } |
| 458 | |
| 459 | @SuppressWarnings({"rawtypes"}) |
| 460 | Set<Comparable> join(Collection<Doc> input, Map<Comparable, Set<Comparable>> joinMap) { |
no test coverage detected