-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #767 from owncloud/ocis-697
Support OData for search queries on the Indexer
- Loading branch information
Showing
10 changed files
with
272 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package indexer | ||
|
||
// dedup removes duplicate values in given slice | ||
func dedup(s []string) []string { | ||
for i := 0; i < len(s); i++ { | ||
for i2 := i + 1; i2 < len(s); i2++ { | ||
if s[i] == s[i2] { | ||
// delete | ||
s = append(s[:i2], s[i2+1:]...) | ||
i2-- | ||
} | ||
} | ||
} | ||
return s | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package indexer | ||
|
||
type queryTree struct { | ||
token *token | ||
root bool | ||
left *queryTree | ||
right *queryTree | ||
} | ||
|
||
// token to be resolved by the index | ||
type token struct { | ||
operator string // original OData operator. i.e: 'startswith', `or`, `and`. | ||
filterType string // equivalent operator from OData -> indexer i.e FindByPartial or FindBy. | ||
operands []string | ||
} | ||
|
||
// newQueryTree constructs a new tree with a root node. | ||
func newQueryTree() queryTree { | ||
return queryTree{ | ||
root: true, | ||
} | ||
} | ||
|
||
// insert populates first the LHS of the tree first, if this is not possible it fills the RHS. | ||
func (t *queryTree) insert(tkn *token) { | ||
if t != nil && t.root { | ||
t.left = &queryTree{token: tkn} | ||
return | ||
} | ||
|
||
if t.left == nil { | ||
t.left = &queryTree{token: tkn} | ||
return | ||
} | ||
|
||
if t.left != nil && t.right == nil { | ||
t.right = &queryTree{token: tkn} | ||
return | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.