Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions cmd/seq-db/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,4 @@ var (
HintOptions("", storeapi.StoreModeCold, storeapi.StoreModeHot).
Default("").
String()

// Deprecated. Will be removed in the future versions.
// We already use SeqQL by default.
flagUseSeqQLByDefault = kingpin.Flag("use-seq-ql-by-default", "enable seq-ql as default query language").
Default("false").
Bool()
)
1 change: 0 additions & 1 deletion cmd/seq-db/seq-db.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func main() {
config.CaseSensitive = cfg.Indexing.CaseSensitive
config.SkipFsync = cfg.Resources.SkipFsync
config.MaxRequestedDocuments = cfg.Limits.SearchDocs
config.UseSeqQLByDefault = *flagUseSeqQLByDefault

backoff.DefaultConfig.MaxDelay = 10 * time.Second

Expand Down
2 changes: 0 additions & 2 deletions config/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,4 @@ var (
MaxFetchSizeBytes = 4 * units.MiB

MaxRequestedDocuments = 100_000 // maximum number of documents that can be requested in one fetch request

UseSeqQLByDefault = false
)
1 change: 0 additions & 1 deletion docs/en/01-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ Note: make sure `curl` and `jq` are installed to run this example.
curl --request POST \
--url http://localhost:9002/search \
--header 'Content-Type: application/json' \
--header 'Grpc-Metadata-use-seq-ql: true' \
--data-binary '
{
"query":{
Expand Down
1 change: 0 additions & 1 deletion docs/ru/01-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ curl --request POST \
curl --request POST \
--url http://localhost:9002/search \
--header 'Content-Type: application/json' \
--header 'Grpc-Metadata-use-seq-ql: true' \
--data-binary '
{
"query":{
Expand Down
13 changes: 8 additions & 5 deletions frac/processor/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package processor

import (
"fmt"
"strings"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -39,7 +40,9 @@ func (p *staticProvider) provide(token string) ([]uint32, error) {
}

func (p *staticProvider) newStatic(literal *parser.Literal) (node.Node, error) {
data, err := p.provide(literal.String())
builder := &strings.Builder{}
literal.DumpSeqQL(builder)
data, err := p.provide(builder.String())
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -73,19 +76,19 @@ func TestEval(t *testing.T) {
}

t.Run("simple", func(t *testing.T) {
ast, err := parser.ParseQuery(`((NOT m:a AND m:b) AND (m:c OR m:d))`, nil)
query, err := parser.ParseSeqQL(`((NOT m:a AND m:b) AND (m:c OR m:d))`, nil)
require.NoError(t, err)
root, err := buildEvalTree(ast, 1, 12, &searchStats{}, false, newStatic)
root, err := buildEvalTree(query.Root, 1, 12, &searchStats{}, false, newStatic)
require.NoError(t, err)

assert.Equal(t, "((STATIC NAND STATIC) AND (STATIC OR STATIC))", root.String())
assert.Equal(t, []uint32{3, 6, 9, 10}, readAll(root))
})

t.Run("not", func(t *testing.T) {
ast, err := parser.ParseQuery(`NOT ((NOT m:a AND m:b) AND (m:c OR m:d))`, nil)
query, err := parser.ParseSeqQL(`NOT ((NOT m:a AND m:b) AND (m:c OR m:d))`, nil)
require.NoError(t, err)
root, err := buildEvalTree(ast, 1, 12, &searchStats{}, false, newStatic)
root, err := buildEvalTree(query.Root, 1, 12, &searchStats{}, false, newStatic)
require.NoError(t, err)

assert.Equal(t, "(NOT ((STATIC NAND STATIC) AND (STATIC OR STATIC)))", root.String())
Expand Down
40 changes: 0 additions & 40 deletions parser/ast_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,46 +84,6 @@ func propagateNot(node *ASTNode) (*ASTNode, bool) {
return node, not
}

// Dump is used in tests only
func (e *ASTNode) Dump(builder *strings.Builder) {
switch t := e.Value.(type) {
case *Logical:
builder.WriteByte('(')
switch t.Operator {
case LogicalNot:
builder.WriteString("NOT ")
e.Children[0].Dump(builder)
case LogicalNAnd:
builder.WriteString("NOT ")
fallthrough
case LogicalOr, LogicalAnd:
e.Children[0].Dump(builder)
if t.Operator == LogicalOr {
builder.WriteString(" OR ")
} else {
builder.WriteString(" AND ")
}
e.Children[1].Dump(builder)
default:
panic("unknown operator")
}
builder.WriteByte(')')
case *Literal:
t.Dump(builder)
case *Range:
t.Dump(builder)
default:
panic("unknown token implementation")
}
}

// String is used in tests only
func (e *ASTNode) String() string {
builder := &strings.Builder{}
e.Dump(builder)
return builder.String()
}

func (e *ASTNode) DumpSeqQL(b *strings.Builder) {
switch t := e.Value.(type) {
case *Logical:
Expand Down
127 changes: 18 additions & 109 deletions parser/ast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,97 +6,28 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

type astTest struct {
name string
query string
exp string
}
func TestBuildingTree(t *testing.T) {
a := assert.New(t)

func TestParsingAST(t *testing.T) {
tests := []astTest{
{
name: `simple_0`,
query: `service: composer-api`,
exp: `service:composer-api`,
},
{
name: `simple_1`,
query: ` s : a OR l : 3 `,
exp: `(s:a OR l:3)`,
},
{
name: `simple_2`,
query: `s: a OR l: 3 AND q:b`,
exp: `(s:a OR (l:3 AND q:b))`,
},
{
name: `simple_3`,
query: `s: a OR l: 3 OR q:b`,
exp: `((s:a OR l:3) OR q:b)`,
},
{
name: `simple_4`,
query: ` NOT s : a `,
exp: `(NOT s:a)`,
},
{
name: `simple_5`,
query: `s:a OR NOT s:b OR s:c`,
exp: `((s:a OR (NOT s:b)) OR s:c)`,
},
{
name: `simple_6`,
query: `NOT (s:a OR s:c)`,
exp: `(NOT (s:a OR s:c))`,
},
{
name: `simple_7`,
query: `NOT NOT s:a`,
exp: `(NOT (NOT s:a))`,
},
{
name: `wildcard_0`,
query: `service:*`,
exp: `service:*`,
},
{
name: `wildcard_1`,
query: ` service : * `,
exp: `service:*`,
},
}
for _, tst := range tests {
t.Run(tst.name, func(t *testing.T) {
act, err := buildAst(tst.query, nil)
require.NoError(t, err)
query, err := parse(`a:a OR b:b AND NOT c:c`, nil)
a.NoError(err)
fmt.Println(query.SeqQLString())

genStr := act.String()
assert.Equal(t, tst.exp, genStr)
second, err := buildAst(genStr, nil)
require.NoError(t, err)
assert.Equal(t, genStr, second.String())
})
}
}

func TestBuildingTree(t *testing.T) {
act, err := buildAst(`a:a OR b:b AND NOT c:c`, nil)
assert.NoError(t, err)
assert.Equal(t, LogicalOr, act.Value.(*Logical).Operator)
assert.Equal(t, 2, len(act.Children))
assert.Equal(t, "a:a", act.Children[0].Value.(*Literal).String())
assert.Equal(t, 0, len(act.Children[0].Children))
assert.Equal(t, LogicalAnd, act.Children[1].Value.(*Logical).Operator)
assert.Equal(t, 2, len(act.Children[1].Children))
assert.Equal(t, "b:b", act.Children[1].Children[0].Value.(*Literal).String())
assert.Equal(t, 0, len(act.Children[1].Children[0].Children))
assert.Equal(t, LogicalNot, act.Children[1].Children[1].Value.(*Logical).Operator)
assert.Equal(t, 1, len(act.Children[1].Children[1].Children))
assert.Equal(t, "c:c", act.Children[1].Children[1].Children[0].Value.(*Literal).String())
assert.Equal(t, 0, len(act.Children[1].Children[1].Children[0].Children))
act := query.Root
a.Equal(LogicalOr, act.Value.(*Logical).Operator)
a.Equal(2, len(act.Children))
a.Equal("a:a", act.Children[0].SeqQLString())
a.Equal(0, len(act.Children[0].Children))
a.Equal(LogicalAnd, act.Children[1].Value.(*Logical).Operator)
a.Equal(2, len(act.Children[1].Children))
a.Equal("b:b", act.Children[1].Children[0].SeqQLString())
a.Equal(0, len(act.Children[1].Children[0].Children))
a.Equal(LogicalNot, act.Children[1].Children[1].Value.(*Logical).Operator)
a.Equal(1, len(act.Children[1].Children[1].Children))
a.Equal("c:c", act.Children[1].Children[1].Children[0].SeqQLString())
a.Equal(0, len(act.Children[1].Children[1].Children[0].Children))
}

func tLogical(t logicalKind) Token {
Expand Down Expand Up @@ -133,25 +64,3 @@ func addOperator(e *ASTNode, cnt int) {
}
addOperator(e.Children[rand.Intn(len(e.Children))], cnt)
}

func checkSelf(t *testing.T, e *ASTNode) {
q := e.String()
exp, err := buildAst(q, nil)
require.NoError(t, err)
require.Equal(t, q, exp.String())
}

func TestParsingASTStress(t *testing.T) {
iterations := 500
if testing.Short() {
iterations = 50
}
rand.Seed(14444323)
for i := 0; i < iterations; i++ {
exp := &ASTNode{}
for i := 0; i < 100; i++ {
addOperator(exp, 2*i)
checkSelf(t, exp)
}
}
}
23 changes: 0 additions & 23 deletions parser/bench_test.go

This file was deleted.

Loading
Loading