MCPcopy
hub / github.com/cayleygraph/cayley / scanValue

Method scanValue

graph/sql/iterator.go:202–239  ·  view source on GitHub ↗
(r *sql.Rows)

Source from the content-addressed store, hash-verified

200}
201
202func (it *iteratorBase) scanValue(r *sql.Rows) bool {
203 it.ensureColumns()
204 nodes := make([]NodeHash, len(it.cols))
205 pointers := make([]interface{}, len(nodes))
206 for i := range pointers {
207 pointers[i] = &nodes[i]
208 }
209 if err := r.Scan(pointers...); err != nil {
210 it.err = err
211 return false
212 }
213 it.tags = make(map[string]graph.Ref)
214 for i, name := range it.cols {
215 if !strings.Contains(name, tagPref) {
216 it.tags[name] = nodes[i].ValueHash
217 }
218 }
219 if len(it.cind) > 1 {
220 var q QuadHashes
221 for _, d := range quad.Directions {
222 i, ok := it.cind[d]
223 if !ok {
224 it.err = fmt.Errorf("cannot find quad %v in query output (columns: %v)", d, it.cols)
225 return false
226 }
227 q.Set(d, nodes[i].ValueHash)
228 }
229 it.res = q
230 return true
231 }
232 i, ok := it.cind[quad.Any]
233 if !ok {
234 it.err = fmt.Errorf("cannot find node hash in query output (columns: %v, cind: %v)", it.cols, it.cind)
235 return false
236 }
237 it.res = nodes[i]
238 return true
239}
240
241func (it *iteratorBase) Err() error {
242 return it.err

Callers 4

NextMethod · 0.80
NextPathMethod · 0.80
ContainsMethod · 0.80
NextPathMethod · 0.80

Calls 5

ensureColumnsMethod · 0.95
ContainsMethod · 0.65
ErrorfMethod · 0.65
ScanMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected