Package de.lmu.ifi.dbs.elki.datasource.bundle

Examples of de.lmu.ifi.dbs.elki.datasource.bundle.MultipleObjectsBundle


        String l2 = objects.data(o2, lblcol).toString();
        return l1.compareToIgnoreCase(l2);
      }
    });

    MultipleObjectsBundle bundle = new MultipleObjectsBundle();
    for(int j = 0; j < objects.metaLength(); j++) {
      // Reorder column accordingly
      List<?> in = objects.getColumn(j);
      List<Object> data = new ArrayList<Object>(size);
      for(int i = 0; i < size; i++) {
        data.add(in.get(offsets[i]));
      }
      bundle.appendColumn(objects.meta(j), data);
    }
    return bundle;
  }
View Full Code Here


    this.classLabelFactory = classLabelFactory;
  }

  @Override
  public MultipleObjectsBundle filter(MultipleObjectsBundle objects) {
    MultipleObjectsBundle bundle = new MultipleObjectsBundle();
    // Find a labellist column
    boolean done = false;
    boolean keeplabelcol = false;
    for(int i = 0; i < objects.metaLength(); i++) {
      SimpleTypeInformation<?> meta = objects.meta(i);
      // Skip non-labellist columns - or if we already had a labellist
      if(done || meta.getRestrictionClass() != LabelList.class) {
        bundle.appendColumn(meta, objects.getColumn(i));
        continue;
      }
      done = true;

      // We split the label column into two parts
      List<ClassLabel> clscol = new ArrayList<ClassLabel>(objects.dataLength());
      List<LabelList> lblcol = new ArrayList<LabelList>(objects.dataLength());

      // Split the column
      for(Object obj : objects.getColumn(i)) {
        if(obj != null) {
          LabelList ll = (LabelList) obj;
          try {
            ClassLabel lbl = classLabelFactory.makeFromString(ll.remove(classLabelIndex));
            clscol.add(lbl);
          }
          catch(Exception e) {
            throw new AbortException("Cannot initialize class labels: "+e.getMessage(), e);
          }
          lblcol.add(ll);
          if(ll.size() > 0) {
            keeplabelcol = true;
          }
        }
        else {
          clscol.add(null);
          lblcol.add(null);
        }
      }
      bundle.appendColumn(TypeUtil.CLASSLABEL, clscol);
      // Only add the label column when it's not empty.
      if(keeplabelcol) {
        bundle.appendColumn(meta, lblcol);
      }
    }
    return bundle;
  }
View Full Code Here

    this.externalIdIndex = externalIdIndex;
  }

  @Override
  public MultipleObjectsBundle filter(MultipleObjectsBundle objects) {
    MultipleObjectsBundle bundle = new MultipleObjectsBundle();
    // Find a labellist column
    boolean done = false;
    boolean keeplabelcol = false;
    for(int i = 0; i < objects.metaLength(); i++) {
      SimpleTypeInformation<?> meta = objects.meta(i);
      // Skip non-labellist columns - or if we already had a labellist
      if(done || meta.getRestrictionClass() != LabelList.class) {
        bundle.appendColumn(meta, objects.getColumn(i));
        continue;
      }
      done = true;

      // We split the label column into two parts
      List<ExternalID> eidcol = new ArrayList<ExternalID>(objects.dataLength());
      List<LabelList> lblcol = new ArrayList<LabelList>(objects.dataLength());

      // Split the column
      for(Object obj : objects.getColumn(i)) {
        if(obj != null) {
          LabelList ll = (LabelList) obj;
          eidcol.add(new ExternalID(ll.remove(externalIdIndex)));
          lblcol.add(ll);
          if(ll.size() > 0) {
            keeplabelcol = true;
          }
        }
        else {
          eidcol.add(null);
          lblcol.add(null);
        }
      }

      bundle.appendColumn(TypeUtil.EXTERNALID, eidcol);
      // Only add the label column when it's not empty.
      if(keeplabelcol) {
        bundle.appendColumn(meta, lblcol);
      }
    }
    return bundle;
  }
View Full Code Here

  @Override
  public MultipleObjectsBundle filter(MultipleObjectsBundle objects) {
    if(objects.dataLength() == 0) {
      return objects;
    }
    MultipleObjectsBundle bundle = new MultipleObjectsBundle();

    for(int r = 0; r < objects.metaLength(); r++) {
      @SuppressWarnings("unchecked")
      SimpleTypeInformation<Object> type = (SimpleTypeInformation<Object>) objects.meta(r);
      @SuppressWarnings("unchecked")
      final List<Object> column = (List<Object>) objects.getColumn(r);
      if(!getInputTypeRestriction().isAssignableFromType(type)) {
        bundle.appendColumn(type, column);
        continue;
      }
      // Get the replacement type information
      @SuppressWarnings("unchecked")
      final SimpleTypeInformation<I> castType = (SimpleTypeInformation<I>) type;

      // When necessary, perform an initialization scan
      if(prepareStart(castType)) {
        for(Object o : column) {
          @SuppressWarnings("unchecked")
          final I obj = (I) o;
          prepareProcessInstance(obj);
        }
        prepareComplete();
      }

      @SuppressWarnings("unchecked")
      final List<O> castColumn = (List<O>) column;
      bundle.appendColumn(convertedType(castType), castColumn);

      // Normalization scan
      for(int i = 0; i < objects.dataLength(); i++) {
        @SuppressWarnings("unchecked")
        final I obj = (I) column.get(i);
View Full Code Here

  @Override
  public MultipleObjectsBundle filter(MultipleObjectsBundle objects) {
    if(objects.dataLength() == 0) {
      return objects;
    }
    MultipleObjectsBundle bundle = new MultipleObjectsBundle();

    for(int r = 0; r < objects.metaLength(); r++) {
      @SuppressWarnings("unchecked")
      SimpleTypeInformation<Object> type = (SimpleTypeInformation<Object>) objects.meta(r);
      @SuppressWarnings("unchecked")
      final List<Object> column = (List<Object>) objects.getColumn(r);
      if(!getInputTypeRestriction().isAssignableFromType(type)) {
        bundle.appendColumn(type, column);
        continue;
      }
      // Should be a vector type after above test.
      @SuppressWarnings("unchecked")
      final VectorFieldTypeInformation<V> vtype = VectorFieldTypeInformation.class.cast(type);

      // Get the replacement type informations
      VectorFieldTypeInformation<V> type1 = new VectorFieldTypeInformation<V>(type.getRestrictionClass(), type.getSerializer(), dims.length, dims.length);
      VectorFieldTypeInformation<V> type2 = new VectorFieldTypeInformation<V>(type.getRestrictionClass(), type.getSerializer(), vtype.dimensionality() - dims.length, vtype.dimensionality() - dims.length);
      final List<V> col1 = new ArrayList<V>(column.size());
      final List<V> col2 = new ArrayList<V>(column.size());
      bundle.appendColumn(type1, col1);
      bundle.appendColumn(type2, col2);

      // Build other dimensions array.
      int[] odims = new int[vtype.dimensionality() - dims.length];
      {
        int i = 0;
View Full Code Here

      final int temp = offsets[j];
      offsets[j] = offsets[i - 1];
      offsets[i - 1] = temp;
    }

    MultipleObjectsBundle bundle = new MultipleObjectsBundle();
    for(int j = 0; j < objects.metaLength(); j++) {
      // Reorder column accordingly
      List<?> in = objects.getColumn(j);
      List<Object> data = new ArrayList<Object>(size);
      for(int i = 0; i < size; i++) {
        data.add(in.get(offsets[i]));
      }
      bundle.appendColumn(objects.meta(j), data);
    }
    return bundle;
  }
View Full Code Here

  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;
  }
View Full Code Here

  public void initialize() {
    if(databaseConnection != null) {
      if(logger.isDebugging()) {
        logger.debugFine("Loading data from database connection.");
      }
      MultipleObjectsBundle objpackages = databaseConnection.loadData();
      // Run at most once.
      databaseConnection = null;

      // Find DBID column
      int idrepnr = findDBIDColumn(objpackages);
      // Build DBID array
      if(idrepnr == -1) {
        this.ids = DBIDUtil.generateStaticDBIDRange(objpackages.dataLength());
      }
      else {
        final ArrayModifiableDBIDs newids = DBIDUtil.newArray(objpackages.dataLength());
        for(int j = 0; j < objpackages.dataLength(); j++) {
          DBID newid = (DBID) objpackages.data(j, idrepnr);
          newids.add(newid);
        }
        this.ids = newids;
      }
      // Replace id representation.
      // TODO: this is an ugly hack
      this.idrep = new DBIDView(this, this.ids);
      relations.add(this.idrep);
      getHierarchy().add(this, idrep);

      // insert into db - note: DBIDs should have been prepared before this!
      Relation<?>[] targets = alignColumns(objpackages);

      for(int j = 0; j < objpackages.dataLength(); j++) {
        // insert object
        final DBID newid = ids.get(j);
        for(int i = 0; i < targets.length; i++) {
          // DBIDs were handled above.
          if(i == idrepnr) {
            continue;
          }
          @SuppressWarnings("unchecked")
          final Relation<Object> relation = (Relation<Object>) targets[i];
          relation.set(newid, objpackages.data(j, i));
        }
      }

      for(Relation<?> relation : relations) {
        SimpleTypeInformation<?> meta = relation.getDataTypeInformation();
View Full Code Here

  /**
   * Runs the wrapper with the specified arguments.
   */
  @Override
  public void run() throws UnableToComplyException {
    MultipleObjectsBundle data = generator.loadData();
    if(logger.isVerbose()) {
      logger.verbose("Writing output ...");
    }
    try {
      if(outputFile.exists()) {
View Full Code Here

    this.startid = startid;
  }

  @Override
  public MultipleObjectsBundle filter(MultipleObjectsBundle objects) {
    MultipleObjectsBundle bundle = new MultipleObjectsBundle();
    List<DBID> ids = new ArrayList<DBID>(objects.dataLength());
    for(int i = 0; i < objects.dataLength(); i++) {
      ids.add(DBIDUtil.importInteger(startid + i));
    }
    bundle.appendColumn(TypeUtil.DBID, ids);
    // copy other columns
    for(int j = 0; j < objects.metaLength(); j++) {
      bundle.appendColumn(objects.meta(j), objects.getColumn(j));
    }
    return bundle;
  }
View Full Code Here

TOP

Related Classes of de.lmu.ifi.dbs.elki.datasource.bundle.MultipleObjectsBundle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.