Esempio n. 1
0
// getColumnFamily starts a read in a goroutine and returns a channel.
func getColumnFamily(cf string, pool gossie.ConnectionPool, rowKey string) <-chan rowResult {
	outChan := make(chan rowResult)

	go func() {
		glog.V(3).Infoln("Reading data for " + cf + " ...")
		row, err := pool.Reader().Cf(cf).Get([]byte(rowKey))
		if err != nil {
			outChan <- rowResult{nil, err}
		}
		outChan <- rowResult{row, nil}
	}()

	return outChan
}
Esempio n. 2
0
// getColumnFamilyRange starts a range read in a goroutine and returns a channel.
func getColumnFamilyRange(cf string, pool gossie.ConnectionPool, startPrefix string,
	endPrefix string, maxResults int) <-chan rowResults {
	outChan := make(chan rowResults)

	go func() {
		glog.V(3).Infoln("Reading data for " + cf + " ...")
		rows, err := pool.Reader().Cf(cf).ReturnNilRows(true).RangeGet(
			&gossie.Range{Start: []byte(startPrefix), End: []byte(endPrefix), Count: maxResults})
		if err != nil {
			outChan <- rowResults{nil, err}
		}
		outChan <- rowResults{rows, nil}
	}()

	return outChan
}