From 58bd49ee95dc055d65939b32c139c63d881c1710 Mon Sep 17 00:00:00 2001 From: Fengqian Gao Date: Wed, 19 Feb 2014 15:45:10 +0800 Subject: [PATCH] Add comments for _build_paginate_query Add comments for _build_paginate_query which will called _recurse_sort_keys. It will generate the query criteria recursively if multiple sort keys passed in. Change-Id: I102308fc1a57f1ba8bd96e64badedbcf60840c28 --- ceilometer/storage/impl_mongodb.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ceilometer/storage/impl_mongodb.py b/ceilometer/storage/impl_mongodb.py index 62fff58b4..b94dc5f2b 100644 --- a/ceilometer/storage/impl_mongodb.py +++ b/ceilometer/storage/impl_mongodb.py @@ -547,6 +547,14 @@ class Connection(base.Connection): sort_criteria_list = [] for i in range(len(sort_keys)): + #NOTE(fengqian): Generate the query criteria recursively. + #sort_keys=[k1, k2, k3], maker_value=[v1, v2, v3] + #sort_flags = ['$lt', '$gt', 'lt']. + #The query criteria should be + #{'k3': {'$lt': 'v3'}, 'k2': {'eq': 'v2'}, 'k1': {'eq': 'v1'}}, + #{'k2': {'$gt': 'v2'}, 'k1': {'eq': 'v1'}}, + #{'k1': {'$lt': 'v1'}} with 'OR' operation. + #Each recurse will generate one items of three. sort_criteria_list.append(cls._recurse_sort_keys( sort_keys[:(len(sort_keys) - i)], marker, _op))