gortiz commented on code in PR #14264: URL: https://github.com/apache/pinot/pull/14264#discussion_r1818856485
########## pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/window/value/FirstValueWindowFunction.java: ########## @@ -78,12 +86,78 @@ private List<Object> processRowsWindow(List<Object[]> rows) { lowerBound++; upperBound = Math.min(upperBound + 1, numRows - 1); } + + return result; + } + + private List<Object> processRowsWindowIgnoreNulls(List<Object[]> rows) { + int numRows = rows.size(); + int lowerBound = _windowFrame.getLowerBound(); + int upperBound = Math.min(_windowFrame.getUpperBound(), numRows - 1); + + int indexOfFirstNonNullValue = -1; + // Find first non-null value in the first window + for (int i = Math.max(lowerBound, 0); i <= upperBound; i++) { + Object value = extractValueFromRow(rows.get(i)); + if (value != null) { + indexOfFirstNonNullValue = i; + break; + } Review Comment: This code is also repeated when the lower bound is moved. I think it is worth it to move the code to its own function. Something like `findFirstNotNullInWindow(rows, lowerBound, upperBound)`. Not only makes the code easier to read but also makes the job easier for the jit trying to optimize the loop. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org