0

box.space.test.index.secondary:select({1,'RU', 2})

---
- - [47, 6, 1, 'RU', 2, 11, 6]
  - [44, 3, 1, 'RU', 2, 101, 6]
  - [42, 1, 1, 'RU', 2, 189, 6]
  - [34, 3, 1, 'RU', 2, 260, 5]
  - [49, 8, 1, 'RU', 2, 290, 6]
  - [41, 0, 1, 'RU', 2, 303, 6]
  - [37, 6, 1, 'RU', 2, 494, 5]
  - [35, 4, 1, 'RU', 2, 633, 5]
  - [45, 4, 1, 'RU', 2, 694, 6]
  - [43, 2, 1, 'RU', 2, 780, 6]
  - [46, 5, 1, 'RU', 2, 833, 6]
  - [40, 9, 1, 'RU', 2, 870, 5]
  - [48, 7, 1, 'RU', 2, 927, 6]
  - [50, 9, 1, 'RU', 2, 930, 6]
...

box.space.test.index.secondary

---
- unique: false
  parts:
  - type: NUM
    fieldno: 3
  - type: STR
    fieldno: 4
  - type: NUM
    fieldno: 5
  - type: NUM
    fieldno: 6
  id: 2
  space_id: 512
  name: secondary
  type: TREE
...

local r='' for k,tuple in box.space.test.index.secondary:pairs({1, 'RU', 2}) do r=r..', found ('..tuple[1]. .')' if (tuple[7]<6) then r = r ..', delete(' ..tuple[1] .. ')' box.space.test:delete(tuple[1]) end end返回 r

---
- ', found (47), found (44), found (42), found (34), delete(34), found (41), found(37), delete(37), found (45), found (43), found (46), found (40), delete(40), found(50)'
...

box.space.test.index.secondary:select({1,'RU', 2})

---
- - [47, 6, 1, 'RU', 2, 11, 6]
  - [44, 3, 1, 'RU', 2, 101, 6]
  - [42, 1, 1, 'RU', 2, 189, 6]
  - [49, 8, 1, 'RU', 2, 290, 6]
  - [41, 0, 1, 'RU', 2, 303, 6]
  - [35, 4, 1, 'RU', 2, 633, 5]
  - [45, 4, 1, 'RU', 2, 694, 6]
  - [43, 2, 1, 'RU', 2, 780, 6]
  - [46, 5, 1, 'RU', 2, 833, 6]
  - [48, 7, 1, 'RU', 2, 927, 6]
  - [50, 9, 1, 'RU', 2, 930, 6]
...

local r='' for k,tuple in box.space.test.index.secondary:pairs({1, 'RU', 2}) do r=r..', found ('..tuple[1]. .')' if (tuple[7]<6) then r = r ..', delete(' ..tuple[1] .. ')' box.space.test:delete(tuple[1]) end end返回 r

---
- ', found (47), found (44), found (42), found (49), found (41), found (35), delete(35), found (43), found (46), found (48), found (50)'
...

box.space.test.index.secondary:select({1,'RU', 2})

---
- - [47, 6, 1, 'RU', 2, 11, 6]
  - [44, 3, 1, 'RU', 2, 101, 6]
  - [42, 1, 1, 'RU', 2, 189, 6]
  - [49, 8, 1, 'RU', 2, 290, 6]
  - [41, 0, 1, 'RU', 2, 303, 6]
  - [45, 4, 1, 'RU', 2, 694, 6]
  - [43, 2, 1, 'RU', 2, 780, 6]
  - [46, 5, 1, 'RU', 2, 833, 6]
  - [48, 7, 1, 'RU', 2, 927, 6]
  - [50, 9, 1, 'RU', 2, 930, 6]
...

正如我所见 :pairs 在第一次运行时看不到 35 个元组,并且仅在第二次执行时才看到。为什么?

ps:抱歉解释太长了...

4

0 回答 0