/** * Creates a {@link StandingQueryAttribute} which returns true if the given attribute does not have values for * an object. * <p> * An index can then be built on this attribute, and it will be able to to answer a <code>not(has(attribute))</code> * query, returning objects which do not have values for that attribute, in constant time complexity O(1). * * @param entityIndex The index which will be used in a <code>not(has(attribute))</code> query * @return a {@link StandingQueryAttribute} which returns true if the given attribute does not have values for * an object */ @Deprecated static <O extends Entity, A> StandingQueryAttribute<EntityHandle<O>> forObjectsMissing(EntityIndex<O, A> entityIndex) { return forStandingQuery(not(has(entityIndex))); }
@Override public Stream<T> getCollectionStream(Repository repository) { IndexedCollection<EntityHandle<Deleted>> deletedCollection = repository.getIndexEngine().getIndexedCollection(Deleted.class); IndexedCollection<EntityHandle<Undeleted>> undeletedCollection = repository.getIndexEngine().getIndexedCollection(Undeleted.class); ResultSet<EntityHandle<E>> resultSet = repository .query(klass, not(existsIn(deletedCollection, idAttribute, Deleted.REFERENCE_ID, not(existsIn(undeletedCollection, Deleted.ID, Undeleted.DELETED_ID))))); return streamOf(resultSet) .map(h -> loader.load(repository, h.get().uuid()).get()) .onClose(resultSet::close); }
default Optional<Deleted> deleted() { Not<EntityHandle<Deleted>> additionalQuery = not(existsIn(getRepository().getIndexEngine() .getIndexedCollection(Undeleted.class), Deleted.ID, Undeleted.DELETED_ID)); return latestAssociatedEntity(Deleted.class, Deleted.REFERENCE_ID, Deleted.TIMESTAMP, additionalQuery); }
@Override public Stream<T> getCollectionStream(Repository repository) { IndexedCollection<EntityHandle<Deleted>> deletedCollection = repository.getIndexEngine() .getIndexedCollection(Deleted.class); IndexedCollection<EntityHandle<Undeleted>> undeletedCollection = repository.getIndexEngine() .getIndexedCollection( Undeleted.class); Query<EntityHandle<Deleted>> query = and(not(existsIn(undeletedCollection, Deleted.ID, Undeleted.DELETED_ID)), isLatestEntity(deletedCollection, new DeletedQueryFunction(), Deleted.TIMESTAMP)); ResultSet<EntityHandle<Deleted>> resultSet = repository.query(Deleted.class, query); return streamOf(resultSet) .map(h -> loader.load(repository, h.get().reference()).get()) .onClose(resultSet::close); }