Exemple #1
0
Fichier : c.go Projet : qgweb/new
func (this CproData) ReocrdCookieEx(param map[string]string) error {
	var (
		cp        = parseCookieParam(param)
		conn      = db.GetHbaseConn()
		tableName = "xu-cookie-ex"
	)

	if err := this.createTable(conn, tableName); err != nil {
		return err
	}

	if !bson.IsObjectIdHex(cp.id) {
		return errors.New("cookie-id参数错误")
	}

	put := hbase.NewPut([]byte(bson.NewObjectId().Hex()))
	put.AddStringValue("base", "ckid", cp.id)
	put.AddStringValue("base", "cox", cp.cox)
	put.AddStringValue("base", "ua", cp.ua)
	put.AddStringValue("base", "date", cp.date)
	put.AddStringValue("base", "ip", cp.ip)
	put.AddStringValue("base", "pid", cp.pid)
	put.AddStringValue("base", "cid", cp.cid)
	put.AddStringValue("base", "is_new", cp.is_new)
	conn.Put(tableName, put)
	return nil
}
Exemple #2
0
Fichier : c.go Projet : qgweb/new
// 域名访客找回
func (this CproData) DomainVisitor(pkgId string, cookie string, domain string) error {
	var (
		conn      = db.GetHbaseConn()
		date      = timestamp.GetDayTimestamp(0)
		tableName = "domain-cookie"
	)

	if err := this.createTable(conn, tableName); err != nil {
		return err
	}

	put := hbase.NewPut([]byte(pkgId + "_" + date + "_" + cookie))
	put.AddStringValue("base", "date", timestamp.GetDayTimestamp(0))
	put.AddStringValue("base", "cookie", cookie)
	put.AddStringValue("base", "domain", domain)
	conn.Put(tableName, put)
	return nil
}
Exemple #3
0
Fichier : c.go Projet : qgweb/new
// 记录广告投放信息
// 包括点击,pv,ad,ua等
func (this CproData) RecordAdvertPutInfo(param map[string]string) error {
	var (
		ap        = parseAdvertParam(param)
		conn      = db.GetHbaseConn()
		tableName = "advert-put-record"
		key       = ap.advert + "_" + encrypt.DefaultMd5.Encode(ap.ad+encrypt.DefaultBase64.Encode(ap.ua))
		merr      string
	)

	if err := this.createTable(conn, tableName); err != nil {
		return err
	}

	put := hbase.NewPut([]byte(key))
	put.AddStringValue("base", "ad", ap.ad)
	put.AddStringValue("base", "ua", encrypt.DefaultBase64.Encode(ap.ua))
	put.AddStringValue("base", "aid", ap.advert)

	incr := hbase.NewIncr([]byte(key))
	if ap.pv == "1" {
		incr.AddStringValue("base", "pv", 1)
	}
	if ap.click == "1" {
		incr.AddStringValue("base", "click", 1)
	}

	if _, err := conn.Put(tableName, put); err != nil {
		merr = merr + err.Error()
	}
	if _, err := conn.Incr(tableName, incr); err != nil {
		merr = merr + "|" + err.Error()
	}

	if merr != "" {
		return errors.New(merr)
	}

	return nil
}