/** * Given a destination vertex, get all of the vertices which are linked to * that destination. * * @param destination the destination vertex * * @return a {@link Set} of the source vertices */ public Set<Object> getSources(final Object destination) { return Collections.unmodifiableSet(edgeGraph.column(destination).keySet()); }
for (String table : counts.columnKeySet()) { long count = 0; for (Map.Entry<Integer, Long> entry : counts.column(table).entrySet()) { count += entry.getValue(); countsFile.write("Table\tPartition\tRows\tPercent from total rows\n"); for (String table : counts.columnKeySet()) { for (int partition : counts.column(table).keySet()) { long count = counts.get(partition, table); long total = totalsPerTable.get(table); topsFile.write("Table\tPartition\tKey\tRows\tPercent from total rows\n"); for (String table : tops.columnKeySet()) { for (int partition : tops.column(table).keySet()) { long total = totalsPerTable.get(table); LinkedHashMap<String, Long> top = tops.get(partition, table);
@Override public Iterable<GraphEdge<V, E>> incomingEdgesOf(V vertex) { return graphTable.column(vertex).values(); }
/** * Given a destination vertex, get all of the vertices which are linked to * that destination. * * @param destination the destination vertex * * @return a {@link Set} of the source vertices */ public Set<Object> getSources(final Object destination) { return Collections.unmodifiableSet(edgeGraph.column(destination).keySet()); }
@Override public Iterable<GraphEdge<V, E>> edgesOf(V vertex) { return Sets.union(Sets.newHashSet(graphTable.row(vertex).values()), Sets.newHashSet(graphTable.column(vertex).values())); }
/** * Return the {@link User} with the specified {@code username} * * @param username * @return the {@link User} */ @Nullable private User getUser(ByteBuffer username) { lock.readLock().lock(); try { Map<Short, Object> usernames = accounts .column(AccountAttribute.USERNAME.key()); String seeking = ByteBuffers.encodeAsHex(username); for (Entry<Short, Object> profile : usernames.entrySet()) { String stored = (String) profile.getValue(); if(seeking.equals(stored)) { return new User(profile.getKey()); } } return null; } finally { lock.readLock().unlock(); } }
/** * Return the uid of the user identified by {@code username}. * * @param username * @return the uid */ @VisibleForTesting protected short getUserId(ByteBuffer username) { lock.readLock().lock(); try { Preconditions.checkArgument(exists(username), "The specified user does not exist"); Map<Short, Object> credsCol = accounts .column(AccountAttribute.USERNAME.key()); for (Map.Entry<Short, Object> creds : credsCol.entrySet()) { String value = (String) creds.getValue(); if(value.equals(ByteBuffers.encodeAsHex(username))) { return creds.getKey(); } } return -1; // suppress compiler error // but this statement will // never actually execute } finally { lock.readLock().unlock(); } }
public void remove(V v){ // Get vertices connected with this one for(GraphEdge<V,E> edge : edgesOf(v)){ V connectedVertex = edge.getVertex1().equals(v) ? edge.getVertex2() : edge.getVertex1(); // Is this vertex connected with a different vertex? if (!greaterThan(1, edgesOf(connectedVertex))){ disconnected.add(connectedVertex); } } if (graphTable.containsRow(v)){ graphTable.row(v).clear(); } if (graphTable.containsColumn(v)){ graphTable.column(v).clear(); } // Check for disconnected vertices disconnected.remove(v); // v no longer exists }