Yasuhiro Horimoto 2019-04-23 11:18:01 +0900 (Tue, 23 Apr 2019) Revision: 24b8b9b85d8a096481b5415f11edb6a24ffe1b58 https://github.com/groonga/groonga/commit/24b8b9b85d8a096481b5415f11edb6a24ffe1b58 Message: doc: add explanation about window function over shards (#942) * doc: add explanation about window function over shards * doc: add more explanation about window function over shards Added files: doc/source/example/reference/commands/logical_count/window_function_for_over_shard.log doc/source/example/reference/commands/logical_range_filter/window_function_for_over_shard.log doc/source/example/reference/commands/logical_select/window_function_for_over_shard.log Modified files: doc/files.am doc/locale/ja/LC_MESSAGES/reference.po doc/source/reference/commands/logical_count.rst doc/source/reference/commands/logical_range_filter.rst doc/source/reference/commands/logical_select.rst Modified: doc/files.am (+15 -0) =================================================================== --- doc/files.am 2019-04-22 17:10:48 +0900 (8103a8adf) +++ doc/files.am 2019-04-23 11:18:01 +0900 (f2a263743) @@ -139,6 +139,7 @@ absolute_source_files = \ $(top_srcdir)/doc/source/example/reference/commands/logical_count/setup_schema.log \ $(top_srcdir)/doc/source/example/reference/commands/logical_count/usage.log \ $(top_srcdir)/doc/source/example/reference/commands/logical_count/usage_plugin_register.log \ + $(top_srcdir)/doc/source/example/reference/commands/logical_count/window_function_for_over_shard.log \ $(top_srcdir)/doc/source/example/reference/commands/logical_parameters/range_index_always.log \ $(top_srcdir)/doc/source/example/reference/commands/logical_parameters/range_index_auto.log \ $(top_srcdir)/doc/source/example/reference/commands/logical_parameters/range_index_never.log \ @@ -162,6 +163,7 @@ absolute_source_files = \ $(top_srcdir)/doc/source/example/reference/commands/logical_range_filter/sort_keys_one.log \ $(top_srcdir)/doc/source/example/reference/commands/logical_range_filter/usage_plugin_register.log \ $(top_srcdir)/doc/source/example/reference/commands/logical_range_filter/usage_setup.log \ + $(top_srcdir)/doc/source/example/reference/commands/logical_range_filter/window_function_for_over_shard.log \ $(top_srcdir)/doc/source/example/reference/commands/logical_select/cache_no.log \ $(top_srcdir)/doc/source/example/reference/commands/logical_select/columns_name_flags.log \ $(top_srcdir)/doc/source/example/reference/commands/logical_select/columns_name_stage.log \ @@ -207,6 +209,7 @@ absolute_source_files = \ $(top_srcdir)/doc/source/example/reference/commands/logical_select/sort_keys.log \ $(top_srcdir)/doc/source/example/reference/commands/logical_select/usage_plugin_register.log \ $(top_srcdir)/doc/source/example/reference/commands/logical_select/usage_setup.log \ + $(top_srcdir)/doc/source/example/reference/commands/logical_select/window_function_for_over_shard.log \ $(top_srcdir)/doc/source/example/reference/commands/logical_shard_list/logical_table.log \ $(top_srcdir)/doc/source/example/reference/commands/logical_shard_list/usage_list.log \ $(top_srcdir)/doc/source/example/reference/commands/logical_shard_list/usage_register.log \ @@ -1197,6 +1200,7 @@ source_files_relative_from_doc_dir = \ source/example/reference/commands/logical_count/setup_schema.log \ source/example/reference/commands/logical_count/usage.log \ source/example/reference/commands/logical_count/usage_plugin_register.log \ + source/example/reference/commands/logical_count/window_function_for_over_shard.log \ source/example/reference/commands/logical_parameters/range_index_always.log \ source/example/reference/commands/logical_parameters/range_index_auto.log \ source/example/reference/commands/logical_parameters/range_index_never.log \ @@ -1220,6 +1224,7 @@ source_files_relative_from_doc_dir = \ source/example/reference/commands/logical_range_filter/sort_keys_one.log \ source/example/reference/commands/logical_range_filter/usage_plugin_register.log \ source/example/reference/commands/logical_range_filter/usage_setup.log \ + source/example/reference/commands/logical_range_filter/window_function_for_over_shard.log \ source/example/reference/commands/logical_select/cache_no.log \ source/example/reference/commands/logical_select/columns_name_flags.log \ source/example/reference/commands/logical_select/columns_name_stage.log \ @@ -1265,6 +1270,7 @@ source_files_relative_from_doc_dir = \ source/example/reference/commands/logical_select/sort_keys.log \ source/example/reference/commands/logical_select/usage_plugin_register.log \ source/example/reference/commands/logical_select/usage_setup.log \ + source/example/reference/commands/logical_select/window_function_for_over_shard.log \ source/example/reference/commands/logical_shard_list/logical_table.log \ source/example/reference/commands/logical_shard_list/usage_list.log \ source/example/reference/commands/logical_shard_list/usage_register.log \ @@ -2227,9 +2233,15 @@ html_files_relative_from_locale_dir = \ html/_images/geo-points.png \ html/_images/used-when-indexing.png \ html/_images/used-when-searching.png \ + html/_static/ajax-loader.gif \ html/_static/basic.css \ + html/_static/comment-bright.png \ + html/_static/comment-close.png \ + html/_static/comment.png \ html/_static/doctools.js \ html/_static/documentation_options.js \ + html/_static/down-pressed.png \ + html/_static/down.png \ html/_static/favicon.ico \ html/_static/file.png \ html/_static/groonga.css \ @@ -2245,6 +2257,9 @@ html_files_relative_from_locale_dir = \ html/_static/searchtools.js \ html/_static/underscore-1.3.1.js \ html/_static/underscore.js \ + html/_static/up-pressed.png \ + html/_static/up.png \ + html/_static/websupport.js \ html/characteristic.html \ html/client.html \ html/community.html \ Modified: doc/locale/ja/LC_MESSAGES/reference.po (+26 -5) =================================================================== --- doc/locale/ja/LC_MESSAGES/reference.po 2019-04-22 17:10:48 +0900 (e85ca8310) +++ doc/locale/ja/LC_MESSAGES/reference.po 2019-04-23 11:18:01 +0900 (80f65a2e2) @@ -7960,8 +7960,32 @@ msgstr "" ":doc:`select` のすべてのウィンドウ関数関連パラメーターをサポートしています。" "詳細は :ref:`select-window-function-related-parameters` を見てください。" -msgid "Window function over multiple tables aren't supported yet." -msgstr "複数のテーブルをまたがったウィンドウ関数はまだサポートしていません。" +msgid "" +"Window function over multiple tables aren't supported version 9.0.1 or " +"before. Groonga supported it since version 9.0.2 or later. However, we need " +"to align the same order for shard key and leading group key or sort key." +msgstr "" +"バージョン9.0.1以前では、複数のテーブルをまたがったウィンドウ関数はサポートし" +"ていません。バージョン9.0.2以降ではサポートしていますが、先頭のグループキーま" +"たは、ソートキーがシャードキーと同じ順序で並んでいる必要があります。" + +msgid "" +"For example, we can apply the window function to over multiple tables as " +"below case. Because the below example aligns the same order for shard key " +"and leading group key." +msgstr "" +"例えば、以下のようなケースでは、複数のテーブルをまたいでウインドウ関数を適用" +"できます。以下の例では、先頭のグループキーがシャードキーと同じ順序で並んでい" +"るからです。" + +msgid "" +"The leading group key is ``price`` and shard key is ``timestamp`` in the " +"below example. We can apply the window function to over multiple tables in " +"the below example. Because ``price`` and ``timestamp`` aligns the same order." +msgstr "" +"以下の例では、先頭のグループキーは ``price`` でシャードキーは ``timestamp`` " +"です。 ``price`` と ``timestamp`` は同じ順序で並んでいるため、複数のテーブル" +"をまたいでウインドウ関数を適用できます。" msgid "``columns[${NAME}].window.sort_keys``" msgstr "" @@ -29242,6 +29266,3 @@ msgstr "" msgid "``window_sum``" msgstr "" - -#~ msgid "Then flush database::" -#~ msgstr "データベースを書き出す::" Added: doc/source/example/reference/commands/logical_count/window_function_for_over_shard.log (+46 -0) 100644 =================================================================== --- /dev/null +++ doc/source/example/reference/commands/logical_count/window_function_for_over_shard.log 2019-04-23 11:18:01 +0900 (2278cf852) @@ -0,0 +1,46 @@ +Execution example:: + + plugin_register sharding + + table_create Logs_20170415 TABLE_NO_KEY + column_create Logs_20170415 timestamp COLUMN_SCALAR Time + column_create Logs_20170415 price COLUMN_SCALAR UInt32 + column_create Logs_20170415 n_likes COLUMN_SCALAR UInt32 + + table_create Logs_20170416 TABLE_NO_KEY + column_create Logs_20170416 timestamp COLUMN_SCALAR Time + column_create Logs_20170416 price COLUMN_SCALAR UInt32 + column_create Logs_20170416 n_likes COLUMN_SCALAR UInt32 + + load --table Logs_20170415 + [ + {"timestamp": "2017/04/15 00:00:00", "n_likes": 2, "price": 100}, + {"timestamp": "2017/04/15 01:00:00", "n_likes": 1, "price": 100}, + {"timestamp": "2017/04/15 01:00:00", "n_likes": 2, "price": 200} + ] + + load --table Logs_20170416 + [ + {"timestamp": "2017/04/16 10:00:00", "n_likes": 1, "price": 200}, + {"timestamp": "2017/04/16 11:00:00", "n_likes": 2, "price": 300}, + {"timestamp": "2017/04/16 11:00:00", "n_likes": 1, "price": 300} + ] + + logical_count Logs \ + --shard_key timestamp \ + --columns[count].stage initial \ + --columns[count].type UInt32 \ + --columns[count].flags COLUMN_SCALAR \ + --columns[count].value 'window_count()' \ + --columns[count].window.group_keys price \ + --filter 'count >= 1' + # [ + # [ + # 0, + # 0.0, + # 0.0 + # ], + # [ + # 4 + # ] + # ] Added: doc/source/example/reference/commands/logical_range_filter/window_function_for_over_shard.log (+84 -0) 100644 =================================================================== --- /dev/null +++ doc/source/example/reference/commands/logical_range_filter/window_function_for_over_shard.log 2019-04-23 11:18:01 +0900 (5ab68f3cb) @@ -0,0 +1,84 @@ +Execution example:: + + plugin_register sharding + + table_create Logs_20170415 TABLE_NO_KEY + column_create Logs_20170415 timestamp COLUMN_SCALAR Time + column_create Logs_20170415 price COLUMN_SCALAR UInt32 + column_create Logs_20170415 n_likes COLUMN_SCALAR UInt32 + + table_create Logs_20170416 TABLE_NO_KEY + column_create Logs_20170416 timestamp COLUMN_SCALAR Time + column_create Logs_20170416 price COLUMN_SCALAR UInt32 + column_create Logs_20170416 n_likes COLUMN_SCALAR UInt32 + + load --table Logs_20170415 + [ + {"timestamp": "2017/04/15 00:00:00", "n_likes": 2, "price": 100}, + {"timestamp": "2017/04/15 01:00:00", "n_likes": 1, "price": 100}, + {"timestamp": "2017/04/15 01:00:00", "n_likes": 2, "price": 200} + ] + + load --table Logs_20170416 + [ + {"timestamp": "2017/04/16 10:00:00", "n_likes": 1, "price": 200}, + {"timestamp": "2017/04/16 11:00:00", "n_likes": 2, "price": 300}, + {"timestamp": "2017/04/16 11:00:00", "n_likes": 1, "price": 300} + ] + + logical_range_filter Logs \ + --shard_key timestamp \ + --columns[count].stage initial \ + --columns[count].type UInt32 \ + --columns[count].flags COLUMN_SCALAR \ + --columns[count].value 'window_count()' \ + --columns[count].window.group_keys price \ + --output_columns price,count + # [ + # [ + # 0, + # 0.0, + # 0.0 + # ], + # [ + # [ + # [ + # 6 + # ], + # [ + # [ + # "price", + # "UInt32" + # ], + # [ + # "count", + # "UInt32" + # ] + # ], + # [ + # 100, + # 2 + # ], + # [ + # 100, + # 2 + # ], + # [ + # 200, + # 2 + # ], + # [ + # 200, + # 2 + # ], + # [ + # 300, + # 2 + # ], + # [ + # 300, + # 2 + # ] + # ] + # ] + # ] Added: doc/source/example/reference/commands/logical_select/window_function_for_over_shard.log (+84 -0) 100644 =================================================================== --- /dev/null +++ doc/source/example/reference/commands/logical_select/window_function_for_over_shard.log 2019-04-23 11:18:01 +0900 (2d8a2dbc5) @@ -0,0 +1,84 @@ +Execution example:: + + plugin_register sharding + + table_create Logs_20170415 TABLE_NO_KEY + column_create Logs_20170415 timestamp COLUMN_SCALAR Time + column_create Logs_20170415 price COLUMN_SCALAR UInt32 + column_create Logs_20170415 n_likes COLUMN_SCALAR UInt32 + + table_create Logs_20170416 TABLE_NO_KEY + column_create Logs_20170416 timestamp COLUMN_SCALAR Time + column_create Logs_20170416 price COLUMN_SCALAR UInt32 + column_create Logs_20170416 n_likes COLUMN_SCALAR UInt32 + + load --table Logs_20170415 + [ + {"timestamp": "2017/04/15 00:00:00", "n_likes": 2, "price": 100}, + {"timestamp": "2017/04/15 01:00:00", "n_likes": 1, "price": 100}, + {"timestamp": "2017/04/15 01:00:00", "n_likes": 2, "price": 200} + ] + + load --table Logs_20170416 + [ + {"timestamp": "2017/04/16 10:00:00", "n_likes": 1, "price": 200}, + {"timestamp": "2017/04/16 11:00:00", "n_likes": 2, "price": 300}, + {"timestamp": "2017/04/16 11:00:00", "n_likes": 1, "price": 300} + ] + + logical_select Logs \ + --shard_key timestamp \ + --columns[count].stage initial \ + --columns[count].type UInt32 \ + --columns[count].flags COLUMN_SCALAR \ + --columns[count].value 'window_count()' \ + --columns[count].window.group_keys price \ + --output_columns price,count + # [ + # [ + # 0, + # 0.0, + # 0.0 + # ], + # [ + # [ + # [ + # 6 + # ], + # [ + # [ + # "price", + # "UInt32" + # ], + # [ + # "count", + # "UInt32" + # ] + # ], + # [ + # 100, + # 2 + # ], + # [ + # 100, + # 2 + # ], + # [ + # 200, + # 2 + # ], + # [ + # 200, + # 2 + # ], + # [ + # 300, + # 2 + # ], + # [ + # 300, + # 2 + # ] + # ] + # ] + # ] Modified: doc/source/reference/commands/logical_count.rst (+48 -1) =================================================================== --- doc/source/reference/commands/logical_count.rst 2019-04-22 17:10:48 +0900 (a9ff5b95c) +++ doc/source/reference/commands/logical_count.rst 2019-04-23 11:18:01 +0900 (d5e936b28) @@ -564,7 +564,54 @@ details. .. note:: - Window function over multiple tables aren't supported yet. + Window function over multiple tables aren't supported version 9.0.1 or before. + Groonga supported it since version 9.0.2 or later. + However, we need to align the same order for shard key and leading group key or sort key. + + For example, we can apply the window function to over multiple tables as below case. + Because the below example aligns the same order for shard key and leading group key. + + The leading group key is ``price`` and shard key is ``timestamp`` in the below example. + We can apply the window function to over multiple tables in the below example. + Because ``price`` and ``timestamp`` aligns the same order. + +.. groonga-command +.. include:: ../../example/reference/commands/logical_count/window_function_for_over_shard.log + +.. plugin_register sharding +.. +.. table_create Logs_20170415 TABLE_NO_KEY +.. column_create Logs_20170415 timestamp COLUMN_SCALAR Time +.. column_create Logs_20170415 price COLUMN_SCALAR UInt32 +.. column_create Logs_20170415 n_likes COLUMN_SCALAR UInt32 +.. +.. table_create Logs_20170416 TABLE_NO_KEY +.. column_create Logs_20170416 timestamp COLUMN_SCALAR Time +.. column_create Logs_20170416 price COLUMN_SCALAR UInt32 +.. column_create Logs_20170416 n_likes COLUMN_SCALAR UInt32 +.. +.. load --table Logs_20170415 +.. [ +.. {"timestamp": "2017/04/15 00:00:00", "n_likes": 2, "price": 100}, +.. {"timestamp": "2017/04/15 01:00:00", "n_likes": 1, "price": 100}, +.. {"timestamp": "2017/04/15 01:00:00", "n_likes": 2, "price": 200} +.. ] +.. +.. load --table Logs_20170416 +.. [ +.. {"timestamp": "2017/04/16 10:00:00", "n_likes": 1, "price": 200}, +.. {"timestamp": "2017/04/16 11:00:00", "n_likes": 2, "price": 300}, +.. {"timestamp": "2017/04/16 11:00:00", "n_likes": 1, "price": 300} +.. ] +.. +.. logical_count Logs \ +.. --shard_key timestamp \ +.. --columns[count].stage initial \ +.. --columns[count].type UInt32 \ +.. --columns[count].flags COLUMN_SCALAR \ +.. --columns[count].value 'window_count()' \ +.. --columns[count].window.group_keys price \ +.. --output_columns price,count .. _logical-count-columns-name-window-sort-keys: Modified: doc/source/reference/commands/logical_range_filter.rst (+48 -1) =================================================================== --- doc/source/reference/commands/logical_range_filter.rst 2019-04-22 17:10:48 +0900 (15d42095a) +++ doc/source/reference/commands/logical_range_filter.rst 2019-04-23 11:18:01 +0900 (38105e2c2) @@ -602,7 +602,54 @@ details. .. note:: - Window function over multiple tables aren't supported yet. + Window function over multiple tables aren't supported version 9.0.1 or before. + Groonga supported it since version 9.0.2 or later. + However, we need to align the same order for shard key and leading group key or sort key. + + For example, we can apply the window function to over multiple tables as below case. + Because the below example aligns the same order for shard key and leading group key. + + The leading group key is ``price`` and shard key is ``timestamp`` in the below example. + We can apply the window function to over multiple tables in the below example. + Because ``price`` and ``timestamp`` aligns the same order. + +.. groonga-command +.. include:: ../../example/reference/commands/logical_range_filter/window_function_for_over_shard.log + +.. plugin_register sharding +.. +.. table_create Logs_20170415 TABLE_NO_KEY +.. column_create Logs_20170415 timestamp COLUMN_SCALAR Time +.. column_create Logs_20170415 price COLUMN_SCALAR UInt32 +.. column_create Logs_20170415 n_likes COLUMN_SCALAR UInt32 +.. +.. table_create Logs_20170416 TABLE_NO_KEY +.. column_create Logs_20170416 timestamp COLUMN_SCALAR Time +.. column_create Logs_20170416 price COLUMN_SCALAR UInt32 +.. column_create Logs_20170416 n_likes COLUMN_SCALAR UInt32 +.. +.. load --table Logs_20170415 +.. [ +.. {"timestamp": "2017/04/15 00:00:00", "n_likes": 2, "price": 100}, +.. {"timestamp": "2017/04/15 01:00:00", "n_likes": 1, "price": 100}, +.. {"timestamp": "2017/04/15 01:00:00", "n_likes": 2, "price": 200} +.. ] +.. +.. load --table Logs_20170416 +.. [ +.. {"timestamp": "2017/04/16 10:00:00", "n_likes": 1, "price": 200}, +.. {"timestamp": "2017/04/16 11:00:00", "n_likes": 2, "price": 300}, +.. {"timestamp": "2017/04/16 11:00:00", "n_likes": 1, "price": 300} +.. ] +.. +.. logical_range_filter Logs \ +.. --shard_key timestamp \ +.. --columns[count].stage initial \ +.. --columns[count].type UInt32 \ +.. --columns[count].flags COLUMN_SCALAR \ +.. --columns[count].value 'window_count()' \ +.. --columns[count].window.group_keys price \ +.. --output_columns price,count .. _logical-range-filter-columns-name-window-sort-keys: Modified: doc/source/reference/commands/logical_select.rst (+48 -1) =================================================================== --- doc/source/reference/commands/logical_select.rst 2019-04-22 17:10:48 +0900 (2002c82c8) +++ doc/source/reference/commands/logical_select.rst 2019-04-23 11:18:01 +0900 (8a46cead7) @@ -882,7 +882,54 @@ details. .. note:: - Window function over multiple tables aren't supported yet. + Window function over multiple tables aren't supported version 9.0.1 or before. + Groonga supported it since version 9.0.2 or later. + However, we need to align the same order for shard key and leading group key or sort key. + + For example, we can apply the window function to over multiple tables as below case. + Because the below example aligns the same order for shard key and leading group key. + + The leading group key is ``price`` and shard key is ``timestamp`` in the below example. + We can apply the window function to over multiple tables in the below example. + Because ``price`` and ``timestamp`` aligns the same order. + +.. groonga-command +.. include:: ../../example/reference/commands/logical_select/window_function_for_over_shard.log + +.. plugin_register sharding +.. +.. table_create Logs_20170415 TABLE_NO_KEY +.. column_create Logs_20170415 timestamp COLUMN_SCALAR Time +.. column_create Logs_20170415 price COLUMN_SCALAR UInt32 +.. column_create Logs_20170415 n_likes COLUMN_SCALAR UInt32 +.. +.. table_create Logs_20170416 TABLE_NO_KEY +.. column_create Logs_20170416 timestamp COLUMN_SCALAR Time +.. column_create Logs_20170416 price COLUMN_SCALAR UInt32 +.. column_create Logs_20170416 n_likes COLUMN_SCALAR UInt32 +.. +.. load --table Logs_20170415 +.. [ +.. {"timestamp": "2017/04/15 00:00:00", "n_likes": 2, "price": 100}, +.. {"timestamp": "2017/04/15 01:00:00", "n_likes": 1, "price": 100}, +.. {"timestamp": "2017/04/15 01:00:00", "n_likes": 2, "price": 200} +.. ] +.. +.. load --table Logs_20170416 +.. [ +.. {"timestamp": "2017/04/16 10:00:00", "n_likes": 1, "price": 200}, +.. {"timestamp": "2017/04/16 11:00:00", "n_likes": 2, "price": 300}, +.. {"timestamp": "2017/04/16 11:00:00", "n_likes": 1, "price": 300} +.. ] +.. +.. logical_select Logs \ +.. --shard_key timestamp \ +.. --columns[count].stage initial \ +.. --columns[count].type UInt32 \ +.. --columns[count].flags COLUMN_SCALAR \ +.. --columns[count].value 'window_count()' \ +.. --columns[count].window.group_keys price \ +.. --output_columns price,count .. _logical-select-columns-name-window-sort-keys: -------------- next part -------------- An HTML attachment was scrubbed... URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190423/cab1415c/attachment-0001.html>