Use filtros

O Bigtable oferece os seguintes tipos de filtros:

Esta página descreve detalhadamente cada filtro do Bigtable e mostra como usar cada tipo de filtro através das bibliotecas de cliente da Google Cloud. Antes de ler esta página, leia o artigo Filtros.

Pode encontrar exemplos adicionais que mostram como usar filtros para ler várias linhas de dados no artigo Ler dados.

Dados para exemplos

Os exemplos nesta página partem do princípio de que está a armazenar dados de séries cronológicas para smartphones e tablets, e que os seguintes dados foram escritos numa tabela. A tabela tem duas famílias de colunas, stats_summary e cell_plan. Cada família de colunas tem três colunas.

stats_summary cell_plan
chave da linha connected_cell connected_wifi os_build data_plan_01gb data_plan_05gb data_plan_10gb
phone#4c410523#20190501 1 1 PQ2A.190405.003 true@time menos uma hora

False @time
verdadeiro
phone#4c410523#20190502 1 1 PQ2A.190405.004 verdadeiro
phone#4c410523#20190505 0 1 PQ2A.190406.000 verdadeiro
phone#5c10102#20190501 1 1 PQ2A.190401.002 verdadeiro
phone#5c10102#20190502 1 0 PQ2A.190406.000 verdadeiro

Limitar filtros

As secções seguintes descrevem cada filtro de limitação. Os filtros de limitação controlam que linhas ou células são incluídas na resposta, com base na correspondência com critérios específicos.

Quando usa uma cadeia para combinar vários filtros de limitação, tenha em atenção que a linha de entrada para cada filtro na cadeia é a linha de saída do filtro anterior na cadeia. Por exemplo, se encadear dois filtros e o primeiro filtro gerar apenas duas das células da linha original, o segundo filtro vê apenas essas duas células.

Filtros de seleção de linhas

Esta secção descreve os filtros que pode usar para obter linhas numa tabela.

Amostra de linha

Este filtro permite-lhe obter uma amostra aleatória de linhas num determinado intervalo. Com base numa probabilidade que especificar, o filtro escolhe aleatoriamente se a linha de saída deve ser igual à linha de entrada ou se deve ser omitida dos resultados.

Go

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

func filterLimitRowSample(w io.Writer, projectID, instanceID string, tableName string) error {
	filter := bigtable.RowSampleFilter(.75)
	return readWithFilter(w, projectID, instanceID, tableName, filter)
}

HBase

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitRowSample(String projectId, String instanceId, String tableId) {
  // A filter that matches cells from a row with probability .75
  Filter filter = new RandomRowFilter(.75f);
  Scan scan = new Scan().setFilter(filter);
  readWithFilter(projectId, instanceId, tableId, scan);
}

Java

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitRowSample(String projectId, String instanceId, String tableId) {
  // A filter that matches cells from a row with probability .75
  Filter filter = FILTERS.key().sample(.75);
  readFilter(projectId, instanceId, tableId, filter);
}

Python

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

def filter_limit_row_sample(project_id, instance_id, table_id):
    from google.cloud import bigtable
    from google.cloud.bigtable import row_filters

    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.RowSampleFilter(0.75))
    for row in rows:
        print_row(row)

Python asyncio

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

async def filter_limit_row_sample(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(row_filter=row_filters.RowSampleFilter(0.75))

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)

C#

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

/// <summary>
/// /// Read using a row sample 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 Task<string> FilterLimitRowSample(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID")
{
    // A filter that matches cells from a row with probability .75
    RowFilter filter = RowFilters.RowSample(.75);
    return ReadFilter(projectId, instanceId, tableId, filter);
}

C++

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::Table table) {
  // Filter the results, only include rows with a given probability
  cbt::Filter filter = cbt::Filter::RowSample(0.75);

  // Read and print the rows.
  for (StatusOr<cbt::Row>& 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";
  }
}

Node.js

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

const filter = {
  row: {
    sample: 0.75,
  },
};
readWithFilter(filter);

PHP

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

/**
 * Create a limiting filter on rows using a random sampling
 *
 * @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_row_sample(
    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::key()->sample(.75);

    $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);
    }
}

Ruby

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

# instance_id = "my-instance"
# table_id    = "my-table"
filter = Google::Cloud::Bigtable::RowFilter.sample 0.75
read_with_filter instance_id, table_id, filter

Regex da chave da linha

Este filtro verifica se a chave da linha da linha de entrada corresponde a uma expressão regular. A expressão regular tem de usar a sintaxe RE2. Uma vez que as chaves de linhas podem conter bytes arbitrários, use \C como a expressão de caráter universal em vez da expressão . para corresponder a qualquer caráter, incluindo novas linhas.

Para melhorar o desempenho, o Bigtable tenta otimizar o filtro extraindo um prefixo literal do início da expressão regular. Se for identificado um prefixo, o Bigtable restringe a pesquisa ao intervalo de chaves que começa com esse prefixo, evitando uma análise completa da tabela.

Esta otimização só ocorre nas seguintes condições:

  • O prefixo só pode conter carateres alfanuméricos e os seguintes símbolos sem escape: -, _, : e ,.
  • A extração do prefixo para no primeiro caráter sem escape que não esteja no conjunto permitido. Por exemplo, os separadores de chaves comuns, como um cardinal (#) ou os metacarateres de expressões regulares, como um ponto sem caráter de escape (.), interrompem a extração. Para incluir carateres especiais no prefixo otimizado, interprete-os de forma literal com uma barra invertida (\) ou use funções da biblioteca cliente RE2, como RE2.quoteMeta em Java.
  • O carater de barra vertical (|) não é suportado.

Se a sua expressão regular não puder ser resolvida para um prefixo literal, por exemplo, se começar com um caráter universal ou procurar uma substring, o Bigtable requer uma análise completa da tabela.

Go

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

func filterLimitRowRegex(w io.Writer, projectID, instanceID string, tableName string) error {
	filter := bigtable.RowKeyFilter(".*#20190501$")
	return readWithFilter(w, projectID, instanceID, tableName, filter)
}

HBase

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitRowRegex(String projectId, String instanceId, String tableId) {
  // A filter that matches cells from rows whose keys satisfy the given regex
  Filter filter = new RowFilter(CompareOp.EQUAL, new RegexStringComparator(".*#20190501$"));
  Scan scan = new Scan().setFilter(filter).setMaxVersions();
  readWithFilter(projectId, instanceId, tableId, scan);
}

Java

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitRowRegex(String projectId, String instanceId, String tableId) {
  // A filter that matches cells from rows whose keys satisfy the given regex
  Filter filter = FILTERS.key().regex(".*#20190501$");
  readFilter(projectId, instanceId, tableId, filter);
}

Python

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

def filter_limit_row_regex(project_id, instance_id, table_id):
    from google.cloud import bigtable
    from google.cloud.bigtable import row_filters

    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.RowKeyRegexFilter(".*#20190501$".encode("utf-8"))
    )
    for row in rows:
        print_row(row)

Python asyncio

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

async def filter_limit_row_regex(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(
        row_filter=row_filters.RowKeyRegexFilter(".*#20190501$".encode("utf-8"))
    )

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)

C#

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

/// <summary>
/// /// Read using a row regex 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 Task<string> FilterLimitRowRegex(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID")
{
    // A filter that matches cells from rows whose keys satisfy the given regex
    RowFilter filter = RowFilters.RowKeyRegex(".*#20190501$");
    return ReadFilter(projectId, instanceId, tableId, filter);
}

C++

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::Table table) {
  // Filter the results, only include rows where row_key matches given regular
  // expression
  cbt::Filter filter = cbt::Filter::RowKeysRegex(".*#20190501$");
  // Read and print the rows.
  for (StatusOr<cbt::Row>& 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";
  }
}

Node.js

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

const filter = {
  row: /.*#20190501$/,
};
readWithFilter(filter);

PHP

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

/**
 * Create a limiting filter on a cell value using a regex
 *
 * @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_row_regex(
    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::key()->regex('.*#20190501$');

    $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);
    }
}

Ruby

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

# instance_id = "my-instance"
# table_id    = "my-table"
filter = Google::Cloud::Bigtable::RowFilter.key ".*#20190501$"
read_with_filter instance_id, table_id, filter

Filtros de seleção de células

Esta secção descreve os filtros que pode usar para obter células numa tabela.

Limite de células por coluna

Este filtro limita o número de células em cada coluna que são incluídas na linha de saída. Quando este filtro é aplicado, cada linha de saída inclui as N células mais recentes de cada coluna e omite todas as outras células dessa coluna.

Se também estiver a usar um filtro de intercalação e o filtro de intercalação produzir cópias duplicadas de uma célula, cada cópia conta para o limite.

Go

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

func filterLimitCellsPerCol(w io.Writer, projectID, instanceID string, tableName string) error {
	filter := bigtable.LatestNFilter(2)
	return readWithFilter(w, projectID, instanceID, tableName, filter)
}

HBase

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitCellsPerCol(String projectId, String instanceId, String tableId) {
  // A filter that matches only the most recent 2 cells within each column
  Scan scan = new Scan().setMaxVersions(2);
  readWithFilter(projectId, instanceId, tableId, scan);
}

Java

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitCellsPerCol(String projectId, String instanceId, String tableId) {
  // A filter that matches only the most recent 2 cells within each column
  Filter filter = FILTERS.limit().cellsPerColumn(2);
  readFilter(projectId, instanceId, tableId, filter);
}

Python

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

def filter_limit_cells_per_col(project_id, instance_id, table_id):
    from google.cloud import bigtable
    from google.cloud.bigtable import row_filters

    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.CellsColumnLimitFilter(2))
    for row in rows:
        print_row(row)

Python ayncio

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

# Copyright 2024, Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


async def filter_limit_row_sample(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(row_filter=row_filters.RowSampleFilter(0.75))

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)


async def filter_limit_row_regex(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(
        row_filter=row_filters.RowKeyRegexFilter(".*#20190501$".encode("utf-8"))
    )

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)


async def filter_limit_cells_per_col(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(row_filter=row_filters.CellsColumnLimitFilter(2))

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)


async def filter_limit_cells_per_row(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(row_filter=row_filters.CellsRowLimitFilter(2))

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)


async def filter_limit_cells_per_row_offset(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(row_filter=row_filters.CellsRowOffsetFilter(2))

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)


async def filter_limit_col_family_regex(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(
        row_filter=row_filters.FamilyNameRegexFilter("stats_.*$".encode("utf-8"))
    )

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)


async def filter_limit_col_qualifier_regex(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(
        row_filter=row_filters.ColumnQualifierRegexFilter(
            "connected_.*$".encode("utf-8")
        )
    )

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)


async def filter_limit_col_range(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(
        row_filter=row_filters.ColumnRangeFilter(
            "cell_plan", b"data_plan_01gb", b"data_plan_10gb", inclusive_end=False
        )
    )

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)


async def filter_limit_value_range(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(
        row_filter=row_filters.ValueRangeFilter(b"PQ2A.190405", b"PQ2A.190406")
    )

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)




async def filter_limit_value_regex(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(
        row_filter=row_filters.ValueRegexFilter("PQ2A.*$".encode("utf-8"))
    )

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)


async def filter_limit_timestamp_range(project_id, instance_id, table_id):
    import datetime

    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    end = datetime.datetime(2019, 5, 1)

    query = ReadRowsQuery(row_filter=row_filters.TimestampRangeFilter(end=end))

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)


async def filter_limit_block_all(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(row_filter=row_filters.BlockAllFilter(True))

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)


async def filter_limit_pass_all(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(row_filter=row_filters.PassAllFilter(True))

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)


async def filter_modify_strip_value(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(row_filter=row_filters.StripValueTransformerFilter(True))

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)


async def filter_modify_apply_label(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(row_filter=row_filters.ApplyLabelFilter(label="labelled"))

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)


async def filter_composing_chain(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(
        row_filter=row_filters.RowFilterChain(
            filters=[
                row_filters.CellsColumnLimitFilter(1),
                row_filters.FamilyNameRegexFilter("cell_plan"),
            ]
        )
    )

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)


async def filter_composing_interleave(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(
        row_filter=row_filters.RowFilterUnion(
            filters=[
                row_filters.ValueRegexFilter("true"),
                row_filters.ColumnQualifierRegexFilter("os_build"),
            ]
        )
    )

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)


async def filter_composing_condition(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(
        row_filter=row_filters.ConditionalRowFilter(
            predicate_filter=row_filters.RowFilterChain(
                filters=[
                    row_filters.ColumnQualifierRegexFilter("data_plan_10gb"),
                    row_filters.ValueRegexFilter("true"),
                ]
            ),
            true_filter=row_filters.ApplyLabelFilter(label="passed-filter"),
            false_filter=row_filters.ApplyLabelFilter(label="filtered-out"),
        )
    )

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)




def print_row(row):
    from google.cloud._helpers import _datetime_from_microseconds

    print("Reading data for {}:".format(row.row_key.decode("utf-8")))
    last_family = None
    for cell in row.cells:
        if last_family != cell.family:
            print("Column Family {}".format(cell.family))
            last_family = cell.family

        labels = " [{}]".format(",".join(cell.labels)) if len(cell.labels) else ""
        print(
            "\t{}: {} @{}{}".format(
                cell.qualifier.decode("utf-8"),
                cell.value.decode("utf-8"),
                _datetime_from_microseconds(cell.timestamp_micros),
                labels,
            )
        )
    print("")

C#

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

/// <summary>
/// /// Read using a cells per column 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 Task<string> FilterLimitCellsPerCol(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID")
{
    // A filter that matches only the most recent 2 cells within each column
    RowFilter filter = RowFilters.CellsPerColumnLimit(2);
    return ReadFilter(projectId, instanceId, tableId, filter);
}

C++

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::Table table) {
  // Filter the results, only include limited cells
  cbt::Filter filter = cbt::Filter::Latest(2);
  // Read and print the rows.
  for (StatusOr<cbt::Row>& 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";
  }
}

Node.js

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

const filter = {
  column: {
    cellLimit: 2,
  },
};
readWithFilter(filter);

PHP

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

/**
 * Create a limiting filter on cells per column
 *
 * @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_cells_per_col(
    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::limit()->cellsPerColumn(2);

    $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);
    }
}

Ruby

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

# instance_id = "my-instance"
# table_id    = "my-table"
filter = Google::Cloud::Bigtable::RowFilter.cells_per_column 2
read_with_filter instance_id, table_id, filter

Limite de células por linha

Este filtro limita o número de células em cada linha de saída. Quando este filtro é aplicado, cada linha de saída inclui as primeiras N células da linha de entrada e omite todas as células seguintes dessa linha. As primeiras N células são lidas, independentemente da coluna em que se encontram, pela ordem em que são armazenadas no Bigtable.

Para saber como os dados são armazenados no Bigtable, consulte as práticas recomendadas de criação de esquemas.

Uma coluna numa linha pode conter várias células. Cada célula contém um valor para a coluna e um carimbo de data/hora único. Como resultado, limitar uma linha a N células pode ser diferente de obter as primeiras N colunas da linha. Por exemplo, se usar um filtro com um limite de 20 células por linha para ler uma linha com 30 colunas e cada coluna tiver 10 células com data/hora, a linha de saída devolve valores apenas das duas primeiras colunas na linha (2 * 10 = 20).

A utilização deste filtro em combinação com um filtro de deslocamento é útil para a paginação se precisar de ler uma linha grande.

Go

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

func filterLimitCellsPerRow(w io.Writer, projectID, instanceID string, tableName string) error {
	filter := bigtable.CellsPerRowLimitFilter(2)
	return readWithFilter(w, projectID, instanceID, tableName, filter)
}

HBase

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitCellsPerRow(String projectId, String instanceId, String tableId) {
  // A filter that matches the first 2 cells of each row
  //    Filter filter = new ColumnCountGetFilter(2);
  Filter filter = new ColumnPaginationFilter(2, 0);

  Scan scan = new Scan().setFilter(filter);
  readWithFilter(projectId, instanceId, tableId, scan);
}

Java

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitCellsPerRow(String projectId, String instanceId, String tableId) {
  // A filter that matches the first 2 cells of each row
  Filter filter = FILTERS.limit().cellsPerRow(2);
  readFilter(projectId, instanceId, tableId, filter);
}

Python

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

def filter_limit_cells_per_row(project_id, instance_id, table_id):
    from google.cloud import bigtable
    from google.cloud.bigtable import row_filters

    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.CellsRowLimitFilter(2))
    for row in rows:
        print_row(row)

Python asyncio

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

async def filter_limit_cells_per_row(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(row_filter=row_filters.CellsRowLimitFilter(2))

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)

C#

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

/// <summary>
/// /// Read using a cells per row 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 Task<string> FilterLimitCellsPerRow(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID")
{
    // A filter that matches the first 2 cells of each row
    RowFilter filter = RowFilters.CellsPerRowLimit(2);
    return ReadFilter(projectId, instanceId, tableId, filter);
}

C++

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::Table table) {
  // Filter the results, only include limited cells per row
  cbt::Filter filter = cbt::Filter::CellsRowLimit(2);
  // Read and print the rows.
  for (StatusOr<cbt::Row>& 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";
  }
}

Node.js

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

const filter = {
  row: {
    cellLimit: 2,
  },
};
readWithFilter(filter);

PHP

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

/**
 * Create a limiting filter on cells per row
 *
 * @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_cells_per_row(
    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::limit()->cellsPerRow(2);

    $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);
    }
}

Ruby

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

# instance_id = "my-instance"
# table_id    = "my-table"
filter = Google::Cloud::Bigtable::RowFilter.cells_per_row 2
read_with_filter instance_id, table_id, filter

Desvio de células por linha

Este filtro omite as primeiras N células de cada linha de saída. Todas as células restantes são incluídas na linha de saída. As primeiras N células são ignoradas, independentemente da coluna em que se encontram.

Uma coluna numa linha pode conter várias células. Cada célula contém um valor para a coluna e um carimbo de data/hora único. Como resultado, ignorar as primeiras N células de uma linha pode ser diferente de ignorar as primeiras N colunas na linha. Por exemplo, se usar um filtro com um desvio de 20 células por linha para ler uma linha com 30 colunas e cada coluna tiver 10 células com data/hora, a linha de saída devolve valores de todas as células na linha, exceto as das duas primeiras colunas (2 * 10 = 20).

Se também estiver a usar um filtro de intercalação e o filtro de intercalação produzir cópias duplicadas de uma célula, cada cópia conta para o desvio.

Go

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

func filterLimitCellsPerRowOffset(w io.Writer, projectID, instanceID string, tableName string) error {
	filter := bigtable.CellsPerRowOffsetFilter(2)
	return readWithFilter(w, projectID, instanceID, tableName, filter)
}

HBase

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitCellsPerRowOffset(
    String projectId, String instanceId, String tableId) {
  // A filter that skips the first 2 cells per row
  Filter filter = new ColumnPaginationFilter(Integer.MAX_VALUE, 2);
  Scan scan = new Scan().setFilter(filter);
  readWithFilter(projectId, instanceId, tableId, scan);
}

Java

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitCellsPerRowOffset(
    String projectId, String instanceId, String tableId) {
  // A filter that skips the first 2 cells per row
  Filter filter = FILTERS.offset().cellsPerRow(2);
  readFilter(projectId, instanceId, tableId, filter);
}

Python

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

def filter_limit_cells_per_row_offset(project_id, instance_id, table_id):
    from google.cloud import bigtable
    from google.cloud.bigtable import row_filters

    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.CellsRowOffsetFilter(2))
    for row in rows:
        print_row(row)

Python asyncio

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

async def filter_limit_cells_per_row_offset(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(row_filter=row_filters.CellsRowOffsetFilter(2))

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)

C#

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

/// <summary>
/// /// Read using a cells per row offset 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 Task<string> FilterLimitCellsPerRowOffset(string projectId, string instanceId, string tableId)
{
    // A filter that skips the first 2 cells per row
    RowFilter filter = RowFilters.CellsPerRowOffset(2);
    return ReadFilter(projectId, instanceId, tableId, filter);
}

C++

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::Table table) {
  cbt::Filter filter = cbt::Filter::CellsRowOffset(2);
  // Read and print the rows.
  for (StatusOr<cbt::Row>& 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";
  }
}

Node.js

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

const filter = {
  row: {
    cellOffset: 2,
  },
};
readWithFilter(filter);

PHP

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

/**
 * Create a limiting filter offsetting cells per row
 *
 * @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_cells_per_row_offset(
    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::offset()->cellsPerRow(2);

    $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);
    }
}

Ruby

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

# instance_id = "my-instance"
# table_id    = "my-table"
filter = Google::Cloud::Bigtable::RowFilter.cells_per_row_offset 2
read_with_filter instance_id, table_id, filter

Regex da família de colunas

Este filtro inclui células na linha de saída apenas se a família de colunas de uma célula corresponder a uma expressão regular.

A expressão regular tem de usar a sintaxe RE2. A expressão regular não pode conter o caráter :, mesmo que o caráter não seja usado como um literal. Uma vez que as famílias de colunas não podem conter carateres de nova linha, pode usar . ou \C como expressão universal.

Go

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

func filterLimitColFamilyRegex(w io.Writer, projectID, instanceID string, tableName string) error {
	filter := bigtable.FamilyFilter("stats_.*$")
	return readWithFilter(w, projectID, instanceID, tableName, filter)
}

HBase

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitColFamilyRegex(
    String projectId, String instanceId, String tableId) {
  // A filter that matches cells whose column family satisfies the given regex
  Filter filter = new FamilyFilter(CompareOp.EQUAL, new RegexStringComparator("stats_.*$"));
  Scan scan = new Scan().setFilter(filter);
  readWithFilter(projectId, instanceId, tableId, scan);
}

Java

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitColFamilyRegex(
    String projectId, String instanceId, String tableId) {
  // A filter that matches cells whose column family satisfies the given regex
  Filter filter = FILTERS.family().regex("stats_.*$");
  readFilter(projectId, instanceId, tableId, filter);
}

Python

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

def filter_limit_col_family_regex(project_id, instance_id, table_id):
    from google.cloud import bigtable
    from google.cloud.bigtable import row_filters

    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.FamilyNameRegexFilter("stats_.*$".encode("utf-8"))
    )
    for row in rows:
        print_row(row)

Python asyncio

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

async def filter_limit_col_family_regex(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(
        row_filter=row_filters.FamilyNameRegexFilter("stats_.*$".encode("utf-8"))
    )

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)

C#

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

/// <summary>
/// /// Read using a family regex 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 Task<string> FilterLimitColFamilyRegex(string projectId, string instanceId, string tableId)
{
    // A filter that matches cells whose column family satisfies the given regex
    RowFilter filter = RowFilters.FamilyNameRegex("stats_.*$");
    return ReadFilter(projectId, instanceId, tableId, filter);
}

C++

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::Table table) {
  cbt::Filter filter = cbt::Filter::FamilyRegex("stats_.*$");
  // Read and print the rows.
  for (StatusOr<cbt::Row>& 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";
  }
}

Node.js

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

const filter = {
  family: /stats_.*$/,
};
readWithFilter(filter);

PHP

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

/**
 * Create a limiting filter on a column family with a regex
 *
 * @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_col_family_regex(
    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::family()->regex('stats_.*$');

    $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);
    }
}

Ruby

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

# instance_id = "my-instance"
# table_id    = "my-table"
filter = Google::Cloud::Bigtable::RowFilter.family "stats_.*$"
read_with_filter instance_id, table_id, filter

Regex do qualificador da coluna

Este filtro inclui células na linha de saída apenas se o qualificador de coluna de uma célula corresponder a uma expressão regular.

A expressão regular tem de usar a sintaxe RE2. Uma vez que os qualificadores de coluna podem conter bytes arbitrários, incluindo carateres de nova linha, deve usar \C como a expressão de caráter universal na maioria dos casos. A expressão . não corresponde a carateres de nova linha.

Go

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

func filterLimitColQualifierRegex(w io.Writer, projectID, instanceID string, tableName string) error {
	filter := bigtable.ColumnFilter("connected_.*$")
	return readWithFilter(w, projectID, instanceID, tableName, filter)
}

HBase

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitColQualifierRegex(
    String projectId, String instanceId, String tableId) {
  // A filter that matches cells whose column qualifier satisfies the given regex
  Filter filter =
      new QualifierFilter(CompareOp.EQUAL, new RegexStringComparator("connected_.*$"));
  Scan scan = new Scan().setFilter(filter);
  readWithFilter(projectId, instanceId, tableId, scan);
}

Java

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitColQualifierRegex(
    String projectId, String instanceId, String tableId) {
  // A filter that matches cells whose column qualifier satisfies the given regex
  Filter filter = FILTERS.qualifier().regex("connected_.*$");
  readFilter(projectId, instanceId, tableId, filter);
}

Python

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

def filter_limit_col_qualifier_regex(project_id, instance_id, table_id):
    from google.cloud import bigtable
    from google.cloud.bigtable import row_filters

    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.ColumnQualifierRegexFilter("connected_.*$".encode("utf-8"))
    )
    for row in rows:
        print_row(row)

Python asyncio

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

async def filter_limit_col_qualifier_regex(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(
        row_filter=row_filters.ColumnQualifierRegexFilter(
            "connected_.*$".encode("utf-8")
        )
    )

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)

C#

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

/// <summary>
/// /// Read using a qualifier regex 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 Task<string> FilterLimitColQualifierRegex(string projectId, string instanceId, string tableId)
{
    // A filter that matches cells whose column qualifier satisfies the given regex
    RowFilter filter = RowFilters.ColumnQualifierRegex("connected_.*$");
    return ReadFilter(projectId, instanceId, tableId, filter);
}

C++

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::Table table) {
  cbt::Filter filter = cbt::Filter::ColumnRegex("connected_.*$");
  // Read and print the rows.
  for (StatusOr<cbt::Row>& 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";
  }
}

Node.js

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

const filter = {
  column: /connected_.*$/,
};
readWithFilter(filter);

PHP

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

/**
 * Create a limiting filter on a column qualifier with a regex
 *
 * @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_col_qualifier_regex(
    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::qualifier()->regex('connected_.*$');

    $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);
    }
}

Ruby

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

# instance_id = "my-instance"
# table_id    = "my-table"
filter = Google::Cloud::Bigtable::RowFilter.qualifier "connected_.*$"
read_with_filter instance_id, table_id, filter

Intervalo de colunas

Este filtro inclui células na linha de saída apenas se estiverem numa família de colunas específica e apenas se os respetivos qualificadores de colunas estiverem num intervalo específico. Especifica o intervalo indicando um qualificador de início e um qualificador de fim.

Go

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

func filterLimitColRange(w io.Writer, projectID, instanceID string, tableName string) error {
	filter := bigtable.ColumnRangeFilter("cell_plan", "data_plan_01gb", "data_plan_10gb")
	return readWithFilter(w, projectID, instanceID, tableName, filter)
}

HBase

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitColRange(String projectId, String instanceId, String tableId) {
  // A filter that matches cells whose column qualifiers are between data_plan_01gb and
  // data_plan_10gb in the column family cell_plan
  Filter filter =
      new ColumnRangeFilter(
          Bytes.toBytes("data_plan_01gb"), true, Bytes.toBytes("data_plan_10gb"), false);
  Scan scan = new Scan().addFamily(Bytes.toBytes("cell_plan")).setFilter(filter).setMaxVersions();
  readWithFilter(projectId, instanceId, tableId, scan);
}

Java

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitColRange(String projectId, String instanceId, String tableId) {
  // A filter that matches cells whose column qualifiers are between data_plan_01gb and
  // data_plan_10gb in the column family cell_plan
  Filter filter =
      FILTERS
          .qualifier()
          .rangeWithinFamily("cell_plan")
          .startClosed("data_plan_01gb")
          .endOpen("data_plan_10gb");
  readFilter(projectId, instanceId, tableId, filter);
}

Python

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

def filter_limit_col_range(project_id, instance_id, table_id):
    from google.cloud import bigtable
    from google.cloud.bigtable import row_filters

    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.ColumnRangeFilter(
            "cell_plan", b"data_plan_01gb", b"data_plan_10gb", inclusive_end=False
        )
    )
    for row in rows:
        print_row(row)

Python asyncio

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

async def filter_limit_col_range(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(
        row_filter=row_filters.ColumnRangeFilter(
            "cell_plan", b"data_plan_01gb", b"data_plan_10gb", inclusive_end=False
        )
    )

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)

C#

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

/// <summary>
/// /// Read using a qualifer 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 Task<string> FilterLimitColRange(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID")
{
    // A filter that matches cells whose column qualifiers are between data_plan_01gb and
    // data_plan_10gb in the column family cell_plan
    RowFilter filter = RowFilters.ColumnRange(ColumnRange.ClosedOpen("cell_plan", "data_plan_01gb", "data_plan_10gb"));
    return ReadFilter(projectId, instanceId, tableId, filter);
}

C++

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::Table table) {
  cbt::Filter filter = cbt::Filter::ColumnRange("cell_plan", "data_plan_01gb",
                                                "data_plan_10gb");
  // Read and print the rows.
  for (StatusOr<cbt::Row>& 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";
  }
}

Node.js

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

const filter = {
  column: {
    family: 'cell_plan',
    start: 'data_plan_01gb',
    end: {
      value: 'data_plan_10gb',
      inclusive: false,
    },
  },
};
readWithFilter(filter);

PHP

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

/**
 * Create a limiting filter on a range of columns
 *
 * @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_col_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::qualifier()
        ->rangeWithinFamily('cell_plan')
        ->startClosed('data_plan_01gb')
        ->endOpen('data_plan_10gb');

    $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);
    }
}

Ruby

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

# instance_id = "my-instance"
# table_id    = "my-table"
range = Google::Cloud::Bigtable::ColumnRange.new("cell_plan").from("data_plan_01gb").to("data_plan_10gb")
filter = Google::Cloud::Bigtable::RowFilter.column_range range
read_with_filter instance_id, table_id, filter

Intervalo de valores

Este filtro inclui células na linha de saída apenas se os respetivos valores estiverem dentro de um intervalo específico. Especifica o intervalo indicando um valor de início e um valor de fim.

  • Para obter células cujo valor seja anterior a um valor específico, especifique esse valor como o valor final exclusivo e omita o valor inicial.
  • Para obter células cujo valor seja igual ou posterior a um valor específico, especifique esse valor como o valor inicial inclusivo e omita o valor final.

Go

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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)
}

HBase

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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
  ValueFilter valueGreaterFilter =
      new ValueFilter(
          CompareFilter.CompareOp.GREATER_OR_EQUAL,
          new BinaryComparator(Bytes.toBytes("PQ2A.190405")));
  ValueFilter valueLesserFilter =
      new ValueFilter(
          CompareFilter.CompareOp.LESS_OR_EQUAL,
          new BinaryComparator(Bytes.toBytes("PQ2A.190406")));

  FilterList filter = new FilterList(FilterList.Operator.MUST_PASS_ALL);
  filter.addFilter(valueGreaterFilter);
  filter.addFilter(valueLesserFilter);

  Scan scan = new Scan().setFilter(filter);
  readWithFilter(projectId, instanceId, tableId, scan);
}

Java

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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);
}

Python

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

def filter_limit_value_range(project_id, instance_id, table_id):
    from google.cloud import bigtable
    from google.cloud.bigtable import row_filters

    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)

Python asyncio

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

async def filter_limit_value_range(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(
        row_filter=row_filters.ValueRangeFilter(b"PQ2A.190405", b"PQ2A.190406")
    )

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)

C#

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

/// <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 Task<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);
}

C++

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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 (StatusOr<cbt::Row>& 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";
  }
}

Node.js

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

PHP

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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);
    }
}

Ruby

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

# 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

Expressão regular de valor

Este filtro inclui células na linha de saída apenas se o valor da célula corresponder a uma expressão regular.

A expressão regular tem de usar a sintaxe RE2. Uma vez que os valores podem conter bytes arbitrários, incluindo carateres de nova linha, deve usar \C como a expressão universal na maioria dos casos. A expressão . não corresponde a carateres de nova linha.

Go

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

func filterLimitValueRegex(w io.Writer, projectID, instanceID string, tableName string) error {
	filter := bigtable.ValueFilter("PQ2A.*$")
	return readWithFilter(w, projectID, instanceID, tableName, filter)
}

HBase

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitValueRegex(String projectId, String instanceId, String tableId) {
  // A filter that matches cells whose value satisfies the given regex
  Filter filter = new ValueFilter(CompareOp.EQUAL, new RegexStringComparator("PQ2A.*$"));

  Scan scan = new Scan().setFilter(filter);
  readWithFilter(projectId, instanceId, tableId, scan);
}

Java

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitValueRegex(String projectId, String instanceId, String tableId) {
  // A filter that matches cells whose value satisfies the given regex
  Filter filter = FILTERS.value().regex("PQ2A.*$");
  readFilter(projectId, instanceId, tableId, filter);
}

Python

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.



def filter_limit_value_regex(project_id, instance_id, table_id):
    from google.cloud import bigtable
    from google.cloud.bigtable import row_filters

    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.ValueRegexFilter("PQ2A.*$".encode("utf-8"))
    )
    for row in rows:
        print_row(row)

Python ayncio

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.



async def filter_limit_value_regex(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(
        row_filter=row_filters.ValueRegexFilter("PQ2A.*$".encode("utf-8"))
    )

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)

C#

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

/// <summary>
/// /// Read using a value regex 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 Task<string> FilterLimitValueRegex(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID")
{
    // A filter that matches cells whose value satisfies the given regex
    RowFilter filter = RowFilters.ValueRegex("PQ2A.*$");
    return ReadFilter(projectId, instanceId, tableId, filter);
}

C++

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::Table table) {
  cbt::Filter filter = cbt::Filter::ValueRegex("PQ2A.*$");
  // Read and print the rows.
  for (StatusOr<cbt::Row>& 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";
  }
}

Node.js

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

const filter = {
  value: /PQ2A.*$/,
};
readWithFilter(filter);

PHP

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

/**
 * Create a limiting filter on a cell value using a regex
 *
 * @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_regex(
    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()->regex('PQ2A.*$');

    $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);
    }
}

Ruby

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

# instance_id = "my-instance"
# table_id    = "my-table"
filter = Google::Cloud::Bigtable::RowFilter.value "PQ2A.*$"
read_with_filter instance_id, table_id, filter

Intervalo de data/hora

Este filtro inclui células na linha de saída apenas se as respetivas indicações de tempo estiverem dentro de um intervalo específico. Especifica o intervalo indicando uma hora de início, que é inclusiva, e uma hora de fim, que é exclusiva. A unidade predefinida é microssegundos, e a indicação de tempo tem de ser um múltiplo de 1000.

  • Para obter células cujos carimbos de data/hora sejam anteriores a uma hora específica, especifique essa hora como a hora de fim e omita a hora de início para que não tenha limites.
  • Para obter células cujas datas/horas sejam iguais ou mais recentes do que uma hora específica, especifique essa hora como a hora de início e omita a hora de fim para que não tenha limites.

Go

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

func filterLimitTimestampRange(w io.Writer, projectID, instanceID string, tableName string) error {
	startTime := time.Unix(0, 0)
	endTime := time.Now().Add(-1 * time.Hour)
	filter := bigtable.TimestampRangeFilter(startTime, endTime)

	return readWithFilter(w, projectID, instanceID, tableName, filter)
}

HBase

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitTimestampRange(
    String projectId, String instanceId, String tableId) {
  // A filter that matches cells whose timestamp is from an hour ago or earlier
  // Get a time representing one hour ago
  long timestamp = Instant.now().minus(1, ChronoUnit.HOURS).toEpochMilli();
  try {
    Scan scan = new Scan().setTimeRange(0, timestamp).setMaxVersions();
    readWithFilter(projectId, instanceId, tableId, scan);
  } catch (IOException e) {
    System.out.println("There was an issue with your timestamp \n" + e.toString());
  }
}

Java

Nota: os métodos startOpen() e endClosed() não são suportados para filtros de intervalo de data/hora nesta biblioteca cliente.

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitTimestampRange(
    String projectId, String instanceId, String tableId) {
  // Get a time representing one hour ago
  long timestamp = Instant.now().minus(1, ChronoUnit.HOURS).toEpochMilli() * 1000;

  // A filter that matches cells whose timestamp is from an hour ago or earlier
  Filter filter = FILTERS.timestamp().range().startClosed(0L).endOpen(timestamp);
  readFilter(projectId, instanceId, tableId, filter);
}

Python

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

def filter_limit_timestamp_range(project_id, instance_id, table_id):
    from google.cloud import bigtable
    from google.cloud.bigtable import row_filters
    import datetime

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

    end = datetime.datetime(2019, 5, 1)

    rows = table.read_rows(
        filter_=row_filters.TimestampRangeFilter(row_filters.TimestampRange(end=end))
    )
    for row in rows:
        print_row(row)

Python asyncio

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

async def filter_limit_timestamp_range(project_id, instance_id, table_id):
    import datetime

    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    end = datetime.datetime(2019, 5, 1)

    query = ReadRowsQuery(row_filter=row_filters.TimestampRangeFilter(end=end))

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)

C#

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

/// <summary>
/// /// Read using a timestamp 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 Task<string> FilterLimitTimestampRange(string projectId, string instanceId, string tableId)
{
    BigtableVersion timestamp_minus_hr = new BigtableVersion(new DateTime(2020, 1, 10, 13, 0, 0, DateTimeKind.Utc));

    // A filter that matches cells whose timestamp is from an hour ago or earlier
    RowFilter filter = RowFilters.TimestampRange(new DateTime(0), timestamp_minus_hr.ToDateTime());
    return ReadFilter(projectId, instanceId, tableId, filter);
}

C++

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::Table table) {
  cbt::Filter filter =
      cbt::Filter::TimestampRange(microseconds(1000), milliseconds(2));
  // Read and print the rows.
  for (StatusOr<cbt::Row>& 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";
  }
}

Node.js

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

const start = 0;
const end = new Date(2019, 5, 1);
end.setUTCHours(0);
const filter = {
  time: {
    start,
    end,
  },
};
readWithFilter(filter);

PHP

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

/**
 * Create a limiting filter on a range of cell timestamps
 *
 * @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
 * @param int $endTime The timestamp upto which you want to fetch the rows
 */
function filter_limit_timestamp_range(
    string $projectId,
    string $instanceId,
    string $tableId,
    int $endTime = null
): void {
    // Connect to an existing table with an existing instance.
    $dataClient = new BigtableClient([
        'projectId' => $projectId,
    ]);
    $table = $dataClient->table($instanceId, $tableId);
    $endTime = is_null($endTime) ? (time() - 60 * 60) * 1000 * 1000 : $endTime;

    $start = 0;
    $filter = Filter::timestamp()
        ->range()
        ->startClosed($start)
        ->endOpen($endTime);

    $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);
    }
}

Ruby

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

# instance_id = "my-instance"
# table_id    = "my-table"
timestamp_minus_hr = (Time.now.to_f * 1_000_000).round(-3) - (60 * 60 * 1000 * 1000)
puts timestamp_minus_hr
filter = Google::Cloud::Bigtable::RowFilter.timestamp_range from: 0, to: timestamp_minus_hr

read_with_filter instance_id, table_id, filter

Filtros únicos avançados

Os seguintes filtros podem ser difíceis de usar.

Bloquear todas

Este filtro remove todas as células da linha de saída.

Se estiver a usar um filtro de intercalação, pode combinar o filtro de bloqueio total com o filtro de cadeia para desativar temporariamente parte da intercalação.

Go

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

func filterLimitBlockAll(w io.Writer, projectID, instanceID string, tableName string) error {
	filter := bigtable.BlockAllFilter()
	return readWithFilter(w, projectID, instanceID, tableName, filter)
}

HBase

Esta biblioteca de cliente não suporta este filtro.

Java

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitBlockAll(String projectId, String instanceId, String tableId) {
  // A filter that does not match any cells
  Filter filter = FILTERS.block();
  readFilter(projectId, instanceId, tableId, filter);
}

Python

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

def filter_limit_block_all(project_id, instance_id, table_id):
    from google.cloud import bigtable
    from google.cloud.bigtable import row_filters

    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.BlockAllFilter(True))
    for row in rows:
        print_row(row)

Python asyncio

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

async def filter_limit_block_all(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(row_filter=row_filters.BlockAllFilter(True))

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)

C#

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

/// <summary>
/// /// Read using a block all 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 Task<string> FilterLimitBlockAll(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID")
{
    // A filter that does not match any cells
    RowFilter filter = RowFilters.BlockAllFilter();
    return ReadFilter(projectId, instanceId, tableId, filter);
}

C++

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

Node.js

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

const filter = {
  all: false,
};
readWithFilter(filter);

PHP

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

/**
 * Create a block all filter
 *
 * @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_block_all(
    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::block();

    $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);
    }
}

Ruby

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

# instance_id = "my-instance"
# table_id    = "my-table"
filter = Google::Cloud::Bigtable::RowFilter.block
read_with_filter instance_id, table_id, filter

Passar tudo

Este filtro inclui todas as células da linha de entrada na linha de saída. É equivalente a uma leitura sem filtro.

O filtro Pass all pode ser útil se estiver a compor vários filtros e precisar de gerar células em alguns casos, mas não noutros.

Go

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

func filterLimitPassAll(w io.Writer, projectID, instanceID string, tableName string) error {
	filter := bigtable.PassAllFilter()
	return readWithFilter(w, projectID, instanceID, tableName, filter)
}

HBase

Esta biblioteca de cliente não suporta este filtro.

Java

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterLimitPassAll(String projectId, String instanceId, String tableId) {
  // A filter that matches all cells
  Filter filter = FILTERS.pass();
  readFilter(projectId, instanceId, tableId, filter);
}

Python

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

def filter_limit_pass_all(project_id, instance_id, table_id):
    from google.cloud import bigtable
    from google.cloud.bigtable import row_filters

    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.PassAllFilter(True))
    for row in rows:
        print_row(row)

Python asyncio

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

async def filter_limit_pass_all(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(row_filter=row_filters.PassAllFilter(True))

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)

C#

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

/// <summary>
/// /// Read using a pass all 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 Task<string> FilterLimitPassAll(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID")
{
    // A filter that matches all cells
    RowFilter filter = RowFilters.PassAllFilter();
    return ReadFilter(projectId, instanceId, tableId, filter);
}

C++

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::Table table) {
  cbt::Filter filter = cbt::Filter::PassAllFilter();
  // Read and print the rows.
  for (StatusOr<cbt::Row>& 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";
  }
}

Node.js

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

const filter = {
  all: true,
};
readWithFilter(filter);

PHP

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

/**
 * Create a pass all filter
 *
 * @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_pass_all(
    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::pass();

    $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);
    }
}

Ruby

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

# instance_id = "my-instance"
# table_id    = "my-table"
filter = Google::Cloud::Bigtable::RowFilter.pass
read_with_filter instance_id, table_id, filter

Lava-louça

Este filtro copia todas as células da linha de entrada para a linha de saída final, mesmo que outro filtro normalmente removesse ou alterasse essas células.

Quando usa uma cadeia de filtros, outros filtros limitadores só podem afetar a respetiva linha de saída, que se torna a linha de entrada para o filtro seguinte na cadeia. O filtro de destino é diferente: insere células diretamente na linha de saída final, que aparece nos resultados de leitura.

Por exemplo, suponha que cria uma cadeia de dois filtros:

  1. O filtro de lavatório
  2. O filtro de bloqueio de tudo, que elimina todas as células da linha

Por si só, o filtro de bloqueio de tudo resultaria numa linha vazia, que não seria incluída nos resultados de leitura. No entanto, o filtro de destino força a cópia de todas as células da linha de entrada para a linha de saída final, independentemente do que outros filtros na cadeia possam fazer. Como resultado, a combinação do filtro de destino e do filtro de bloqueio de tudo tem o mesmo efeito que não usar nenhum filtro, e a linha de entrada original, com todas as respetivas células, aparece nos resultados de leitura.

Modificar filtros

As secções seguintes descrevem cada filtro de modificação. A modificação dos filtros afeta os dados ou os metadados das células individuais.

Aplicar etiqueta

Este filtro adiciona uma etiqueta a todas as células de uma linha. Use este filtro como parte de uma interleave para indicar que filtro fez com que uma célula fosse incluída na linha de saída. A sua aplicação pode usar a etiqueta de cada célula para fazer um processamento adicional no lado do cliente.

Cada etiqueta não pode ter mais de 15 carateres. Além disso, cada etiqueta tem de corresponder à expressão regular RE2 [a-z0-9\\-]+.

Cada célula só pode ter uma etiqueta. Consequentemente, uma cadeia de filtros só pode incluir o filtro de aplicação de etiqueta uma vez.

Go

Esta biblioteca de cliente não suporta este filtro.

HBase

Esta biblioteca de cliente não suporta este filtro.

Java

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterModifyApplyLabel(String projectId, String instanceId, String tableId) {
  // A filter that applies the given label to the outputted cell
  Filter filter = FILTERS.label("labelled");
  readFilter(projectId, instanceId, tableId, filter);
}

Python

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

def filter_modify_apply_label(project_id, instance_id, table_id):
    from google.cloud import bigtable
    from google.cloud.bigtable import row_filters

    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.ApplyLabelFilter(label="labelled"))
    for row in rows:
        print_row(row)

Python asyncio

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

async def filter_modify_apply_label(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(row_filter=row_filters.ApplyLabelFilter(label="labelled"))

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)

C#

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

/// <summary>
/// /// Read using a strip value 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 Task<string> FilterModifyApplyLabel(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID")
{
    // A filter that applies the given label to the outputted cell
    RowFilter filter = new RowFilter { ApplyLabelTransformer = "labelled" };
    return ReadFilter(projectId, instanceId, tableId, filter);
}

C++

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::Table table) {
  cbt::Filter filter = cbt::Filter::ApplyLabelTransformer("labelled");
  // Read and print the rows.
  for (StatusOr<cbt::Row>& 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()
                << ", label(";
      for (auto const& label : cell.labels()) {
        std::cout << label << ",";
      }
      std::cout << ")],";
    }
    std::cout << "\n";
  }
}

Node.js

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

const filter = {
  label: 'labelled',
};
readWithFilter(filter);

PHP

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

/**
 * Create a filter that applies a label
 *
 * @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_modify_apply_label(
    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::label('labelled');

    $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);
    }
}

Ruby

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

# instance_id = "my-instance"
# table_id    = "my-table"
filter = Google::Cloud::Bigtable::RowFilter.label "labelled"
read_with_filter instance_id, table_id, filter

Valor da faixa

Este filtro substitui o valor de cada célula por uma string vazia. Use este filtro quando só precisar de contabilizar o número de linhas ou células que correspondem aos seus critérios, em vez de obter todos os dados dessas linhas ou células.

Go

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

func filterModifyStripValue(w io.Writer, projectID, instanceID string, tableName string) error {
	filter := bigtable.StripValueFilter()
	return readWithFilter(w, projectID, instanceID, tableName, filter)
}

HBase

Na biblioteca do cliente HBase, o filtro de valor de remoção chama-se KeyOnlyFilter. Não está disponível nenhuma amostra.

Java

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterModifyStripValue(String projectId, String instanceId, String tableId) {
  // A filter that replaces the outputted cell value with the empty string
  Filter filter = FILTERS.value().strip();
  readFilter(projectId, instanceId, tableId, filter);
}

Python

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

def filter_modify_strip_value(project_id, instance_id, table_id):
    from google.cloud import bigtable
    from google.cloud.bigtable import row_filters

    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.StripValueTransformerFilter(True))
    for row in rows:
        print_row(row)

Python asyncio

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

async def filter_modify_strip_value(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(row_filter=row_filters.StripValueTransformerFilter(True))

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)

C#

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

/// <summary>
/// /// Read using a strip value 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 Task<string> FilterModifyStripValue(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID")
{
    // A filter that replaces the outputted cell value with the empty string
    RowFilter filter = RowFilters.StripValueTransformer();
    return ReadFilter(projectId, instanceId, tableId, filter);
}

C++

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::Table table) {
  cbt::Filter filter = cbt::Filter::StripValueTransformer();
  // Read and print the rows.
  for (StatusOr<cbt::Row>& 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";
  }
}

Node.js

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

const filter = {
  value: {
    strip: true,
  },
};
readWithFilter(filter);

PHP

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

/**
 * Create a filter that strips the value
 *
 * @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_modify_strip_value(
    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()->strip();

    $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);
    }
}

Ruby

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

# instance_id = "my-instance"
# table_id    = "my-table"
filter = Google::Cloud::Bigtable::RowFilter.strip_value
read_with_filter instance_id, table_id, filter

Filtros de composição

As secções seguintes descrevem cada filtro de composição. A composição de filtros permite-lhe combinar vários filtros num só, o que torna possível aplicar mais do que um filtro a um único pedido de leitura.

Chain

Este filtro aplica uma série de filtros, por ordem, a cada linha de saída. Um filtro de encadeamento é como usar um E lógico.

Cada filtro na cadeia só vê o resultado do filtro anterior. Por exemplo, se encadear dois filtros e o primeiro filtro remover metade das células da linha de saída, o segundo filtro não tem acesso às células que foram removidas.

Por outras palavras, a ordem dos filtros é importante. Se alterar a ordem dos filtros encadeados, pode obter dados diferentes nas linhas de saída.

Go

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

func filterComposingChain(w io.Writer, projectID, instanceID string, tableName string) error {
	filter := bigtable.ChainFilters(bigtable.LatestNFilter(1), bigtable.FamilyFilter("cell_plan"))
	return readWithFilter(w, projectID, instanceID, tableName, filter)
}

HBase

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterComposingChain(String projectId, String instanceId, String tableId) {
  // A filter that selects one cell per row AND within the column family cell_plan
  Filter familyFilter =
      new FamilyFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes("cell_plan")));
  Filter columnCountGetFilter = new ColumnCountGetFilter(3);

  FilterList filter = new FilterList(FilterList.Operator.MUST_PASS_ALL);
  filter.addFilter(columnCountGetFilter);
  filter.addFilter(familyFilter);
  Scan scan = new Scan().setFilter(filter);
  readWithFilter(projectId, instanceId, tableId, scan);
}

Java

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterComposingChain(String projectId, String instanceId, String tableId) {
  // A filter that selects one cell per column AND within the column family cell_plan
  Filter filter =
      FILTERS
          .chain()
          .filter(FILTERS.limit().cellsPerColumn(1))
          .filter(FILTERS.family().exactMatch("cell_plan"));
  readFilter(projectId, instanceId, tableId, filter);
}

Python

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

def filter_composing_chain(project_id, instance_id, table_id):
    from google.cloud import bigtable
    from google.cloud.bigtable import row_filters

    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.RowFilterChain(
            filters=[
                row_filters.CellsColumnLimitFilter(1),
                row_filters.FamilyNameRegexFilter("cell_plan"),
            ]
        )
    )
    for row in rows:
        print_row(row)

Python asyncio

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

async def filter_composing_chain(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(
        row_filter=row_filters.RowFilterChain(
            filters=[
                row_filters.CellsColumnLimitFilter(1),
                row_filters.FamilyNameRegexFilter("cell_plan"),
            ]
        )
    )

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)

C#

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

/// <summary>
/// /// Read using a chain 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 Task<string> FilterComposingChain(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID")
{
    // A filter that selects one cell per column AND within the column family cell_plan
    RowFilter filter = RowFilters.Chain(RowFilters.CellsPerColumnLimit(1), RowFilters.FamilyNameExact("cell_plan"));
    return ReadFilter(projectId, instanceId, tableId, filter);
}

C++

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::Table table) {
  cbt::Filter filter = cbt::Filter::Chain(
      cbt::Filter::Latest(1), cbt::Filter::FamilyRegex("cell_plan"));
  // Read and print the rows.
  for (StatusOr<cbt::Row>& 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";
  }
}

Node.js

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

const filter = [
  {
    column: {
      cellLimit: 1,
    },
  },
  {
    family: 'cell_plan',
  },
];
readWithFilter(filter);

PHP

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

/**
 * Create a composite filter using chaining
 *
 * @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_composing_chain(
    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::chain()
        ->addFilter(Filter::limit()->cellsPerColumn(1))
        ->addFilter(Filter::family()->exactMatch('cell_plan'));

    $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);
    }
}

Ruby

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

# instance_id = "my-instance"
# table_id    = "my-table"
filter = Google::Cloud::Bigtable::RowFilter.chain.cells_per_column(1).family("cell_plan")
read_with_filter instance_id, table_id, filter

Intercalar

Este filtro envia a linha de entrada através de vários filtros de componentes, gerando uma linha de saída temporária de cada filtro de componentes. Todas as células das linhas de saída temporárias são, em seguida, combinadas numa linha de saída final. Um filtro de intercalação é como usar um OU lógico.

As intercalações podem fazer com que as células sejam duplicadas na linha de saída. Por exemplo, se a intercalação incluir dois filtros e ambos os filtros incluírem uma célula específica nas respetivas linhas de saída temporárias, a linha de saída final vai incluir duas cópias dessa célula.

Se os filtros de componentes produzirem várias células que tenham todas a mesma família de colunas, qualificador de coluna e data/hora, a linha de saída final agrupa todas essas células numa ordem não especificada.

Go

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

func filterComposingInterleave(w io.Writer, projectID, instanceID string, tableName string) error {
	filter := bigtable.InterleaveFilters(bigtable.ValueFilter("true"), bigtable.ColumnFilter("os_build"))
	return readWithFilter(w, projectID, instanceID, tableName, filter)
}

HBase

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterComposingInterleave(
    String projectId, String instanceId, String tableId) {
  // A filter that matches cells with the value true OR with the column qualifier os_build
  Filter qualifierFilter =
      new QualifierFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes("os_build")));
  Filter valueFilter =
      new ValueFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes("true")));

  FilterList filter = new FilterList(Operator.MUST_PASS_ONE);
  filter.addFilter(qualifierFilter);
  filter.addFilter(valueFilter);

  Scan scan = new Scan().setFilter(filter).setMaxVersions();
  readWithFilter(projectId, instanceId, tableId, scan);
}

Java

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterComposingInterleave(
    String projectId, String instanceId, String tableId) {
  // A filter that matches cells with the value true OR with the column qualifier os_build
  Filter filter =
      FILTERS
          .interleave()
          .filter(FILTERS.value().exactMatch("true"))
          .filter(FILTERS.qualifier().exactMatch("os_build"));
  readFilter(projectId, instanceId, tableId, filter);
}

Python

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

def filter_composing_interleave(project_id, instance_id, table_id):
    from google.cloud import bigtable
    from google.cloud.bigtable import row_filters

    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.RowFilterUnion(
            filters=[
                row_filters.ValueRegexFilter("true"),
                row_filters.ColumnQualifierRegexFilter("os_build"),
            ]
        )
    )
    for row in rows:
        print_row(row)

Python asyncio

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

async def filter_composing_interleave(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(
        row_filter=row_filters.RowFilterUnion(
            filters=[
                row_filters.ValueRegexFilter("true"),
                row_filters.ColumnQualifierRegexFilter("os_build"),
            ]
        )
    )

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)

C#

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

/// <summary>
/// /// Read using an interleave 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 Task<string> FilterComposingInterleave(string projectId, string instanceId, string tableId)
{
    // A filter that matches cells with the value true OR with the column qualifier os_build
    RowFilter filter = RowFilters.Interleave(RowFilters.ValueExact("true"), RowFilters.ColumnQualifierExact("os_build"));
    return ReadFilter(projectId, instanceId, tableId, filter);
}

C++

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::Table table) {
  cbt::Filter filter = cbt::Filter::Interleave(
      cbt::Filter::ValueRegex("true"), cbt::Filter::ColumnRegex("os_build"));
  // Read and print the rows.
  for (StatusOr<cbt::Row>& 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";
  }
}

Node.js

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

const filter = {
  interleave: [
    {
      value: 'true',
    },
    {column: 'os_build'},
  ],
};
readWithFilter(filter);

PHP

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

/**
 * Create a composite filter using interleaving
 *
 * @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_composing_interleave(
    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::interleave()
        ->addFilter(Filter::value()->exactMatch('1'))
        ->addFilter(Filter::qualifier()->exactMatch('os_build'));

    $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);
    }
}

Ruby

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

# instance_id = "my-instance"
# table_id    = "my-table"
filter = Google::Cloud::Bigtable::RowFilter.interleave.value("true").qualifier("os_build")
read_with_filter instance_id, table_id, filter

Condição

Este filtro aplica um filtro verdadeiro ou um filtro falso à linha de entrada.

Para escolher entre os filtros verdadeiro e falso, é aplicado um filtro de predicado à linha de entrada. Se o resultado do filtro de predicado contiver, pelo menos, uma célula, o filtro verdadeiro é aplicado. Se o resultado do filtro de predicado estiver vazio, o filtro falso é aplicado.

A linha de saída do filtro de predicado é usada apenas para escolher entre os filtros verdadeiro e falso. Não aparece na resposta ao seu pedido de leitura.

O filtro de predicado não é executado atomicamente com o filtro verdadeiro ou falso. Por outras palavras, os dados na linha de entrada podem mudar entre o momento em que o filtro de predicado é executado e o momento em que o filtro verdadeiro ou falso é executado. Este comportamento pode originar resultados inconsistentes ou inesperados.

Quando usa o filtro de condição, pode omitir o filtro verdadeiro ou falso. Omitir um filtro é o mesmo que especificar o filtro de bloqueio de tudo. Se o filtro de predicado escolher uma condição que omitiu, a linha de saída fica vazia.

Go

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

func filterComposingCondition(w io.Writer, projectID, instanceID string, tableName string) error {
	filter := bigtable.ConditionFilter(
		bigtable.ChainFilters(bigtable.ColumnFilter("data_plan_10gb"), bigtable.ValueFilter("true")),
		bigtable.StripValueFilter(),
		bigtable.PassAllFilter())
	return readWithFilter(w, projectID, instanceID, tableName, filter)
}

HBase

Esta biblioteca de cliente não suporta este filtro.

Java

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

public static void filterComposingCondition(String projectId, String instanceId, String tableId) {
  // A filter that applies the label passed-filter IF the cell has the column qualifier
  // data_plan_10gb AND the value true, OTHERWISE applies the label filtered-out
  Filter filter =
      FILTERS
          .condition(
              FILTERS
                  .chain()
                  .filter(FILTERS.qualifier().exactMatch("data_plan_10gb"))
                  .filter(FILTERS.value().exactMatch("true")))
          .then(FILTERS.label("passed-filter"))
          .otherwise(FILTERS.label("filtered-out"));
  readFilter(projectId, instanceId, tableId, filter);
}

Python

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

def filter_composing_condition(project_id, instance_id, table_id):
    from google.cloud import bigtable
    from google.cloud.bigtable import row_filters

    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.ConditionalRowFilter(
            base_filter=row_filters.RowFilterChain(
                filters=[
                    row_filters.ColumnQualifierRegexFilter("data_plan_10gb"),
                    row_filters.ValueRegexFilter("true"),
                ]
            ),
            true_filter=row_filters.ApplyLabelFilter(label="passed-filter"),
            false_filter=row_filters.ApplyLabelFilter(label="filtered-out"),
        )
    )
    for row in rows:
        print_row(row)

Python asyncio

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

async def filter_composing_condition(project_id, instance_id, table_id):
    from google.cloud.bigtable.data import (
        BigtableDataClientAsync,
        ReadRowsQuery,
        row_filters,
    )

    query = ReadRowsQuery(
        row_filter=row_filters.ConditionalRowFilter(
            predicate_filter=row_filters.RowFilterChain(
                filters=[
                    row_filters.ColumnQualifierRegexFilter("data_plan_10gb"),
                    row_filters.ValueRegexFilter("true"),
                ]
            ),
            true_filter=row_filters.ApplyLabelFilter(label="passed-filter"),
            false_filter=row_filters.ApplyLabelFilter(label="filtered-out"),
        )
    )

    async with BigtableDataClientAsync(project=project_id) as client:
        async with client.get_table(instance_id, table_id) as table:
            for row in await table.read_rows(query):
                print_row(row)

C#

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

/// <summary>
/// /// Read using a conditional 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 Task<string> FilterComposingCondition(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID")
{
    // A filter that applies the label passed-filter IF the cell has the column qualifier
    // data_plan_10gb AND the value true, OTHERWISE applies the label filtered-out
    RowFilter filter = RowFilters.Condition(
        RowFilters.Chain(RowFilters.ColumnQualifierExact("data_plan_10gb"), RowFilters.ValueExact("true")),
        new RowFilter { ApplyLabelTransformer = "passed-filter" },
        new RowFilter { ApplyLabelTransformer = "filtered-out" }
        );
    return ReadFilter(projectId, instanceId, tableId, filter);
}

C++

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::Table table) {
  cbt::Filter filter = cbt::Filter::Condition(
      cbt::Filter::Chain(cbt::Filter::ValueRegex("true"),
                         cbt::Filter::ColumnRegex("data_plan_10gb")),
      cbt::Filter::ApplyLabelTransformer("passed-filter"),
      cbt::Filter::ApplyLabelTransformer("filtered-out"));
  // Read and print the rows.
  for (StatusOr<cbt::Row>& 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()
                << ", label(";
      for (auto const& label : cell.labels()) {
        std::cout << label << ",";
      }
      std::cout << ")],";
    }
    std::cout << "\n";
  }
}

Node.js

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

const filter = {
  condition: {
    test: [
      {column: 'data_plan_10gb'},
      {
        value: 'true',
      },
    ],
    pass: {
      label: 'passed-filter',
    },
    fail: {
      label: 'filtered-out',
    },
  },
};
readWithFilter(filter);

PHP

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

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

/**
 * Create a composite filter using a conditional
 *
 * @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_composing_condition(
    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::condition(
        Filter::chain()
            ->addFilter(Filter::value()->exactMatch('1'))
            ->addFilter(Filter::qualifier()->exactMatch('data_plan_10gb'))
    )
        ->then(Filter::label('passed-filter'))
        ->otherwise(Filter::label('filtered-out'));

    $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);
    }
}

Ruby

Para saber como instalar e usar a biblioteca cliente do Bigtable, consulte o artigo Bibliotecas cliente do Bigtable.

Para se autenticar no Bigtable, configure as Credenciais padrão da aplicação. Para mais informações, consulte o artigo Configure a autenticação para bibliotecas de cliente.

# instance_id = "my-instance"
# table_id    = "my-table"
filter = Google::Cloud::Bigtable::RowFilter.condition(
  Google::Cloud::Bigtable::RowFilter.chain.qualifier("data_plan_10gb").value("true")
)
                                           .on_match(Google::Cloud::Bigtable::RowFilter.label("passed-filter"))
                                           .otherwise(Google::Cloud::Bigtable::RowFilter.label("filtered-out"))
read_with_filter instance_id, table_id, filter

O que se segue?