Package org.apache.mahout.cf.taste.common

Examples of org.apache.mahout.cf.taste.common.NoSuchItemException


    if (!add && !isIDInModel(userID)) {
      throw new NoSuchUserException();
    }
    for (List<String> item : items) {
      if (!add && !isIDInModel(item.get(0))) {
        throw new NoSuchItemException();
      }
    }
  }
View Full Code Here


    public PreferenceArray get(Long itemID) throws TasteException {
      SliceQuery<Long,Long,Float> query = buildValueSliceQuery(ITEMS_CF);
      query.setKey(itemID);
      ColumnSlice<Long,Float> result = query.execute().get();
      if (result == null) {
        throw new NoSuchItemException(itemID);
      }
      List<HColumn<Long,Float>> userIDColumns = result.getColumns();
      if (userIDColumns.isEmpty()) {
        throw new NoSuchItemException(itemID);
      }
      int size = userIDColumns.size();
      PreferenceArray prefs = new GenericItemPreferenceArray(size);
      prefs.setItemID(0, itemID);
      for (int i = 0; i < size; i++) {
View Full Code Here

    public FastIDSet get(Long itemID) throws TasteException {
      SliceQuery<Long,Long,byte[]> query = buildNoValueSliceQuery(ITEMS_CF);
      query.setKey(itemID);
      ColumnSlice<Long,byte[]> result = query.execute().get();
      if (result == null) {
        throw new NoSuchItemException(itemID);
      }
      List<HColumn<Long,byte[]>> columns = result.getColumns();
      FastIDSet userIDs = new FastIDSet(columns.size());
      for (HColumn<Long,?> userIDColumn : columns) {
        userIDs.add(userIDColumn.getName());
View Full Code Here

    } catch (IOException e) {
      throw new TasteException("Failed to retrieve item preferences from HBase", e);
    }

    if (result.isEmpty()) {
      throw new NoSuchItemException(itemID);
    }

    SortedMap<byte[], byte[]> families = result.getFamilyMap(USERS_CF);
    PreferenceArray prefs = new GenericItemPreferenceArray(families.size());
    prefs.setItemID(0, itemID);
View Full Code Here

    } catch (IOException e) {
      throw new TasteException("Failed to retrieve item preferences from HBase", e);
    }

    if (results[0].isEmpty()) {
      throw new NoSuchItemException(itemID1);
    }
    if (results[1].isEmpty()) {
      throw new NoSuchItemException(itemID2);
    }

    // First item
    Result result = results[0];
    SortedMap<byte[], byte[]> families = result.getFamilyMap(USERS_CF);
View Full Code Here

    if (useridx == null) {
      throw new NoSuchUserException();
    }
    Integer itemidx = itemMap.get(itemID);
    if (itemidx == null) {
      throw new NoSuchItemException();
    }
    return predictRating(useridx, itemidx);
  }
View Full Code Here

  @Override
  public PreferenceArray getPreferencesForItem(long itemID) throws NoSuchItemException {
    PreferenceArray prefs = preferenceForItems.get(itemID);
    if (prefs == null) {
      throw new NoSuchItemException();
    }
    return prefs;
  }
View Full Code Here

      rs = stmt.executeQuery();

      if (rs.next()) {
        return rs.getDouble(1);
      } else {
        throw new NoSuchItemException();
      }

    } catch (SQLException sqle) {
      log.warn("Exception while retrieving user", sqle);
      throw new TasteException(sqle);
View Full Code Here

  @Override
  public PreferenceArray getPreferencesForItem(long itemID) throws NoSuchItemException {
    FastIDSet userIDs = preferenceForItems.get(itemID);
    if (userIDs == null) {
      throw new NoSuchItemException();
    }
    PreferenceArray prefArray = new BooleanItemPreferenceArray(userIDs.size());
    int i = 0;
    LongPrimitiveIterator it = userIDs.iterator();
    while (it.hasNext()) {
View Full Code Here

    if (itemIDs.length == 0) {
      return 0;
    }
    FastIDSet userIDs = preferenceForItems.get(itemIDs[0]);
    if (userIDs == null) {
      throw new NoSuchItemException();
    }
    FastIDSet intersection = new FastIDSet(userIDs.size());
    intersection.addAll(userIDs);
    int i = 1;
    while (!intersection.isEmpty() && i < itemIDs.length) {
      userIDs = preferenceForItems.get(itemIDs[i]);
      if (userIDs == null) {
        throw new NoSuchItemException();
      }
      intersection.retainAll(userIDs);
      i++;
    }
    return intersection.size();
View Full Code Here

TOP

Related Classes of org.apache.mahout.cf.taste.common.NoSuchItemException

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.