@Override public boolean contains(long k) { return containsKey(k); } @Override
@Override public LongArrayList recommendInternal(ClickData clickData) { //filter out items that have not received at last one click in the last time frame //first, retrieve the recommendation results of the underlying algorithm LongArrayList rec = mainStrategy.recommendInternal(clickData); //create lists of filtered items and retained items LongArrayList filteredRec = new LongArrayList(); LongArrayList filteredRecNotMatch = new LongArrayList(); //iterate over the recommendation list of the underlying strategy for (int j = 0; j < rec.size(); j++) { long i = rec.getLong(j); //filter items whose last-clicked timestamp is too old if ((itemClickTime.containsKey(i)) && ((clickData.click.timestamp.getTime()-itemClickTime.get(i))<filterTime)) { filteredRec.add(i); } else if (fallback) { //if we have a fallback, add the filtered item to the fallback list filteredRecNotMatch.add(i); } } //merge the filtered list with the fallback list (empty in case fallback==false) filteredRec.addAll(filteredRecNotMatch); //return the filtered list return filteredRec; }
private static Long2LongOpenHashMap mapRemoteVertices( IPartitionBuilder partitionBuilder, LongArrayList remoteVertices) throws IOException { // map remote vertices Long2LongOpenHashMap remoteVerticesMappings = new Long2LongOpenHashMap(remoteVertices.size(), 1f); for (ISerializablePartition partition : partitionBuilder.getPartitions()) { for (long remoteVertexId : remoteVertices) { ISubgraph subgraph = partition.getSubgraphForVertex(remoteVertexId); if (subgraph != null && !subgraph.getVertex(remoteVertexId).isRemote()) { assert (!remoteVerticesMappings.containsKey(remoteVertexId)); remoteVerticesMappings.put(remoteVertexId, subgraph.getId()); } } } return remoteVerticesMappings; }