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 <http://www.gnu.org/licenses/>.
 */

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<Object>());
    }
    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();
    }
  }
}
@@ -959,16 +959,73 @@
 yList;%0A%0A
+import de.lmu.ifi.dbs.elki.datasource.bundle.BundleMeta;%0A
 import d
@@ -1337,25 +1337,30 @@
 ter 
-implements Object
+extends AbstractStream
 Filt
@@ -1483,16 +1483,76 @@
 lass);%0A%0A
+  /**%0A   * Number of columns%0A   */%0A  private int cols = 0;%0A%0A
   /**%0A  
@@ -1626,16 +1626,703 @@
 );%0A  %7D%0A%0A
+  @Override%0A  public BundleMeta getMeta() %7B%0A    return source.getMeta();%0A  %7D%0A%0A  @Override%0A  public Object data(int rnum) %7B%0A    return source.data(rnum);%0A  %7D%0A%0A  @Override%0A  public Event nextEvent() %7B%0A    while(true) %7B%0A      Event ev = source.nextEvent();%0A      switch(ev)%7B%0A      case END_OF_STREAM:%0A        return ev;%0A      case META_CHANGED:%0A        cols = source.getMeta().size();%0A        return ev;%0A      case NEXT_OBJECT:%0A        boolean good = true;%0A        for(int j = 0; j %3C cols; j++) %7B%0A          if(source.data(j) == null) %7B%0A            good = false;%0A            break;%0A          %7D%0A        %7D%0A        if(good) %7B%0A          return ev;%0A        %7D%0A        continue;%0A      %7D%0A    %7D%0A  %7D%0A%0A
   @Overr

Make streaming.