Hi,
Currently Optiq creates new array/custom class for Enumerable.current() method:
public Object current() {
final Object[] current = (Object[]) inputEnumerator.current();
return new Object[] {
net.hydromatic.optiq.runtime.SqlFunctions.toLong(current[4]) > 0L ? (Float) current[5] : (Float) null,
5,
(Float) current[6],
(Long) current[7],
(Long) current[8],
(Long) current[9],
(Long) current[10],
net.hydromatic.optiq.runtime.SqlFunctions.toInt(current[1]),
net.hydromatic.optiq.runtime.SqlFunctions.toInt(current[0])};
}
I wonder if we can optimize it to reuse the same row holder, but filling it with new data during each iteration.
I guess the following should be better in terms of number of allocated and thrown away objects:
final Object[] res = new Object[9];
public Object current() {
final Object[] current = (Object[]) inputEnumerator.current();
res[0] = net.hydromatic.optiq.runtime.SqlFunctions.toLong(current[4]) > 0L ? (Float) current[5] : (Float) null;
res[1] = 5;
res[2] = (Float) current[6],
res[3] = (Long) current[7],
res[4] = (Long) current[8],
res[5] = (Long) current[9],
res[6] = (Long) current[10],
res[7] = net.hydromatic.optiq.runtime.SqlFunctions.toInt(current[1]),
res[8] = net.hydromatic.optiq.runtime.SqlFunctions.toInt(current[0])};
return res;
}