Skip to content

Commit

Permalink
Allow a caller to ignore row numbers
Browse files Browse the repository at this point in the history
For calls to readCoordinates, read, and slice the returned value order
in the `Data` response is the same as requested.  While having the row
numbers included in the response is convenient, when the number of cells
being returned is high this incurs memory and serialization overhead.
This is especially true when retrieving a small number of columns for a
large number of rows; in this case `rowNumbers` can actually be more
expensive to include than the data itself.

Here we use the Ice context and "omero.tables.include_row_numbers" to
additively affect the client API without changing any of the Ice method
prototypes.
  • Loading branch information
chris-allan committed Jun 19, 2024
1 parent 8d8108d commit 8636894
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/omero/hdfstorageV2.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,13 +550,21 @@ def getWhereList(self, stamp, condition, variables, unused,
aue.serverExceptionClass = str(err.__class__.__name__)
raise aue

def _as_data(self, cols, rowNumbers):
def _as_data(self, cols, rowNumbers, current):
"""
Constructs a omero.grid.Data object for returning to the client.
"""
include_row_numbers = True
try:
include_row_numbers = current.ctx.get(
"omero.tables.include_row_numbers", "true"
).lower() == "true"
except Exception:
pass
data = omero.grid.Data()
data.columns = cols
data.rowNumbers = rowNumbers
if include_row_numbers:
data.rowNumbers = rowNumbers
# Convert to millis since epoch
data.lastModification = int(self._stamp * 1000)
return data
Expand All @@ -568,7 +576,7 @@ def readCoordinates(self, stamp, rowNumbers, current):
cols = self.cols(None, current)
for col in cols:
col.readCoordinates(self.__mea, rowNumbers)
return self._as_data(cols, rowNumbers)
return self._as_data(cols, rowNumbers, current)

@stamped
def read(self, stamp, colNumbers, start, stop, current):
Expand All @@ -586,7 +594,7 @@ def read(self, stamp, colNumbers, start, stop, current):
elif start is None and stop is None:
rowNumbers = list(range(self.__length()))

return self._as_data(cols, rowNumbers)
return self._as_data(cols, rowNumbers, current)

@stamped
def slice(self, stamp, colNumbers, rowNumbers, current):
Expand All @@ -604,7 +612,7 @@ def slice(self, stamp, colNumbers, rowNumbers, current):
col = cols[i]
col.readCoordinates(self.__mea, rowNumbers)
rv.append(col)
return self._as_data(rv, rowNumbers)
return self._as_data(rv, rowNumbers, current)

#
# Lifecycle methods
Expand Down

0 comments on commit 8636894

Please sign in to comment.