Skip to content
This repository has been archived by the owner on Nov 22, 2018. It is now read-only.

Commit

Permalink
release v1.0.5: Unvendor lldb, use stable lldb. Closes #128.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Mercl committed Jul 11, 2016
1 parent 2cbfdfc commit a9f03fa
Show file tree
Hide file tree
Showing 43 changed files with 78 additions and 17,830 deletions.
52 changes: 28 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,26 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

.PHONY: all clean nuke
.PHONY: all clean cover cpu editor internalError later mem nuke todo edit

grep=--include=*.go --include=*.l --include=*.y --include=*.yy --exclude=ql.y
ngrep='TODOOK\|parser\.go\|scanner\.go\|.*_string\.go'

all: editor scanner.go parser.go
go build
go vet || true
golint
go vet 2>&1 | grep -v $(ngrep) || true
golint 2>&1 | grep -v $(ngrep) || true
make todo
unused . || true
misspell *.go
gosimple || true
go install ./...

bench: all
go test -run NONE -bench .

clean:
go clean
rm -f *~ y.go y.tab.c *.out ql.test
rm -f *~ y.go y.tab.c *.out *.test

coerce.go: helper/helper.go
if [ -f coerce.go ] ; then rm coerce.go ; fi
Expand All @@ -25,10 +30,12 @@ coerce.go: helper/helper.go
cover:
t=$(shell tempfile) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t

cpu: ql.test
go test -c
./$< -test.bench . -test.cpuprofile cpu.out
go tool pprof --lines $< cpu.out
cpu: clean
go test -run @ -bench . -cpuprofile cpu.out
go tool pprof -lines *.test cpu.out

edit:
gvim -p Makefile *.l *.y *.go

editor: ql.y scanner.go parser.go coerce.go
gofmt -s -l -w *.go
Expand All @@ -38,12 +45,15 @@ editor: ql.y scanner.go parser.go coerce.go
internalError:
egrep -ho '"internal error.*"' *.go | sort | cat -n

mem: ql.test
go test -c
./$< -test.bench . -test.memprofile mem.out
go tool pprof --lines --web --alloc_space $< mem.out
later:
@grep -n $(grep) LATER * || true
@grep -n $(grep) MAYBE * || true

mem: clean
go test -run @ -bench . -memprofile mem.out -memprofilerate 1 -timeout 24h
go tool pprof -lines -web -alloc_space *.test mem.out

nuke:
nuke: clean
go clean -i

parser.go: parser.y
Expand All @@ -53,8 +63,6 @@ parser.go: parser.y
rm -f $$a
sed -i -e 's|//line.*||' -e 's/yyEofCode/yyEOFCode/' $@

ql.test: all

ql.y: doc.go
sed -n '1,/^package/ s/^\/\/ //p' < $< \
| ebnf2y -o $@ -oe $*.ebnf -start StatementList -pkg $* -p _
Expand All @@ -64,11 +72,7 @@ scanner.go: scanner.l parser.go
golex -o $@ $<

todo:
@grep -n ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* *.go *.l parser.y || true
@grep -n TODO *.go *.l parser.y testdata.ql || true
@grep -n BUG *.go *.l parser.y || true
@grep -n println *.go *.l parser.y || true

later:
@grep -n LATER *.go *.l parser.y || true
@grep -n MAYBE *.go *.l parser.y || true
@grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * || true
@grep -nr $(grep) TODO * || true
@grep -nr $(grep) BUG * || true
@grep -nr $(grep) [^[:alpha:]]println * || true
55 changes: 21 additions & 34 deletions all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const benchScale = 1e6
func init() {
log.SetFlags(log.Flags() | log.Lshortfile)
isTesting = true
use(dieHard, caller, dumpTables2, dumpTables3, dumpFields, dumpFlds, dumpCols, typeof, stypeof)
}

func dieHard(exitValue int) {
Expand Down Expand Up @@ -319,7 +320,7 @@ func rnds16(rng *rand.Rand, n int) string {

var (
benchmarkScaleOnce sync.Once
benchmarkSelectOnce = map[string]sync.Once{}
benchmarkSelectOnce = map[string]bool{}
)

func benchProlog(b *testing.B) {
Expand All @@ -335,13 +336,12 @@ func benchmarkSelect(b *testing.B, n int, sel List, ts testDB) {
if testing.Verbose() {
benchProlog(b)
id := fmt.Sprintf("%T|%d", ts, n)
once := benchmarkSelectOnce[id]
once.Do(func() {
if !benchmarkSelectOnce[id] {
b.Logf(`Having a table of %d records, each of size 1kB, measure the performance of
%s
`, n, sel)
})
benchmarkSelectOnce[id] = once
}
benchmarkSelectOnce[id] = true
}

db, err := ts.setup()
Expand Down Expand Up @@ -463,19 +463,18 @@ func TestString(t *testing.T) {
}
}

var benchmarkInsertOnce = map[string]sync.Once{}
var benchmarkInsertOnce = map[string]bool{}

func benchmarkInsert(b *testing.B, batch, total int, ts testDB) {
if testing.Verbose() {
benchProlog(b)
id := fmt.Sprintf("%T|%d|%d", ts, batch, total)
once := benchmarkInsertOnce[id]
once.Do(func() {
if !benchmarkInsertOnce[id] {
b.Logf(`In batches of %d record(s), insert a total of %d records, each of size 1kB, into a table.
`, batch, total)
})
benchmarkInsertOnce[id] = once
}
benchmarkInsertOnce[id] = true
}

if total%batch != 0 {
Expand Down Expand Up @@ -1221,23 +1220,22 @@ func TestIndices(t *testing.T) {
testIndices(db, t)
}

var benchmarkInsertBoolOnce = map[string]sync.Once{}
var benchmarkInsertBoolOnce = map[string]bool{}

func benchmarkInsertBool(b *testing.B, db *DB, size int, selectivity float64, index bool, teardown func()) {
if testing.Verbose() {
benchProlog(b)
id := fmt.Sprintf("%t|%d|%g|%t", db.isMem, size, selectivity, index)
once := benchmarkInsertBoolOnce[id]
once.Do(func() {
if !benchmarkInsertBoolOnce[id] {
s := "INDEXED"
if !index {
s = "NON " + s
}
b.Logf(`Insert %d records into a table having a single bool %s column. Batch size: 1 record.
`, size, s)
})
benchmarkInsertBoolOnce[id] = once
}
benchmarkInsertBoolOnce[id] = true
}

if teardown != nil {
Expand Down Expand Up @@ -1401,7 +1399,7 @@ func BenchmarkInsertBoolFileX1e3(b *testing.B) {
benchmarkInsertBoolFile(b, 1e3, 0.5, true)
}

var benchmarkSelectBoolOnce = map[string]sync.Once{}
var benchmarkSelectBoolOnce = map[string]bool{}

func benchmarkSelectBool(b *testing.B, db *DB, size int, selectivity float64, index bool, teardown func()) {
sel, err := Compile("SELECT * FROM t WHERE b;")
Expand All @@ -1412,8 +1410,7 @@ func benchmarkSelectBool(b *testing.B, db *DB, size int, selectivity float64, in
if testing.Verbose() {
benchProlog(b)
id := fmt.Sprintf("%t|%d|%g|%t", db.isMem, size, selectivity, index)
once := benchmarkSelectBoolOnce[id]
once.Do(func() {
if !benchmarkSelectBoolOnce[id] {
s := "INDEXED"
if !index {
s = "NON " + s
Expand All @@ -1422,8 +1419,8 @@ func benchmarkSelectBool(b *testing.B, db *DB, size int, selectivity float64, in
%.0f%% of them are true. Measure the performance of
%s
`, s, size, 100*selectivity, sel)
})
benchmarkSelectBoolOnce[id] = once
}
benchmarkSelectBoolOnce[id] = true
}

if teardown != nil {
Expand Down Expand Up @@ -1743,23 +1740,22 @@ func TestIndex(t *testing.T) {
}
}

var benchmarkCrossJoinOnce = map[string]sync.Once{}
var benchmarkCrossJoinOnce = map[string]bool{}

func benchmarkCrossJoin(b *testing.B, db *DB, create, sel List, size1, size2 int, index bool, teardown func()) {
if testing.Verbose() {
benchProlog(b)
id := fmt.Sprintf("%t|%d|%d|%t", db.isMem, size1, size2, index)
once := benchmarkCrossJoinOnce[id]
once.Do(func() {
if !benchmarkCrossJoinOnce[id] {
s := "INDEXED "
if !index {
s = "NON " + s
}
b.Logf(`Fill two %stables with %d and %d records of random numbers [0, 1). Measure the performance of
%s
`, s, size1, size2, sel)
})
benchmarkCrossJoinOnce[id] = once
}
benchmarkCrossJoinOnce[id] = true
}

if teardown != nil {
Expand Down Expand Up @@ -2066,15 +2062,6 @@ func dumpFields(f []*fld) string {
return strings.Join(a, ", ")
}

func rndBytes(n int, seed int64) []byte {
rng := rand.New(rand.NewSource(seed))
b := make([]byte, n)
for i := range b {
b[i] = byte(rng.Int())
}
return b
}

func TestIssue50(t *testing.T) { // https://github.com/cznic/ql/issues/50
if testing.Short() {
t.Skip("skipping test in short mode.")
Expand Down
10 changes: 5 additions & 5 deletions design/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ record handle} and the B+Tree value is not used.
+------+-----------------+ +--------------+
If the indexed values are not all NULL then key of the B+Tree key are the indexed
values and the B+Tree value is the record handle.
values and the B+Tree value is the record handle.
B+Tree key B+Tree value
+----------------+ +---------------+
Expand Down Expand Up @@ -262,7 +262,7 @@ out are stripped off and "resupplied" on decoding transparently. See also
blob.go. If the length of the resulting slice is <= shortBlob, the first and
only chunk is the scalar encoding of
[]interface{}{typeTag, slice}. // initial (and last) chunk
The length of slice can be zero (for blob("")). If the resulting slice is long
Expand All @@ -285,9 +285,9 @@ Links
Referenced from above:
[0]: http://godoc.org/github.com/cznic/exp/lldb#hdr-Block_handles
[1]: http://godoc.org/github.com/cznic/exp/lldb#EncodeScalars
[2]: http://godoc.org/github.com/cznic/exp/lldb#BTree
[0]: http://godoc.org/github.com/cznic/lldb#hdr-Block_handles
[1]: http://godoc.org/github.com/cznic/lldb#EncodeScalars
[2]: http://godoc.org/github.com/cznic/lldb#BTree
Rationale
Expand Down
9 changes: 7 additions & 2 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
//
// Change list
//
// 2016-07-11: Release v1.0.5 undoes vendoring of lldb. QL now uses stable lldb
// (github.com/cznic/lldb).
//
// https://github.com/cznic/ql/issues/128
//
// 2016-07-06: Release v1.0.4 fixes a panic when closing the WAL file.
//
// https://github.com/cznic/ql/pull/127
Expand Down Expand Up @@ -804,7 +809,7 @@
//
// expr1 LIKE expr2
//
// yeild a boolean value true if expr2, a regular expression, matches expr1
// yield a boolean value true if expr2, a regular expression, matches expr1
// (see also [6]). Both expression must be of type string. If any one of the
// expressions is NULL the result is NULL.
//
Expand Down Expand Up @@ -891,7 +896,7 @@
//
// expr IS NOT NULL // case B
//
// yeild a boolean value true if expr does not have a specific type (case A) or
// yield a boolean value true if expr does not have a specific type (case A) or
// if expr has a specific type (case B). In other cases the result is a boolean
// value false.
//
Expand Down
33 changes: 0 additions & 33 deletions etc.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"io"
"math"
"math/big"
"strings"
"time"
)

Expand Down Expand Up @@ -2764,38 +2763,6 @@ var isSystemName = map[string]bool{
"__Table": true,
}

func qualifier(s string) string {
if pos := strings.IndexByte(s, '.'); pos >= 0 {
s = s[:pos]
}
return s
}

func mustQualifier(s string) string {
q := qualifier(s)
if q == s {
panic("internal error 068")
}

return q
}

func selector(s string) string {
if pos := strings.IndexByte(s, '.'); pos >= 0 {
s = s[pos+1:]
}
return s
}

func mustSelector(s string) string {
q := selector(s)
if q == s {
panic("internal error 053")
}

return q
}

func qnames(l []string) []string {
r := make([]string, len(l))
for i, v := range l {
Expand Down
Loading

0 comments on commit a9f03fa

Please sign in to comment.