@SuppressWarnings({ "unchecked" }) private List<ValueUpdate> createAddValueUpdateForArray(Array arr, int weight) { List<ValueUpdate> ret = new ArrayList<>(arr.size()); for (Iterator<FieldValue> it = arr.fieldValueIterator(); it.hasNext(); ) { ret.add(new AddValueUpdate(it.next(), weight)); } return ret; }
/** * Write out the value of array field * * @param field - field description (name and data type) * @param array - field value */ public <T extends FieldValue> void write(FieldBase field, Array<T> array) { buf.putInt1_2_4Bytes(array.size()); List<T> lst = array.getValues(); for (FieldValue value : lst) { value.serialize(this); } }
/** * Write out the value of array field * * @param field - field description (name and data type) * @param array - field value */ public <T extends FieldValue> void write(FieldBase field, Array<T> array) { buf.putInt1_2_4Bytes(array.size()); List<T> lst = array.getValues(); for (FieldValue value : lst) { value.serialize(this); } }
@Override public Progress process(Processing processing) { if (processing.getDocumentOperations().size() != 1) { //we were given more than one document, return log.log(LogLevel.DEBUG, "More than one document given, returning. (Was given " + processing.getDocumentOperations().size() + " documents)."); return Progress.DONE; } if (!doProcessOuterDocument(processing.getDocumentOperations().get(0), documentTypeName)) { return Progress.DONE; } Document outerDoc = ((DocumentPut)processing.getDocumentOperations().get(0)).getDocument();; @SuppressWarnings("unchecked") Array<Document> innerDocuments = (Array<Document>) outerDoc.getFieldValue(arrayFieldName); if (innerDocuments == null) { //the document does not have the field, return log.log(LogLevel.DEBUG, "The given Document does not have a field value for field " + arrayFieldName + ", returning. (Was given " + outerDoc + ")."); return Progress.DONE; } if (innerDocuments.size() == 0) { //the array is empty, return log.log(LogLevel.DEBUG, "The given Document does not have any elements in array field " + arrayFieldName + ", returning. (Was given " + outerDoc + ")."); return Progress.DONE; } split(processing, innerDocuments); return Progress.DONE; }