Mangler pattern
This article has multiple issues. Please help or discuss these issues on the talk page. (Learn how and when to remove these template messages)
|
Mangler is a software design pattern. A Mangler is a pattern that performs multiple operations over a series of data, similar to the MapReduce function inside of Bigtable and . Typically, a mangler is fed a series of Maps from which it performs its internal operations and passes its internal state/data to an external Filter.
A typical usage of the Mangler Pattern is during internal search operations. When parsing a query from an end-user, the system will try to strip out a series of un-needed tokens, reassembling the original query into a more usable, functional query.
An important distinction between the Mangler and other patterns is the "Modify in place" optimization, pioneered by the pattern's creator.
This pattern was created by , during his tenure at TransUnion's Research and Development Lab.
Java[]
// This is a trivial implementation of Mangler in Java.
public interface TokenMangler {
List<String> mangleTokens (List<String> tokens);
}
public class LowerCasingTokenMangler implements TokenMangler {
List<String> mangleTokens (List<String> tokens) {
List<String> results = new ArrayList<String>();
for (String token : tokens) {
results.add(token.toLowerCase());
}
return results;
}
}
- Software design patterns