VertexPropertyStore.java 文件源码

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

项目:graphflow 作者:
/**
 * Returns the {@code String} key, and {@code String} 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<String, String>.
 *
 * @throws NoSuchElementException if the vertex with ID {@code vertexId} is larger than the
 * highest vertex ID previously created.
 */
public Map<String, String> getPropertiesAsStrings(int vertexId) {
    if (vertexId > Graph.getInstance().getHighestVertexId()) {
        throw new NoSuchElementException("Vertex with ID " + vertexId + " does not exist.");
    }
    Map<String, String> 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(TypeAndPropertyKeyStore.getInstance().mapShortPropertyKeyToString(
            keyValue.a), keyValue.b.toString());
    }
    return properties;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号