diff options
| author | JP Appel <jeanpierre.appel01@gmail.com> | 2025-06-19 01:22:19 -0400 |
|---|---|---|
| committer | JP Appel <jeanpierre.appel01@gmail.com> | 2025-06-19 01:22:19 -0400 |
| commit | 21d72b2f67fb065d9071907c5c3307434aad3795 (patch) | |
| tree | 9313ca1091d0f4c9b3252639d33b582c58f72d87 /pkg/query/parser.go | |
| parent | 649bbdf8d3fdda4423f2f30bbf98698e8f2faa07 (diff) | |
Add multiple clause and tree level optimizations
Implement optimizations that can be called in parallel or serial.
Optimizations occur mostly in place and result in a logically equivalent
tree when used correctly.
Optimizations
=============
* Sort - sort all statements within a clause tree
* Simplify - apply negation rules to all statements
* Flatten - merge child clauses with parents
* Compact - merge equivalent statements
* Tidy^ - remove zero statements
* Contradictions - zero contradicting statements and clauses
* StrictEquality - zero fuzzy statements when exact statements are within
clause
* Tighten - combine multiple fuzzy statements to the least (AND) or
most (OR) restrictive bounds
^: when used incorrectly can turn an invalid clause tree into a valid
one
Diffstat (limited to 'pkg/query/parser.go')
| -rw-r--r-- | pkg/query/parser.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/pkg/query/parser.go b/pkg/query/parser.go index 14cc227..2bfc014 100644 --- a/pkg/query/parser.go +++ b/pkg/query/parser.go @@ -28,8 +28,8 @@ type opType int const ( OP_UNKNOWN opType = iota OP_EQ // equal - OP_AP // approximate/fuzzy OP_NE // not equal + OP_AP // approximate/fuzzy OP_LT // less than OP_LE // less than or equal OP_GE // greater than or equal @@ -122,6 +122,15 @@ func (v DatetimeValue) Compare(other Valuer) int { var _ Valuer = StringValue{} var _ Valuer = DatetimeValue{} +// Return if OP_EQ behaves like set membership +func (t catType) IsSet() bool { + return t == CAT_TAGS || t == CAT_AUTHOR || t == CAT_LINKS +} + +func (t catType) IsOrdered() bool { + return t == CAT_DATE || t == CAT_FILETIME +} + func (t catType) String() string { switch t { case CAT_TITLE: @@ -143,6 +152,14 @@ func (t catType) String() string { } } +func (t opType) IsFuzzy() bool { + return t == OP_AP || t.IsOrder() +} + +func (t opType) IsOrder() bool { + return t == OP_LT || t == OP_LE || t == OP_GT || t == OP_GE +} + func (t opType) String() string { switch t { case OP_EQ: |
