1from common import getConnectionByEnv, waitForIndex, sortedResults, toSortedFlatList, forceInvokeGC
2from RLTest import Env
3from time import sleep
4
5
6def ft_info_to_dict(env, idx):
7  res = env.execute_command('ft.info', idx)
8  return {res[i]: res[i + 1] for i in range(0, len(res), 2)}
9
10# The output for this test can be used for recreating documentation for `FT.INFO`
11def testInfo(env):
12  env.skip()
13  count = 345678
14  conn = env.getConnection()
15  pl = conn.pipeline()
16
17  idx = 'wikipedia'
18
19  for i in range(count):
20    geo = '1.23456,1.' + str(i / float(count))
21    pl.execute_command('HSET', 'doc%d' % i, 'title', 'hello%d' % i,
22                                            'body', '%dhello%dworld%dhow%dare%dyou%dtoday%d' % (i, i, i, i, i, i, i),
23                                            'n', i / 17.0,
24                                            'geo', geo)
25    if i % 10000 == 0:
26      pl.execute()
27  pl.execute()
28
29  env.expect('FT.CREATE', idx, 'STOPWORDS', 3, 'TLV', 'summer', '2020',
30                               'SCHEMA', 'title', 'TEXT', 'SORTABLE',
31                                         'body', 'TEXT',
32                                         'id', 'NUMERIC',
33                                         'subject location', 'GEO').ok()
34
35  waitForIndex(env, idx)
36
37  for i in range(count):
38    pl.execute_command('DEL', 'doc%d' % i)
39    if i % 10000 == 0:
40      pl.execute()
41      forceInvokeGC(env, idx)
42  pl.execute()
43
44  #  GC stats
45  for i in range(25):
46    forceInvokeGC(env, idx)
47
48  # cursor stats
49  #query = ['FT.AGGREGATE', idx, '*', 'WITHCURSOR']
50  #res = env.cmd(*query)
51  #env.cmd('FT.CURSOR', 'READ', idx, str(res[1]))
52
53  #print info