Lee con un filtro de rango de valores

Organiza tus páginas con colecciones Guarda y categoriza el contenido según tus preferencias.

Crea un filtro de límite en un rango de valores de celdas.

Explora más

Para obtener documentación en la que se incluye esta muestra de código, consulta lo siguiente:

Muestra de código

C++

Si deseas obtener información sobre cómo instalar y usar la biblioteca cliente para Bigtable, consulta Bibliotecas cliente de Bigtable.

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::Table table) {
  cbt::Filter filter = cbt::Filter::ValueRange("PQ2A.190405", "PQ2A.190406");
  // Read and print the rows.
  for (auto& row :
       table.ReadRows(cbt::RowSet(cbt::RowRange::InfiniteRange()), filter)) {
    if (!row) throw std::move(row).status();
    std::cout << row->row_key() << " = ";
    for (auto const& cell : row->cells()) {
      std::cout << "[" << cell.family_name() << ", "
                << cell.column_qualifier() << ", " << cell.value() << "],";
    }
    std::cout << "\n";
  }
}

C#

Si deseas obtener información sobre cómo instalar y usar la biblioteca cliente para Bigtable, consulta Bibliotecas cliente de Bigtable.

/// <summary>
/// /// Read using a value range filter from an existing table.
///</summary>
/// <param name="projectId">Your Google Cloud Project ID.</param>
/// <param name="instanceId">Your Google Cloud Bigtable Instance ID.</param>
/// <param name="tableId">Your Google Cloud Bigtable table ID.</param>

public string filterLimitValueRange(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID")
{
    // A filter that matches cells whose values are between the given values
    RowFilter filter = RowFilters.ValueRange(ValueRange.Closed("PQ2A.190405", "PQ2A.190406"));
    return readFilter(projectId, instanceId, tableId, filter);
}

Go

Si deseas obtener información sobre cómo instalar y usar la biblioteca cliente para Bigtable, consulta Bibliotecas cliente de Bigtable.

func filterLimitValueRange(w io.Writer, projectID, instanceID string, tableName string) error {
	filter := bigtable.ValueRangeFilter([]byte("PQ2A.190405"), []byte("PQ2A.190406"))
	return readWithFilter(w, projectID, instanceID, tableName, filter)
}

Java

Si deseas obtener información sobre cómo instalar y usar la biblioteca cliente para Bigtable, consulta Bibliotecas cliente de Bigtable.

public static void filterLimitValueRange() {
  // TODO(developer): Replace these variables before running the sample.
  String projectId = "my-project-id";
  String instanceId = "my-instance-id";
  String tableId = "mobile-time-series";
  filterLimitValueRange(projectId, instanceId, tableId);
}

public static void filterLimitValueRange(String projectId, String instanceId, String tableId) {
  // A filter that matches cells whose values are between the given values
  Filter filter = FILTERS.value().range().startClosed("PQ2A.190405").endClosed("PQ2A.190406");
  readFilter(projectId, instanceId, tableId, filter);
}

Node.js

Si deseas obtener información sobre cómo instalar y usar la biblioteca cliente para Bigtable, consulta Bibliotecas cliente de Bigtable.

const filter = {
  value: {
    start: 'PQ2A.190405',
    end: 'PQ2A.190406',
  },
};
readWithFilter(filter);

PHP

Si deseas obtener información sobre cómo instalar y usar la biblioteca cliente para Bigtable, consulta Bibliotecas cliente de Bigtable.

use Google\Cloud\Bigtable\BigtableClient;
use Google\Cloud\Bigtable\Filter;

/**
 * Create a limiting filter on a range of cell values
 *
 * @param string $projectId The Google Cloud project ID
 * @param string $instanceId The ID of the Bigtable instance
 * @param string $tableId The ID of the table to read from
 */
function filter_limit_value_range(
    string $projectId,
    string $instanceId,
    string $tableId
): void {
    // Connect to an existing table with an existing instance.
    $dataClient = new BigtableClient([
        'projectId' => $projectId,
    ]);
    $table = $dataClient->table($instanceId, $tableId);

    $filter = Filter::value()
        ->range()
        ->startClosed('PQ2A.190405')
        ->endOpen('PQ2A.190406');

    $rows = $table->readRows([
        'filter' => $filter
    ]);

    foreach ($rows as $key => $row) {
        // The "print_row" helper function is defined in https://cloud.google.com/bigtable/docs/samples/bigtable-reads-print
        print_row($key, $row);
    }
}

Python

Si deseas obtener información sobre cómo instalar y usar la biblioteca cliente para Bigtable, consulta Bibliotecas cliente de Bigtable.

def filter_limit_value_range(project_id, instance_id, table_id):
    client = bigtable.Client(project=project_id, admin=True)
    instance = client.instance(instance_id)
    table = instance.table(table_id)

    rows = table.read_rows(
        filter_=row_filters.ValueRangeFilter(b"PQ2A.190405", b"PQ2A.190406")
    )

    for row in rows:
        print_row(row)

Ruby

Si deseas obtener información sobre cómo instalar y usar la biblioteca cliente para Bigtable, consulta Bibliotecas cliente de Bigtable.

# instance_id = "my-instance"
# table_id    = "my-table"
range = Google::Cloud::Bigtable::ValueRange.new.from("PQ2A.190405").to("PQ2A.190406")
filter = Google::Cloud::Bigtable::RowFilter.value_range range
read_with_filter instance_id, table_id, filter

¿Qué sigue?

Para buscar y filtrar muestras de código en otros productos de Google Cloud, consulta el navegador de muestra de Google Cloud.