[core] parallelization: introduce the notion of node 'size'

* node size is an estimation of the number of element to process on a given node, that may be used for parallelization.
* replace the explicit reference to an attribute on a node (Parallelization.inputListParamName)
* size can be:
  * dynamic: depends on the size of the node connected to a specific Attribute
  * static
This commit is contained in:
Yann Lanthony 2017-11-17 18:46:21 +01:00
parent 877025090e
commit e8c579c942
13 changed files with 56 additions and 18 deletions

View file

@ -621,6 +621,7 @@ class Node(BaseObject):
self.graph = None # type: Graph
self._chunks = []
self._cmdVars = {}
self._size = 0
self._attributes = DictModel(keyAttrName='name', parent=self)
self.attributesPerUid = defaultdict(set)
self._initFromDesc()
@ -795,6 +796,7 @@ class Node(BaseObject):
chunk.updateStatisticsFromCache()
def updateInternals(self):
self.setSize(self.nodeDesc.size.computeSize(self))
if self.isParallelized:
try:
ranges = self.nodeDesc.parallelization.getRanges(self)
@ -860,6 +862,15 @@ class Node(BaseObject):
def statusNames(self):
return [s.status.name for s in self.status]
def getSize(self):
return self._size
def setSize(self, value):
if self._size == value:
return
self._size = value
self.sizeChanged.emit()
def __repr__(self):
return self.name
@ -872,6 +883,8 @@ class Node(BaseObject):
depth = Property(int, depth.fget, notify=depthChanged)
chunksChanged = Signal()
chunks = Property(Variant, getChunks, notify=chunksChanged)
sizeChanged = Signal()
size = Property(int, getSize, notify=sizeChanged)
WHITE = 0
GRAY = 1