Skip to content
Snippets Groups Projects
Commit 46dbfcfe authored by Philip ABBET's avatar Philip ABBET
Browse files

Add the 'load_data_index_db' function

parent 2abacf92
Branches
Tags
1 merge request!17Merge development branch 1.5.x
Pipeline #
...@@ -1077,6 +1077,39 @@ def load_data_index(cache_root, hash_path): ...@@ -1077,6 +1077,39 @@ def load_data_index(cache_root, hash_path):
#---------------------------------------------------------- #----------------------------------------------------------
def load_data_index_db(cache_root, hash_path):
filename = os.path.join(cache_root, hash_path)
if not os.path.exists(filename):
return None
retval = []
with open(filename, 'rb') as f:
data = json.loads(f.read())
current = data[0]
column_names = current.keys()
for col in range(0, len(column_names)):
retval.append([0])
for row, entry in enumerate(data[1:]):
for col, name in enumerate(column_names):
if entry[name] != current[name]:
retval[col].append(row + 1)
current[name] = entry[name]
for col in range(0, len(column_names)):
retval[col].append(len(data))
return retval
#----------------------------------------------------------
def _foundCommonIndices(lst): def _foundCommonIndices(lst):
"""Returns the list of common indices, given a list of list of indices """Returns the list of common indices, given a list of list of indices
""" """
...@@ -1103,9 +1136,10 @@ def foundSplitRanges(lst, n_split): ...@@ -1103,9 +1136,10 @@ def foundSplitRanges(lst, n_split):
c = 0 c = 0
s = 0 s = 0
for i in range(1, len(ci_lst)): for i in range(1, len(ci_lst)):
if (ci_lst[i] - ci_lst[s] >= average_length and c < n_split - 1) or \ if (ci_lst[i] >= (c + 1) * average_length and c < n_split - 1):
len(ci_lst) - i <= n_split - c:
res.append((ci_lst[s], ci_lst[i] - 1)) res.append((ci_lst[s], ci_lst[i] - 1))
s = i s = i
c += 1 c += 1
elif i == len(ci_lst) - 1:
res.append((ci_lst[s], ci_lst[i] - 1))
return res return res
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment