タイムスタンプ範囲フィルタを使用した読み取り(HBase)

セルのタイムスタンプの範囲に制限フィルタを作成します。

もっと見る

このコードサンプルを含む詳細なドキュメントについては、以下をご覧ください。

コードサンプル

Java

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

次のステップ

他の Google Cloud プロダクトに関連するコードサンプルの検索およびフィルタ検索を行うには、Google Cloud のサンプルをご覧ください。