これらの指標は、ユーザー向けのアプリケーションや ML モデルへの入力として使用できます。通常、これらの使用には低レイテンシと高いスループットが必要です。このようなタイプの指標をクエリ時に計算することは大規模なスケールで実用的ではないため、リアルタイム システムでは、データ取り込み時の事前集計が推奨されます。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-04 UTC。"],[[["\u003cp\u003eBigtable aggregates allow for the aggregation of cell values directly at write time, merging new values with existing aggregated data within the cell.\u003c/p\u003e\n"],["\u003cp\u003eAggregates are useful in scenarios where summarized data is needed rather than individual data points, such as creating counters or time buckets.\u003c/p\u003e\n"],["\u003cp\u003eCreating and updating aggregate cells requires the use of \u003ccode\u003eMutateRow\u003c/code\u003e requests with either \u003ccode\u003eAddToCell\u003c/code\u003e to increment or \u003ccode\u003eMergeToCell\u003c/code\u003e to copy values, sent to specially defined aggregate column families.\u003c/p\u003e\n"],["\u003cp\u003eBigtable supports various aggregation types, including sum, minimum, maximum, and HyperLogLog (HLL), each with specific input types.\u003c/p\u003e\n"],["\u003cp\u003eAggregate cells are subject to garbage collection and replication like other cells, but if an add request is sent to a deleted aggregate cell, a new aggregate cell will be created.\u003c/p\u003e\n"]]],[],null,["# Aggregating values at write time\n================================\n\nThis document provides an overview of the ways that you can aggregate your\nBigtable data at write time. Before you read this document, make\nsure that you're familiar with the [Bigtable\noverview](/bigtable/docs/overview).\n\nMany applications track operational metrics that drive use cases\nincluding in-app reporting, real-time recommendations, and rate limiting.\nExamples of such operational metrics include the following:\n\n- Weekly active users\n- Number of ad impressions\n- Views or shares of social content\n- Number of media streams\n\nYou can use these metrics in user-facing applications or as inputs to machine\nlearning models, and their uses typically require low latency and high\nthroughput. Because computing these types of metrics at query time is\nimpractical at scale, pre-aggregation during data ingestion is the preferred\napproach for real-time systems.\n\nBigtable offers multiple ways of aggregating data at write time,\nincluding conflict-free replicated data types, `ReadModifyWriteRow` requests,\nand continuous materialized views.\n\nAggregating your Bigtable data at write time lets you avoid the\nneed to use any extract, transform, and load (ETL) or streaming processing\nsoftware to aggregate your data before or after you write it to\nBigtable. For example, if your application published messages to\nPub/Sub previously and then used Dataflow to read the messages\nand aggregate the data before writing it to Bigtable, you can\ninstead send the data directly to aggregate cells in Bigtable.\n\nConflict-free replicated data types\n-----------------------------------\n\nBigtable lets you create column families that contain only cells\nof type *aggregate* . Aggregate cells are [conflict-free replicated data\ntype](https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type)\nstructures that are optimized for incremental updates.\n\nIf you're migrating to Bigtable from databases such as Apache\nCassandra, Redis, or Valkey, similar structures in those systems are referred to\nas *counters*.\n\nThe following table lists the supported operations and how newly written values\nare handled.\n\nThe mutation types that you can send to create and update aggregate cells are\n[`AddToCell`](/bigtable/docs/reference/data/rpc/google.bigtable.v2#google.bigtable.v2.Mutation.AddToCell)\nand\n[`MergeToCell`](/bigtable/docs/reference/data/rpc/google.bigtable.v2#mergetocell).\n\nTo get started with counting in Bigtable, see the\n[Create and update counters in\nBigtable](/bigtable/docs/create-update-counters) quickstart.\n\nRead then write\n---------------\n\nAnother way to aggregate your data at write time is by using a\n[ReadModifyWriteRow](/bigtable/docs/reference/data/rpc/google.bigtable.v2#readmodifywriterowrequest)\nrequest, which lets you manipulate the value of a cell by incrementing or\nappending to the value transactionally. For more information about when to use\nthis approach, see\n[Appends](/bigtable/docs/writes#appends).\n\nContinuous materialized views\n-----------------------------\n\nA continuous materialized view is a pre-computed result of a SQL query that\naggregates data in a source table. The view continuously processes data as it's\ningested into the source table and batches the updates. This includes updates\nand deletes. Using continuous materialized views can increase performance and\nefficiency. For more information, see [Continuous materialized\nviews](/bigtable/docs/continuous-materialized-views).\n\nWhat's next\n-----------\n\n- [See code samples showing how to add a value to an aggregate\n cell](/bigtable/docs/writing-data#increments-appends).\n- [Review concepts related to schema design.](/bigtable/docs/schema-design)"]]