From 279b08024e8069414550b06a588db90be9615663 Mon Sep 17 00:00:00 2001
From: Konstantin Osipov <kostja@tarantool.org>
Date: Fri, 12 Jul 2013 22:48:25 +0400
Subject: [PATCH] Rename cardinality to arity.

Incompatible change,
https://blueprints.launchpad.net/tarantool/+spec/cardinality-arity

cardinality is how many unique elements a set contains. wrong term
for the max number of fields in a tuple
---
 cfg/tarantool_box_cfg.c        | 32 ++++++++++++++++----------------
 cfg/tarantool_box_cfg.h        |  2 +-
 doc/user/space.xml             |  2 +-
 doc/user/stored-procedures.xml |  8 ++++----
 src/box/box_cfg.cfg_tmpl       |  2 +-
 src/box/box_lua_space.cc       |  4 ++--
 src/box/space.cc               |  6 +++---
 test/box/admin.result          |  2 +-
 test/box/configuration.result  | 26 +++++++++++++-------------
 test/box/lua.result            |  4 ++--
 test/memcached/lua.result      |  2 +-
 test/memcached/lua.test        |  2 +-
 test/memcached/off.result      |  2 +-
 13 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/cfg/tarantool_box_cfg.c b/cfg/tarantool_box_cfg.c
index 59831dba1c..7ceaca74cd 100644
--- a/cfg/tarantool_box_cfg.c
+++ b/cfg/tarantool_box_cfg.c
@@ -131,7 +131,7 @@ swap_tarantool_cfg(struct tarantool_cfg *c1, struct tarantool_cfg *c2) {
 static int
 acceptDefault_name__space(tarantool_cfg_space *c) {
 	c->enabled = -1;
-	c->cardinality = -1;
+	c->arity = -1;
 	c->estimated_rows = 0;
 	c->index = NULL;
 	return 0;
@@ -275,9 +275,9 @@ static NameAtom _name__space__enabled[] = {
 	{ "space", -1, _name__space__enabled + 1 },
 	{ "enabled", -1, NULL }
 };
-static NameAtom _name__space__cardinality[] = {
-	{ "space", -1, _name__space__cardinality + 1 },
-	{ "cardinality", -1, NULL }
+static NameAtom _name__space__arity[] = {
+	{ "space", -1, _name__space__arity + 1 },
+	{ "arity", -1, NULL }
 };
 static NameAtom _name__space__estimated_rows[] = {
 	{ "space", -1, _name__space__estimated_rows + 1 },
@@ -920,7 +920,7 @@ acceptValue(tarantool_cfg* c, OptDef* opt, int check_rdonly) {
 			return CNF_RDONLY;
 		c->space[opt->name->index]->enabled = bln;
 	}
-	else if ( cmpNameAtoms( opt->name, _name__space__cardinality) ) {
+	else if ( cmpNameAtoms( opt->name, _name__space__arity) ) {
 		if (opt->paramType != scalarType )
 			return CNF_WRONGTYPE;
 		ARRAYALLOC(c->space, opt->name->index + 1, _name__space, check_rdonly, CNF_FLAG_STRUCT_NEW | CNF_FLAG_STRUCT_NOTSET);
@@ -934,9 +934,9 @@ acceptValue(tarantool_cfg* c, OptDef* opt, int check_rdonly) {
 			return CNF_WRONGINT;
 		if ( (i32 == LONG_MIN || i32 == LONG_MAX) && errno == ERANGE)
 			return CNF_WRONGRANGE;
-		if (check_rdonly && c->space[opt->name->index]->cardinality != i32)
+		if (check_rdonly && c->space[opt->name->index]->arity != i32)
 			return CNF_RDONLY;
-		c->space[opt->name->index]->cardinality = i32;
+		c->space[opt->name->index]->arity = i32;
 	}
 	else if ( cmpNameAtoms( opt->name, _name__space__estimated_rows) ) {
 		if (opt->paramType != scalarType )
@@ -1237,7 +1237,7 @@ typedef enum IteratorState {
 	S_name__replication_source,
 	S_name__space,
 	S_name__space__enabled,
-	S_name__space__cardinality,
+	S_name__space__arity,
 	S_name__space__estimated_rows,
 	S_name__space__index,
 	S_name__space__index__type,
@@ -1682,7 +1682,7 @@ tarantool_cfg_iterator_next(tarantool_cfg_iterator_t* i, tarantool_cfg *c, char
 		case S_name__space:
 			i->state = S_name__space;
 		case S_name__space__enabled:
-		case S_name__space__cardinality:
+		case S_name__space__arity:
 		case S_name__space__estimated_rows:
 		case S_name__space__index:
 		case S_name__space__index__type:
@@ -1702,17 +1702,17 @@ tarantool_cfg_iterator_next(tarantool_cfg_iterator_t* i, tarantool_cfg *c, char
 						}
 						sprintf(*v, "%s", c->space[i->idx_name__space]->enabled == -1 ? "false" : c->space[i->idx_name__space]->enabled ? "true" : "false");
 						snprintf(buf, PRINTBUFLEN-1, "space[%d].enabled", i->idx_name__space);
-						i->state = S_name__space__cardinality;
+						i->state = S_name__space__arity;
 						return buf;
-					case S_name__space__cardinality:
+					case S_name__space__arity:
 						*v = malloc(32);
 						if (*v == NULL) {
 							free(i);
 							out_warning(CNF_NOMEMORY, "No memory to output value");
 							return NULL;
 						}
-						sprintf(*v, "%"PRId32, c->space[i->idx_name__space]->cardinality);
-						snprintf(buf, PRINTBUFLEN-1, "space[%d].cardinality", i->idx_name__space);
+						sprintf(*v, "%"PRId32, c->space[i->idx_name__space]->arity);
+						snprintf(buf, PRINTBUFLEN-1, "space[%d].arity", i->idx_name__space);
 						i->state = S_name__space__estimated_rows;
 						return buf;
 					case S_name__space__estimated_rows:
@@ -2026,7 +2026,7 @@ dup_tarantool_cfg(tarantool_cfg* dst, tarantool_cfg* src) {
 
 			dst->space[i->idx_name__space]->__confetti_flags = src->space[i->idx_name__space]->__confetti_flags;
 			dst->space[i->idx_name__space]->enabled = src->space[i->idx_name__space]->enabled;
-			dst->space[i->idx_name__space]->cardinality = src->space[i->idx_name__space]->cardinality;
+			dst->space[i->idx_name__space]->arity = src->space[i->idx_name__space]->arity;
 			dst->space[i->idx_name__space]->estimated_rows = src->space[i->idx_name__space]->estimated_rows;
 
 			dst->space[i->idx_name__space]->index = NULL;
@@ -2380,8 +2380,8 @@ cmp_tarantool_cfg(tarantool_cfg* c1, tarantool_cfg* c2, int only_check_rdonly) {
 
 			return diff;
 		}
-		if (c1->space[i1->idx_name__space]->cardinality != c2->space[i2->idx_name__space]->cardinality) {
-			snprintf(diff, PRINTBUFLEN - 1, "%s", "c->space[]->cardinality");
+		if (c1->space[i1->idx_name__space]->arity != c2->space[i2->idx_name__space]->arity) {
+			snprintf(diff, PRINTBUFLEN - 1, "%s", "c->space[]->arity");
 
 			return diff;
 		}
diff --git a/cfg/tarantool_box_cfg.h b/cfg/tarantool_box_cfg.h
index 2c883bbdca..2f69815645 100644
--- a/cfg/tarantool_box_cfg.h
+++ b/cfg/tarantool_box_cfg.h
@@ -32,7 +32,7 @@ typedef struct tarantool_cfg_space {
 	unsigned char __confetti_flags;
 
 	confetti_bool_t	enabled;
-	int32_t	cardinality;
+	int32_t	arity;
 	int32_t	estimated_rows;
 	tarantool_cfg_space_index**	index;
 } tarantool_cfg_space;
diff --git a/doc/user/space.xml b/doc/user/space.xml
index 655af9e063..4b37baabf0 100644
--- a/doc/user/space.xml
+++ b/doc/user/space.xml
@@ -44,7 +44,7 @@ struct space_t
    * If given, each tuple in the space must have exactly
    * this many fields.
    */
-  unsigned int cardinality;
+  unsigned int arity;
   /* Only used for HASH indexes, to preallocate memory. */
   unsigned int estimated_rows;
   struct index_t index[];
diff --git a/doc/user/stored-procedures.xml b/doc/user/stored-procedures.xml
index ae4d40dbbb..cbb100b7ff 100644
--- a/doc/user/stored-procedures.xml
+++ b/doc/user/stored-procedures.xml
@@ -582,7 +582,7 @@ Call ERROR, Illegal parameters, key is not u32 (ER_ILLEGAL_PARAMS)
 <programlisting>localhost> show configuration
 ---
 ...
-  space[4].cardinality: "-1"
+  space[4].arity: "-1"
   space[4].estimated_rows: "0"
   space[4].index[0].type: "HASH"
   space[4].index[0].unique: "true"
@@ -652,7 +652,7 @@ localhost> lua box.select_range(4, 1, 2, '1')
 <programlisting>localhost> show configuration
 ---
 ...
-  space[4].cardinality: "-1"
+  space[4].arity: "-1"
   space[4].estimated_rows: "0"
   space[4].index[0].type: "HASH"
   space[4].index[0].unique: "true"
@@ -1230,7 +1230,7 @@ lua box.cjson.decode('{"hello": "world"}').hello
     <para>This package is a container for all
     configured spaces. A space object provides access to space
     attributes, such as id, whether or not a space is
-    enabled, space cardinality, estimated number of rows. It also
+    enabled, space arity, estimated number of rows. It also
     contains object-oriented versions of <code>box</code>
     functions. For example, instead of <code>box.insert(0, ...)</code>
     one can write <code>box.space[0]:insert(...)</code>.
@@ -1251,7 +1251,7 @@ lua box.cjson.decode('{"hello": "world"}').hello
 
     <varlistentry>
         <term>
-            <emphasis role="lua">space.cardinality</emphasis>
+            <emphasis role="lua">space.arity</emphasis>
         </term>
         <listitem><simpara>
             A limit on tuple field count for tuples in this space.
diff --git a/src/box/box_cfg.cfg_tmpl b/src/box/box_cfg.cfg_tmpl
index 318b287932..5b1e3864c7 100644
--- a/src/box/box_cfg.cfg_tmpl
+++ b/src/box/box_cfg.cfg_tmpl
@@ -35,7 +35,7 @@ replication_source=NULL
 space = [
   {
     enabled = false, required
-    cardinality = -1
+    arity = -1
     estimated_rows = 0
     index = [
       {
diff --git a/src/box/box_lua_space.cc b/src/box/box_lua_space.cc
index 6fff336d78..dc0d434baf 100644
--- a/src/box/box_lua_space.cc
+++ b/src/box/box_lua_space.cc
@@ -49,8 +49,8 @@ lbox_pushspace(struct lua_State *L, struct space *space)
 {
 	lua_newtable(L);
 
-	/* space.cardinality */
-	lua_pushstring(L, "cardinality");
+	/* space.arity */
+	lua_pushstring(L, "arity");
 	lua_pushnumber(L, space->arity);
 	lua_settable(L, -3);
 
diff --git a/src/box/space.cc b/src/box/space.cc
index d9c2550104..39b6272ca1 100644
--- a/src/box/space.cc
+++ b/src/box/space.cc
@@ -202,7 +202,7 @@ space_validate_tuple(struct space *sp, struct tuple *new_tuple)
 {
 	if (sp->arity > 0 && sp->arity != new_tuple->field_count)
 		tnt_raise(IllegalParams,
-			  "tuple field count must match space cardinality");
+			  "tuple field count must match space arity");
 
 }
 
@@ -237,8 +237,8 @@ space_config()
 
 		assert(cfg.memcached_port == 0 || i != cfg.memcached_space);
 
-		uint32_t arity = (cfg_space->cardinality != -1 ?
-				  cfg_space->cardinality : 0);
+		uint32_t arity = (cfg_space->arity != -1 ?
+				  cfg_space->arity : 0);
 		/*
 		 * Collect key/field info. We need aggregate
 		 * information on all keys before we can create
diff --git a/test/box/admin.result b/test/box/admin.result
index 5e9a0f43e4..7035da227c 100644
--- a/test/box/admin.result
+++ b/test/box/admin.result
@@ -70,7 +70,7 @@ configuration:
   memcached_expire_full_sweep: "3600"
   replication_source: (null)
   space[0].enabled: "true"
-  space[0].cardinality: "-1"
+  space[0].arity: "-1"
   space[0].estimated_rows: "0"
   space[0].index[0].type: "HASH"
   space[0].index[0].unique: "true"
diff --git a/test/box/configuration.result b/test/box/configuration.result
index 62f81900b6..18faf41fc8 100644
--- a/test/box/configuration.result
+++ b/test/box/configuration.result
@@ -46,17 +46,17 @@ configuration:
   memcached_expire_full_sweep: "3600"
   replication_source: (null)
   space[0].enabled: "true"
-  space[0].cardinality: "-1"
+  space[0].arity: "-1"
   space[0].estimated_rows: "0"
   space[0].index[0].type: "HASH"
   space[0].index[0].unique: "true"
   space[0].index[0].key_field[0].fieldno: "0"
   space[0].index[0].key_field[0].type: "NUM"
   space[1].enabled: "false"
-  space[1].cardinality: "-1"
+  space[1].arity: "-1"
   space[1].estimated_rows: "0"
   space[2].enabled: "true"
-  space[2].cardinality: "-1"
+  space[2].arity: "-1"
   space[2].estimated_rows: "0"
   space[2].index[0].type: "HASH"
   space[2].index[0].unique: "true"
@@ -110,70 +110,70 @@ configuration:
   memcached_expire_full_sweep: "3600"
   replication_source: (null)
   space[0].enabled: "false"
-  space[0].cardinality: "-1"
+  space[0].arity: "-1"
   space[0].estimated_rows: "0"
   space[0].index[0].type: "HASH"
   space[0].index[0].unique: "false"
   space[0].index[0].key_field[0].fieldno: "0"
   space[0].index[0].key_field[0].type: "NUM"
   space[1].enabled: "true"
-  space[1].cardinality: "-1"
+  space[1].arity: "-1"
   space[1].estimated_rows: "0"
   space[1].index[0].type: "HASH"
   space[1].index[0].unique: "true"
   space[1].index[0].key_field[0].fieldno: "0"
   space[1].index[0].key_field[0].type: "NUM"
   space[2].enabled: "false"
-  space[2].cardinality: "-1"
+  space[2].arity: "-1"
   space[2].estimated_rows: "0"
   space[2].index[0].type: "HASH"
   space[2].index[0].unique: "false"
   space[2].index[0].key_field[0].fieldno: "0"
   space[2].index[0].key_field[0].type: "NUM"
   space[3].enabled: "true"
-  space[3].cardinality: "-1"
+  space[3].arity: "-1"
   space[3].estimated_rows: "0"
   space[3].index[0].type: "HASH"
   space[3].index[0].unique: "true"
   space[3].index[0].key_field[0].fieldno: "0"
   space[3].index[0].key_field[0].type: "NUM"
   space[4].enabled: "false"
-  space[4].cardinality: "-1"
+  space[4].arity: "-1"
   space[4].estimated_rows: "0"
   space[4].index[0].type: "HASH"
   space[4].index[0].unique: "false"
   space[4].index[0].key_field[0].fieldno: "0"
   space[4].index[0].key_field[0].type: "NUM"
   space[5].enabled: "true"
-  space[5].cardinality: "-1"
+  space[5].arity: "-1"
   space[5].estimated_rows: "0"
   space[5].index[0].type: "HASH"
   space[5].index[0].unique: "true"
   space[5].index[0].key_field[0].fieldno: "0"
   space[5].index[0].key_field[0].type: "NUM"
   space[6].enabled: "false"
-  space[6].cardinality: "-1"
+  space[6].arity: "-1"
   space[6].estimated_rows: "0"
   space[6].index[0].type: "HASH"
   space[6].index[0].unique: "false"
   space[6].index[0].key_field[0].fieldno: "0"
   space[6].index[0].key_field[0].type: "NUM"
   space[7].enabled: "true"
-  space[7].cardinality: "-1"
+  space[7].arity: "-1"
   space[7].estimated_rows: "0"
   space[7].index[0].type: "HASH"
   space[7].index[0].unique: "true"
   space[7].index[0].key_field[0].fieldno: "0"
   space[7].index[0].key_field[0].type: "NUM"
   space[8].enabled: "false"
-  space[8].cardinality: "-1"
+  space[8].arity: "-1"
   space[8].estimated_rows: "0"
   space[8].index[0].type: "HASH"
   space[8].index[0].unique: "false"
   space[8].index[0].key_field[0].fieldno: "0"
   space[8].index[0].key_field[0].type: "NUM"
   space[9].enabled: "true"
-  space[9].cardinality: "-1"
+  space[9].arity: "-1"
   space[9].estimated_rows: "0"
   space[9].index[0].type: "HASH"
   space[9].index[0].unique: "true"
diff --git a/test/box/lua.result b/test/box/lua.result
index 95c8a0e1f0..5ce56a2d74 100644
--- a/test/box/lua.result
+++ b/test/box/lua.result
@@ -456,10 +456,10 @@ lua for k,v in pairs(box.cfg) do print(' - ', k, ': ', v) end
 ...
 lua for k,v in pairs(box.space[0]) do if type(v) ~= 'table' then print(' - ', k, ': ', v) end end
 ---
- - cardinality: 0
  - estimated_rows: 0
  - n: 0
  - enabled: true
+ - arity: 0
 ...
 reload configuration
 ---
@@ -504,10 +504,10 @@ lua for k,v in pairs(box.cfg) do print(' - ', k, ': ', v) end
 ...
 lua for k,v in pairs(box.space[0]) do if type(v) ~= 'table' then print(' - ', k, ': ', v) end end
 ---
- - cardinality: 0
  - estimated_rows: 0
  - n: 0
  - enabled: true
+ - arity: 0
 ...
 lua box.cfg.nosuchoption = 1
 ---
diff --git a/test/memcached/lua.result b/test/memcached/lua.result
index 9c24c73eed..d1e437fddb 100644
--- a/test/memcached/lua.result
+++ b/test/memcached/lua.result
@@ -1,4 +1,4 @@
-lua box.space[box.cfg.memcached_space].cardinality
+lua box.space[box.cfg.memcached_space].arity
 ---
  - 4
 ...
diff --git a/test/memcached/lua.test b/test/memcached/lua.test
index 6e1fd54b9e..feb3dfda82 100644
--- a/test/memcached/lua.test
+++ b/test/memcached/lua.test
@@ -1,5 +1,5 @@
 # encoding: utf-8
-admin("lua box.space[box.cfg.memcached_space].cardinality")
+admin("lua box.space[box.cfg.memcached_space].arity")
 admin("lua box.space[box.cfg.memcached_space].estimated_rows")
 admin("lua box.space[box.cfg.memcached_space].n")
 admin("lua box.space[box.cfg.memcached_space].index[0].idx")
diff --git a/test/memcached/off.result b/test/memcached/off.result
index a2ccef2bcc..b5bd0d754b 100644
--- a/test/memcached/off.result
+++ b/test/memcached/off.result
@@ -45,7 +45,7 @@ configuration:
   memcached_expire_full_sweep: "3600"
   replication_source: (null)
   space[0].enabled: "true"
-  space[0].cardinality: "-1"
+  space[0].arity: "-1"
   space[0].estimated_rows: "0"
   space[0].index[0].type: "HASH"
   space[0].index[0].unique: "true"
-- 
GitLab