Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: kostja@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [PATCH] box: account index.pairs in box.stat.SELECT
Date: Thu, 11 Apr 2019 22:44:25 +0300	[thread overview]
Message-ID: <0f5fb28d436492ba232a23ae5972eae45078c2a9.1555011830.git.vdavydov.dev@gmail.com> (raw)

box.stat.SELECT accounts index.get and index.select, but not
index.pairs, which is confusing since pairs() may be used even
more often than select() in a Lua application.
---
https://github.com/tarantool/tarantool/commits/dv/account-pairs-in-stat-select

 src/box/index.cc       |  1 +
 test/box/stat.result   | 39 +++++++++++++++++++++++++++++++++++++++
 test/box/stat.test.lua | 12 ++++++++++++
 3 files changed, 52 insertions(+)

diff --git a/src/box/index.cc b/src/box/index.cc
index 3c53ae81..2817d076 100644
--- a/src/box/index.cc
+++ b/src/box/index.cc
@@ -380,6 +380,7 @@ box_index_iterator(uint32_t space_id, uint32_t index_id, int type,
 		return NULL;
 	}
 	txn_commit_ro_stmt(txn);
+	rmean_collect(rmean_box, IPROTO_SELECT, 1);
 	return it;
 }
 
diff --git a/test/box/stat.result b/test/box/stat.result
index af1607db..757ec0bc 100644
--- a/test/box/stat.result
+++ b/test/box/stat.result
@@ -70,6 +70,45 @@ box.stat.ERROR.total
 ---
 - 1
 ...
+-- select, get, and pairs
+space:get(1)
+---
+- [1, 'tuple1']
+...
+box.stat.SELECT.total
+---
+- 5
+...
+space:get(11)
+---
+...
+box.stat.SELECT.total
+---
+- 6
+...
+space:select(5)
+---
+- - [5, 'tuple5']
+...
+box.stat.SELECT.total
+---
+- 7
+...
+space:select(15)
+---
+- []
+...
+box.stat.SELECT.total
+---
+- 8
+...
+for _ in space:pairs() do end
+---
+...
+box.stat.SELECT.total
+---
+- 9
+...
 -- reset
 box.stat.reset()
 ---
diff --git a/test/box/stat.test.lua b/test/box/stat.test.lua
index 65555127..6ee1ec44 100644
--- a/test/box/stat.test.lua
+++ b/test/box/stat.test.lua
@@ -26,6 +26,18 @@ box.stat.SELECT.total
 space:get('Impossible value')
 box.stat.ERROR.total
 
+-- select, get, and pairs
+space:get(1)
+box.stat.SELECT.total
+space:get(11)
+box.stat.SELECT.total
+space:select(5)
+box.stat.SELECT.total
+space:select(15)
+box.stat.SELECT.total
+for _ in space:pairs() do end
+box.stat.SELECT.total
+
 -- reset
 box.stat.reset()
 box.stat.INSERT.total
-- 
2.11.0

             reply	other threads:[~2019-04-11 19:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-11 19:44 Vladimir Davydov [this message]
2019-04-11 20:04 ` Konstantin Osipov
2019-04-11 20:30   ` Vladimir Davydov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0f5fb28d436492ba232a23ae5972eae45078c2a9.1555011830.git.vdavydov.dev@gmail.com \
    --to=vdavydov.dev@gmail.com \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH] box: account index.pairs in box.stat.SELECT' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox