VertexPropertyStore.java 文件源码

java
阅读 18 收藏 0 点赞 0 评论 0

项目:graphflow 作者:
/**
 * Returns the {@code Short} key, and {@code Object} value pair properties of the vertex with
 * the given ID.
 * Warning: If a vertex's properties are empty, it can be because of two things: (1) the
 * vertex was never created; or (2) the vertex has indeed no properties.
 *
 * @param vertexId The ID of the vertex.
 *
 * @return The possibly empty properties of the vertex as a Map<Short, Object>.
 *
 * @throws NoSuchElementException if the vertex with ID {@code vertexId} is larger than the
 * highest vertex ID previously created.
 */
public Map<Short, Object> getProperties(int vertexId) {
    if (vertexId > Graph.getInstance().getHighestVertexId()) {
        throw new NoSuchElementException("Vertex with ID " + vertexId + " does not exist.");
    }
    Map<Short, Object> properties = new HashMap<>();
    byte[] data = vertexProperties[vertexId];
    if (null == data) {
        return properties;
    }
    propertyIterator.reset(data, 0, data.length);
    Pair<Short, Object> keyValue;
    while (propertyIterator.hasNext()) {
        keyValue = propertyIterator.next();
        properties.put(keyValue.a, keyValue.b);
    }
    return properties;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号