Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
CascadingRadium committed Aug 5, 2024
1 parent 2ac9741 commit 796fa7c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
2 changes: 1 addition & 1 deletion index.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (b *Batch) Index(id string, data interface{}) error {
return ErrorEmptyID
}
if eventIndex, ok := b.index.(index.EventIndex); ok {

Check failure on line 49 in index.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, ubuntu-latest)

undefined: index.EventIndex

Check failure on line 49 in index.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, macos-latest)

undefined: index.EventIndex

Check failure on line 49 in index.go

View workflow job for this annotation

GitHub Actions / test (1.21.x, ubuntu-latest)

undefined: index.EventIndex

Check failure on line 49 in index.go

View workflow job for this annotation

GitHub Actions / test (1.21.x, macos-latest)

undefined: index.EventIndex

Check failure on line 49 in index.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, ubuntu-latest)

undefined: index.EventIndex

Check failure on line 49 in index.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, macos-latest)

undefined: index.EventIndex
eventIndex.FireEvent(index.EventKindIndex)
eventIndex.FireIndexEvent()
}
doc := document.NewDocument(id)
err := b.index.Mapping().MapDocument(doc, data)
Expand Down
14 changes: 3 additions & 11 deletions index/scorch/scorch.go
Original file line number Diff line number Diff line change
Expand Up @@ -878,16 +878,8 @@ func (s *Scorch) CopyReader() index.CopyReader {
return rv
}

// external API to fire a scorch event externally from bleve
func (s *Scorch) FireEvent(eventKind index.EventKind) {
// external API to fire a scorch event (EventKindIndexStart) externally from bleve
func (s *Scorch) FireIndexEvent() {
// switch on bleve the event kind and fire the corresponding scorch event
switch eventKind {
case index.EventKindIndex:
// bleve is about to index a document using the Index() API
// fire the corresponding scorch event
s.fireEvent(EventKindIndexStart, 0)
default:
// do nothing
return
}
s.fireEvent(EventKindIndexStart, 0)
}
8 changes: 4 additions & 4 deletions index_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func (i *indexImpl) Index(id string, data interface{}) (err error) {
if !i.open {
return ErrorIndexClosed
}
i.FireEvent(index.EventKindIndex)
i.FireIndexEvent()
doc := document.NewDocument(id)
err = i.m.MapDocument(doc, data)
if err != nil {
Expand Down Expand Up @@ -1113,15 +1113,15 @@ func (f FileSystemDirectory) GetWriter(filePath string) (io.WriteCloser,
os.O_RDWR|os.O_CREATE, 0600)
}

func (i *indexImpl) FireEvent(eventKind index.EventKind) {
func (i *indexImpl) FireIndexEvent() {
// get the internal index implementation
intIndex, err := i.Advanced()
if err != nil {
return
}
// check if the internal index implementation supports events
if eventIntIndex, ok := intIndex.(index.EventIndex); ok {
if eventInternalIndex, ok := intIndex.(index.EventIndex); ok {

Check failure on line 1123 in index_impl.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, ubuntu-latest)

undefined: index.EventIndex

Check failure on line 1123 in index_impl.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, macos-latest)

undefined: index.EventIndex

Check failure on line 1123 in index_impl.go

View workflow job for this annotation

GitHub Actions / test (1.21.x, ubuntu-latest)

undefined: index.EventIndex

Check failure on line 1123 in index_impl.go

View workflow job for this annotation

GitHub Actions / test (1.21.x, macos-latest)

undefined: index.EventIndex

Check failure on line 1123 in index_impl.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, ubuntu-latest)

undefined: index.EventIndex

Check failure on line 1123 in index_impl.go

View workflow job for this annotation

GitHub Actions / test (1.22.x, macos-latest)

undefined: index.EventIndex
// fire the event
eventIntIndex.FireEvent(eventKind)
eventInternalIndex.FireIndexEvent()
}
}

0 comments on commit 796fa7c

Please sign in to comment.