(
filename, ngroups, ntables, nrows, complevel, complib, recsize
)
| 24 | |
| 25 | |
| 26 | def create_file( |
| 27 | filename, ngroups, ntables, nrows, complevel, complib, recsize |
| 28 | ): |
| 29 | |
| 30 | # First, create the groups |
| 31 | |
| 32 | # Open a file in "w"rite mode |
| 33 | fileh = tb.open_file(filename, mode="w", title="PyTables Stress Test") |
| 34 | |
| 35 | for k in range(ngroups): |
| 36 | # Create the group |
| 37 | group = fileh.create_group("/", "group%04d" % k, "Group %d" % k) |
| 38 | |
| 39 | fileh.close() |
| 40 | |
| 41 | # Now, create the tables |
| 42 | rowswritten = 0 |
| 43 | rowsize = 0 |
| 44 | for k in range(ngroups): |
| 45 | fileh = tb.open_file(filename, mode="a", root_uep="group%04d" % k) |
| 46 | # Get the group |
| 47 | group = fileh.root |
| 48 | for j in range(ntables): |
| 49 | # Create a table |
| 50 | table = fileh.create_table( |
| 51 | group, |
| 52 | "table%04d" % j, |
| 53 | Test, |
| 54 | "Table%04d" % j, |
| 55 | tb.Filters(complevel, complib), |
| 56 | nrows, |
| 57 | ) |
| 58 | rowsize = table.rowsize |
| 59 | # Get the row object associated with the new table |
| 60 | row = table.row |
| 61 | # Fill the table |
| 62 | for i in range(nrows): |
| 63 | row["ngroup"] = k |
| 64 | row["ntable"] = j |
| 65 | row["nrow"] = i |
| 66 | row.append() |
| 67 | |
| 68 | rowswritten += nrows |
| 69 | table.flush() |
| 70 | |
| 71 | # Close the file |
| 72 | fileh.close() |
| 73 | |
| 74 | return (rowswritten, rowsize) |
| 75 | |
| 76 | |
| 77 | def read_file(filename, ngroups, recsize, verbose): |
no test coverage detected