- java.lang.Object
- 
- com.pervasive.datarush.schema.PatternBasedDiscovery
 
- 
- All Implemented Interfaces:
- TextRecordDiscoverer
 - Direct Known Subclasses:
- JsonPatternBasedDiscovery
 
 public class PatternBasedDiscovery extends Object implements TextRecordDiscoverer Discovers a schema for delimited text by checking values against a mapping of regular expressions to data types.
- 
- 
Field SummaryFields Modifier and Type Field Description static List<TypePattern>DEFAULT_PATTERNSThe default patterns used in discovery when none are specified, in order:TypePattern.INT_PATTERNTypePattern.LONG_PATTERNTypePattern.DOUBLE_PATTERNTypePattern.MONEY_PATTERNTypePattern.DATE_PATTERNTypePattern.TIME_PATTERNTypePattern.TIMESTAMP_PATTERNTypePattern.BOOLEAN_PATTERNTypePattern.IP4ADDRESS_PATTERNTypePattern.IP6ADDRESS_PATTERNTypePattern.DURATION_PATTERNTypePattern.PERIOD_PATTERN
 - 
Constructor SummaryConstructors Constructor Description PatternBasedDiscovery()Creates a default mapping.PatternBasedDiscovery(List<TypePattern> patterns)Creates a mapping using the specified patterns.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description TextRecorddiscoverForRead(List<List<String>> rows, boolean containsHeader, TextConversionDefaults defaults)Constructs a schema for reading based on the given file analysis.TextRecordgenerateForWrite(RecordTokenType type, TextConversionDefaults defaults)Constructs a schema for writing based on the given record type.protected TextDataTypemergeTypes(TextDataType l, TextDataType r)protected TextDataTypepredictType(String value)
 
- 
- 
- 
Field Detail- 
DEFAULT_PATTERNSpublic static List<TypePattern> DEFAULT_PATTERNS The default patterns used in discovery when none are specified, in order:- TypePattern.INT_PATTERN
- TypePattern.LONG_PATTERN
- TypePattern.DOUBLE_PATTERN
- TypePattern.MONEY_PATTERN
- TypePattern.DATE_PATTERN
- TypePattern.TIME_PATTERN
- TypePattern.TIMESTAMP_PATTERN
- TypePattern.BOOLEAN_PATTERN
- TypePattern.IP4ADDRESS_PATTERN
- TypePattern.IP6ADDRESS_PATTERN
- TypePattern.DURATION_PATTERN
- TypePattern.PERIOD_PATTERN
 
 
- 
 - 
Constructor Detail- 
PatternBasedDiscoverypublic PatternBasedDiscovery() Creates a default mapping. The default mapping detects:- See Also:
- DEFAULT_PATTERNS
 
 - 
PatternBasedDiscoverypublic PatternBasedDiscovery(List<TypePattern> patterns) Creates a mapping using the specified patterns. Patterns are tested in the order listed with the first matching pattern used to determine type. Conflicts between records on a field's type are resolved toTextTypes.STRINGin most cases. If a field value matches the default null indicator, it is ignored for typing purposes.- Parameters:
- patterns- the patterns against which to compare values. The list is in precedence order; the first pattern to match determines the type.
 
 
- 
 - 
Method Detail- 
predictTypeprotected TextDataType predictType(String value) 
 - 
mergeTypesprotected TextDataType mergeTypes(TextDataType l, TextDataType r) 
 - 
discoverForReadpublic TextRecord discoverForRead(List<List<String>> rows, boolean containsHeader, TextConversionDefaults defaults) Description copied from interface:TextRecordDiscovererConstructs a schema for reading based on the given file analysis. The analysis may or may not include a header row, as indicated.- Specified by:
- discoverForReadin interface- TextRecordDiscoverer
- Parameters:
- rows- the analyzed rows from a text file
- containsHeader- indicates whether the first row of the analyzed file is a header
- defaults- defaults for the discovered schema
- Returns:
- a schema appropriate for reading the file.
 
 - 
generateForWritepublic TextRecord generateForWrite(RecordTokenType type, TextConversionDefaults defaults) Description copied from interface:TextRecordDiscovererConstructs a schema for writing based on the given record type.- Specified by:
- generateForWritein interface- TextRecordDiscoverer
- Parameters:
- type- the record type of the data
- defaults- defaults for the discovered schema
- Returns:
- a schema appropriate for writing data of the given type
 
 
- 
 
-