Search in sources :

Example 6 with EntityIterable

use of jetbrains.exodus.entitystore.EntityIterable in project meghanada-server by mopemope.

the class ProjectDatabase method find.

public <U> List<U> find(String entityType, String propName, String value, Function<? super Entity, ? extends U> mapper) {
    return this.entityStore.computeInReadonlyTransaction(txn -> {
        EntityIterable iterable = txn.find(entityType, propName, value);
        List<U> result = new ArrayList<>(8);
        for (Entity entity : iterable) {
            result.add(mapper.apply(entity));
        }
        return result;
    });
}
Also used : Entity(jetbrains.exodus.entitystore.Entity) EntityIterable(jetbrains.exodus.entitystore.EntityIterable) ArrayList(java.util.ArrayList)

Example 7 with EntityIterable

use of jetbrains.exodus.entitystore.EntityIterable in project meghanada-server by mopemope.

the class ProjectDatabase method findStartingWith.

public <U> List<U> findStartingWith(String entityType, String propName, String value, Function<? super Entity, ? extends U> mapper) {
    return this.entityStore.computeInReadonlyTransaction(txn -> {
        EntityIterable iterable = txn.findStartingWith(entityType, propName, value);
        List<U> result = new ArrayList<>(8);
        for (Entity entity : iterable) {
            result.add(mapper.apply(entity));
        }
        return result;
    });
}
Also used : Entity(jetbrains.exodus.entitystore.Entity) EntityIterable(jetbrains.exodus.entitystore.EntityIterable) ArrayList(java.util.ArrayList)

Example 8 with EntityIterable

use of jetbrains.exodus.entitystore.EntityIterable in project meghanada-server by mopemope.

the class ProjectDatabaseHelper method getMemberDescriptors.

public static Optional<List<MemberDescriptor>> getMemberDescriptors(String fqcn) {
    ProjectDatabase database = ProjectDatabase.getInstance();
    return database.computeInReadonly(txn -> {
        EntityIterable it = txn.find(ClassIndex.ENTITY_TYPE, ProjectDatabase.ID, fqcn).intersect(txn.findWithBlob(ClassIndex.ENTITY_TYPE, BLOB_PROP_MEMBERS));
        Entity entity = it.getFirst();
        if (isNull(entity)) {
            return Optional.empty();
        }
        try (InputStream in = entity.getBlob(BLOB_PROP_MEMBERS)) {
            @SuppressWarnings("unchecked") List<MemberDescriptor> res = Serializer.readObject(in, ArrayList.class);
            return Optional.ofNullable(res);
        } catch (Exception e) {
            log.catching(e);
            return Optional.empty();
        }
    });
}
Also used : Entity(jetbrains.exodus.entitystore.Entity) EntityIterable(jetbrains.exodus.entitystore.EntityIterable) MemberDescriptor(meghanada.reflect.MemberDescriptor) InputStream(java.io.InputStream) IOException(java.io.IOException)

Example 9 with EntityIterable

use of jetbrains.exodus.entitystore.EntityIterable in project meghanada-server by mopemope.

the class ProjectDatabaseHelper method saveLoadJar.

public static void saveLoadJar(String filePath) {
    ProjectDatabase database = ProjectDatabase.getInstance();
    database.execute(txn -> {
        EntityIterable it = txn.find(ClassIndex.FILE_ENTITY_TYPE, "filePath", filePath);
        if (nonNull(it.getFirst())) {
            return false;
        }
        Entity entity = txn.newEntity(ClassIndex.FILE_ENTITY_TYPE);
        entity.setProperty("filePath", filePath);
        return true;
    });
}
Also used : Entity(jetbrains.exodus.entitystore.Entity) EntityIterable(jetbrains.exodus.entitystore.EntityIterable)

Example 10 with EntityIterable

use of jetbrains.exodus.entitystore.EntityIterable in project meghanada-server by mopemope.

the class ProjectDatabaseHelper method saveCallerMap.

public static boolean saveCallerMap(String projectRoot, Map<String, Set<String>> map) {
    ProjectDatabase database = ProjectDatabase.getInstance();
    return database.execute(txn -> {
        EntityIterable entities = txn.find(Project.ENTITY_TYPE, ProjectDatabase.ID, projectRoot);
        Entity entity = entities.getFirst();
        if (isNull(entity)) {
            return false;
        }
        try {
            ProjectDatabase.setSerializeBlobData(entity, BLOB_PROP_CALLER, map);
        } catch (IOException e) {
            log.catching(e);
            txn.abort();
            return false;
        }
        // txn.saveEntity(entity);
        return true;
    });
}
Also used : Entity(jetbrains.exodus.entitystore.Entity) EntityIterable(jetbrains.exodus.entitystore.EntityIterable) IOException(java.io.IOException)

Aggregations

EntityIterable (jetbrains.exodus.entitystore.EntityIterable)24 Entity (jetbrains.exodus.entitystore.Entity)23 IOException (java.io.IOException)11 InputStream (java.io.InputStream)6 ArrayList (java.util.ArrayList)5 EntityStoreException (jetbrains.exodus.entitystore.EntityStoreException)4 EntityIterableBase (jetbrains.exodus.entitystore.iterate.EntityIterableBase)4 UncheckedIOException (java.io.UncheckedIOException)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Nonnull (javax.annotation.Nonnull)2 ExodusException (jetbrains.exodus.ExodusException)2 ComparableGetter (jetbrains.exodus.entitystore.ComparableGetter)2 EntityId (jetbrains.exodus.entitystore.EntityId)2 File (java.io.File)1 Serializable (java.io.Serializable)1 EntityIterator (jetbrains.exodus.entitystore.EntityIterator)1 Explainer (jetbrains.exodus.entitystore.Explainer)1 PersistentEntityStoreImpl (jetbrains.exodus.entitystore.PersistentEntityStoreImpl)1