Skip to content

Commit

Permalink
Add write batch function
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Artoul committed Nov 6, 2018
1 parent a22e1bf commit f92d26b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/dbnode/persist/fs/commitlog/commit_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ func (l *commitLog) flushEvery(interval time.Duration) {
}

func (l *commitLog) write() {
outer:
for write := range l.writes {
if write.eventType == flushEventType {
l.writerState.writer.Flush(false)
Expand Down Expand Up @@ -456,7 +457,7 @@ func (l *commitLog) write() {
l.commitLogFailFn(err)
}

continue
break outer
}
}
l.metrics.success.Inc(1)
Expand Down Expand Up @@ -548,6 +549,13 @@ func (l *commitLog) Write(
})
}

func (l *commitLog) WriteBatch(
ctx context.Context,
writes WritesBatch,
) error {
return l.writeFn(ctx, writes)
}

func (l *commitLog) writeWait(
ctx context.Context,
writes WritesBatch,
Expand Down
6 changes: 6 additions & 0 deletions src/dbnode/persist/fs/commitlog/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ type CommitLog interface {
annotation ts.Annotation,
) error

// Write does the same thing as Write, but in batches.
WriteBatch(
ctx context.Context,
writes WritesBatch,
) error

// Close the commit log
Close() error

Expand Down

0 comments on commit f92d26b

Please sign in to comment.