summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Erf <erf@mongodb.com>2014-11-13 15:07:19 -0500
committerKyle Erf <erf@mongodb.com>2014-11-13 15:07:19 -0500
commit374b0fb92787e531e493de7a5d89ab4b73725b38 (patch)
tree7f27d1ebc334f78c12613d959ec3c89bada9240c
parent633684b3998eaf750d3c01720836ccfeb7e08266 (diff)
downloadmongo-374b0fb92787e531e493de7a5d89ab4b73725b38.tar.gz
TOOLS-354 progress bars should use int64 values
Former-commit-id: 3919cbdb068a1d96c7b83c4902136fd9bb7e8cfa
-rw-r--r--common/progress/manager_test.go4
-rw-r--r--common/progress/progress_bar.go8
-rw-r--r--common/progress/progress_bar_test.go4
-rw-r--r--mongodump/mongodump.go8
-rw-r--r--mongorestore/oplog.go7
-rw-r--r--mongorestore/restore.go8
6 files changed, 20 insertions, 19 deletions
diff --git a/common/progress/manager_test.go b/common/progress/manager_test.go
index 02f68b558df..cb022944449 100644
--- a/common/progress/manager_test.go
+++ b/common/progress/manager_test.go
@@ -17,7 +17,7 @@ func TestManagerAttachAndDetach(t *testing.T) {
So(manager, ShouldNotBeNil)
Convey("adding 3 bars", func() {
- localCounter := 5
+ localCounter := int64(5)
pbar1 := &ProgressBar{
Name: "\nTEST1",
Max: 10,
@@ -115,7 +115,7 @@ func TestManagerStartAndStop(t *testing.T) {
Convey("With a progress.Manager with a WaitTime of 10 ms and one bar", t, func() {
manager = NewProgressBarManager(time.Millisecond * 10)
So(manager, ShouldNotBeNil)
- localCounter := 5
+ localCounter := int64(5)
pbar := &ProgressBar{
Name: "\nTEST",
Max: 10,
diff --git a/common/progress/progress_bar.go b/common/progress/progress_bar.go
index 091f12937e5..407b4852490 100644
--- a/common/progress/progress_bar.go
+++ b/common/progress/progress_bar.go
@@ -21,14 +21,14 @@ const (
type ProgressBar struct {
// Name is an identifier printed along with the bar
Name string
- // Max is the maximum value the counter addressed at CounterPtr
- // is expected to reach (ie, the total)
- Max int
// BarLength is the number of characters used to print the bar
BarLength int
+ // Max is the maximum value the counter addressed at CounterPtr
+ // is expected to reach (ie, the total)
+ Max int64
// CounterPtr is a pointer to an integer the increases as progress
// is made. The value pointed to is read periodically to draw the bar.
- CounterPtr *int
+ CounterPtr *int64
// Writer is where the ProgressBar is written out to
Writer io.Writer
// WaitTime is the time to wait between writing the bar
diff --git a/common/progress/progress_bar_test.go b/common/progress/progress_bar_test.go
index e173ef0900e..9ef3dc5fe84 100644
--- a/common/progress/progress_bar_test.go
+++ b/common/progress/progress_bar_test.go
@@ -9,7 +9,7 @@ import (
)
func TestBasicProgressBar(t *testing.T) {
- var localCounter int
+ var localCounter int64
writeBuffer := &bytes.Buffer{}
Convey("With a simple ProgressBar", t, func() {
@@ -54,7 +54,7 @@ func TestBasicProgressBar(t *testing.T) {
}
func TestBarConcurrency(t *testing.T) {
- var localCounter int
+ var localCounter int64
writeBuffer := &bytes.Buffer{}
Convey("With a simple ProgressBar", t, func() {
diff --git a/mongodump/mongodump.go b/mongodump/mongodump.go
index f7228ca61b6..b757c0b1176 100644
--- a/mongodump/mongodump.go
+++ b/mongodump/mongodump.go
@@ -346,7 +346,7 @@ func (dump *MongoDump) DumpIntent(intent *intents.Intent) error {
// handle repairs as a special case, since we cannot count them
log.Logf(log.Always, "writing repair of %v to %v", intent.Key(), outFilepath)
repairIter := session.DB(intent.DB).C(intent.C).Repair()
- repairCounter := 0
+ var repairCounter int64
if err := dump.dumpIterToWriter(repairIter, out, &repairCounter); err != nil {
if strings.Index(err.Error(), "no such cmd: repairCursor") > 0 {
// return a more helpful error message for early server versions
@@ -385,7 +385,7 @@ func (dump *MongoDump) DumpIntent(intent *intents.Intent) error {
func (dump *MongoDump) dumpQueryToWriter(
query *mgo.Query, intent *intents.Intent, writer io.Writer) (err error) {
- dumpCounter := 0
+ var dumpCounter int64
total, err := query.Count()
if err != nil {
@@ -395,7 +395,7 @@ func (dump *MongoDump) dumpQueryToWriter(
bar := &progress.ProgressBar{
Name: intent.Key(),
- Max: total,
+ Max: int64(total),
CounterPtr: &dumpCounter,
Writer: log.Writer(0),
BarLength: ProgressBarLength,
@@ -413,7 +413,7 @@ func (dump *MongoDump) dumpQueryToWriter(
// dumpIterToWriter takes an mgo iterator, a writer, and a pointer to
// a counter, and dumps the iterator's contents to the writer.
func (dump *MongoDump) dumpIterToWriter(
- iter *mgo.Iter, writer io.Writer, counterPtr *int) error {
+ iter *mgo.Iter, writer io.Writer, counterPtr *int64) error {
buffChan := make(chan []byte)
go func() {
diff --git a/mongorestore/oplog.go b/mongorestore/oplog.go
index eac84c02900..0ecce17d274 100644
--- a/mongorestore/oplog.go
+++ b/mongorestore/oplog.go
@@ -51,11 +51,12 @@ func (restore *MongoRestore) RestoreOplog() error {
entryArray := make([]interface{}, 0, 1024)
rawOplogEntry := &bson.Raw{}
- var totalBytes, entrySize, bufferedBytes int
+ var totalBytes int64
+ var entrySize, bufferedBytes int
bar := progress.ProgressBar{
Name: "oplog",
- Max: int(size),
+ Max: size,
CounterPtr: &totalBytes,
WaitTime: 3 * time.Second,
Writer: log.Writer(0),
@@ -101,7 +102,7 @@ func (restore *MongoRestore) RestoreOplog() error {
}
bufferedBytes += entrySize
- totalBytes += entrySize
+ totalBytes += int64(entrySize)
entryArray = append(entryArray, entryAsOplog)
}
// finally, flush the remaining entries
diff --git a/mongorestore/restore.go b/mongorestore/restore.go
index 0eddff111c0..81272992cf2 100644
--- a/mongorestore/restore.go
+++ b/mongorestore/restore.go
@@ -218,14 +218,14 @@ func (restore *MongoRestore) RestoreCollectionToDB(dbName, colName string,
collection := session.DB(dbName).C(colName)
// progress bar handlers
- bytesRead := 0
+ var bytesRead int64
// only print progress bar if we know the bounds
// TODO have useful progress meters when max=0
if fileSize > 0 {
bar := &progress.ProgressBar{
Name: fmt.Sprintf("%v.%v", dbName, colName),
- Max: int(fileSize),
+ Max: int64(fileSize),
CounterPtr: &bytesRead,
Writer: log.Writer(0),
BarLength: ProgressBarLength,
@@ -245,7 +245,7 @@ func (restore *MongoRestore) RestoreCollectionToDB(dbName, colName string,
defer close(killChan)
// start a goroutine for adding up the number of bytes read
- bytesReadChan := make(chan int, restore.OutputOptions.BulkBufferSize*MaxInsertThreads)
+ bytesReadChan := make(chan int64, restore.OutputOptions.BulkBufferSize*MaxInsertThreads)
go func() {
for {
select {
@@ -293,7 +293,7 @@ func (restore *MongoRestore) RestoreCollectionToDB(dbName, colName string,
resultChan <- err
return
}
- bytesReadChan <- len(rawDoc.Data)
+ bytesReadChan <- int64(len(rawDoc.Data))
case <-killChan:
return
}