Search in sources :

Example 6 with MediaObjectReader

use of org.vitrivr.cineast.core.db.dao.reader.MediaObjectReader in project cineast by vitrivr.

the class FindObjectByIdPostHandler method performPost.

@Override
public MediaObjectQueryResult performPost(IdList context, Context ctx) {
    final Map<String, String> parameters = ctx.pathParamMap();
    if (context == null || context.getIds().length == 0) {
        return new MediaObjectQueryResult("", new ArrayList<>(0));
    }
    final MediaObjectReader ol = new MediaObjectReader(Config.sharedConfig().getDatabase().getSelectorSupplier().get());
    final Map<String, MediaObjectDescriptor> objects = ol.lookUpObjects(Arrays.asList(context.getIds()));
    ol.close();
    return new MediaObjectQueryResult("", new ArrayList<>(objects.values()));
}
Also used : MediaObjectDescriptor(org.vitrivr.cineast.core.data.entities.MediaObjectDescriptor) MediaObjectQueryResult(org.vitrivr.cineast.api.messages.result.MediaObjectQueryResult) MediaObjectReader(org.vitrivr.cineast.core.db.dao.reader.MediaObjectReader)

Example 7 with MediaObjectReader

use of org.vitrivr.cineast.core.db.dao.reader.MediaObjectReader in project cineast by vitrivr.

the class CineastQueryService method getMediaObjects.

@Override
public void getMediaObjects(CineastGrpc.MediaObjectIdList request, StreamObserver<CineastGrpc.MediaObjectQueryResult> responseObserver) {
    Set<String> ids = request.getIdsList().stream().map(CineastGrpc.MediaObjectId::getId).collect(Collectors.toSet());
    MediaObjectReader reader = new MediaObjectReader(Config.sharedConfig().getDatabase().getSelectorSupplier().get());
    Map<String, MediaObjectDescriptor> objects = reader.lookUpObjects(ids);
    CineastGrpc.MediaObjectQueryResult result = CineastGrpc.MediaObjectQueryResult.newBuilder().addAllObjects(objects.values().stream().map(MediaObjectUtil::fromMediaObjectDescriptor).collect(Collectors.toList())).build();
    responseObserver.onNext(result);
    responseObserver.onCompleted();
}
Also used : MediaObjectDescriptor(org.vitrivr.cineast.core.data.entities.MediaObjectDescriptor) MediaObjectReader(org.vitrivr.cineast.core.db.dao.reader.MediaObjectReader)

Aggregations

MediaObjectReader (org.vitrivr.cineast.core.db.dao.reader.MediaObjectReader)7 MediaObjectDescriptor (org.vitrivr.cineast.core.data.entities.MediaObjectDescriptor)5 MediaObjectQueryResult (org.vitrivr.cineast.api.messages.result.MediaObjectQueryResult)3 MediaObjectMetadataDescriptor (org.vitrivr.cineast.core.data.entities.MediaObjectMetadataDescriptor)2 MediaObjectMetadataReader (org.vitrivr.cineast.core.db.dao.reader.MediaObjectMetadataReader)2 StreamObserver (io.grpc.stub.StreamObserver)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 TimeUnit (java.util.concurrent.TimeUnit)1 Collectors (java.util.stream.Collectors)1 StopWatch (org.apache.commons.lang3.time.StopWatch)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 QueryStage (org.vitrivr.cineast.api.grpc.data.QueryStage)1 QueryTerm (org.vitrivr.cineast.api.grpc.data.QueryTerm)1