Search in sources :

Example 6 with BundleMeta

use of de.lmu.ifi.dbs.elki.datasource.bundle.BundleMeta in project elki by elki-project.

the class AbstractStreamConversionFilter method nextEvent.

@Override
public Event nextEvent() {
    Event ev = source.nextEvent();
    if (ev == Event.META_CHANGED) {
        if (meta == null) {
            meta = new BundleMeta();
        }
        BundleMeta origmeta = source.getMeta();
        for (int i = meta.size(); i < origmeta.size(); i++) {
            if (column < 0) {
                @SuppressWarnings("unchecked") SimpleTypeInformation<Object> type = (SimpleTypeInformation<Object>) origmeta.get(i);
                // Test whether this type matches
                if (getInputTypeRestriction().isAssignableFromType(type)) {
                    @SuppressWarnings("unchecked") final SimpleTypeInformation<I> castType = (SimpleTypeInformation<I>) type;
                    meta.add(convertedType(castType));
                    column = i;
                    continue;
                }
            }
            meta.add(origmeta.get(i));
        }
    }
    return ev;
}
Also used : BundleMeta(de.lmu.ifi.dbs.elki.datasource.bundle.BundleMeta) SimpleTypeInformation(de.lmu.ifi.dbs.elki.data.type.SimpleTypeInformation)

Example 7 with BundleMeta

use of de.lmu.ifi.dbs.elki.datasource.bundle.BundleMeta in project elki by elki-project.

the class ClassLabelFromPatternFilter method getMeta.

@Override
public BundleMeta getMeta() {
    if (meta == null) {
        // Rebuild metadata.
        BundleMeta origmeta = source.getMeta();
        meta = new BundleMeta(origmeta.size() + 1);
        meta.add(TypeUtil.SIMPLE_CLASSLABEL);
        labelcols.clear();
        for (int i = 0; i < origmeta.size(); i++) {
            final SimpleTypeInformation<?> orig = origmeta.get(i);
            if (TypeUtil.GUESSED_LABEL.isAssignableFromType(orig)) {
                labelcols.add(i);
            }
            meta.add(orig);
        }
    }
    return meta;
}
Also used : BundleMeta(de.lmu.ifi.dbs.elki.datasource.bundle.BundleMeta)

Example 8 with BundleMeta

use of de.lmu.ifi.dbs.elki.datasource.bundle.BundleMeta in project elki by elki-project.

the class NumberVectorLabelParser method buildMeta.

/**
 * Update the meta element.
 */
protected void buildMeta() {
    if (haslabels) {
        meta = new BundleMeta(2);
        meta.add(getTypeInformation(mindim, maxdim));
        meta.add(TypeUtil.LABELLIST);
    } else {
        meta = new BundleMeta(1);
        meta.add(getTypeInformation(mindim, maxdim));
    }
}
Also used : BundleMeta(de.lmu.ifi.dbs.elki.datasource.bundle.BundleMeta)

Example 9 with BundleMeta

use of de.lmu.ifi.dbs.elki.datasource.bundle.BundleMeta in project elki by elki-project.

the class SimplePolygonParser method buildMeta.

/**
 * Update the meta element.
 */
protected void buildMeta() {
    if (haslabels) {
        meta = new BundleMeta(3);
        meta.add(TypeUtil.POLYGON_TYPE);
        meta.add(TypeUtil.EXTERNALID);
        meta.add(TypeUtil.LABELLIST);
    } else {
        meta = new BundleMeta(2);
        meta.add(TypeUtil.POLYGON_TYPE);
        meta.add(TypeUtil.EXTERNALID);
    }
}
Also used : BundleMeta(de.lmu.ifi.dbs.elki.datasource.bundle.BundleMeta)

Example 10 with BundleMeta

use of de.lmu.ifi.dbs.elki.datasource.bundle.BundleMeta in project elki by elki-project.

the class VectorDimensionalityFilter method updateMeta.

/**
 * Update metadata.
 */
private void updateMeta() {
    meta = new BundleMeta();
    BundleMeta origmeta = source.getMeta();
    for (int i = 0; i < origmeta.size(); i++) {
        SimpleTypeInformation<?> type = origmeta.get(i);
        if (column < 0) {
            // Test whether this type matches
            if (TypeUtil.NUMBER_VECTOR_VARIABLE_LENGTH.isAssignableFromType(type)) {
                if (type instanceof VectorFieldTypeInformation) {
                    @SuppressWarnings("unchecked") final VectorFieldTypeInformation<V> castType = (VectorFieldTypeInformation<V>) type;
                    if (dim != -1 && castType.mindim() > dim) {
                        throw new AbortException("Would filter all vectors: minimum dimensionality " + castType.mindim() + " > desired dimensionality " + dim);
                    }
                    if (dim != -1 && castType.maxdim() < dim) {
                        throw new AbortException("Would filter all vectors: maximum dimensionality " + castType.maxdim() + " < desired dimensionality " + dim);
                    }
                    if (dim == -1) {
                        dim = castType.mindim();
                    }
                    if (castType.mindim() == castType.maxdim()) {
                        meta.add(castType);
                        column = i;
                        continue;
                    }
                }
                @SuppressWarnings("unchecked") final VectorTypeInformation<V> castType = (VectorTypeInformation<V>) type;
                if (dim != -1) {
                    meta.add(new VectorFieldTypeInformation<>(FilterUtil.guessFactory(castType), dim, dim, castType.getSerializer()));
                } else {
                    LOG.warning("No dimensionality yet for column " + i);
                    meta.add(castType);
                }
                column = i;
                continue;
            }
        }
        meta.add(type);
    }
}
Also used : BundleMeta(de.lmu.ifi.dbs.elki.datasource.bundle.BundleMeta) VectorFieldTypeInformation(de.lmu.ifi.dbs.elki.data.type.VectorFieldTypeInformation) VectorTypeInformation(de.lmu.ifi.dbs.elki.data.type.VectorTypeInformation) AbortException(de.lmu.ifi.dbs.elki.utilities.exceptions.AbortException)

Aggregations

BundleMeta (de.lmu.ifi.dbs.elki.datasource.bundle.BundleMeta)11 AbortException (de.lmu.ifi.dbs.elki.utilities.exceptions.AbortException)3 SimpleTypeInformation (de.lmu.ifi.dbs.elki.data.type.SimpleTypeInformation)2 IOException (java.io.IOException)2 BitVector (de.lmu.ifi.dbs.elki.data.BitVector)1 LabelList (de.lmu.ifi.dbs.elki.data.LabelList)1 NumberVector (de.lmu.ifi.dbs.elki.data.NumberVector)1 VectorFieldTypeInformation (de.lmu.ifi.dbs.elki.data.type.VectorFieldTypeInformation)1 VectorTypeInformation (de.lmu.ifi.dbs.elki.data.type.VectorTypeInformation)1 BundleStreamSource (de.lmu.ifi.dbs.elki.datasource.bundle.BundleStreamSource)1 Event (de.lmu.ifi.dbs.elki.datasource.bundle.BundleStreamSource.Event)1 MultipleObjectsBundle (de.lmu.ifi.dbs.elki.datasource.bundle.MultipleObjectsBundle)1 StreamingParser (de.lmu.ifi.dbs.elki.datasource.parser.StreamingParser)1 Object2IntMap (it.unimi.dsi.fastutil.objects.Object2IntMap)1 BufferedInputStream (java.io.BufferedInputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 FileChannel (java.nio.channels.FileChannel)1 ArrayList (java.util.ArrayList)1