@Override public Iterable<SubDocument> apply(SplitDocument input) { if (input == null) { throw new IllegalArgumentException(); } return input.getSubDocuments().row(type).values(); } }
private void insertSingleDoc(SplitDocument doc) throws ImplementationDbException, UserDbException, RetryTransactionException { DbConnection connection = getConnection(); connection.insertRootDocuments(collection, Collections.singleton(doc)); for (SubDocType type : doc.getSubDocuments().rowKeySet()) { Collection<SubDocument> subDocs = doc.getSubDocuments().row(type).values(); connection.insertSubdocuments(collection, type, subDocs); } }
private static KVDocument translateDocStructure(SubDocValueToDocValueTranslator.Argument arg) { DocStructure structure = (DocStructure) arg.structure; SplitDocument splitDocument = arg.splitDoc; LinkedHashMap<String, KVValue<?>> map = new LinkedHashMap<>(); SubDocument subDoc = splitDocument.getSubDocuments().get( structure.getType(), structure.getIndex()); for (String keyName : subDoc.getType().getAttributeKeys()) { //childStructure will be null if the child is a scalar StructureElement childStructure = structure.getElements().get(keyName); arg.structure = childStructure; map.put( keyName, subDoc.getValue(keyName).accept(VALUE_TRANSLATOR, arg) ); } for (Map.Entry<String, StructureElement> entry : structure.getElements().entrySet()) { if (entry.getValue() instanceof DocStructure) { //arrays has already been mapped as values StructureElement childStructure = structure.getElements().get(entry.getKey()); arg.structure = childStructure; map.put( entry.getKey(), translateDocStructure(arg) ); } } return new MapKVDocument(map); }
types.addAll(splitDocument.getSubDocuments().rowKeySet());