フィルタを使用する

Bigtable には次のタイプのフィルタが用意されています。

このページでは、Bigtable の各フィルタについて詳しく説明し、Cloud クライアント ライブラリの各タイプのフィルタを使用する方法を示します。このページをお読みいただく前に、フィルタをご覧ください。

フィルタを使用して複数行のデータを読み取る方法を示すその他のサンプルについては、データの読み取りをご覧ください。

サンプル用のデータ

このページの例では、スマートフォンとタブレットの時系列データを保存し、次のデータがテーブルに書き込まれていることを前提としています。このテーブルには、stats_summarycell_plan の 2 つの列ファミリーがあります。 各列ファミリーには 3 つの列があります。

stats_summary cell_plan
行キー 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 minus one hour

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

制限フィルタ

以降のセクションでは、各制限フィルタについて説明します。制限フィルタは、特定の条件に一致するかどうかに基づいて、レスポンスに含める行またはセルを制御します。

チェーンを使用して複数の制限フィルタを組み合わせる場合、チェーン内の各フィルタの入力行は、チェーン内の前のフィルタの出力行である点に留意してください。たとえば、2 つのフィルタを連結し、最初のフィルタで元の行の 2 つのセルのみが出力される場合、2 番目のフィルタはそれら 2 つのセルのみを表示します。

行選択フィルタ

このセクションでは、テーブル内の行を取得するために使用できるフィルタについて説明します。

行のサンプル

このフィルタを使用すると、特定の範囲内の行のランダムなサンプルを取得できます。 指定した確率に基づいて、出力行を入力行と同じにするか、結果から除外するかをランダムに選択します。

Go

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

HBase

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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 同期

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

    rows = table.read_rows(filter_=row_filters.RowSampleFilter(0.75))
    for row in rows:
        print_row(row)

C#

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

/// <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 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++

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

PHP

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

行キーの正規表現

このフィルタは、入力行の行キーが正規表現と一致するかどうかを確認します。 行キーが一致する場合、出力行は入力行と同じになります。行キーが一致しない場合、出力行は空になります。

行キー接頭辞として機能する正規表現を提供する場合、このフィルタはテーブル全体をスキャンしません。たとえば、^phone\C* など、接頭辞のような正規表現を含むリクエストは、接頭辞フィルタ phone を含むリクエストと同様に処理されます。

正規表現では RE2 構文を使用する必要があります。行キーには改行文字を含む任意のバイトを含めることができるため、ほとんどの場合、ワイルドカード式として \C を使用する必要があります。. 式は改行文字と一致しません。

Go

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

HBase

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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 同期

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

    rows = table.read_rows(
        filter_=row_filters.RowKeyRegexFilter(".*#20190501$".encode("utf-8"))
    )
    for row in rows:
        print_row(row)

C#

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

/// <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 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++

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

PHP

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

セル選択フィルタ

このセクションでは、テーブル内のセルを取得するために使用できるフィルタについて説明します。

列あたりのセル数の上限

このフィルタは、出力行に含まれる各列のセル数を制限します。このフィルタを適用すると、各出力行には各列の最新の N 個のセルが含まれ、その列の他のセルはすべて除外されます。

インターリーブ フィルタを併用しており、インターリーブ フィルタによってセルのコピーが重複して生成された場合は、各コピーが制限対象としてカウントされます。

Go

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

HBase

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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 同期

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

    rows = table.read_rows(filter_=row_filters.CellsColumnLimitFilter(2))
    for row in rows:
        print_row(row)

C#

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

/// <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 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++

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

PHP

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

# 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

行あたりのセル数の上限

このフィルタは、各出力行のセル数を制限します。このフィルタを適用すると、各出力行には入力行の最初の N 個のセルが含まれ、その行の後続のセルはすべて除外されます。最初の N 個のセルは、どの列にあるかにかかわらず、Bigtable に格納されている順序で読み取られます。

Bigtable でのデータの格納方法の詳細については、スキーマ設計のベスト プラクティスをご覧ください。

行の列には複数のセルを含めることができます。各セルには、列の値と一意のタイムスタンプが含まれます。その結果、行を N 個のセルに制限することは、行から最初の N 列を取得することとは異なる場合があります。たとえば、行あたりのセル数の上限が 20 個のフィルタを使用し、30 列ある行を読み取り、各列にタイムスタンプ付きのセルが 10 個ある場合、出力行は行の最初の 2 列の値(2 × 10 = 20)のみを返します。

このフィルタをオフセット フィルタと組み合わせて使用することは、大きな行を読み取る必要がある場合にページ分割を行う際に有用です。

Go

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

HBase

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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 同期

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

    rows = table.read_rows(filter_=row_filters.CellsRowLimitFilter(2))
    for row in rows:
        print_row(row)

C#

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

/// <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 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++

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

PHP

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

# 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

行あたりのセル数のオフセット

このフィルタでは、各出力行から最初の N 個のセルが省略されます。残りのセルはすべて出力行に含まれます。最初の N 個のセルは、どの列に含まれていてもスキップされます。

行の列には複数のセルを含めることができます。各セルには、列の値と一意のタイムスタンプが含まれます。そのため、行の最初の N 個のセルをスキップすることは、行の最初の N 列をスキップすることとは異なる場合があります。たとえば、行あたりのセル数のオフセットが 20 個のフィルタを使用し、30 列ある行を読み取り、各列にタイムスタンプ付きのセルが 10 個ある場合、出力行は最初の 2 列に含まれるセルを除く行内のすべてのセルの値(2 × 10 = 20)を返します。

インターリーブ フィルタを併用しており、インターリーブ フィルタによってセルのコピーが重複して生成された場合は、各コピーがオフセットの対象としてカウントされます。

Go

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

HBase

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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 同期

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

    rows = table.read_rows(filter_=row_filters.CellsRowOffsetFilter(2))
    for row in rows:
        print_row(row)

C#

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

    /// <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 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++

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

PHP

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

# 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

列ファミリーの正規表現

このフィルタは、セルの列ファミリーが正規表現と一致する場合にのみ出力行にセルを含めます。

正規表現では RE2 構文を使用する必要があります。文字がリテラルとして使用されていない場合でも、正規表現に : 文字を含めることはできません。列ファミリーに改行文字を含めることはできないため、. または \C をワイルドカード式として使用できます。

Go

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

HBase

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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 同期

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

    rows = table.read_rows(
        filter_=row_filters.FamilyNameRegexFilter("stats_.*$".encode("utf-8"))
    )
    for row in rows:
        print_row(row)

C#

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

    /// <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 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++

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

PHP

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

列修飾子の正規表現

このフィルタは、セルの列修飾子が正規表現と一致する場合にのみ出力行にセルを含めます。

正規表現では RE2 構文を使用する必要があります。列修飾子には改行文字を含む任意のバイトを含めることができるため、ほとんどの場合に、ワイルドカード式として \C を使用する必要があります。. 式は改行文字と一致しません。

Go

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

HBase

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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 同期

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

    rows = table.read_rows(
        filter_=row_filters.ColumnQualifierRegexFilter("connected_.*$".encode("utf-8"))
    )
    for row in rows:
        print_row(row)

C#

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

    /// <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 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++

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

PHP

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

列の範囲

このフィルタは、特定の列ファミリーに属し、列修飾子が特定の範囲内にある場合にのみ、出力行にセルを含めます。 範囲を指定するには、開始修飾子と終了修飾子を指定します。

Go

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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 同期

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

    rows = table.read_rows(
        filter_=row_filters.ColumnRangeFilter(
            "cell_plan", b"data_plan_01gb", b"data_plan_10gb", inclusive_end=False
        )
    )
    for row in rows:
        print_row(row)

C#

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

/// <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 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++

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

PHP

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

# 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

値の範囲

このフィルタは、値が特定の範囲内にある場合にのみ、出力行にセルを含めます。範囲を指定するには、開始値と終了値を指定します。

  • 値が特定の値の前にあるセルを取得するには、その値を終了値(除外)として指定し、開始値を省略します。
  • 値が特定の値以降のセルを取得するには、その値を開始値(包括)として指定し、終了値を省略します。

Go

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

HBase

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

public static void filterLimitValueRange(String projectId, String instanceId, String tableId) {
  // A filter that matches cells whose values are between the given values
  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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

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

Python 同期

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

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

    for row in rows:
        print_row(row)

C#

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

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

C++

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

PHP

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

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

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

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

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

Ruby

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

値の正規表現

このフィルタは、値が正規表現と一致する場合にのみ、出力行にセルを含めます。

正規表現では RE2 構文を使用する必要があります。値には改行文字を含む任意のバイトを含めることができるため、ほとんどの場合に、ワイルドカード式として \C を使用する必要があります。. 式は改行文字と一致しません。

Go

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

HBase

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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 同期

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。



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

    rows = table.read_rows(
        filter_=row_filters.ValueRegexFilter("PQ2A.*$".encode("utf-8"))
    )
    for row in rows:
        print_row(row)

C#

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

/// <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 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++

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

PHP

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

タイムスタンプの範囲

このフィルタは、タイムスタンプが特定の範囲内にある場合にのみ、出力行にセルを含めます。範囲を指定するには、開始時刻(包括)と終了時刻(除外)を指定します。デフォルトの単位はマイクロ秒で、タイムスタンプは 1,000 の倍数にする必要があります。

  • タイムスタンプが特定の時刻よりも古いセルを取得するには、その時刻を終了時刻として指定し、開始時刻を省略して制限が適用されないようにします。
  • タイムスタンプが特定の時刻以降のセルを取得するには、その時刻を開始時刻として指定し、終了時刻を省略して制限が適用されないようにします。

Go

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

注: メソッド startOpen()endClosed() は現在、このクライアント ライブラリのタイムスタンプ範囲フィルタではサポートされていません。

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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 同期

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

    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)

C#

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

    /// <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 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++

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

PHP

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

# 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

高度な単一フィルタ

次のフィルタは使用が困難な場合があります。

すべてブロック

このフィルタは、出力行からすべてのセルを削除します。

インターリーブ フィルタを使用している場合は、すべてブロック フィルタとチェーン フィルタを組み合わせて、インターリーブの一部を一時的に無効にできます。

Go

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

HBase

このクライアント ライブラリはこのフィルタをサポートしていません。

Java

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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 同期

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

    rows = table.read_rows(filter_=row_filters.BlockAllFilter(True))
    for row in rows:
        print_row(row)

C#

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

/// <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 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++

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

PHP

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

すべて渡す

このフィルタは、入力行のすべてのセルを出力行に含めます。これは、フィルタを適用しない場合の読み取りと同じです。

すべて渡すフィルタは、複数のフィルタを合成し、一部の場合にはセルを出力する必要があり、その他の場合にはセルを出力する必要がないケースで有用であることが考えられます。

Go

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

HBase

このクライアント ライブラリはこのフィルタをサポートしていません。

Java

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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 同期

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

    rows = table.read_rows(filter_=row_filters.PassAllFilter(True))
    for row in rows:
        print_row(row)

C#

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

/// <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 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++

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

PHP

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

シンク

このフィルタは、入力行のすべてのセルを最終的な出力行にコピーします。通常であれば、別のフィルタが、それらのセルを削除または変更する場合であっても同様に処理します。

フィルタのチェーンを使用する場合、他の制限フィルタは自身の出力行にのみ影響し、この出力行がチェーン内の次のフィルタの入力行になります。シンクフィルタは、読み取り結果に表示される最終出力行に直接セルを挿入する点が異なります。

たとえば、2 つのフィルタのチェーンを作成するとします。

  1. シンクフィルタ
  2. すべてブロック フィルタは、行からすべてのセルを削除します

すべてブロックするフィルタは、単独で読み取り結果に含まれない空の行を生成します。ただし、シンクフィルタは、チェーン内の他のフィルタの処理内容にかかわらず、入力行のすべてのセルを強制的に最終出力行にコピーします。その結果、シンクフィルタとすべてブロック フィルタを組み合わせても、フィルタをまったく使用しないのと同じ効果があり、元の入力行とそのすべてのセルが読み取り結果に表示されます。

変更フィルタ

以降のセクションでは、各変更フィルタについて説明します。変更フィルタは、個別のセルのデータまたはメタデータに影響します。

ラベル適用

このフィルタは、行内のすべてのセルにラベルを追加します。このフィルタをインターリーブの一部として使用し、出力行にセルを含める処理を行ったフィルタを示します。アプリケーションは、各セルのラベルを使用してクライアント側で追加の処理を実行できます。

各ラベルは 15 文字以内で指定してください。また、各ラベルは RE2 正規表現 [a-z0-9\\-]+ と一致する必要があります。

各セルに設定できるラベルは 1 つのみです。そのため、フィルタのチェーンにはラベル適用フィルタを 1 回のみ含めることができます。

Go

このクライアント ライブラリはこのフィルタをサポートしていません。

HBase

このクライアント ライブラリはこのフィルタをサポートしていません。

Java

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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 同期

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

    rows = table.read_rows(filter_=row_filters.ApplyLabelFilter(label="labelled"))
    for row in rows:
        print_row(row)

C#

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

/// <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 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++

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

PHP

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

値を削除

このフィルタは、各セルの値を空の文字列に置き換えます。このフィルタは、行またはセルのすべてのデータを取得するのではなく、条件に一致する行またはセルの数をカウントすることのみが必要な場合に使用します。

Go

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

HBase

HBase クライアント ライブラリでは、値削除フィルタは KeyOnlyFilter と呼ばれます。サンプルはありません。

Java

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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 同期

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

    rows = table.read_rows(filter_=row_filters.StripValueTransformerFilter(True))
    for row in rows:
        print_row(row)

C#

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

/// <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 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++

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

PHP

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

合成フィルタ

以降のセクションでは、各合成フィルタについて説明します。合成フィルタを使用すると、複数のフィルタを 1 つにまとめて、1 つの読み取りリクエストに複数のフィルタを適用できます。

チェーン

このフィルタは、各出力行に一連のフィルタを順番に適用します。チェーン フィルタは論理 AND を使用することと類似しています。

チェーン内の各フィルタには、前のフィルタの出力のみが表示されます。たとえば、2 つのフィルタを連結し、最初のフィルタが出力行からセルの半分を削除した場合、2 番目のフィルタは削除されたセルにアクセスできません。

つまり、フィルタの順序は重要です。チェーン フィルタの順序を変更すると、出力行に異なるデータが表示される場合があります。

Go

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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 同期

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

    rows = table.read_rows(
        filter_=row_filters.RowFilterChain(
            filters=[
                row_filters.CellsColumnLimitFilter(1),
                row_filters.FamilyNameRegexFilter("cell_plan"),
            ]
        )
    )
    for row in rows:
        print_row(row)

C#

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

/// <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 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++

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

PHP

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

# 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

インターリーブ

このフィルタは、複数のコンポーネント フィルタを介して入力行を送信し、各コンポーネント フィルタから一時的な出力行を生成します。その後、一時出力行のすべてのセルが最終出力行に結合されます。インターリーブ フィルタは論理 OR を使用することと類似しています。

インターリーブを行うと、出力行でセルが重複する場合があります。たとえば、インターリーブに 2 つのフィルタがあり、両方のフィルタで一時出力行に特定のセルが含まれている場合、最終出力行にはそのセルの 2 つのコピーが含まれます。

コンポーネント フィルタがすべて同じ列ファミリー、列修飾子、タイムスタンプを持つ複数のセルを出力する場合、最終出力行はそれらのセルを不特定の順序でグループ化します。

Go

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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 同期

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

    rows = table.read_rows(
        filter_=row_filters.RowFilterUnion(
            filters=[
                row_filters.ValueRegexFilter("true"),
                row_filters.ColumnQualifierRegexFilter("os_build"),
            ]
        )
    )
    for row in rows:
        print_row(row)

C#

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

    /// <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 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++

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

PHP

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

# 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

Condition

このフィルタは、true フィルタまたは false フィルタを入力行に適用します。

true または false のフィルタを選択するには、述語フィルタを入力行に適用します。述語フィルタの出力に少なくとも 1 つのセルが含まれている場合は、true フィルタが適用されます。述語フィルタの出力が空の場合は、false フィルタが適用されます。

述語フィルタの出力行は、true または false のフィルタを選択するためにのみ使用されます。読み取りリクエストに対するレスポンスには表示されません。

述語フィルタは、true または false のフィルタではアトミックに実行されません。 つまり、入力行のデータは、述語フィルタの実行時と true または false のフィルタの実行時との間で変化する可能性があります。この動作は、整合性のない結果や予期しない結果につながる可能性があります。

条件フィルタを使用する場合は、true または false のフィルタを省略できます。 フィルタを省略することは、すべてブロック フィルタを指定することと同じです。 述語フィルタが省略した条件を選択した場合、出力行は空になります。

Go

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

このクライアント ライブラリはこのフィルタをサポートしていません。

Java

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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 同期

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

    rows = table.read_rows(
        filter_=row_filters.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)

C#

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

/// <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 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++

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

PHP

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

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

Bigtable 用のクライアント ライブラリをインストールして使用する方法については、Bigtable クライアント ライブラリをご覧ください。

Bigtable で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、クライアント ライブラリの認証を設定するをご覧ください。

# 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

次のステップ