use of org.vitrivr.cineast.core.db.dao.reader.MediaSegmentReader in project cineast by vitrivr.
the class CliUtils method printInfoForSegment.
public static void printInfoForSegment(String segmentId, DBSelector selector, String _filterCategory, boolean printObjInfo) {
System.out.println("= Retrieving segment information for " + segmentId + "=");
MediaSegmentReader segmentReader = new MediaSegmentReader(selector);
Optional<MediaSegmentDescriptor> segmentDescriptor = segmentReader.lookUpSegment(segmentId);
segmentDescriptor.ifPresent(System.out::println);
segmentDescriptor.ifPresent(descriptor -> {
if (printObjInfo) {
printInfoForObject(descriptor.getObjectId(), selector);
}
});
System.out.println("= Retrieving segment metadata =");
MediaSegmentMetadataReader reader = new MediaSegmentMetadataReader(selector);
reader.lookupMultimediaMetadata(segmentId).forEach(System.out::println);
System.out.println("Retrieving all columns for segment " + segmentId);
RetrievalRuntimeConfig retrievalRuntimeConfig = Config.sharedConfig().getRetriever();
retrievalRuntimeConfig.getRetrieverCategories().forEach(cat -> {
if (_filterCategory != null) {
if (!cat.equals(_filterCategory)) {
return;
}
}
retrievalRuntimeConfig.getRetrieversByCategory(cat).forEachEntry((retriever, weight) -> {
System.out.println("= Retrieving for feature: " + retriever.getClass().getSimpleName() + " =");
retriever.getTableNames().forEach(tableName -> {
selector.open(tableName);
List<Map<String, PrimitiveTypeProvider>> rows = selector.getRows("id", new StringTypeProvider(segmentId));
if (retriever.getClass() == RangeBooleanRetriever.class) {
rows = selector.getRows("segmentid", new StringTypeProvider(segmentId));
}
rows.forEach(row -> {
System.out.println("== New row == ");
row.forEach((key, value) -> System.out.println(tableName + "." + key + " - " + value));
});
});
return true;
});
});
System.out.println("Done");
}
use of org.vitrivr.cineast.core.db.dao.reader.MediaSegmentReader in project cineast by vitrivr.
the class CineastQueryService method getNeighboringSegments.
@Override
public void getNeighboringSegments(CineastGrpc.MediaSegmentIdList request, StreamObserver<CineastGrpc.MediaSegmentQueryResult> responseObserver) {
MediaSegmentReader mediaSegmentReader = new MediaSegmentReader(Config.sharedConfig().getDatabase().getSelectorSupplier().get());
Set<String> ids = request.getIdsList().stream().map(CineastGrpc.MediaSegmentId::getId).collect(Collectors.toSet());
Map<String, MediaSegmentDescriptor> descriptors = mediaSegmentReader.lookUpSegments(ids);
int range = QueryContainerUtil.queryConfig(request.getQueryConfig()).getMaxResults().orElse(DEFAULT_NEIGHBORING_SEGMENTS) / 2;
if (range > 0) {
Set<MediaSegmentDescriptor> results = new HashSet<>(2 * range * descriptors.size());
for (MediaSegmentDescriptor d : descriptors.values()) {
results.addAll(mediaSegmentReader.lookUpSegmentsByNumberRange(d.getObjectId(), d.getSequenceNumber() - range, d.getSequenceNumber() + range));
}
CineastGrpc.MediaSegmentQueryResult result = CineastGrpc.MediaSegmentQueryResult.newBuilder().addAllSegments(results.stream().map(MediaSegmentUtil::fromMediaSegmentDescriptor).collect(Collectors.toList())).build();
responseObserver.onNext(result);
}
responseObserver.onCompleted();
mediaSegmentReader.close();
}
use of org.vitrivr.cineast.core.db.dao.reader.MediaSegmentReader in project cineast by vitrivr.
the class MetadataFeatureModule method init.
@Override
public void init(DBSelectorSupplier selectorSupply) {
this.dbSelector = selectorSupply.get();
this.dbSelector.open(this.featureEntityName());
this.mediaSegmentReader = new MediaSegmentReader(selectorSupply.get());
}
Aggregations