예제 #1
0
파일: reader.go 프로젝트: hailocab/gossie
func (r *reader) IndexedGet(rang *IndexedRange) ([]*Row, error) {
	if r.cf == "" {
		return nil, errors.New("No column family specified")
	}

	if !r.setWhere {
		return nil, errors.New("At least one Where call must be made")
	}

	if rang == nil || rang.Count <= 0 {
		return make([]*Row, 0), nil
	}

	ic := r.buildIndexClause(rang)
	cp := r.buildColumnParent()
	sp := r.buildPredicate()

	var ret []*cassandra.KeySlice
	err := r.pool.run(func(c *connection) *transactionError {
		var err error
		ret, err = c.client.GetIndexedSlices(
			cp, ic, sp, cassandra.ConsistencyLevel(r.consistencyLevel))
		return &transactionError{err}
	})

	if err != nil {
		return nil, err
	}

	return rowsFromTListKeySlice(ret), nil
}
예제 #2
0
파일: reader.go 프로젝트: hailocab/gossie
func (r *reader) RangeGet(rang *Range) ([]*Row, error) {
	if r.cf == "" {
		return nil, errors.New("No column family specified")
	}

	if rang == nil || rang.Count <= 0 {
		return make([]*Row, 0), nil
	}

	kr := r.buildKeyRange(rang)
	cp := r.buildColumnParent()
	sp := r.buildPredicate()

	var ret []*cassandra.KeySlice
	err := r.pool.run(func(c *connection) *transactionError {
		var err error
		ret, err = c.client.GetRangeSlices(
			cp, sp, kr, cassandra.ConsistencyLevel(r.consistencyLevel))
		return &transactionError{err}
	})

	if err != nil {
		return nil, err
	}

	return rowsFromTListKeySlice(ret), nil
}
예제 #3
0
파일: reader.go 프로젝트: hailocab/gossie
func (r *reader) MultiCount(keys [][]byte) ([]*RowColumnCount, error) {
	if r.cf == "" {
		return nil, errors.New("No column family specified")
	}

	if len(keys) <= 0 {
		return make([]*RowColumnCount, 0), nil
	}

	cp := r.buildColumnParent()
	sp := r.buildPredicate()
	tk := keys

	var ret map[string]int32
	err := r.pool.run(func(c *connection) *transactionError {
		var err error
		ret, err = c.client.MultigetCount(
			tk, cp, sp, cassandra.ConsistencyLevel(r.consistencyLevel))
		return &transactionError{err}
	})

	if err != nil {
		return nil, err
	}

	return rowsColumnCountFromTMap(ret), nil
}
예제 #4
0
파일: writer.go 프로젝트: hailocab/gossie
func (w *writer) Run() error {
	toRun := func(c *connection) *transactionError {
		err := c.client.BatchMutate(
			w.writers, cassandra.ConsistencyLevel(w.consistencyLevel))
		return &transactionError{err}
	}
	if w.usedCounters {
		return w.pool.runWithRetries(toRun, 1)
	}
	return w.pool.run(toRun)
}
예제 #5
0
파일: reader.go 프로젝트: hailocab/gossie
func (r *reader) Count(key []byte) (int, error) {
	if r.cf == "" {
		return 0, errors.New("No column family specified")
	}

	cp := r.buildColumnParent()
	sp := r.buildPredicate()

	var ret int32
	err := r.pool.run(func(c *connection) *transactionError {
		var err error
		ret, err = c.client.GetCount(
			key, cp, sp, cassandra.ConsistencyLevel(r.consistencyLevel))
		return &transactionError{err}
	})

	if err != nil {
		return 0, err
	}

	return int(ret), nil
}
예제 #6
0
파일: reader.go 프로젝트: hailocab/gossie
func (r *reader) Get(key []byte) (*Row, error) {
	if r.cf == "" {
		return nil, errors.New("No column family specified")
	}

	cp := r.buildColumnParent()
	sp := r.buildPredicate()

	var ret []*cassandra.ColumnOrSuperColumn
	err := r.pool.run(func(c *connection) *transactionError {
		var err error
		ret, err = c.client.GetSlice(
			key, cp, sp, cassandra.ConsistencyLevel(r.consistencyLevel))
		return &transactionError{err}
	})

	if err != nil {
		return nil, err
	}

	return rowFromTListColumns(key, ret), nil
}