chore: format our golang codes by 'goreturns -l -w .' (#47)
be noted that we don't need to format generated codes, e.g. generated by thrift
This commit is contained in:
parent
a247e34ea4
commit
927eb455ef
@ -82,5 +82,5 @@ func flows2map(flows []*proxy.Flow, m map[int64]int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Load map[wayid] to speed with %d items, %d forward and %d backward.\n", (fwdCnt+bwdCnt), fwdCnt, bwdCnt)
|
fmt.Printf("Load map[wayid] to speed with %d items, %d forward and %d backward.\n", (fwdCnt + bwdCnt), fwdCnt, bwdCnt)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setChan2True(c chan<- bool) {
|
func setChan2True(c chan<- bool) {
|
||||||
|
|||||||
@ -1,16 +1,16 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
|
||||||
"os"
|
|
||||||
"log"
|
|
||||||
"fmt"
|
|
||||||
"strconv"
|
|
||||||
"io"
|
|
||||||
"encoding/csv"
|
"encoding/csv"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strings"
|
"log"
|
||||||
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
"github.com/Telenav/osrm-backend/traffic_updater/go/gen-go/proxy"
|
"github.com/Telenav/osrm-backend/traffic_updater/go/gen-go/proxy"
|
||||||
)
|
)
|
||||||
@ -51,7 +51,6 @@ func TestGenerateSingleRecord2(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func validateStatistic(ds *dumperStatistic, t *testing.T) {
|
func validateStatistic(ds *dumperStatistic, t *testing.T) {
|
||||||
sum := ds.Sum()
|
sum := ds.Sum()
|
||||||
if (sum.wayCnt != 4) || (sum.nodeCnt != 9) || (sum.fwdRecordCnt != 4) || (sum.bwdRecordCnt != 3) || (sum.wayMatchedCnt != 4) || (sum.nodeMatchedCnt != 9) {
|
if (sum.wayCnt != 4) || (sum.nodeCnt != 9) || (sum.fwdRecordCnt != 4) || (sum.bwdRecordCnt != 3) || (sum.wayMatchedCnt != 4) || (sum.nodeMatchedCnt != 9) {
|
||||||
@ -177,4 +176,3 @@ func compareFileContentUnstable(f1, f2 string, t *testing.T) {
|
|||||||
t.Error("TestLoadWay2Nodeids failed to generate correct map\n")
|
t.Error("TestLoadWay2Nodeids failed to generate correct map\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/snappy"
|
"github.com/golang/snappy"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -38,7 +39,6 @@ func load(mappingPath string, data chan<- string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// input data format
|
// input data format
|
||||||
// wayid1, n1, n2
|
// wayid1, n1, n2
|
||||||
// wayid2, n3, n4, n5
|
// wayid2, n3, n4, n5
|
||||||
@ -54,5 +54,3 @@ func convert(data <-chan string, sources [TASKNUM]chan string) {
|
|||||||
sources[chanIndex] <- str
|
sources[chanIndex] <- str
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"sync"
|
"sync"
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func TestLoadWay2Nodeids(t *testing.T) {
|
func TestLoadWay2Nodeids(t *testing.T) {
|
||||||
// load result into sources
|
// load result into sources
|
||||||
var sources [TASKNUM]chan string
|
var sources [TASKNUM]chan string
|
||||||
@ -19,7 +18,7 @@ func TestLoadWay2Nodeids(t *testing.T) {
|
|||||||
allWay2NodesChan := make(chan string, 10000)
|
allWay2NodesChan := make(chan string, 10000)
|
||||||
var wgs sync.WaitGroup
|
var wgs sync.WaitGroup
|
||||||
wgs.Add(TASKNUM)
|
wgs.Add(TASKNUM)
|
||||||
for i:= 0; i < TASKNUM; i++ {
|
for i := 0; i < TASKNUM; i++ {
|
||||||
//fmt.Printf("### current i is %d\n", i)
|
//fmt.Printf("### current i is %d\n", i)
|
||||||
go mergeChannels(sources[i], allWay2NodesChan, &wgs)
|
go mergeChannels(sources[i], allWay2NodesChan, &wgs)
|
||||||
}
|
}
|
||||||
@ -61,4 +60,3 @@ func generateMockWay2nodeids(way2nodeids map[string]bool) {
|
|||||||
way2nodeids["24418343,84760849102,84760850102"] = true
|
way2nodeids["24418343,84760849102,84760850102"] = true
|
||||||
way2nodeids["24418344,84760846102,84760858102"] = true
|
way2nodeids["24418344,84760846102,84760858102"] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,10 +2,11 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"strings"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"io"
|
"io"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/golang/snappy"
|
"github.com/golang/snappy"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -48,7 +49,7 @@ func main() {
|
|||||||
defer fo.Close()
|
defer fo.Close()
|
||||||
defer fo.Sync()
|
defer fo.Sync()
|
||||||
|
|
||||||
buf := make([]byte, 128 * 1024)
|
buf := make([]byte, 128*1024)
|
||||||
if inputCompressed {
|
if inputCompressed {
|
||||||
_, err := io.CopyBuffer(fo, snappy.NewReader(fi), buf)
|
_, err := io.CopyBuffer(fo, snappy.NewReader(fi), buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -156,4 +156,3 @@ func main() {
|
|||||||
endTime := time.Now()
|
endTime := time.Now()
|
||||||
fmt.Printf("Total processing time for wayid2nodeids-extract takes %f seconds\n", endTime.Sub(startTime).Seconds())
|
fmt.Printf("Total processing time for wayid2nodeids-extract takes %f seconds\n", endTime.Sub(startTime).Seconds())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user