All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.scalar.db.sql.ResultSet Maven / Gradle / Ivy

There is a newer version: 3.14.0
Show newest version
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();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy