Search in sources :

Example 1 with StreamFilter

use of de.lmu.ifi.dbs.elki.datasource.filter.StreamFilter in project elki by elki-project.

the class AbstractDatabaseConnection method invokeStreamFilters.

/**
 * Transforms the specified list of objects and their labels into a list of
 * objects and their associations.
 *
 * @param stream the objects to process
 * @return processed objects
 */
protected BundleStreamSource invokeStreamFilters(BundleStreamSource stream) {
    if (filters == null) {
        return stream;
    }
    // We dynamically switch between streaming and bundle operations.
    MultipleObjectsBundle bundle = null;
    for (ObjectFilter filter : filters) {
        if (filter instanceof StreamFilter) {
            stream = ((StreamFilter) filter).init((stream != null) ? stream : bundle.asStream());
            bundle = null;
        } else {
            bundle = filter.filter((bundle != null) ? bundle : stream.asMultipleObjectsBundle());
            stream = null;
        }
    }
    return (stream != null) ? stream : bundle.asStream();
}
Also used : MultipleObjectsBundle(de.lmu.ifi.dbs.elki.datasource.bundle.MultipleObjectsBundle) ObjectFilter(de.lmu.ifi.dbs.elki.datasource.filter.ObjectFilter) StreamFilter(de.lmu.ifi.dbs.elki.datasource.filter.StreamFilter)

Example 2 with StreamFilter

use of de.lmu.ifi.dbs.elki.datasource.filter.StreamFilter in project elki by elki-project.

the class AbstractDatabaseConnection method invokeBundleFilters.

/**
 * Transforms the specified list of objects and their labels into a list of
 * objects and their associations.
 *
 * @param bundle the objects to process
 * @return processed objects
 */
protected MultipleObjectsBundle invokeBundleFilters(MultipleObjectsBundle bundle) {
    if (filters == null) {
        return bundle;
    }
    // We dynamically switch between streaming and bundle operations.
    BundleStreamSource stream = null;
    for (ObjectFilter filter : filters) {
        if (filter instanceof StreamFilter) {
            StreamFilter sfilter = (StreamFilter) filter;
            stream = sfilter.init((stream != null) ? stream : bundle.asStream());
            // No longer a bundle
            bundle = null;
        } else {
            bundle = filter.filter((bundle != null) ? bundle : stream.asMultipleObjectsBundle());
            // No longer a stream
            stream = null;
        }
    }
    return (bundle != null) ? bundle : stream.asMultipleObjectsBundle();
}
Also used : ObjectFilter(de.lmu.ifi.dbs.elki.datasource.filter.ObjectFilter) StreamFilter(de.lmu.ifi.dbs.elki.datasource.filter.StreamFilter) BundleStreamSource(de.lmu.ifi.dbs.elki.datasource.bundle.BundleStreamSource)

Aggregations

ObjectFilter (de.lmu.ifi.dbs.elki.datasource.filter.ObjectFilter)2 StreamFilter (de.lmu.ifi.dbs.elki.datasource.filter.StreamFilter)2 BundleStreamSource (de.lmu.ifi.dbs.elki.datasource.bundle.BundleStreamSource)1 MultipleObjectsBundle (de.lmu.ifi.dbs.elki.datasource.bundle.MultipleObjectsBundle)1