Example #1
0
  /** Overriden method from SQLMultiSource */
  public Rating next() {
    if (!hasNext()) return null;

    Rating l = new Rating(instances);
    Attribute[] attributes = getAttributes();
    SparseInstance d = new SparseInstance(attributes.length - 2);
    Long start;
    try {
      l.setUserId(Utils.objectToInteger(records.getObject(1)));
      l.setObjectId(Utils.objectToInteger(records.getObject(2)));
      int flixId = Integer.parseInt(records.getObject(2).toString());
      int i = 0;
      for (; i < this.attributes.length; i++) {
        start = System.currentTimeMillis();
        if (attributes[i].isNominal()) d.setValue(i, records.getObject(i + 3).toString());
        else d.setValue(i, Utils.objectToDouble(records.getObject(i + 3)));
        Oracle += System.currentTimeMillis() - start;
      }
      SparseInstance movie = imdb.getMovie(flixId);
      d = (SparseInstance) d.mergeInstance(movie);
      d.setDataset(instances);

      start = System.currentTimeMillis();
      records.next();
      Oracle += System.currentTimeMillis() - start;
    } catch (SQLException e) {
      e.printStackTrace();
      return null;
    }
    l.setRecord(d);
    return l;
  }