// CHECKSTYLE:OFF MagicNumber @Override public Rating poll() { Preconditions.checkState(rating != null, "cursor is closed"); while (rowCursor.hasNext()) { String[] fields = rowCursor.next(); if (fields.length < 3) { logger.error("{}:{}: invalid input, skipping line", fileName, rowCursor.getLineNumber()); continue; } rating.setUserId(Long.parseLong(fields[0])); rating.setItemId(Long.parseLong(fields[1])); rating.setRating(Double.parseDouble(fields[2])); rating.setTimestamp(-1); if (fields.length >= 4) { rating.setTimestamp(Long.parseLong(fields[3])); } return rating; } return null; }
@Override public void close() { rowCursor.close(); rating = null; }