func (n *unionNode) readLeft() (bool, error) { next, err := n.left.Next() for ; next; next, err = n.left.Next() { if n.explain == explainDebug { n.debugVals = n.left.DebugValues() if n.debugVals.output != debugValueRow { // Pass through any non-row debug info. return true, nil } } if n.emitAll { return true, nil } n.scratch = n.scratch[:0] if n.scratch, err = sqlbase.EncodeDTuple(n.scratch, n.left.Values()); err != nil { return false, err } if n.emit.emitLeft(n.scratch) { return true, nil } if n.explain == explainDebug { // Mark the row as filtered out. n.debugVals.output = debugValueFiltered return true, nil } } if err != nil { return false, err } n.leftDone = true n.left.Close() return false, nil }
func (n *unionNode) readRight() (bool, error) { next, err := n.right.Next() for ; next; next, err = n.right.Next() { if n.explain == explainDebug { n.debugVals = n.right.DebugValues() if n.debugVals.output != debugValueRow { // Pass through any non-row debug info. return true, nil } } if n.emitAll { return true, nil } n.scratch = n.scratch[:0] if n.scratch, err = sqlbase.EncodeDTuple(n.scratch, n.right.Values()); err != nil { return false, err } // TODO(dan): Sending the entire encodeDTuple to be stored in the map would // use a lot of memory for big rows or big resultsets. Consider using a hash // of the bytes instead. if n.emit.emitRight(n.scratch) { return true, nil } if n.explain == explainDebug { // Mark the row as filtered out. n.debugVals.output = debugValueFiltered return true, nil } } if err != nil { return false, err } n.rightDone = true n.right.Close() return n.readLeft() }