Package ua_parser
Class CachingParser
- java.lang.Object
-
- ua_parser.Parser
-
- ua_parser.CachingParser
-
public class CachingParser extends Parser
When doing webanalytics (with for example PIG) the main pattern is to process weblogs in clickstreams. A basic fact about common clickstreams is that in general the same browser will do multiple requests in sequence. This has the effect that the same useragent will appear in the logfiles and we will see the need to parse the same useragent over and over again. This class introduces a very simple LRU cache to reduce the number of times the parsing is actually done. The default cache size is 1000 and can be configured as object creation. Note: The object handles one cache per parsing method - be carefull when using big sizes.- Author:
- Niels Basjes
-
-
Constructor Summary
Constructors Constructor Description CachingParser()CachingParser(int cacheSize)CachingParser(InputStream regexYaml)CachingParser(InputStream regexYaml, int cacheSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Clientparse(String agentString)DeviceparseDevice(String agentString)OSparseOS(String agentString)UserAgentparseUserAgent(String agentString)
-
-
-
Constructor Detail
-
CachingParser
public CachingParser()
-
CachingParser
public CachingParser(InputStream regexYaml)
-
CachingParser
public CachingParser(int cacheSize)
-
CachingParser
public CachingParser(InputStream regexYaml, int cacheSize)
-
-
Method Detail
-
parseUserAgent
public UserAgent parseUserAgent(String agentString)
- Overrides:
parseUserAgentin classParser
-
parseDevice
public Device parseDevice(String agentString)
- Overrides:
parseDevicein classParser
-
-