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;
});
}
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;
});
}
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();
}
});
}
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;
});
}
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;
});
}
Aggregations