Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove use of dump methods from index reader #1516

Merged
merged 1 commit into from
Dec 6, 2020
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: 5 additions & 1 deletion cmd/bleve/cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ var dumpCmd = &cobra.Command{
if err != nil {
return fmt.Errorf("error getting index reader: %v", err)
}
upsideDownReader, ok := r.(*upsidedown.IndexReader)
if !ok {
return fmt.Errorf("dump is only supported by index type upsidedown")
}

dumpChan := r.DumpAll()
dumpChan := upsideDownReader.DumpAll()
for rowOrErr := range dumpChan {
switch rowOrErr := rowOrErr.(type) {
case error:
Expand Down
6 changes: 5 additions & 1 deletion cmd/bleve/cmd/dumpDoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ var dumpDocCmd = &cobra.Command{
if err != nil {
return fmt.Errorf("error getting index reader: %v", err)
}
upsideDownReader, ok := r.(*upsidedown.IndexReader)
if !ok {
return fmt.Errorf("dump doc is only supported by index type upsidedown")
}

dumpChan := r.DumpDoc(args[1])
dumpChan := upsideDownReader.DumpDoc(args[1])
for rowOrErr := range dumpChan {
switch rowOrErr := rowOrErr.(type) {
case error:
Expand Down
6 changes: 5 additions & 1 deletion cmd/bleve/cmd/dumpFields.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ var dumpFieldsCmd = &cobra.Command{
if err != nil {
return fmt.Errorf("error getting index reader: %v", err)
}
upsideDownReader, ok := r.(*upsidedown.IndexReader)
if !ok {
return fmt.Errorf("dump fields is only supported by index type upsidedown")
}

dumpChan := r.DumpFields()
dumpChan := upsideDownReader.DumpFields()
for rowOrErr := range dumpChan {
switch rowOrErr := rowOrErr.(type) {
case error:
Expand Down
7 changes: 6 additions & 1 deletion http/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,14 @@ func (h *DebugDocumentHandler) ServeHTTP(w http.ResponseWriter, req *http.Reques
showError(w, req, fmt.Sprintf("error operning index reader: %v", err), 500)
return
}
upsideDownReader, ok := internalIndexReader.(*upsidedown.IndexReader)
if !ok {
showError(w, req, fmt.Sprintf("dump is only supported by index type upsidedown"), 500)
return
}

var rv []interface{}
rowChan := internalIndexReader.DumpDoc(docID)
rowChan := upsideDownReader.DumpDoc(docID)
for row := range rowChan {
switch row := row.(type) {
case error:
Expand Down
14 changes: 9 additions & 5 deletions index/upsidedown/dump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"
"time"

index "github.com/blevesearch/bleve_index_api"
"github.com/blevesearch/bleve/index/upsidedown/store/boltdb"
index "github.com/blevesearch/bleve_index_api"

"github.com/blevesearch/bleve/document"
)
Expand Down Expand Up @@ -96,7 +96,11 @@ func TestDump(t *testing.T) {
if err != nil {
t.Fatal(err)
}
fieldsRows := reader.DumpFields()
upsideDownReader, ok := reader.(*IndexReader)
if !ok {
t.Fatal("dump is only supported by index type upsidedown")
}
fieldsRows := upsideDownReader.DumpFields()
for range fieldsRows {
fieldsCount++
}
Expand All @@ -110,7 +114,7 @@ func TestDump(t *testing.T) {
// 3 stored fields
expectedDocRowCount := int(1 + (2 * (64 / document.DefaultPrecisionStep)) + 3)
docRowCount := 0
docRows := reader.DumpDoc("1")
docRows := upsideDownReader.DumpDoc("1")
for range docRows {
docRowCount++
}
Expand All @@ -119,7 +123,7 @@ func TestDump(t *testing.T) {
}

docRowCount = 0
docRows = reader.DumpDoc("2")
docRows = upsideDownReader.DumpDoc("2")
for range docRows {
docRowCount++
}
Expand All @@ -136,7 +140,7 @@ func TestDump(t *testing.T) {
// 16 date term row counts (shared for both docs, same date value)
expectedAllRowCount := int(1 + fieldsCount + (2 * expectedDocRowCount) + 2 + 2 + int((2 * (64 / document.DefaultPrecisionStep))))
allRowCount := 0
allRows := reader.DumpAll()
allRows := upsideDownReader.DumpAll()
for range allRows {
allRowCount++
}
Expand Down