예제 #1
0
func DebugPid() {
	var db *dbm.DB = dbConnect(dbname)
	a, _ := db.Array("URLtoPageId")
	enum, err := a.Enumerator(true)
	//risky approach
	key2, value, err := enum.Next()
	for ; err != io.EOF; key2, value, err = enum.Next() {

		fmt.Printf("%v	%v\n", key2[0].(string), value[0].(int64))
	}
	db.Close()
}
예제 #2
0
func GetPageId(URL string) int64 {
	var db *dbm.DB = dbConnect(dbname)
	URLtoPageId, _ := db.Array("URLtoPageId")
	pid, err := URLtoPageId.Get(URL)
	if err != nil {
		closeDb(db)
		return 0
	} else {
		closeDb(db)
		return pid.(int64)
	}

	return -1
}
예제 #3
0
func SetPageId(URL string) int64 {
	var db *dbm.DB = dbConnect(dbname)
	URLtoPageId, _ := db.Array("URLtoPageId")
	pid, _ := URLtoPageId.Get(URL)
	if pid == nil {
		i := generatePId(URLtoPageId)
		//var i int64 = 0
		URLtoPageId.Set(i, URL)
		closeDb(db)
		return i
	} else {
		closeDb(db)
		return pid.(int64)
	}

	return -1
}