コード例 #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;
  }
コード例 #2
0
 @SuppressWarnings("unchecked")
 public void configDataSource(XMLConfiguration config, String section, String dataSourceName) {
   super.configDataSource(config, section, dataSourceName);
   Configuration dsConf = config.configurationAt(section);
   imdb.configDataSource(config, section + ".IMDb");
   if (dsConf.containsKey("users")) {
     usersList = dsConf.getList("users");
   }
   usersToLoad = Utils.getIntFromConfIfNotNull(dsConf, "usersToLoad", usersToLoad);
 }
コード例 #3
0
  public Attribute[] getAttributes() {

    if (allAttributes != null) return allAttributes;
    Attribute[] IMDbAttributes = imdb.getAttributes();
    int size = attributes.length + IMDbAttributes.length;
    Attribute[] attrs = new Attribute[size];
    for (int i = 0; i < attributes.length; i++) {
      attrs[i] = attributes[i];
    }
    // IMDB
    for (int i = 0; i < IMDbAttributes.length; i++) {
      attrs[attributes.length + i] = IMDbAttributes[i];
    }
    allAttributes = attrs;
    FastVector list = new FastVector();
    for (int i = 0; i < attrs.length; i++) {
      list.addElement(attrs[i]);
    }
    instances = new Instances("name", list, 10);
    instances.setClassIndex(0);
    return attrs;
  }
コード例 #4
0
 public String getName() {
   return name + imdb.getName();
 }