@Override public String apply(Document doc) { return doc.getStringId(); } };
@Override public boolean apply(Document input) { return input != null && ids.contains(input.getStringId()); } };
public DocumentRefid apply(Document document) { return new DocumentRefid(document.getStringId()); } });
/** * Transfers document and cluster lists to the attributes map after deserialization. */ @Commit private void afterDeserialization() throws Exception { if (otherAttributesForSerialization != null) { attributes = SimpleXmlWrappers.unwrap(otherAttributesForSerialization); } attributesView = Collections.unmodifiableMap(attributes); attributes.put(AttributeNames.QUERY, query != null ? query.trim() : null); attributes.put(AttributeNames.DOCUMENTS, documents); attributes.put(AttributeNames.CLUSTERS, clusters); // Convert document ids to the actual references if (clusters != null && documents != null) { final Map<String, Document> documentsById = Maps.newHashMap(); for (Document document : documents) { documentsById.put(document.getStringId(), document); } for (Cluster cluster : clusters) { documentIdToReference(cluster, documentsById); } } }
for (Document doc : documents) String id = doc.getStringId(); if (!ids.add(id) && id != null)
@Override protected void afterFetch(SearchEngineResponse response, ProcessingResult processingResult) { if (readClusters) { final Set<String> ids = Sets.newHashSet(); List<Document> documents = processingResult.getDocuments(); if (documents == null) documents = Collections.emptyList(); List<Cluster> clusters = processingResult.getClusters(); if (documents != null && clusters != null) { for (Document doc : documents) { ids.add(doc.getStringId()); } Predicate<Document> docFilter = new Predicate<Document>() { @Override public boolean apply(Document input) { return input != null && ids.contains(input.getStringId()); } }; this.clusters = sanityCheck(clusters, docFilter); } } }