Package net.myrrix.common.collection

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


  private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    try {
      FastByIDMap<FastIDSet> newKnownItemIDs = readKnownIDs(in);
      FastByIDMap<float[]> newX = readMatrix(in);
      FastByIDMap<float[]> newY = readMatrix(in);
      FastIDSet itemTagIDs = readIDSet(in);
      FastIDSet userTagIDs = readIDSet(in);
      List<IDCluster> userClusters = readClusters(in);
      List<IDCluster> itemClusters = readClusters(in);
      generation = new Generation(newKnownItemIDs,
                                  newX,
                                  newY,
View Full Code Here


    }
    FastByIDMap<FastIDSet> newKnownItemIDs = new FastByIDMap<FastIDSet>(knownItemIDsCount);
    for (int i = 0; i < knownItemIDsCount; i++) {
      long id = in.readLong();
      int setCount = in.readInt();
      FastIDSet set = new FastIDSet(setCount);
      for (int j = 0; j < setCount; j++) {
        set.add(in.readLong());
      }
      newKnownItemIDs.put(id, set);
    }
    return newKnownItemIDs;
  }
View Full Code Here

      out.writeInt(NULL_COUNT);
    } else {
      out.writeInt(knownItemIDs.size());
      for (FastByIDMap.MapEntry<FastIDSet> entry : knownItemIDs.entrySet()) {
        out.writeLong(entry.getKey());
        FastIDSet itemIDs = entry.getValue();
        out.writeInt(itemIDs.size());
        LongPrimitiveIterator it = itemIDs.iterator();
        while (it.hasNext()) {
          out.writeLong(it.nextLong());
        }
      }
    }
View Full Code Here

    }
  }
 
  private static FastIDSet readIDSet(ObjectInputStream in) throws IOException {
    int count = in.readInt();
    FastIDSet ids = new FastIDSet(count);
    for (int i = 0; i < count; i++) {
      ids.add(in.readLong());
    }
    return ids;
  }
View Full Code Here

  private static List<IDCluster> readClusters(ObjectInputStream in) throws IOException {
    int count = in.readInt();
    List<IDCluster> clusters = Lists.newArrayListWithCapacity(count);
    for (int i = 0; i < count; i++) {
      int membersSize = in.readInt();
      FastIDSet members = new FastIDSet(membersSize);
      for (int j = 0; j < membersSize; j++) {
        members.add(in.readLong());
      }
      int centroidSize = in.readInt();
      float[] centroid = new float[centroidSize];
      for (int j = 0; j < centroidSize; j++) {
        centroid[j] = in.readFloat();
View Full Code Here

    if (clusters == null) {
      out.writeInt(0);
    } else {
      out.writeInt(clusters.size());
      for (IDCluster cluster : clusters) {
        FastIDSet members = cluster.getMembers();
        out.writeInt(members.size());
        LongPrimitiveIterator it = members.iterator();
        while (it.hasNext()) {
          out.writeLong(it.nextLong());
        }
        float[] centroid = cluster.getCentroid();
        out.writeInt(centroid.length);
View Full Code Here

    RealMatrix translation = multiply(y1, x2);

    FastByIDMap<float[]> xMerged = MatrixUtils.multiply(translation.transpose(), x1);

    FastIDSet emptySet = new FastIDSet();
    FastByIDMap<FastIDSet> knownItems = new FastByIDMap<FastIDSet>();
    LongPrimitiveIterator it = xMerged.keySetIterator();
    while (it.hasNext()) {
      knownItems.put(it.nextLong(), emptySet);
    }

    FastIDSet x1ItemTagIDs = model1.getItemTagIDs();
    FastIDSet y2UserTagIDs = model2.getUserTagIDs();

    Generation merged = new Generation(knownItems, xMerged, y2, x1ItemTagIDs, y2UserTagIDs);
    GenerationSerializer.writeGeneration(merged, mergedModelFile);
  }
View Full Code Here

  }

  @Test
  public void testAllIDs() throws Exception {
    ClientRecommender client = getClient();
    FastIDSet allUserIDs = client.getAllUserIDs();
    FastIDSet allItemIDs = client.getAllItemIDs();
    assertEquals(943, allUserIDs.size());
    assertTrue(allUserIDs.contains(1L));
    assertEquals(1682, allItemIDs.size());
    assertTrue(allItemIDs.contains(421L));
  }
View Full Code Here

    if (n < streamSize) {
      it = new SamplingLongPrimitiveIterator(random, stream, (double) n / streamSize);     
    } else {
      it = stream;
    }
    FastIDSet chosen = new FastIDSet(n);   
    while (it.hasNext()) {
      chosen.add(it.nextLong());
    }
    return chosen.toArray();
  }
View Full Code Here

   
    if (userTagIDs.contains(itemID)) {
      return null;
    }
   
    FastIDSet theKnownItemIDs = knownItemIDs;
    if (theKnownItemIDs != null) {
      synchronized (theKnownItemIDs) {
        if (theKnownItemIDs.contains(itemID)) {
          return null;
        }
      }
    }
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.