Tokenizer defines what a tokenizer must provide.
| 56 | |
| 57 | // Tokenizer defines what a tokenizer must provide. |
| 58 | type Tokenizer interface { |
| 59 | |
| 60 | // Name is name of tokenizer. This should be unique. |
| 61 | Name() string |
| 62 | |
| 63 | // Type returns the string representation of the typeID that we care about. |
| 64 | Type() string |
| 65 | |
| 66 | // Tokens return tokens for a given value. The tokens shouldn't be encoded |
| 67 | // with the byte identifier. |
| 68 | Tokens(interface{}) ([]string, error) |
| 69 | |
| 70 | // Identifier returns the prefix byte for this token type. This should be |
| 71 | // unique. The range 0x80 to 0xff (inclusive) is reserved for user-provided |
| 72 | // custom tokenizers. |
| 73 | Identifier() byte |
| 74 | |
| 75 | // IsSortable returns true if the tokenizer can be used for sorting/ordering. |
| 76 | IsSortable() bool |
| 77 | |
| 78 | // IsLossy returns true if we don't store the values directly as index keys |
| 79 | // during tokenization. If a predicate is tokenized using an IsLossy() tokenizer, |
| 80 | // then we need to fetch the actual value and compare. |
| 81 | IsLossy() bool |
| 82 | } |
| 83 | |
| 84 | var tokenizers = make(map[string]Tokenizer) |
| 85 | var indexFactories = make(map[string]IndexFactory) |
no outgoing calls
no test coverage detected