Skip to content

Instantly share code, notes, and snippets.

@martende
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martende/252f403f0c17cb489de4 to your computer and use it in GitHub Desktop.
Save martende/252f403f0c17cb489de4 to your computer and use it in GitHub Desktop.
package main
import "fmt"
//import "io/ioutil"
import "os"
import "bufio"
import "io"
import "strings"
import "strconv"
func main() {
//////////////// !!!!!!!
/* If I uncomment 2 lines below programm runs fast */
nodesPool := make([]int, 300e6, 300e6)
_ = nodesPool
//////////////////////7
file, err := os.Open("result.txt")
if err != nil {
panic(err)
}
defer file.Close()
reader := bufio.NewReader(file)
var lastLinkIdx = 1 // Dont use first element use 0 as saver
cnt:= 0
totalB := 0
for {
l, err := reader.ReadString('\n')
if err == io.EOF {
fmt.Println("EOF")
break
}
cnt+=1
totalB+=len(l)
lines := strings.Split(l, ":")
nodeId,_ := strconv.Atoi(lines[0])
_ = nodeId
linkIdsStr := strings.Split(lines[1], ",")
var ii = len(linkIdsStr)
_ = ii
/*
if ii == 0 {
nodesPool[nodeId] = 0
} else {
nodesPool[nodeId] = lastLinkIdx
for i, _ := range linkIdsStr {
linkIdsPool[lastLinkIdx],_ = strconv.Atoi(linkIdsStr[i])
lastLinkIdx+=1
}
}*/
}
fmt.Println("pool ",cnt,totalB,lastLinkIdx)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment