private LongSet getEffectiveCandidates(long user, LongSet candidates, LongSet exclude) { if (candidates == null) { candidates = getPredictableItems(user); } if (exclude == null) { exclude = getDefaultExcludes(user); } logger.debug("computing effective candidates for user {} from {} candidates and {} excluded items", user, candidates.size(), exclude.size()); if (!exclude.isEmpty()) { candidates = LongUtils.setDifference(candidates, exclude); } return candidates; }
@Nonnull @Override public MetricResult measureUserRecList(Recommender rec, TestUser user, int targetLength, List<Long> recommendations, Context context) { LongSet good = goodItems.selectItems(context.universe, rec, user); if (good.isEmpty()) { logger.warn("no good items for user {}", user.getUserId()); } Integer rank = null; int i = 0; for (long item: recommendations) { i++; if (good.contains(item)) { rank = i; break; } } UserResult result = new UserResult(rank); context.addUser(result); return result.withSuffix(suffix); }
@Nonnull @Override public MetricResult measureUserRecList(Recommender rec, TestUser user, int targetLength, List<Long> recs, Context context) { LongSet good = goodItems.selectItems(context.universe, rec, user); if (good.isEmpty()) { logger.warn("no good items for user {}", user.getUserId()); return new UserResult(0); } if (recs == null || recs.isEmpty()) { return MetricResult.empty(); } int n = 0; double ngood = 0; double sum = 0; for (long id: recs) { n += 1; if (good.contains(id)) { // it is good ngood += 1; // add to MAP sum sum += ngood / n; } } double aveP = ngood > 0 ? sum / ngood : 0; UserResult result = new UserResult(aveP); context.addUser(result); return result.withSuffix(suffix); }
public boolean isEmpty() { return _set.isEmpty(); }
public boolean isEmpty() { return _set.isEmpty(); }
public boolean isEmpty() { return _set.isEmpty(); }
/** * filter magic * * @param resultNode is the result node to be checked * @return true if the node should be filtered out, and false if it should not be */ public boolean isDirectInteraction(long resultNode) { return !leftNodeEdgeSet.isEmpty() && leftNodeEdgeSet.contains(resultNode); } }
private void lightsExecuteGroups( final R2SceneLightsConsumerType c) { /* * For each non-empty group... */ for (int index = 1; index < this.group_max; ++index) { final Group g = this.groups[index]; if (g.lights_unclipped.isEmpty()) { continue; } this.lightsExecuteGroup(c, g); } }
private LongSet getEffectiveCandidates(long user, LongSet candidates, LongSet exclude) { if (candidates == null) { candidates = getPredictableItems(user); } if (exclude == null) { exclude = getDefaultExcludes(user); } logger.debug("computing effective candidates for user {} from {} candidates and {} excluded items", user, candidates.size(), exclude.size()); if (!exclude.isEmpty()) { candidates = LongUtils.setDifference(candidates, exclude); } return candidates; }
@Nonnull @Override public MetricResult measureUser(TestUser user, ResultList recommendations, Context context) { LongSet good = goodItems.selectItems(context.universe, context.recommender, user); if (good.isEmpty()) { logger.warn("no good items for user {}", user.getUserId()); } Integer rank = null; int i = 0; for(Result res: recommendations) { i++; if(good.contains(res.getId())) { rank = i; break; } } UserResult result = new UserResult(rank); context.addUser(result); return result.withSuffix(suffix); }
public TweetAuthorFilter( LeftIndexedMultiSegmentBipartiteGraph leftIndexedBipartiteGraph, LongSet whitelistTweetAuthors, LongSet blacklistTweetAuthors, StatsReceiver statsReceiver) { super(statsReceiver); this.isIgnoreWhitelist = whitelistTweetAuthors.isEmpty(); if (this.isIgnoreWhitelist) { this.whitelistedTweets = new LongOpenHashSet(); this.blacklistedTweets = getTweetsByAuthors(leftIndexedBipartiteGraph, blacklistTweetAuthors); } else { // Performance hack. Remove blacklisted authors from the whitelist, and only check whitelist LongSet dedupedWhitelistAuthors = dedupWhitelistAuthors(whitelistTweetAuthors, blacklistTweetAuthors); this.whitelistedTweets = getTweetsByAuthors(leftIndexedBipartiteGraph, dedupedWhitelistAuthors); this.blacklistedTweets = new LongOpenHashSet(); } }
if (!this.closedConnections.isEmpty()) { for (long guid : this.closedConnections) { PlayerConnection connection = this.playersByGuid.remove(guid);
@Nonnull @Override public MetricResult measureUser(TestUser user, ResultList recs, Context context) { LongSet good = goodItems.selectItems(context.universe, context.recommender, user); if (good.isEmpty()) { logger.warn("no good items for user {}", user.getUserId()); return new UserResult(0, false); } if (recs == null || recs.isEmpty()) { return MetricResult.empty(); } int n = 0; double ngood = 0; double sum = 0; for(Result res : recs) { n += 1; if(good.contains(res.getId())) { // it is good ngood += 1; // add to MAP sum sum += ngood / n; } } UserResult result = new UserResult(sum / good.size(), ngood > 0); context.addUser(result); return result.withSuffix(suffix); }
if ( removeEntities != null && !removeEntities.isEmpty() ) { LongIterator removeIterator = removeEntities.iterator(); while ( removeIterator.hasNext() ) {
private boolean canBeViewedByClient(ChunkAdapter chunk) { // A player can always view when having 0 chunks if (this.playerChunks.isEmpty()) { return true; } // Check if there is at least one chunk around long key = CoordinateUtils.toLong(chunk.getX() + 1, chunk.getZ()); if (this.playerChunks.contains(key)) { return true; } key = CoordinateUtils.toLong(chunk.getX() - 1, chunk.getZ()); if (this.playerChunks.contains(key)) { return true; } key = CoordinateUtils.toLong(chunk.getX(), chunk.getZ() + 1); if (this.playerChunks.contains(key)) { return true; } key = CoordinateUtils.toLong(chunk.getX(), chunk.getZ() - 1); return this.playerChunks.contains(key); }
/** * Sends a world chunk to the player. This is used by world adapters in order to give the player connection * a chance to know once it is ready for spawning. * * @param chunkAdapter which should be sent to the client * @return true when the chunk has been sent, false when not */ private boolean sendWorldChunk(ChunkAdapter chunkAdapter) { this.playerChunks.add(chunkAdapter.longHashCode()); this.loadingChunks.remove(chunkAdapter.longHashCode()); this.addToSendQueue(chunkAdapter.getCachedPacket()); this.entity.getEntityVisibilityManager().updateAddedChunk(chunkAdapter); if (this.state == PlayerConnectionState.LOGIN && this.loadingChunks.isEmpty()) { int spawnXChunk = CoordinateUtils.fromBlockToChunk((int) this.entity.getLocation().getX()); int spawnZChunk = CoordinateUtils.fromBlockToChunk((int) this.entity.getLocation().getZ()); WorldAdapter worldAdapter = this.entity.getWorld(); worldAdapter.movePlayerToChunk(spawnXChunk, spawnZChunk, this.entity); this.getEntity().firstSpawn(); this.state = PlayerConnectionState.PLAYING; this.entity.getLoginPerformance().setChunkEnd(this.entity.getWorld().getServer().getCurrentTickTime()); this.entity.getLoginPerformance().print(); } return true; }
if ( !this.tempHashes[1].isEmpty() ) { LongIterator toRemoveCursor = this.tempHashes[1].iterator(); while ( toRemoveCursor.hasNext() ) {