sci-visus/OpenVisus

default_layout is empty when idx is created from Python

klacansky opened this issue · 2 comments

import numpy as np
from OpenVisus import *
CreateIdx(url='test.idx', dim=3, data=np.zeros((100,100,100)))

creates the following file

(version)
6
(box)
0 99 0 99 0 99
(fields)
DATA float64 default_compression(zip) default_layout() default_value(0) min(0) max(0) 
(bits)
V012012012012012012012
(bitsperblock)
16
(blocksperfile)
32
(interleave block)
0
(filename_template)
./test/%04x.bin
(missing_blocks)
0

The default_layout() is empty, which in turn makes the parser in Field.cpp to parse the layout as "default_value(0" (line 95), which in turn crashes visus in debug mode in file IdxFile.cpp on line 197.

I suggest to either fix the parsing code (by setting the thrid argument, bPurgeEmptyItems, to false) or generate idx file with default_layout present.

I am trying to replicate but with the current master (Windows/Debug mode) I cannot get the same error/assert.
An empty default_layout should be fine (empty==rowmajor which is not the preferred layout for blocks).

In IdxFile line 197 I have

  //one file per dataset
  if (blocksperfile == -1)
  {
    blocksperfile = (int)totblocks;
    VisusAssert(blocksperfile == totblocks);
  }

and in Field.cpp line 95 I have:

else if (StringUtils::contains(sfield, "compressed"))

is this what you have?
Can you run inside Visual Studio and copy the call stack?
Even better if you can create a pull request if it's an easy fix,

Thanks a lot for spending time on it!

Unfortunately, I was unable to build OpenVisus static libraries on the latest commit. The bug is present on the commit c218370. Adding "rowmajor" between the default layout parentheses solved the issue.