func main() { rand.Seed(time.Now().UnixNano()) x.Init() checkFlagsAndInitDirs() ps, err := store.NewStore(*postingDir) x.Checkf(err, "Error initializing postings store") defer ps.Close() if len(*schemaFile) > 0 { err = schema.Parse(*schemaFile) x.Checkf(err, "Error while loading schema: %s", *schemaFile) } // Posting will initialize index which requires schema. Hence, initialize // schema before calling posting.Init(). posting.Init(ps) worker.Init(ps) x.Check(group.ParseGroupConfig(*conf)) // Setup external communication. che := make(chan error, 1) go setupServer(che) go worker.StartRaftNodes(*walDir) if err := <-che; !strings.Contains(err.Error(), "use of closed network connection") { log.Fatal(err) } }
func main() { x.Init() s = &status{ start: time.Now(), } filesList := strings.Split(*files, ",") x.AssertTrue(len(filesList) > 0) for _, file := range filesList { processFile(file) } fmt.Printf("Number of mutations run : %d\n", s.mutations) fmt.Printf("Number of RDFs processed : %d\n", s.rdfs) fmt.Printf("Time spent : %v\n", time.Since(s.start)) fmt.Printf("RDFs processed per second : %d\n", s.rdfs/uint64(time.Since(s.start).Seconds())) }
func TestMain(m *testing.M) { x.Init() os.Exit(m.Run()) }
func main() { x.Init() fin, err := os.Open(filename) x.Check(err) defer fin.Close() scanner := bufio.NewScanner(fin) var numLines, numValues, numNames, numReleaseDates int graph = make(map[string]map[uint64][]uint64) gNames = make(map[uint64]string) gReleaseDates = make(map[uint64]string) for scanner.Scan() { numLines++ tokens := strings.Split(scanner.Text(), "\t") x.AssertTruef(len(tokens) == 4, scanner.Text()) src := tokens[0] x.AssertTrue(bracketed(src)) src = removeFirstLast(src) srcUID := farm.Fingerprint64([]byte(src)) pred := tokens[1] x.AssertTrue(bracketed(pred)) pred = removeFirstLast(pred) value := tokens[2] if bracketed(value) { // Normal edge. value = removeFirstLast(value) destUID := farm.Fingerprint64([]byte(value)) m, found := graph[pred] if !found { m = make(map[uint64][]uint64) graph[pred] = m } m[srcUID] = append(m[srcUID], destUID) } else { numValues++ // Check for "@". pos := strings.LastIndex(value, "@") if pos >= 0 { pred = pred + "." + value[pos+1:] value = removeFirstLast(value[:pos]) } if pred == "type.object.name.en" { numNames++ gNames[srcUID] = value } else if pred == "film.film.initial_release_date" { numReleaseDates++ gReleaseDates[srcUID] = value } } } fmt.Printf("Num lines read: %d\n", numLines) fmt.Printf("Num predicates: %d\n", len(graph)) fmt.Printf("Num values read: %d\n", numValues) fmt.Printf("Num names read: %d\n", numNames) fmt.Printf("Num release dates read: %d\n", numReleaseDates) x.AssertTrue(numLines > 0) x.AssertTrue(len(graph) > 0) x.AssertTrue(numValues > 0) x.AssertTrue(numNames > 0) x.AssertTrue(numReleaseDates > 0) // doFilterString() // doSortRelease() doGen() }
func main() { x.Init() fin, err := os.Open(filename) x.Check(err) defer fin.Close() scanner := bufio.NewScanner(fin) var numLines, numValues, numNames, numReleaseDates int invGraph = make(map[string]map[uint64][]uint64) for scanner.Scan() { numLines++ tokens := strings.Split(scanner.Text(), "\t") x.AssertTruef(len(tokens) == 4, scanner.Text()) src := tokens[0] x.AssertTrue(bracketed(src)) src = removeFirstLast(src) srcUID := farm.Fingerprint64([]byte(src)) pred := tokens[1] x.AssertTrue(bracketed(pred)) pred = removeFirstLast(pred) value := tokens[2] if bracketed(value) { // Normal edge. value = removeFirstLast(value) destUID := farm.Fingerprint64([]byte(value)) m, found := invGraph[pred] if !found { m = make(map[uint64][]uint64) invGraph[pred] = m } // We are building an inverse map! m[destUID] = append(m[destUID], srcUID) } else { // A value. numValues++ value = removeFirstLast(value) if pred == "type.object.name" { numNames++ // Do some custom processing here. value = strings.ToLower(value) vTokens := strings.Split(value, " ") var found bool for _, t := range vTokens { if t == "the" { found = true break } } if found { goodUIDs = append(goodUIDs, srcUID) } } else if pred == "film.film.initial_release_date" { numReleaseDates++ } } } fmt.Printf("Num lines read: %d\n", numLines) fmt.Printf("Num predicates: %d\n", len(invGraph)) fmt.Printf("Num values read: %d\n", numValues) fmt.Printf("Num names read: %d\n", numNames) fmt.Printf("Num release dates read: %d\n", numReleaseDates) fmt.Printf("Num good UIDs: %d\n", len(goodUIDs)) x.AssertTrue(numLines > 0) x.AssertTrue(len(invGraph) > 0) x.AssertTrue(numValues > 0) x.AssertTrue(numNames > 0) x.AssertTrue(numReleaseDates > 0) x.AssertTrue(len(goodUIDs) > 0) doGood() }