use of org.vitrivr.cineast.core.data.providers.primitive.StringTypeProvider 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.core.data.providers.primitive.StringTypeProvider in project cineast by vitrivr.
the class SegmentTags method getSimilar.
@Override
public List<ScoreElement> getSimilar(String segmentId, ReadableQueryConfig qc) {
List<Map<String, PrimitiveTypeProvider>> rows = this.selector.getRows("id", new StringTypeProvider(segmentId));
if (rows.isEmpty()) {
return Collections.emptyList();
}
ArrayList<WeightedTag> wtags = new ArrayList<>(rows.size());
for (Map<String, PrimitiveTypeProvider> row : rows) {
wtags.add(new IncompleteTag(row.get("tagid").getString(), "", "", row.get("score").getFloat()));
}
return getSimilar(wtags, qc);
}
use of org.vitrivr.cineast.core.data.providers.primitive.StringTypeProvider in project cineast by vitrivr.
the class AverageColorRaster method getSimilar.
@Override
public List<ScoreElement> getSimilar(String segmentId, ReadableQueryConfig qc) {
List<Map<String, PrimitiveTypeProvider>> rows = this.selector.getRows(GENERIC_ID_COLUMN_QUALIFIER, new StringTypeProvider(segmentId));
if (rows.isEmpty()) {
return new ArrayList<>(1);
}
Map<String, PrimitiveTypeProvider> map = rows.get(0);
return getSimilar(map.get("raster").getFloatArray(), map.get("hist").getFloatArray(), qc);
}
use of org.vitrivr.cineast.core.data.providers.primitive.StringTypeProvider in project cineast by vitrivr.
the class TagReader method getTagsByName.
/**
* Returns all {@link Tag}s that are equal to the specified name.
*
* @param name To value with which to compare the {@link Tag}s.
* @return List of matching {@link Tag}s.
*/
public List<Tag> getTagsByName(String name) {
List<Map<String, PrimitiveTypeProvider>> rows = this.selector.getRows("name", new StringTypeProvider(name));
ArrayList<Tag> _return = new ArrayList<>(rows.size());
for (Map<String, PrimitiveTypeProvider> row : rows) {
Tag t = fromMap(row);
if (t != null) {
_return.add(t);
}
}
return _return;
}
use of org.vitrivr.cineast.core.data.providers.primitive.StringTypeProvider in project cineast by vitrivr.
the class DBIntegrationTest method getFeatureVectors.
@Test
@DisplayName("get multiple feature vectors")
void getFeatureVectors() {
this.selector.open(testVectorTableName);
final List<PrimitiveTypeProvider> vectors = this.selector.getFeatureVectorsGeneric(ID_COL_NAME, new StringTypeProvider("0"), FEATURE_VECTOR_COL_NAME);
Assertions.assertTrue((Arrays.equals(PrimitiveTypeProvider.getSafeFloatArray(vectors.get(0)), new float[] { 0, 0, 0 }) | Arrays.equals(PrimitiveTypeProvider.getSafeFloatArray(vectors.get(0)), new float[] { 0, 1, 0 })));
Assertions.assertTrue((Arrays.equals(PrimitiveTypeProvider.getSafeFloatArray(vectors.get(1)), new float[] { 0, 0, 0 }) | Arrays.equals(PrimitiveTypeProvider.getSafeFloatArray(vectors.get(1)), new float[] { 0, 1, 0 })));
}
Aggregations