package de.lmu.ifi.dbs.elki.datasource.filter; /* This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ import java.util.ArrayList; import de.lmu.ifi.dbs.elki.datasource.bundle.MultipleObjectsBundle; import de.lmu.ifi.dbs.elki.logging.Logging; import de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizer; /** * A filter to remove entries that have missing values. * * @author Erich Schubert */ public class NoMissingValuesFilter implements ObjectFilter { /** * Class logger */ private static final Logging logger = Logging.getLogger(NoMissingValuesFilter.class); /** * Constructor. */ public NoMissingValuesFilter() { super(); } @Override public MultipleObjectsBundle filter(final MultipleObjectsBundle objects) { if(logger.isDebugging()) { logger.debug("Filtering the data set"); } MultipleObjectsBundle bundle = new MultipleObjectsBundle(); for(int j = 0; j < objects.metaLength(); j++) { bundle.appendColumn(objects.meta(j), new ArrayList()); } for(int i = 0; i < objects.dataLength(); i++) { boolean good = true; for(int j = 0; j < objects.metaLength(); j++) { if(objects.data(i, j) == null) { good = false; break; } } if(good) { bundle.appendSimple(objects.getRow(i)); } } return bundle; } /** * Parameterization class. * * @author Erich Schubert * * @apiviz.exclude */ public static class Parameterizer extends AbstractParameterizer { @Override protected Object makeInstance() { return new NoMissingValuesFilter(); } } }