Example #1
0
func (n *unionNode) readLeft() bool {
	for 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
			}
		}

		if n.emitAll {
			return true
		}
		n.scratch = n.scratch[:0]
		if n.scratch, n.err = sqlbase.EncodeDTuple(n.scratch, n.left.Values()); n.err != nil {
			return false
		}
		if n.emit.emitLeft(n.scratch) {
			return true
		}
		if n.explain == explainDebug {
			// Mark the row as filtered out.
			n.debugVals.output = debugValueFiltered
			return true
		}
	}
	n.leftDone = true
	return false
}
Example #2
0
func (n *unionNode) readRight() bool {
	for 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
			}
		}

		if n.emitAll {
			return true
		}
		n.scratch = n.scratch[:0]
		if n.scratch, n.err = sqlbase.EncodeDTuple(n.scratch, n.right.Values()); n.err != nil {
			return false
		}
		// 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
		}
		if n.explain == explainDebug {
			// Mark the row as filtered out.
			n.debugVals.output = debugValueFiltered
			return true
		}
	}

	n.rightDone = true
	return n.readLeft()
}