Package net.myrrix.common.collection

Examples of net.myrrix.common.collection.FastIDSet$KeyIterator


    if (knownItemIDs == null) {
      throw new UnsupportedOperationException("No known item IDs available");
    }

    Lock knownItemLock = generation.getKnownItemLock().readLock();
    FastIDSet userKnownItemIDs;
    knownItemLock.lock();
    try {
      userKnownItemIDs = knownItemIDs.get(userID);
    } finally {
      knownItemLock.unlock();
    }
    if (userKnownItemIDs == null) {
      throw new NoSuchUserException(userID);
    }

    FastByIDMap<float[]> Y = generation.getY();

    Lock yLock = generation.getYLock().readLock();
    yLock.lock();
    try {

      float[] features = Y.get(itemID);
      if (features == null) {
        throw new NoSuchItemException(itemID);
      }
      FastByIDMap<float[]> toFeatures;
      synchronized (userKnownItemIDs) {
        toFeatures = new FastByIDMap<float[]>(userKnownItemIDs.size());
        LongPrimitiveIterator it = userKnownItemIDs.iterator();
        while (it.hasNext()) {
          long fromItemID = it.nextLong();
          float[] fromFeatures = Y.get(fromItemID);
          toFeatures.put(fromItemID, fromFeatures);
        }
View Full Code Here


  }

  private static FastIDSet getIDsFromKeys(FastByIDMap<float[]> map, Lock readLock, FastIDSet tagIDs) {
    readLock.lock();
    try {
      FastIDSet ids = new FastIDSet(map.size());
      LongPrimitiveIterator it = map.keySetIterator();
      while (it.hasNext()) {
        long id = it.nextLong();
        if (!tagIDs.contains(id)) {
          ids.add(id);
        }
      }
      return ids;
    } finally {
      readLock.unlock();
View Full Code Here

    List<IDCluster> clusters = generation.getUserClusters();
    if (clusters == null || clusters.isEmpty()) {
      throw new UnsupportedOperationException();
    }
    Lock lock = generation.getUserClustersLock().readLock();
    FastIDSet members;
    lock.lock();
    try {
      members = clusters.get(n).getMembers();
    } finally {
      lock.unlock();
    }
    synchronized (members) {
      return members.clone();
    }
  }
View Full Code Here

    List<IDCluster> clusters = generation.getItemClusters();
    if (clusters == null || clusters.isEmpty()) {
      throw new UnsupportedOperationException();
    }
    Lock lock = generation.getItemClustersLock().readLock();
    FastIDSet members;
    lock.lock();
    try {
      members = clusters.get(n).getMembers();
    } finally {
      lock.unlock();
    }
    synchronized (members) {
      return members.clone();
    }
  }
View Full Code Here

    return delegate.getNumItemClusters();
  }

  @Override
  public Collection<String> getUserCluster(int n) throws TasteException {
    FastIDSet userIDs = delegate.getUserCluster(n);
    Collection<String> translated = Lists.newArrayListWithCapacity(userIDs.size());
    LongPrimitiveIterator it = userIDs.iterator();
    while (it.hasNext()) {
      translated.add(Long.toString(it.nextLong()));
    }
    return translated;
  }
View Full Code Here

                                  boolean isUser) throws TasteException {
    if (programArgs.length != 1) {
      throw new ArgumentValidationException("no arguments");
    }
    if (translatingRecommender == null) {
      FastIDSet ids = isUser ? recommender.getAllUserIDs() : recommender.getAllItemIDs();
      LongPrimitiveIterator it = ids.iterator();
      while (it.hasNext()) {
        System.out.println(Long.toString(it.nextLong()));
      }
    } else {
      if (isUser) {
View Full Code Here

    if (programArgs.length != 2) {
      throw new ArgumentValidationException("args are n");
    }
    int n = Integer.parseInt(programArgs[1]);
    if (translatingRecommender == null) {
      FastIDSet ids = isUser ? recommender.getUserCluster(n) : recommender.getItemCluster(n);
      LongPrimitiveIterator it = ids.iterator();
      while (it.hasNext()) {
        System.out.println(Long.toString(it.nextLong()));
      }
    } else {
      Iterable<String> ids =
View Full Code Here

    }, reloadMinutes, reloadMinutes, TimeUnit.MINUTES);
    doLoad();
  }
 
  private void doLoad() {
    FastIDSet newIDs = new FastIDSet();
    // Load something into it
    newIDs.add(1L);
    // ...
    someCurrentIDs = newIDs;
  }
View Full Code Here

    }

    log.info("Max bucket size {}", maxBucketSize);
    log.info("Put {} items into {} buckets", Y.size(), buckets.size());
    // A separate bucket for new items, which will always be considered
    newItems = new FastIDSet();
  }
View Full Code Here

    result.append('\n');
    return result.toString();
  }

  private static long[] keysInOrder(FastByIDMap<?> map) {
    FastIDSet keys = new FastIDSet(map.size());
    LongPrimitiveIterator it = map.keySetIterator();
    while (it.hasNext()) {
      keys.add(it.nextLong());
    }
    long[] keysArray = keys.toArray();
    Arrays.sort(keysArray);
    return keysArray;
  }
View Full Code Here

TOP

Related Classes of net.myrrix.common.collection.FastIDSet$KeyIterator

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.