private OLuceneFullTextIndex searchForIndex(OCommandContext ctx, String className) { OMetadata dbMetadata = ctx.getDatabase().activateOnCurrentThread().getMetadata(); List<OLuceneFullTextIndex> indices = dbMetadata.getSchema().getClass(className).getIndexes().stream() .filter(idx -> idx instanceof OLuceneFullTextIndex).map(idx -> (OLuceneFullTextIndex) idx).collect(Collectors.toList()); if (indices.size() > 1) { throw new IllegalArgumentException("too many full-text indices on given class: " + className); } return indices.size() == 0 ? null : indices.get(0); }
private OLuceneFullTextIndex searchForIndex(String className, OCommandContext ctx, List<String> fieldNames) { OMetadata dbMetadata = ctx.getDatabase().activateOnCurrentThread().getMetadata(); List<OLuceneFullTextIndex> indices = dbMetadata.getSchema().getClass(className).getIndexes().stream() .filter(idx -> idx instanceof OLuceneFullTextIndex).map(idx -> (OLuceneFullTextIndex) idx) .filter(idx -> intersect(idx.getDefinition().getFields(), fieldNames)).collect(Collectors.toList()); if (indices.size() > 1) { throw new IllegalArgumentException("too many indices matching given field name: " + String.join(",", fieldNames)); } return indices.size() == 0 ? null : indices.get(0); }
private OLuceneFullTextIndex searchForIndex(OCommandContext ctx, String className) { OMetadata dbMetadata = ctx.getDatabase().activateOnCurrentThread().getMetadata(); List<OLuceneFullTextIndex> indices = dbMetadata .getSchema() .getClass(className) .getIndexes() .stream() .filter(idx -> idx instanceof OLuceneFullTextIndex) .map(idx -> (OLuceneFullTextIndex) idx) .collect(Collectors.toList()); if (indices.size() > 1) { throw new IllegalArgumentException("too many full-text indices on given class: " + className); } return indices.size() == 0 ? null : indices.get(0); }
/** * Posts the given events; this will be a paired sequence of ODocument, EventKind, ODocument, EventKind, etc... */ private void postEvents(final ODatabase db, final List<Object> events, final String remoteNodeId) { final List<EntityEvent> batchedEvents = new ArrayList<>(); for (int i = 0; i < events.size(); i += 2) { final EntityEvent event = newEntityEvent((ODocument) events.get(i), (EventKind) events.get(i + 1)); if (event != null) { event.setRemoteNodeId(remoteNodeId); eventManager.post(event); db.activateOnCurrentThread(); if (event instanceof Batchable) { batchedEvents.add(event); } } } if (!batchedEvents.isEmpty()) { eventManager.post(new EntityBatchEvent(batchedEvents)); db.activateOnCurrentThread(); } }
protected static OLuceneFullTextIndex getLuceneFullTextIndex(OCommandContext ctx, String indexName) { OMetadata metadata = ctx.getDatabase().activateOnCurrentThread().getMetadata(); OLuceneFullTextIndex index = (OLuceneFullTextIndex) metadata.getIndexManager().getIndex(indexName); if (!(index instanceof OLuceneFullTextIndex)) { throw new IllegalArgumentException("Not a valid Lucene index:: " + indexName); } return index; }
public void close() { ODatabaseDocumentInternal prev = ODatabaseRecordThreadLocal.instance().getIfDefined(); try { db.activateOnCurrentThread(); resultSet.close(); db.close(); ((OSharedContextEmbedded) ((ODatabaseInternal) db).getSharedContext()).getActiveDistributedQueries().remove(queryId); } finally { if (prev == null) { ODatabaseRecordThreadLocal.instance().remove(); } else { ODatabaseRecordThreadLocal.instance().set(prev); } } } }
public List<OResult> fetchNextPage() { ODatabaseDocumentInternal prev = ODatabaseRecordThreadLocal.instance().getIfDefined(); try { db.activateOnCurrentThread(); resultSet.close(); db.close(); } finally { if (prev == null) { ODatabaseRecordThreadLocal.instance().remove(); } else { ODatabaseRecordThreadLocal.instance().set(prev); } } return null; }