SimpleStringMap Class — netty Architecture
Architecture documentation for the SimpleStringMap class in HttpMethodMapBenchmark.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD da154cc5_5577_6968_9d78_8166b1bd42c6["SimpleStringMap"] fb58d464_e70b_796d_4f8b_0f59cab8b4e1["HttpMethodMapBenchmark.java"] da154cc5_5577_6968_9d78_8166b1bd42c6 -->|defined in| fb58d464_e70b_796d_4f8b_0f59cab8b4e1 814cb0b8_41b4_a048_5b16_5206cd37a817["SimpleStringMap()"] da154cc5_5577_6968_9d78_8166b1bd42c6 -->|method| 814cb0b8_41b4_a048_5b16_5206cd37a817 d56e41d6_4eb6_38f9_030a_2ff43bb3a2cf["T()"] da154cc5_5577_6968_9d78_8166b1bd42c6 -->|method| d56e41d6_4eb6_38f9_030a_2ff43bb3a2cf 6db5619e_7bb0_c119_97f8_51f6a5c45bc1["hashCode()"] da154cc5_5577_6968_9d78_8166b1bd42c6 -->|method| 6db5619e_7bb0_c119_97f8_51f6a5c45bc1
Relationship Graph
Source Code
microbench/src/main/java/io/netty/handler/codec/http/HttpMethodMapBenchmark.java lines 114–152
private static final class SimpleStringMap<T> {
private final SimpleStringMap.Node<T>[] values;
private final int valuesMask;
SimpleStringMap(SimpleStringMap.Node<T>... nodes) {
values = (SimpleStringMap.Node<T>[]) new SimpleStringMap.Node[findNextPositivePowerOfTwo(nodes.length)];
valuesMask = values.length - 1;
for (SimpleStringMap.Node<T> node : nodes) {
int i = hashCode(node.key) & valuesMask;
if (values[i] != null) {
throw new IllegalArgumentException("index " + i + " collision between values: [" +
values[i].key + ", " + node.key + "]");
}
values[i] = node;
}
}
T get(String name) {
SimpleStringMap.Node<T> node = values[hashCode(name) & valuesMask];
return node == null || !node.key.equals(name) ? null : node.value;
}
private static int hashCode(String name) {
// This hash code needs to produce a unique index for each HttpMethod. If new methods are added this
// algorithm will need to be adjusted. The goal is to have each enum name's hash value correlate to a unique
// index in the values array.
return name.hashCode() >>> 6;
}
private static final class Node<T> {
final String key;
final T value;
Node(String key, T value) {
this.key = key;
this.value = value;
}
}
}
Source
Frequently Asked Questions
What is the SimpleStringMap class?
SimpleStringMap is a class in the netty codebase, defined in microbench/src/main/java/io/netty/handler/codec/http/HttpMethodMapBenchmark.java.
Where is SimpleStringMap defined?
SimpleStringMap is defined in microbench/src/main/java/io/netty/handler/codec/http/HttpMethodMapBenchmark.java at line 114.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free