KmpSearchProcessorFactory Class — netty Architecture
Architecture documentation for the KmpSearchProcessorFactory class in KmpSearchProcessorFactory.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 07025c3a_cfab_445f_92eb_672016d3f28f["KmpSearchProcessorFactory"] 1a745834_0c75_ddd1_812e_784026a3e4b0["KmpSearchProcessorFactory.java"] 07025c3a_cfab_445f_92eb_672016d3f28f -->|defined in| 1a745834_0c75_ddd1_812e_784026a3e4b0 4e92fc4c_1585_228d_a4c9_d39345c0ef94["KmpSearchProcessorFactory()"] 07025c3a_cfab_445f_92eb_672016d3f28f -->|method| 4e92fc4c_1585_228d_a4c9_d39345c0ef94 68ceb62b_73f5_5a0e_9979_d57a78555094["Processor()"] 07025c3a_cfab_445f_92eb_672016d3f28f -->|method| 68ceb62b_73f5_5a0e_9979_d57a78555094
Relationship Graph
Source Code
buffer/src/main/java/io/netty/buffer/search/KmpSearchProcessorFactory.java lines 29–91
public class KmpSearchProcessorFactory extends AbstractSearchProcessorFactory {
private final int[] jumpTable;
private final byte[] needle;
public static class Processor implements SearchProcessor {
private final byte[] needle;
private final int[] jumpTable;
private long currentPosition;
Processor(byte[] needle, int[] jumpTable) {
this.needle = needle;
this.jumpTable = jumpTable;
}
@Override
public boolean process(byte value) {
while (currentPosition > 0 && PlatformDependent.getByte(needle, currentPosition) != value) {
currentPosition = PlatformDependent.getInt(jumpTable, currentPosition);
}
if (PlatformDependent.getByte(needle, currentPosition) == value) {
currentPosition++;
}
if (currentPosition == needle.length) {
currentPosition = PlatformDependent.getInt(jumpTable, currentPosition);
return false;
}
return true;
}
@Override
public void reset() {
currentPosition = 0;
}
}
KmpSearchProcessorFactory(byte[] needle) {
this.needle = needle.clone();
this.jumpTable = new int[needle.length + 1];
int j = 0;
for (int i = 1; i < needle.length; i++) {
while (j > 0 && needle[j] != needle[i]) {
j = jumpTable[j];
}
if (needle[j] == needle[i]) {
j++;
}
jumpTable[i + 1] = j;
}
}
/**
* Returns a new {@link Processor}.
*/
@Override
public Processor newSearchProcessor() {
return new Processor(needle, jumpTable);
}
}
Source
Frequently Asked Questions
What is the KmpSearchProcessorFactory class?
KmpSearchProcessorFactory is a class in the netty codebase, defined in buffer/src/main/java/io/netty/buffer/search/KmpSearchProcessorFactory.java.
Where is KmpSearchProcessorFactory defined?
KmpSearchProcessorFactory is defined in buffer/src/main/java/io/netty/buffer/search/KmpSearchProcessorFactory.java at line 29.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free