Search in sources :

Example 11 with Entity

use of jetbrains.exodus.entitystore.Entity 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 12 with Entity

use of jetbrains.exodus.entitystore.Entity 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 13 with Entity

use of jetbrains.exodus.entitystore.Entity 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 14 with Entity

use of jetbrains.exodus.entitystore.Entity 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 15 with Entity

use of jetbrains.exodus.entitystore.Entity 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

Entity (jetbrains.exodus.entitystore.Entity)44 EntityIterable (jetbrains.exodus.entitystore.EntityIterable)23 IOException (java.io.IOException)13 EntityIterableBase (jetbrains.exodus.entitystore.iterate.EntityIterableBase)7 InputStream (java.io.InputStream)6 UncheckedIOException (java.io.UncheckedIOException)5 ArrayList (java.util.ArrayList)5 ComparableGetter (jetbrains.exodus.entitystore.ComparableGetter)4 EntityStoreException (jetbrains.exodus.entitystore.EntityStoreException)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 EntityId (jetbrains.exodus.entitystore.EntityId)3 File (java.io.File)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 NoSuchElementException (java.util.NoSuchElementException)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Nonnull (javax.annotation.Nonnull)2 ExodusException (jetbrains.exodus.ExodusException)2 EntityMetaData (jetbrains.exodus.query.metadata.EntityMetaData)2 Serializable (java.io.Serializable)1