|
16 | 16 |
|
17 | 17 | from ..hdf5dtype import isVlen |
18 | 18 | from ..array_util import arrayToBytes, bytesArrayToList |
19 | | -from ..dset_util import getNumElements |
| 19 | +from ..dset_util import getNumElements, getDims |
20 | 20 | from .. import selections |
21 | 21 | from ..h5writer import H5Writer |
22 | 22 | from .httpconn import HttpConn |
@@ -251,7 +251,7 @@ def multiPost(items): |
251 | 251 | items.clear() |
252 | 252 |
|
253 | 253 | self.log.debug(f"hsds_writer> createObjects, {len(obj_ids)} objects") |
254 | | - MAX_OBJECTS_PER_REQUEST = 3 |
| 254 | + MAX_OBJECTS_PER_REQUEST = 300 |
255 | 255 | collections = ("groups", "datasets", "datatypes") |
256 | 256 | col_items = {} |
257 | 257 | dset_value_update_ids = set() |
@@ -286,15 +286,25 @@ def multiPost(items): |
286 | 286 | item[key] = obj_json[key] |
287 | 287 |
|
288 | 288 | # initialize dataset values if provided and not too large |
289 | | - if "updates" in obj_json: |
290 | | - updates = obj_json["updates"] |
291 | | - if updates and len(updates) == 1 and self.getDatasetSize(obj_id) < MAX_INIT_SIZE: |
| 289 | + if collection == "datasets": |
| 290 | + dset_dims = getDims(obj_json) # will be None for null space datasets |
| 291 | + dset_size = self.getDatasetSize(obj_id) # number of bytes defined by the shape |
| 292 | + init_arr = None # data to be passed to post create method |
| 293 | + updates = obj_json.get("updates") |
| 294 | + if updates and len(updates) == 1 and dset_size < MAX_INIT_SIZE: |
292 | 295 | sel, arr = updates[0] |
293 | 296 | if sel.select_type == selections.H5S_SELECT_ALL: |
294 | | - value = bytesArrayToList(arr) |
295 | | - item["value"] = value |
| 297 | + init_arr = arr |
296 | 298 | updates.clear() # reset the update list |
297 | | - if updates: |
| 299 | + if self._init and init_arr is None and dset_dims is not None: |
| 300 | + # get all values from dataset if small enough |
| 301 | + if dset_size < MAX_INIT_SIZE: |
| 302 | + sel_all = selections.select(dset_dims, ...) |
| 303 | + init_arr = self.db.getDatasetValues(obj_id, sel_all) |
| 304 | + if init_arr is not None: |
| 305 | + value = bytesArrayToList(init_arr) |
| 306 | + item["value"] = value |
| 307 | + elif updates or self._init: |
298 | 308 | dset_value_update_ids.add(obj_id) # will set dataset value below |
299 | 309 |
|
300 | 310 | # add to the list of new items for the given collection |
@@ -436,18 +446,13 @@ def updateValues(self, dset_ids): |
436 | 446 | if getCollectionForId(dset_id) != "datasets": |
437 | 447 | continue # ignore groups and datatypes |
438 | 448 | dset_json = self.db.getObjectById(dset_id) |
439 | | - dset_shape = dset_json["shape"] |
440 | | - dset_class = dset_shape['class'] |
441 | | - if dset_class == "H5S_NULL": |
| 449 | + dset_dims = getDims(dset_json) |
| 450 | + if dset_dims is None: |
442 | 451 | # no data to update |
443 | 452 | continue |
444 | 453 | if self._init: |
445 | 454 | # get all data for the dataset |
446 | 455 | # TBD: do this by chunks |
447 | | - if dset_class == "H5S_SCALAR": |
448 | | - dset_dims = [] |
449 | | - else: |
450 | | - dset_dims = dset_shape["dims"] |
451 | 456 | sel_all = selections.select(dset_dims, ...) |
452 | 457 | arr = self.db.getDatasetValues(dset_id, sel_all) |
453 | 458 | if arr is not None: |
@@ -491,7 +496,8 @@ def flush(self): |
491 | 496 | dirty_ids.add(root_id) # add back root for attribute and link creation |
492 | 497 | if not self._no_data: |
493 | 498 | # initialize dataset values |
494 | | - self.updateValues(obj_ids) |
| 499 | + pass |
| 500 | + # self.updateValues(obj_ids) |
495 | 501 | self._init = False |
496 | 502 | elif self.db.new_objects: |
497 | 503 | self.log.debug(f"hsds_writer> {len(self.db.new_objects)} objects to create") |
|
0 commit comments