當前位置: 首頁>>代碼示例>>Golang>>正文


Golang thrift.TMap類代碼示例

本文整理匯總了Golang中github.com/pomack/thrift4go/lib/go/src/thrift.TMap的典型用法代碼示例。如果您正苦於以下問題:Golang TMap類的具體用法?Golang TMap怎麽用?Golang TMap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TMap類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: rowFromTMapColumns

func rowFromTMapColumns(key []byte, tm thrift.TMap) *SuperRow {
	if tm == nil || tm.Len() <= 0 {
		return nil
	}
	r := &SuperRow{Key: key}

	for ele := range tm.Iter() {
		//fmt.Printf("K: %s V: %+v %T\n", ele.Key(), ele.Value(), ele.Value())
		tl := ele.Value().(thrift.TList)
		for colI := range tl.Iter() {
			var col *cassandra.ColumnOrSuperColumn = colI.(*cassandra.ColumnOrSuperColumn)
			row := &Row{Key: col.SuperColumn.Name}
			r.Rows = append(r.Rows, row)
			//fmt.Printf("\tSCName: %s\n", col.SuperColumn.Name)
			//fmt.Printf("Columns: %+v %T\n", col.SuperColumn.Columns, col.SuperColumn.Columns)
			for colX := range col.SuperColumn.Columns.Iter() {
				theRealCol := colX.(*cassandra.Column)
				c := &Column{
					Name:      theRealCol.Name,
					Value:     theRealCol.Value,
					Timestamp: theRealCol.Timestamp,
					Ttl:       theRealCol.Ttl,
				}
				row.Columns = append(row.Columns, c)
				//fmt.Printf("\t\tcol: %s %s\n",theRealCol.Name, theRealCol.Value)
			}
		}
	}
	return r
}
開發者ID:ngmoco,項目名稱:gossie,代碼行數:30,代碼來源:reader.go

示例2: rowsColumnCountFromTMap

func rowsColumnCountFromTMap(tm thrift.TMap) []*RowColumnCount {
	if tm == nil || tm.Len() <= 0 {
		return make([]*RowColumnCount, 0)
	}
	r := make([]*RowColumnCount, 0)
	for rowI := range tm.Iter() {
		key := keyFromTMap(rowI)
		count := int((rowI.Value()).(int32))
		if count > 0 {
			r = append(r, &RowColumnCount{Key: key, Count: count})
		}
	}
	return r
}
開發者ID:rcrowley,項目名稱:gossie,代碼行數:14,代碼來源:reader.go

示例3: rowsFromTMap

func rowsFromTMap(tm thrift.TMap) []*Row {
	if tm == nil || tm.Len() <= 0 {
		return make([]*Row, 0)
	}
	r := make([]*Row, 0)
	for rowI := range tm.Iter() {
		key := keyFromTMap(rowI)
		columns := (rowI.Value()).(thrift.TList)
		row := rowFromTListColumns(key, columns)
		if row != nil {
			r = append(r, row)
		}
	}
	return r
}
開發者ID:rcrowley,項目名稱:gossie,代碼行數:15,代碼來源:reader.go

示例4: addWriter

func (w *writer) addWriter(cf string, key []byte) *cassandra.Mutation {
	tm := cassandra.NewMutation()
	var cfMuts thrift.TMap
	im, exists := w.writers.Get(key)
	if !exists {
		cfMuts = thrift.NewTMap(thrift.STRING, thrift.LIST, 1)
		w.writers.Set(key, cfMuts)
	} else {
		cfMuts = im.(thrift.TMap)
	}
	var mutList thrift.TList
	im, exists = cfMuts.Get(cf)
	if !exists {
		mutList = thrift.NewTList(thrift.STRUCT, 1)
		cfMuts.Set(cf, mutList)
	} else {
		mutList = im.(thrift.TList)
	}
	mutList.Push(tm)
	return tm
}
開發者ID:carloscm,項目名稱:gossie,代碼行數:21,代碼來源:writer.go


注:本文中的github.com/pomack/thrift4go/lib/go/src/thrift.TMap類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。