@Override public void putAll(Document<?> d) { if(d.getID() != null) { documentMap.put(ID_KEY, d.getID().getID()); } if(d.getAction()!=null) { documentMap.put(ACTION_KEY, d.getAction()); } for(Map.Entry<String, Object> e : d.getMetadataMap().entrySet()) { putMetadataField(e.getKey(), e.getValue()); } for(String s : d.getContentFields()) { putContentField(s, d.getContentField(s)); } }
protected static void printInsertOk(HttpResponse response, Document<?> d) { logger.debug("Successfully inserted a document with ID: " + d.getID()); response.setStatusCode(HttpStatus.SC_OK); setStringEntity(response, d.contentFieldsToJson(null)); }
private boolean contains(Document<?> haystack, String needle) { for (String field : haystack.getContentFields()) { if (field.contains(needle)) { return true; } if (contains(haystack.getContentField(field), needle)) { return true; } } return false; }
@SuppressWarnings("unchecked") private void addField(Document<?> doc, SolrInputDocument inputDoc, String field) { if (doc.hasContentField(field)) { Object toField = fieldMappings.get(field); if(toField instanceof String) { inputDoc.addField((String) toField, doc.getContentField(field)); } else if(toField instanceof List){ for(String s : (List<String>) toField) { inputDoc.addField(s, doc.getContentField(field)); } } } }
if(d.getID() == null) { else if(d.getID() instanceof MongoDocumentID) { documentMap.put(MONGO_ID_KEY, d.getID().getID()); } else { try { ObjectId id = MongoDocumentID.getObjectId(d.getID().toJSON()); documentMap.put(MONGO_ID_KEY, id); } catch (JsonException e) { logger.error("Unable to convert ID of type "+d.getID().getClass()+ " to MongoDucumentID", e); return; if(d.getAction()!=null) { setAction(d.getAction()); for(Map.Entry<String, Object> e : d.getMetadataMap().entrySet()) { putMetadataField(e.getKey(), e.getValue()); for(Map.Entry<String, Object> e : d.getContentMap().entrySet()) { putContentField(e.getKey(), e.getValue());
private boolean release(Document<T> md, String stage) { return io.markTouched(md.getID(), stage); }
@Override public DatabaseDocument<MemoryType> convert(Document<?> document) { MemoryDocument md = new MemoryDocument(); try { md.fromJson(document.toJson()); } catch (JsonException e) { e.printStackTrace(); } return md; }
private boolean equalMetadata(Document<?> d) { Set<String> metadata = d.getMetadataMap().keySet(); if(metadata.size()!=getMetadataFields().size()) { return false; } for(String s : metadata) { if(!getMetadataFields().contains(s)) { return false; } if(!Comparator.equals(getMetadataField(s), d.getMetadataMap().get(s))) { return false; } } return true; }
protected SolrInputDocument createSolrInputDocumentWithFieldConfig( Document<?> doc) { SolrInputDocument docToAdd = new SolrInputDocument(); if (sendAll) { for (String inField : doc.getContentFields()) { docToAdd.addField(inField, doc.getContentField(inField)); } } else { for (String inField : fieldMappings.keySet()) { addField(doc, docToAdd, inField); } } return docToAdd; }
@Override public boolean isEqual(Document<?> d) { if(d.getID()!=null) { if(!d.getID().getID().equals(getID().getID())) { return false; } } else { if(getID()!=null) { return false; } } if(d.getAction()!=getAction()) { return false; } if(equalMetadata(d) && equalContent(d)) { return true; } return false; }
private boolean release(Document<T> md, String stage) { return io.markTouched(md.getID(), stage); }
@Override public DatabaseDocument<MongoType> convert(Document<?> document) throws ConversionException { try { if (contains(document, "\u0000")) { throw new ConversionException( "A document cannot contain the NUL character. See https://jira.mongodb.org/browse/SERVER-7691"); } return new MongoDocument(document.toJson()); } catch (JsonException e) { throw new ConversionException( "JSON Exception caught while converting", e); } }
private boolean equalMetadata(Document<?> d) { Set<String> metadata = getMetadataMap().keySet(); if(metadata.size()!=getMetadataFields().size()) { return false; } for(String s : metadata) { if(!getMetadataFields().contains(s)) { return false; } if(!Comparator.equals(getMetadataField(s), d.getMetadataMap().get(s))) { return false; } } return true; }
private boolean equalContent(Document<?> d) { Set<String> content = d.getContentFields(); if(content.size()!=getContentFields().size()) { return false; } for(String s : content) { if(!getContentFields().contains(s)) { return false; } if(!Comparator.equals(getContentField(s), d.getContentField(s))) { return false; } } return true; }
Object id = d != null ? d.getID() : null; logger.info(String.format("type=performance event=query stage_name=%s doc_id=\"%s\" start=%d end=%d total=%d entitystring=%d parse=%d query=%d serialize=%d", stage, id, start, serialize, serialize-start, tostring-start, parse-tostring, query-parse, serialize-query));
private boolean equalContent(Document<?> d) { Set<String> content = d.getContentFields(); if(content.size()!=getContentFields().size()) { return false; } for(String s : content) { if(!getContentFields().contains(s)) { return false; } if(!Comparator.equals(getContentField(s), d.getContentField(s))) { return false; } } return true; }