in cassandra-analytics-common/src/main/java/org/apache/cassandra/spark/sparksql/CellIterator.java [173:243]
private boolean getNext() throws IOException
{
while (scanner.next())
{
// If hasNext returns true, it indicates the partition keys has been loaded into the rid.
// Therefore, let's try to rebuild partition.
// Deserialize partition keys - if we have moved to a new partition - and update 'values' Object[] array.
maybeRebuildPartition();
scanner.advanceToNextColumn();
// Skip partition e.g. if token is outside of Spark worker token range
if (skipPartition)
{
continue;
}
// Deserialize clustering keys - if moved to new CQL row - and update 'values' Object[] array
ByteBuffer columnNameBuf = Objects.requireNonNull(rowData.getColumnName(), "ColumnName buffer in RowData is null, this is unexpected");
maybeRebuildClusteringKeys(columnNameBuf);
// Deserialize CQL field column name
ByteBuffer component = ByteBufferUtils.extractComponent(columnNameBuf, cqlTable.numClusteringKeys());
String columnName = decodeString(component);
if (columnName == null || columnName.isEmpty())
{
if (!hasProjectedValueColumns || !scanner.hasMoreColumns())
{
if (hasProjectedValueColumns)
{
// null out the value of the cell for the case where we have projected value columns
values[values.length - 1] = null;
}
// We use the position of a cell for a value column that is projected, or zero if no value
// columns are projected. The column we find is irrelevant because if we fall under this
// condition it means that we are in a situation where the row has only PK + CK, but no
// regular columns.
next = new Cell(values, firstProjectedValueColumnPositionOrZero, newRow, rowData.getTimestamp());
return true;
}
continue;
}
CqlField field = cqlTable.getField(columnName);
if (field == null)
{
LOGGER.warn("Ignoring unknown column columnName='{}'", columnName);
continue;
}
// Deserialize value field or static column and update 'values' Object[] array
deserializeField(field);
// Static column, so continue reading entire CQL row before returning
if (field.isStaticColumn())
{
continue;
}
// Update next Cell
next = new Cell(values, field.position(), newRow, rowData.getTimestamp());
return true;
}
// Finished so close
next = null;
close();
return false;
}