@Override protected void serializeToStream() { super.serializeToStream(); final List<ODocument> inds = new ArrayList<ODocument>(indexDefinitions.size()); final List<String> indClasses = new ArrayList<String>(indexDefinitions.size()); document.field("className", className); for (final OIndexDefinition indexDefinition : indexDefinitions) { final ODocument indexDocument = indexDefinition.toStream(); inds.add(indexDocument); indClasses.add(indexDefinition.getClass().getName()); } document.field("indexDefinitions", inds, OType.EMBEDDEDLIST); document.field("indClasses", indClasses, OType.EMBEDDEDLIST); document.field("nullValuesIgnored", isNullValuesIgnored()); }
private void addMetadataDocumentIfNotPresent() { final IndexSearcher searcher = searcher(); try { final TopDocs topDocs = searcher.search(new TermQuery(new Term("_CLASS", "JSON_METADATA")), 1); if (topDocs.totalHits == 0) { String metaAsJson = metadata.toJSON(); String defAsJson = indexDefinition.toStream().toJSON(); Document metaDoc = new Document(); metaDoc.add(new StringField("_META_JSON", metaAsJson, Field.Store.YES)); metaDoc.add(new StringField("_DEF_JSON", defAsJson, Field.Store.YES)); metaDoc.add(new StringField("_DEF_CLASS_NAME", indexDefinition.getClass().getCanonicalName(), Field.Store.YES)); metaDoc.add(new StringField("_CLASS", "JSON_METADATA", Field.Store.YES)); addDocument(metaDoc); } } catch (IOException e) { OLogManager.instance().error(this, "Error while retrieving index metadata", e); } finally { release(searcher); } }
synchronized void updateConfiguration(String type, String name, int version, OIndexDefinition indexDefinition, Set<String> clustersToIndex, String algorithm, String valueContainerAlgorithm) { document.field(OIndexInternal.CONFIG_TYPE, type); document.field(OIndexInternal.CONFIG_NAME, name); document.field(OIndexInternal.INDEX_VERSION, version); if (indexDefinition != null) { final ODocument indexDefDocument = indexDefinition.toStream(); if (!indexDefDocument.hasOwners()) ODocumentInternal.addOwner(indexDefDocument, document); document.field(OIndexInternal.INDEX_DEFINITION, indexDefDocument, OType.EMBEDDED); document.field(OIndexInternal.INDEX_DEFINITION_CLASS, indexDefinition.getClass().getName()); } else { document.removeField(OIndexInternal.INDEX_DEFINITION); document.removeField(OIndexInternal.INDEX_DEFINITION_CLASS); } document.field(CONFIG_CLUSTERS, clustersToIndex, OType.EMBEDDEDSET); document.field(ALGORITHM, algorithm); document.field(VALUE_CONTAINER_ALGORITHM, valueContainerAlgorithm); } }
writer.writeAttribute(5, true, "stream", index.getDefinition().toStream());