Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

fixes #50, check for empty array (and increase buffer size) #51

Merged
merged 1 commit into from
Jan 16, 2015
Merged
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
7 changes: 5 additions & 2 deletions pkg/adaptor/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
)

const (
MONGO_BUFFER_SIZE int = 1e6
MONGO_BUFFER_LEN int = 1e5
MONGO_BUFFER_SIZE int = 5e6
MONGO_BUFFER_LEN int = 5e5
)

// Mongodb is an adaptor to read / write to mongodb.
Expand Down Expand Up @@ -214,6 +214,9 @@ func (m *Mongodb) writeBuffer() {
m.buffLock.Lock()
defer m.buffLock.Unlock()
collection := m.mongoSession.DB(m.database).C(m.collection)
if len(m.opsBuffer) == 0 {
return
}

err := collection.Insert(m.opsBuffer...)

Expand Down