Branch: refs/heads/master
  Home:   https://github.com/mailru/tarantool
  Commit: c364dc9db86fd3787d306c305d5a6c4f1d8d76e9
      
https://github.com/mailru/tarantool/commit/c364dc9db86fd3787d306c305d5a6c4f1d8d76e9
  Author: Konstantin Shulgin <[email protected]>
  Date:   2012-05-03 (Thu, 03 May 2012)

  Changed paths:
    M test/box/lua.result
    M test/box/lua.test

  Log Message:
  -----------
  box/lua.test minor fixes.


diff --git a/test/box/lua.result b/test/box/lua.result
index fa860aa..b341480 100644
Binary files a/test/box/lua.result and b/test/box/lua.result differ
diff --git a/test/box/lua.test b/test/box/lua.test
index da4e2e5..bc89b0d 100644
--- a/test/box/lua.test
+++ b/test/box/lua.test
@@ -405,15 +405,15 @@ exec admin "lua print_config()"
 print """
 # Test bug #977898
 """
-# Run a couple of dummy selects to avoid race conditions under valgrind
-exec admin "lua box.select(0, 0, 4)"
-exec admin "lua box.select(0, 0, 5)"
-exec admin "lua box.select(0, 0, 1)"
+# Run a dummy insert to avoid race conditions under valgrind
+exec admin "lua box.insert(0, 4, 8, 16)"
 
 print """
 # Test insert from init.lua
 """
+exec admin "lua box.select(0, 0, 1)"
 exec admin "lua box.select(0, 0, 2)"
+exec admin "lua box.select(0, 0, 4)"
 
 print """
 # clean-up after tests


================================================================
  Commit: 971831995bf544e9e0a3722d2f8ced670926c261
      
https://github.com/mailru/tarantool/commit/971831995bf544e9e0a3722d2f8ced670926c261
  Author: Konstantin Shulgin <[email protected]>
  Date:   2012-05-03 (Thu, 03 May 2012)

  Changed paths:
    M mod/box/box.h
    M mod/box/box.lua
    M mod/box/box.m
    M mod/box/box_lua.m
    M mod/box/index.h
    M mod/box/memcached.m
    M mod/box/tree.m
    M mod/box/tuple.h
    M mod/box/tuple.m
    M src/pickle.m
    M test/connector_c/tt.c

  Log Message:
  -----------
  Merge branch 'master' of github.com:mailru/tarantool


diff --git a/mod/box/box.h b/mod/box/box.h
index 4b7cbf8..bf94f4c 100644
--- a/mod/box/box.h
+++ b/mod/box/box.h
@@ -45,7 +45,12 @@ enum
 
 struct space {
        Index *index[BOX_INDEX_MAX];
-       int cardinality;
+       /** If not set (is 0), any tuple in the
+        * space can have any number of fields (but
+        * @sa max_fieldno). If set, Each tuple
+        * must have exactly this many fields.
+        */
+       int arity;
 
        /**
         * The number of indexes in the space.
@@ -75,7 +80,7 @@ struct space {
         * Each tuple in this space must have, therefore, at least
         * field_count fields.
         */
-       int field_count;
+       int max_fieldno;
 
        bool enabled;
 };
diff --git a/mod/box/box.lua b/mod/box/box.lua
index deecd81..94f31c6 100644
--- a/mod/box/box.lua
+++ b/mod/box/box.lua
@@ -29,15 +29,15 @@ box.flags = create_const_table(
 --
 --
 function box.select_limit(space, index, offset, limit, ...)
-    local cardinality = select('#', ...)
+    local part_count = select('#', ...)
     return box.process(17,
-                       box.pack('iiiiii'..string.rep('p', cardinality),
+                       box.pack('iiiiii'..string.rep('p', part_count),
                                  space,
                                  index,
                                  offset,
                                  limit,
                                  1, -- key count
-                                 cardinality, -- key cardinality
+                                 part_count, -- key part count
                                  ...))
 end
 
@@ -45,15 +45,15 @@ end
 --
 --
 function box.select(space, index, ...)
-    local cardinality = select('#', ...)
+    local part_count = select('#', ...)
     return box.process(17,
-                       box.pack('iiiiii'..string.rep('p', cardinality),
+                       box.pack('iiiiii'..string.rep('p', part_count),
                                  space,
                                  index,
                                  0, -- offset
                                  4294967295, -- limit
                                  1, -- key count
-                                 cardinality, -- key cardinality
+                                 part_count, -- key part count
                                  ...))
 end
 
@@ -80,35 +80,35 @@ end
 -- index is always 0. It doesn't accept compound keys
 --
 function box.delete(space, ...)
-    local cardinality = select('#', ...)
+    local part_count = select('#', ...)
     return box.process(21,
-                       box.pack('iii'..string.rep('p', cardinality),
+                       box.pack('iii'..string.rep('p', part_count),
                                  space,
                                  box.flags.BOX_RETURN_TUPLE,  -- flags
-                                 cardinality, -- key cardinality
+                                 part_count, -- key part count
                                  ...))
 end
 
 -- insert or replace a tuple
 function box.replace(space, ...)
-    local cardinality = select('#', ...)
+    local part_count = select('#', ...)
     return box.process(13,
-                       box.pack('iii'..string.rep('p', cardinality),
+                       box.pack('iii'..string.rep('p', part_count),
                                  space,
                                  box.flags.BOX_RETURN_TUPLE,  -- flags
-                                 cardinality, -- cardinality
+                                 part_count, -- key part count
                                  ...))
 end
 
 -- insert a tuple (produces an error if the tuple already exists)
 function box.insert(space, ...)
-    local cardinality = select('#', ...)
+    local part_count = select('#', ...)
     return box.process(13,
-                       box.pack('iii'..string.rep('p', cardinality),
+                       box.pack('iii'..string.rep('p', part_count),
                                 space,
                                 bit.bor(box.flags.BOX_RETURN_TUPLE,
                                         box.flags.BOX_ADD),  -- flags
-                                cardinality, -- cardinality
+                                part_count, -- key part count
                                 ...))
 end
 
@@ -119,7 +119,7 @@ function box.update(space, key, format, ...)
                        box.pack('iiipi'..format,
                                   space,
                                   1, -- flags, BOX_RETURN_TUPLE
-                                  1, -- cardinality
+                                  1, -- primary key part count
                                   key, -- primary key
                                   op_count, -- op count
                                   ...))
@@ -202,7 +202,7 @@ function box.update_ol(space, ops_list, ...)
 
     -- fill UPDATE command key
     format = format .. 'i'
-    table.insert(args_list, #key) -- key cardinality
+    table.insert(args_list, #key) -- key part count
     for itr, val in ipairs(key) do
         format = format .. 'p'
         table.insert(args_list, val) -- key field
diff --git a/mod/box/box.m b/mod/box/box.m
index 391402f..b61f531 100644
--- a/mod/box/box.m
+++ b/mod/box/box.m
@@ -153,12 +153,12 @@
        }
 
        /* Check to see if the tuple has a sufficient number of fields. */
-       if (txn->tuple->cardinality < sp->field_count)
+       if (txn->tuple->field_count < sp->max_fieldno)
                tnt_raise(IllegalParams, :"tuple must have all indexed fields");
 
        /* Sweep through the tuple and check the field sizes. */
        u8 *data = txn->tuple->data;
-       for (int f = 0; f < sp->field_count; ++f) {
+       for (int f = 0; f < sp->max_fieldno; ++f) {
                /* Get the size of the current field and advance. */
                u32 len = load_varint32((void **) &data);
                data += len;
@@ -186,34 +186,34 @@ size fields (STRING and UNKNOWN). */
 }
 
 static void
-read_key(struct tbuf *data, void **key_ptr, u32 *key_cardinality_ptr)
+read_key(struct tbuf *data, void **key_ptr, u32 *key_part_count_ptr)
 {
        void *key = NULL;
-       u32 key_cardinality = read_u32(data);
-       if (key_cardinality) {
+       u32 key_part_count = read_u32(data);
+       if (key_part_count) {
                key = read_field(data);
                /* advance remaining fields of a key */
-               for (int i = 1; i < key_cardinality; i++)
+               for (int i = 1; i < key_part_count; i++)
                        read_field(data);
        }
 
        *key_ptr = key;
-       *key_cardinality_ptr = key_cardinality;
+       *key_part_count_ptr = key_part_count;
 }
 
 static void __attribute__((noinline))
-prepare_replace(struct box_txn *txn, size_t cardinality, struct tbuf *data)
+prepare_replace(struct box_txn *txn, size_t field_count, struct tbuf *data)
 {
        assert(data != NULL);
-       if (cardinality == 0)
-               tnt_raise(IllegalParams, :"tuple cardinality is 0");
+       if (field_count == 0)
+               tnt_raise(IllegalParams, :"tuple field count is 0");
 
-       if (data->size == 0 || data->size != valid_tuple(data, cardinality))
+       if (data->size == 0 || data->size != valid_tuple(data, field_count))
                tnt_raise(IllegalParams, :"incorrect tuple length");
 
        txn->tuple = tuple_alloc(data->size);
        tuple_txn_ref(txn, txn->tuple);
-       txn->tuple->cardinality = cardinality;
+       txn->tuple->field_count = field_count;
        memcpy(txn->tuple->data, data->data, data->size);
 
        txn->old_tuple = [txn->index findByTuple: txn->tuple];
@@ -416,8 +416,8 @@ typedef void (*init_op_func)(struct update_cmd *cmd,
 struct update_cmd {
        /** Search key */
        void *key;
-       /** Search key cardinality */
-       u32 key_cardinality;
+       /** Search key part count. */
+       u32 key_part_count;
        /** Operations. */
        struct update_op *op;
        struct update_op *op_end;
@@ -733,7 +733,7 @@ case sizeof(i64):
        struct update_cmd *cmd = palloc(fiber->gc_pool,
                                        sizeof(struct update_cmd));
 
-       read_key(data, &cmd->key, &cmd->key_cardinality);
+       read_key(data, &cmd->key, &cmd->key_part_count);
        /* number of operations */
        u32 op_cnt = read_u32(data);
        if (op_cnt > BOX_UPDATE_OP_CNT_MAX)
@@ -858,7 +858,7 @@ case sizeof(i64):
        struct update_op *op = cmd->op;
        struct update_field *field = cmd->field;
        void *old_data = txn->old_tuple->data;
-       int old_field_count = txn->old_tuple->cardinality;
+       int old_field_count = txn->old_tuple->field_count;
 
        update_field_init(field, op, &old_data, old_field_count);
        do {
@@ -952,12 +952,12 @@ case sizeof(i64):
        void *new_data = txn->tuple->data;
        void *new_data_end = new_data + txn->tuple->bsize;
        struct update_field *field;
-       txn->tuple->cardinality = 0;
+       txn->tuple->field_count = 0;
 
        for (field = cmd->field; field < cmd->field_end; field++) {
                if (field->first < field->end) { /* -> field is not deleted. */
                        new_data = save_varint32(new_data, field->new_len);
-                       txn->tuple->cardinality++;
+                       txn->tuple->field_count++;
                }
                void *new_field = new_data;
                void *old_field = field->old;
@@ -1003,7 +1003,7 @@ case sizeof(i64):
                if (field->tail_field_count) {
                        memcpy(new_data, field->tail, field->tail_len);
                        new_data += field->tail_len;
-                       txn->tuple->cardinality += field->tail_field_count;
+                       txn->tuple->field_count += field->tail_field_count;
                }
        }
 }
@@ -1017,7 +1017,7 @@ static void __attribute__((noinline))
        struct update_cmd *cmd = parse_update_cmd(data);
 
        /* Try to find the tuple. */
-       txn->old_tuple = [txn->index findByKey :cmd->key :cmd->key_cardinality];
+       txn->old_tuple = [txn->index findByKey :cmd->key :cmd->key_part_count];
        if (txn->old_tuple == NULL) {
                /* Not found. For simplicity, skip the logging. */
                txn->flags |= BOX_NOT_STORE;
@@ -1065,12 +1065,12 @@ static void __attribute__((noinline))
                        return;
 
                /* read key */
-               u32 key_cardinality;
+               u32 key_part_count;
                void *key;
-               read_key(data, &key, &key_cardinality);
+               read_key(data, &key, &key_part_count);
 
                struct iterator *it = index->position;
-               [index initIteratorByKey: it :ITER_FORWARD :key 
:key_cardinality];
+               [index initIteratorByKey: it :ITER_FORWARD :key 
:key_part_count];
 
                while ((tuple = it->next_equal(it)) != NULL) {
                        if (tuple->flags & GHOST)
@@ -1097,11 +1097,11 @@ static void __attribute__((noinline))
        u32 tuples_affected = 0;
 
        /* read key */
-       u32 key_cardinality;
+       u32 key_part_count;
        void *key;
-       read_key(data, &key, &key_cardinality);
+       read_key(data, &key, &key_part_count);
        /* try to find tuple in primary index */
-       txn->old_tuple = [txn->index findByKey :key :key_cardinality];
+       txn->old_tuple = [txn->index findByKey :key :key_part_count];
 
        if (txn->old_tuple == NULL) {
                /*
@@ -1302,7 +1302,7 @@ void txn_assign_n(struct box_txn *txn, struct tbuf *data)
 static void
 box_dispatch(struct box_txn *txn, struct tbuf *data)
 {
-       u32 cardinality;
+       u32 field_count;
 
        say_debug("box_dispatch(%i)", txn->op);
 
@@ -1310,11 +1310,11 @@ void txn_assign_n(struct box_txn *txn, struct tbuf 
*data)
        case REPLACE:
                txn_assign_n(txn, data);
                txn->flags |= read_u32(data) & BOX_ALLOWED_REQUEST_FLAGS;
-               cardinality = read_u32(data);
-               if (space[txn->n].cardinality > 0
-                   && space[txn->n].cardinality != cardinality)
-                       tnt_raise(IllegalParams, :"tuple cardinality must match 
space cardinality");
-               prepare_replace(txn, cardinality, data);
+               field_count = read_u32(data);
+               if (space[txn->n].arity > 0
+                   && space[txn->n].arity != field_count)
+                       tnt_raise(IllegalParams, :"tuple field count must match 
space cardinality");
+               prepare_replace(txn, field_count, data);
                break;
 
        case DELETE:
@@ -1372,7 +1372,7 @@ void txn_assign_n(struct box_txn *txn, struct tbuf *data)
 
        u32 n, key_len;
        void *key;
-       u32 cardinality, field_no;
+       u32 field_count, field_no;
        u32 flags;
        u32 op_cnt;
 
@@ -1392,10 +1392,10 @@ void txn_assign_n(struct box_txn *txn, struct tbuf 
*data)
        switch (op) {
        case REPLACE:
                flags = read_u32(b);
-               cardinality = read_u32(b);
-               if (b->size != valid_tuple(b, cardinality))
+               field_count = read_u32(b);
+               if (b->size != valid_tuple(b, field_count))
                        abort();
-               tuple_print(buf, cardinality, b->data);
+               tuple_print(buf, field_count, b->data);
                break;
 
        case DELETE:
@@ -1516,7 +1516,7 @@ void txn_assign_n(struct box_txn *txn, struct tbuf *data)
        def->max_fieldno = 0;
        def->part_count = 0;
 
-       /* Calculate key cardinality and maximal field number. */
+       /* Calculate key part count and maximal field number. */
        for (int k = 0; cfg_index->key_field[k] != NULL; ++k) {
                typeof(cfg_index->key_field[k]) cfg_key = 
cfg_index->key_field[k];
 
@@ -1571,20 +1571,20 @@ void txn_assign_n(struct box_txn *txn, struct tbuf 
*data)
 static void
 space_init_field_types(struct space *space)
 {
-       int i, field_count;
+       int i, max_fieldno;
        int key_count = space->key_count;
        struct key_def *key_defs = space->key_defs;
 
        /* find max max field no */
-       field_count = 0;
+       max_fieldno = 0;
        for (i = 0; i < key_count; i++) {
-               field_count = MAX(field_count, key_defs[i].max_fieldno);
+               max_fieldno= MAX(max_fieldno, key_defs[i].max_fieldno);
        }
 
        /* alloc & init field type info */
-       space->field_count = field_count;
-       space->field_types = malloc(field_count * sizeof(enum field_data_type));
-       for (i = 0; i < field_count; i++) {
+       space->max_fieldno = max_fieldno;
+       space->field_types = malloc(max_fieldno * sizeof(enum field_data_type));
+       for (i = 0; i < max_fieldno; i++) {
                space->field_types[i] = UNKNOWN;
        }
 
@@ -1593,7 +1593,7 @@ void txn_assign_n(struct box_txn *txn, struct tbuf *data)
                struct key_def *def = &key_defs[i];
                for (int pi = 0; pi < def->part_count; pi++) {
                        struct key_part *part = &def->parts[pi];
-                       assert(part->fieldno < field_count);
+                       assert(part->fieldno < max_fieldno);
                        space->field_types[part->fieldno] = part->type;
                }
        }
@@ -1628,7 +1628,7 @@ void txn_assign_n(struct box_txn *txn, struct tbuf *data)
                assert(cfg.memcached_port == 0 || i != cfg.memcached_space);
 
                space[i].enabled = true;
-               space[i].cardinality = cfg_space->cardinality;
+               space[i].arity = cfg_space->cardinality;
 
                /*
                 * Collect key/field info. We need aggregate
@@ -1897,7 +1897,7 @@ void txn_assign_n(struct box_txn *txn, struct tbuf *data)
                /* check spaces indexes */
                for (size_t j = 0; space->index[j] != NULL; ++j) {
                        typeof(space->index[j]) index = space->index[j];
-                       u32 index_cardinality = 0;
+                       u32 key_part_count = 0;
                        enum index_type index_type;
 
                        /* check index bound */
@@ -1941,11 +1941,11 @@ void txn_assign_n(struct box_txn *txn, struct tbuf 
*data)
                                        max_key_fieldno = key->fieldno;
                                }
 
-                               ++index_cardinality;
+                               ++key_part_count;
                        }
 
-                       /* check index cardinality */
-                       if (index_cardinality == 0) {
+                       /* Check key part count. */
+                       if (key_part_count == 0) {
                                out_warning(0, "(space = %zu index = %zu) "
                                            "at least one field must be 
defined", i, j);
                                return -1;
@@ -1960,19 +1960,17 @@ void txn_assign_n(struct box_txn *txn, struct tbuf 
*data)
                                return -1;
                        }
 
-                       /* first space index must be unique and cardinality == 
1 */
-                       if (j == 0) {
-                               if (index->unique == false) {
-                                       out_warning(0, "(space = %zu) space 
first index must be unique", i);
-                                       return -1;
-                               }
+                       /* First index must be unique. */
+                       if (j == 0 && index->unique == false) {
+                               out_warning(0, "(space = %zu) space first index 
must be unique", i);
+                               return -1;
                        }
 
                        switch (index_type) {
                        case HASH:
                                /* check hash index */
                                /* hash index must has single-field key */
-                               if (index_cardinality != 1) {
+                               if (key_part_count != 1) {
                                        out_warning(0, "(space = %zu index = 
%zu) "
                                                    "hash index must has a 
single-field key", i, j);
                                        return -1;
@@ -2209,7 +2207,7 @@ void txn_assign_n(struct box_txn *txn, struct tbuf *data)
                return;
 
        header.space = n;
-       header.tuple_size = tuple->cardinality;
+       header.tuple_size = tuple->field_count;
        header.data_size = tuple->bsize;
 
        row = tbuf_alloc(fiber->gc_pool);
diff --git a/mod/box/box_lua.m b/mod/box/box_lua.m
index 51da63d..c161c3c 100644
--- a/mod/box/box_lua.m
+++ b/mod/box/box_lua.m
@@ -105,7 +105,7 @@
 lbox_tuple_len(struct lua_State *L)
 {
        struct box_tuple *tuple = lua_checktuple(L, 1);
-       lua_pushnumber(L, tuple->cardinality);
+       lua_pushnumber(L, tuple->field_count);
        return 1;
 }
 
@@ -125,15 +125,15 @@
                luaL_error(L, "tuple.slice(): bad arguments");
        start = lua_tointeger(L, 2);
        if (start < 0)
-               start += tuple->cardinality;
+               start += tuple->field_count;
        if (argc == 2) {
                end = lua_tointeger(L, 3);
                if (end < 0)
-                       end += tuple->cardinality;
-               else if (end > tuple->cardinality)
-                       end = tuple->cardinality;
+                       end += tuple->field_count;
+               else if (end > tuple->field_count)
+                       end = tuple->field_count;
        } else {
-               end = tuple->cardinality;
+               end = tuple->field_count;
        }
        if (end <= start)
                luaL_error(L, "tuple.slice(): start must be less than end");
@@ -166,8 +166,8 @@
                lua_pushlstring(L, (char *) field, len);
                field += len;
        }
-       assert(lua_gettop(L) == tuple->cardinality + 1);
-       return tuple->cardinality;
+       assert(lua_gettop(L) == tuple->field_count + 1);
+       return tuple->field_count;
 }
 
 /**
@@ -184,9 +184,9 @@
        /* For integer indexes, implement [] operator */
        if (lua_isnumber(L, 2)) {
                int i = luaL_checkint(L, 2);
-               if (i >= tuple->cardinality)
+               if (i >= tuple->field_count)
                        luaL_error(L, "%s: index %d is out of bounds (0..%d)",
-                                  tuplelib_name, i, tuple->cardinality-1);
+                                  tuplelib_name, i, tuple->field_count-1);
                void *field = tuple_field(tuple, i);
                u32 len = load_varint32(&field);
                lua_pushlstring(L, field, len);
@@ -204,7 +204,7 @@
        struct box_tuple *tuple = lua_checktuple(L, 1);
        /* @todo: print the tuple */
        struct tbuf *tbuf = tbuf_alloc(fiber->gc_pool);
-       tuple_print(tbuf, tuple->cardinality, tuple->data);
+       tuple_print(tbuf, tuple->field_count, tuple->data);
        lua_pushlstring(L, tbuf->data, tbuf->size);
        return 1;
 }
@@ -463,17 +463,17 @@ void append_key_part(struct lua_State *L, int i,
                 * userdata: must be a key to start iteration from
                 * an offset. Seed the iterator with this key.
                 */
-               int cardinality;
+               int field_count;
                void *key;
 
                if (argc == 1 && lua_type(L, 2) == LUA_TUSERDATA) {
                        /* Searching by tuple. */
                        struct box_tuple *tuple = lua_checktuple(L, 2);
                        key = tuple->data;
-                       cardinality = tuple->cardinality;
+                       field_count = tuple->field_count;
                } else {
                        /* Single or multi- part key. */
-                       cardinality = argc;
+                       field_count = argc;
                        struct tbuf *data = tbuf_alloc(fiber->gc_pool);
                        for (int i = 0; i < argc; ++i)
                                append_key_part(L, i + 2, data,
@@ -485,13 +485,13 @@ void append_key_part(struct lua_State *L, int i,
                 * indexes. HASH indexes can only use single-part
                 * keys.
                */
-               assert(cardinality != 0);
-               if (cardinality > index->key_def->part_count)
+               assert(field_count != 0);
+               if (field_count > index->key_def->part_count)
                        luaL_error(L, "index.next(): key part count (%d) "
-                                  "does not match index cardinality (%d)",
-                                  cardinality, index->key_def->part_count);
+                                  "does not match index field count (%d)",
+                                  field_count, index->key_def->part_count);
                it = [index allocIterator];
-               [index initIteratorByKey: it :type :key :cardinality];
+               [index initIteratorByKey: it :type :key :field_count];
                lbox_pushiterator(L, it);
        } else { /* 1 item on the stack and it's a userdata. */
                it = lua_checkiterator(L, 2);
@@ -558,14 +558,14 @@ void append_key_part(struct lua_State *L, int i,
 static void
 iov_add_lua_table(struct lua_State *L, int index)
 {
-       u32 *cardinality = palloc(fiber->gc_pool, sizeof(u32));
+       u32 *field_count = palloc(fiber->gc_pool, sizeof(u32));
        u32 *tuple_len = palloc(fiber->gc_pool, sizeof(u32));
 
-       *cardinality = 0;
+       *field_count = 0;
        *tuple_len = 0;
 
        iov_add(tuple_len, sizeof(u32));
-       iov_add(cardinality, sizeof(u32));
+       iov_add(field_count, sizeof(u32));
 
        u8 field_len_buf[5];
        size_t field_len, field_len_len;
@@ -573,7 +573,7 @@ void append_key_part(struct lua_State *L, int i,
 
        lua_pushnil(L);  /* first key */
        while (lua_next(L, index) != 0) {
-               ++*cardinality;
+               ++*field_count;
 
                switch (lua_type(L, -1)) {
                case LUA_TNUMBER:
@@ -635,7 +635,7 @@ void iov_add_ret(struct lua_State *L, int index)
                size_t len = sizeof(u32);
                u32 num = lua_tointeger(L, index);
                tuple = tuple_alloc(len + varint32_sizeof(len));
-               tuple->cardinality = 1;
+               tuple->field_count = 1;
                memcpy(save_varint32(tuple->data, len), &num, len);
                break;
        }
@@ -644,7 +644,7 @@ void iov_add_ret(struct lua_State *L, int index)
                u64 num = tarantool_lua_tointeger64(L, index);
                size_t len = sizeof(u64);
                tuple = tuple_alloc(len + varint32_sizeof(len));
-               tuple->cardinality = 1;
+               tuple->field_count = 1;
                memcpy(save_varint32(tuple->data, len), &num, len);
                break;
        }
@@ -653,7 +653,7 @@ void iov_add_ret(struct lua_State *L, int index)
                size_t len;
                const char *str = lua_tolstring(L, index, &len);
                tuple = tuple_alloc(len + varint32_sizeof(len));
-               tuple->cardinality = 1;
+               tuple->field_count = 1;
                memcpy(save_varint32(tuple->data, len), str, len);
                break;
        }
@@ -663,7 +663,7 @@ void iov_add_ret(struct lua_State *L, int index)
                const char *str = tarantool_lua_tostring(L, index);
                size_t len = strlen(str);
                tuple = tuple_alloc(len + varint32_sizeof(len));
-               tuple->cardinality = 1;
+               tuple->field_count = 1;
                memcpy(save_varint32(tuple->data, len), str, len);
                break;
        }
diff --git a/mod/box/index.h b/mod/box/index.h
index 8473eda..430d31d 100644
--- a/mod/box/index.h
+++ b/mod/box/index.h
@@ -132,11 +132,11 @@ struct key_def {
                        :(enum iterator_type) type
                        :(void *) key :(int) part_count;
 /**
- * Check key cardinality.
+ * Check key part count.
  */
 - (void) checkKeyParts: (int) part_count :(bool) partial_key_allowed;
 /**
- * Unsafe search methods that do not check key cardinality.
+ * Unsafe search methods that do not check key part count.
  */
 - (struct box_tuple *) findUnsafe: (void *) key :(int) part_count;
 - (void) initIteratorUnsafe: (struct iterator *) iterator
diff --git a/mod/box/memcached.m b/mod/box/memcached.m
index 3669d19..a7ad899 100644
--- a/mod/box/memcached.m
+++ b/mod/box/memcached.m
@@ -71,7 +71,7 @@
 store(void *key, u32 exptime, u32 flags, u32 bytes, u8 *data)
 {
        u32 box_flags = 0;
-       u32 cardinality = 4;
+       u32 field_count = 4;
        static u64 cas = 42;
        struct meta m;
 
@@ -79,7 +79,7 @@
 
        tbuf_append(req, &cfg.memcached_space, sizeof(u32));
        tbuf_append(req, &box_flags, sizeof(box_flags));
-       tbuf_append(req, &cardinality, sizeof(cardinality));
+       tbuf_append(req, &field_count, sizeof(field_count));
 
        tbuf_append_field(req, key);
 
@@ -435,7 +435,7 @@ void memcached_get(struct box_txn *txn, size_t keys_count, 
struct tbuf *keys,
        /* Configure memcached space. */
        struct space *memc_s = &space[cfg.memcached_space];
        memc_s->enabled = true;
-       memc_s->cardinality = 4;
+       memc_s->arity = 4;
 
        memc_s->key_count = 1;
        memc_s->key_defs = malloc(sizeof(struct key_def));
diff --git a/mod/box/tree.m b/mod/box/tree.m
index d2c6d08..37b8367 100644
--- a/mod/box/tree.m
+++ b/mod/box/tree.m
@@ -197,7 +197,7 @@
 
        while (i < fieldno) {
                /* if the field is unknown give up on it */
-               if (i >= space->field_count || space->field_types[i] == 
UNKNOWN) {
+               if (i >= space->max_fieldno || space->field_types[i] == 
UNKNOWN) {
                        return -1;
                }
 
@@ -300,7 +300,7 @@
        memset(parts, 0, sizeof(parts[0]) * key_def->part_count);
 
        for (int field = 0; field < key_def->max_fieldno; ++field) {
-               assert(field < tuple->cardinality);
+               assert(field < tuple->field_count);
 
                u8 *data = part_data;
                u32 len = load_varint32((void**) &data);
@@ -375,7 +375,7 @@
        u8 *tuple_data = tuple->data;
 
        for (int field = 0; field < key_def->max_fieldno; ++field) {
-               assert(field < tuple->cardinality);
+               assert(field < tuple->field_count);
 
                u8 *data = tuple_data;
                u32 len = load_varint32((void**) &data);
@@ -400,7 +400,7 @@
        u8 *tuple_data = tuple->data;
 
        for (int field = 0; field < key_def->max_fieldno; ++field) {
-               assert(field < tuple->cardinality);
+               assert(field < tuple->field_count);
 
                u8 *data = tuple_data;
                u32 len = load_varint32((void**) &data);
@@ -541,8 +541,8 @@
                   struct box_tuple *tuple_b, u32 offset_b)
 {
        int part_count = key_def->part_count;
-       assert(first_field + part_count <= tuple_a->cardinality);
-       assert(first_field + part_count <= tuple_b->cardinality);
+       assert(first_field + part_count <= tuple_a->field_count);
+       assert(first_field + part_count <= tuple_b->field_count);
 
        /* Allocate space for offsets. */
        u32 *off_a = alloca(2 * part_count * sizeof(u32));
@@ -590,8 +590,8 @@ u32 first_field  __attribute__((unused)),
                    struct box_tuple *tuple_b, u32 offset_b)
 {
        int part_count = key_def->part_count;
-       assert(first_field + part_count <= tuple_a->cardinality);
-       assert(first_field + part_count <= tuple_b->cardinality);
+       assert(first_field + part_count <= tuple_a->field_count);
+       assert(first_field + part_count <= tuple_b->field_count);
 
        /* Compare key parts. */
        u8 *ad = tuple_a->data + offset_a;
@@ -660,7 +660,7 @@ u32 first_field  __attribute__((unused)),
                       u32 first_field, struct box_tuple *tuple, u32 offset)
 {
        int part_count = key_def->part_count;
-       assert(first_field + part_count <= tuple->cardinality);
+       assert(first_field + part_count <= tuple->field_count);
 
        /* Allocate space for offsets. */
        u32 *off = alloca(part_count * sizeof(u32));
@@ -705,7 +705,7 @@ u32 first_field __attribute__((unused)),
                        struct box_tuple *tuple, u32 offset)
 {
        int part_count = key_def->part_count;
-       assert(first_field + part_count <= tuple->cardinality);
+       assert(first_field + part_count <= tuple->field_count);
 
        /* Compare key parts. */
        if (part_count > key_data->part_count)
@@ -881,10 +881,10 @@ - (struct box_tuple *) findUnsafe: (void *) key : (int) 
part_count
 - (struct box_tuple *) findByTuple: (struct box_tuple *) tuple
 {
        struct key_data *key_data
-               = alloca(sizeof(struct key_data) + 
_SIZEOF_SPARSE_PARTS(tuple->cardinality));
+               = alloca(sizeof(struct key_data) + 
_SIZEOF_SPARSE_PARTS(tuple->field_count));
 
        key_data->data = tuple->data;
-       key_data->part_count = tuple->cardinality;
+       key_data->part_count = tuple->field_count;
        fold_with_sparse_parts(key_def, tuple, key_data->parts);
 
        void *node = sptree_index_find(&tree, key_data);
@@ -901,7 +901,7 @@ - (void) remove: (struct box_tuple *) tuple
 - (void) replace: (struct box_tuple *) old_tuple
                : (struct box_tuple *) new_tuple
 {
-       if (new_tuple->cardinality < key_def->max_fieldno)
+       if (new_tuple->field_count < key_def->max_fieldno)
                tnt_raise(ClientError, :ER_NO_SUCH_FIELD,
                          key_def->max_fieldno);
 
diff --git a/mod/box/tuple.h b/mod/box/tuple.h
index 0a3ed5c..60afa24 100644
--- a/mod/box/tuple.h
+++ b/mod/box/tuple.h
@@ -53,7 +53,7 @@ struct box_tuple
        /** length of the variable part of the tuple */
        u32 bsize;
        /** number of fields in the variable part. */
-       u32 cardinality;
+       u32 field_count;
        /**
         * Fields can have variable length, and thus are packed
         * into a contiguous byte array. Each field is prefixed
@@ -91,13 +91,13 @@ struct box_tuple *
  * key: { value, value, value }
  */
 void
-tuple_print(struct tbuf *buf, uint8_t cardinality, void *f);
+tuple_print(struct tbuf *buf, uint8_t field_count, void *f);
 
 /** Tuple length when adding to iov. */
 static inline size_t tuple_len(struct box_tuple *tuple)
 {
        return tuple->bsize + sizeof(tuple->bsize) +
-               sizeof(tuple->cardinality);
+               sizeof(tuple->field_count);
 }
 #endif /* TARANTOOL_BOX_TUPLE_H_INCLUDED */
 
diff --git a/mod/box/tuple.m b/mod/box/tuple.m
index b7b5512..225830e 100644
--- a/mod/box/tuple.m
+++ b/mod/box/tuple.m
@@ -94,7 +94,7 @@
 {
        void *field = tuple->data;
 
-       if (i >= tuple->cardinality)
+       if (i >= tuple->field_count)
                return NULL;
 
        while (i-- > 0)
@@ -136,15 +136,15 @@
  * key: { value, value, value }
  */
 void
-tuple_print(struct tbuf *buf, uint8_t cardinality, void *f)
+tuple_print(struct tbuf *buf, uint8_t field_count, void *f)
 {
        print_field(buf, f);
        tbuf_printf(buf, ": {");
        f = next_field(f);
 
-       for (size_t i = 1; i < cardinality; i++, f = next_field(f)) {
+       for (size_t i = 1; i < field_count; i++, f = next_field(f)) {
                print_field(buf, f);
-               if (likely(i + 1 < cardinality))
+               if (likely(i + 1 < field_count))
                        tbuf_printf(buf, ", ");
        }
        tbuf_printf(buf, "}");
diff --git a/src/pickle.m b/src/pickle.m
index b92d12d..faa9086 100644
--- a/src/pickle.m
+++ b/src/pickle.m
@@ -190,12 +190,12 @@
 }
 
 u32
-valid_tuple(struct tbuf *buf, u32 cardinality)
+valid_tuple(struct tbuf *buf, u32 field_count)
 {
        void *data = buf->data;
        u32 r, size = buf->size;
 
-       for (int i = 0; i < cardinality; i++)
+       for (int i = 0; i < field_count; i++)
                read_field(buf);
 
        r = size - buf->size;
diff --git a/test/connector_c/tt.c b/test/connector_c/tt.c
index 2204e06..da80546 100644
--- a/test/connector_c/tt.c
+++ b/test/connector_c/tt.c
@@ -437,7 +437,7 @@ static void tt_tnt_net_call_na(struct tt_test *test) {
        while (tnt_next(&i)) {
                struct tnt_reply *r = TNT_ISTREAM_REPLY(&i);
                TT_ASSERT(r->code != 0);
-               TT_ASSERT(strcmp(r->error, "Illegal parameters, tuple 
cardinality is 0") == 0);
+               TT_ASSERT(strcmp(r->error, "Illegal parameters, tuple field 
count is 0") == 0);
        }
        tnt_iter_free(&i);
 }


================================================================
Compare: https://github.com/mailru/tarantool/compare/890ed2f...9718319
_______________________________________________
Mailing list: https://launchpad.net/~tarantool-developers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~tarantool-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to