use of org.vitrivr.cineast.standalone.config.RetrievalRuntimeConfig in project cineast by vitrivr.
the class QueryUtil method retrieveFeaturesForIDByCategory.
/**
* Retrieves all features for a given id (i.e. segment, object id) and a given category.
*/
public static List<Object> retrieveFeaturesForIDByCategory(String id, String category) {
final RetrievalRuntimeConfig retrievalRuntimeConfig = Config.sharedConfig().getRetriever();
final DBSelector selector = Config.sharedConfig().getDatabase().getSelectorSupplier().get();
List<Object> _return = new ArrayList<>();
retrievalRuntimeConfig.getRetrieversByCategory(category).forEachKey(retriever -> {
retriever.getTableNames().forEach(tableName -> {
selector.open(tableName);
List<Map<String, PrimitiveTypeProvider>> rows = selector.getRows(GENERIC_ID_COLUMN_QUALIFIER, new StringTypeProvider(id));
rows.stream().map(row -> row.get(FEATURE_COLUMN_QUALIFIER).toObject()).forEach(_return::add);
});
// Return value false would break the foreEachKey
return true;
});
return _return;
}
use of org.vitrivr.cineast.standalone.config.RetrievalRuntimeConfig in project cineast by vitrivr.
the class QueryUtil method getFeaturesForCategory.
private static Map<String, ArrayList<HashMap<String, Object>>> getFeaturesForCategory(String category, List<String> ids) {
final RetrievalRuntimeConfig retrievalRuntimeConfig = Config.sharedConfig().getRetriever();
Map<String, ArrayList<HashMap<String, Object>>> _return = new HashMap<>();
retrievalRuntimeConfig.getRetrieversByCategory(category).forEach(retriever -> {
retriever.getTableNames().forEach(tableName -> _return.put(tableName, getFeaturesFromEntity(tableName, ids)));
return true;
});
return _return;
}
use of org.vitrivr.cineast.standalone.config.RetrievalRuntimeConfig 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.standalone.config.RetrievalRuntimeConfig in project cineast by vitrivr.
the class QueryUtil method retrieveFeaturesForAllCategories.
public static FeaturesAllCategoriesQueryResult retrieveFeaturesForAllCategories(String id) {
Map<String, Object[]> features = new HashMap<>();
final RetrievalRuntimeConfig retrievalRuntimeConfig = Config.sharedConfig().getRetriever();
retrievalRuntimeConfig.getRetrieverCategories().forEach(cat -> {
List<Object> _features = retrieveFeaturesForIDByCategory(id, cat);
if (_features.size() == 0) {
return;
}
if (_features.get(0) != null) {
features.put(cat, _features.toArray());
}
});
return new FeaturesAllCategoriesQueryResult("", features, id);
}
Aggregations