@Override public Iterable<SubDocument> apply(SplitDocument input) { if (input == null) { throw new IllegalArgumentException(); } return input.getSubDocuments().row(type).values(); } }
public SplitDocument build() { Preconditions.checkState(!build, "This builder has already been used"); if (root == null) { throw new IllegalStateException("structure must be non null"); } assert checkCorrectness(); build = true; return new SplitDocument( id, root, subDocuments, structures ); }
doc.getRoot(), getDsl(), listener ); sb.append(doc.getDocumentId()).append('\t').append(structureId) .append('\n');
@Override public ToroDocument apply(@Nonnull SplitDocument input) { final ToroDocument.DocumentBuilder docBuilder = documentBuilderFactory.newDocBuilder(); SubDocValueToDocValueTranslator.Argument arg = new SubDocValueToDocValueTranslator.Argument(input, input.getRoot()); docBuilder.setRoot(translateDocStructure(arg)); return docBuilder.build(); }
private void standardInsertRootDocuments( @Nonnull String collection, @Nonnull Collection<SplitDocument> docs) { CollectionSchema colSchema = getMeta().getCollectionSchema(collection); Field<Integer> idField = DSL.field("did", SQLDataType.INTEGER.nullable(false)); Field<Integer> sidField = DSL.field("sid", SQLDataType.INTEGER.nullable(false)); InsertValuesStep2<Record, Integer, Integer> insertInto = getDsl() .insertInto( DSL.table(DSL.name(colSchema.getName(), "root")), idField, sidField ); for (SplitDocument splitDocument : docs) { int structureId = colSchema.getStructuresCache().getOrCreateStructure( splitDocument.getRoot(), getDsl(), listener ); insertInto = insertInto.values(splitDocument.getDocumentId(), structureId); } insertInto.execute(); }
private void standardInsertRootDocuments( @Nonnull String collection, @Nonnull Collection<SplitDocument> docs) { CollectionSchema colSchema = getMeta().getCollectionSchema(collection); Field<Integer> idField = DSL.field("did", SQLDataType.INTEGER.nullable(false)); Field<Integer> sidField = DSL.field("sid", SQLDataType.INTEGER.nullable(false)); InsertValuesStep2<Record, Integer, Integer> insertInto = getDsl() .insertInto( DSL.table(DSL.name(colSchema.getName(), "root")), idField, sidField ); for (SplitDocument splitDocument : docs) { int structureId = colSchema.getStructuresCache().getOrCreateStructure( splitDocument.getRoot(), getDsl(), listener ); insertInto = insertInto.values(splitDocument.getDocumentId(), structureId); } insertInto.execute(); }
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 void standardInsertRootDocuments( @Nonnull String collection, @Nonnull Collection<SplitDocument> docs) { CollectionSchema colSchema = getMeta().getCollectionSchema(collection); Field<Integer> idField = DSL.field("did", SQLDataType.INTEGER.nullable(false)); Field<Integer> sidField = DSL.field("sid", SQLDataType.INTEGER.nullable(false)); InsertValuesStep2<Record, Integer, Integer> insertInto = getDsl() .insertInto( DSL.table(DSL.name(colSchema.getName(), "root")), idField, sidField ); for (SplitDocument splitDocument : docs) { int structureId = colSchema.getStructuresCache().getOrCreateStructure( splitDocument.getRoot(), getDsl(), listener ); insertInto = insertInto.values(splitDocument.getDocumentId(), structureId); } insertInto.execute(); }
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());