com.scalar.db.sql.ResultSet Maven / Gradle / Ivy
package com.scalar.db.sql;
import com.google.common.collect.ImmutableList;
import java.util.List;
import java.util.Optional;
/** The result of statements. */
public interface ResultSet extends Iterable {
/**
* Returns the next record.
*
* @return the next record
*/
Optional one();
/**
* Returns all the remaining records as a list; not recommended for queries that return a large
* number of records.
*
* @return all the remaining records as a list
*/
default List all() {
ImmutableList.Builder builder = ImmutableList.builder();
while (true) {
Optional one = one();
if (!one.isPresent()) {
return builder.build();
}
builder.add(one.get());
}
}
/**
* Returns metadata about the columns returned by the statement.
*
* @return metadata about the columns returned by the statement
*/
ColumnDefinitions getColumnDefinitions();
}