Commit 1176bdb6 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Merge computation of partition from oid or tid.

Same work was done in common and master specific partition table.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2355 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent d63e9dfb
...@@ -910,9 +910,8 @@ class Application(object): ...@@ -910,9 +910,8 @@ class Application(object):
# Regroup objects per partition, to ask a minimum set of storage. # Regroup objects per partition, to ask a minimum set of storage.
partition_oid_dict = {} partition_oid_dict = {}
pt = self._getPartitionTable() pt = self._getPartitionTable()
getPartitionFromIndex = pt.getPartitionFromIndex
for oid in oid_list: for oid in oid_list:
partition = pt.getPartitionFromIndex(oid) partition = pt.getPartition(oid)
try: try:
oid_list = partition_oid_dict[partition] oid_list = partition_oid_dict[partition]
except KeyError: except KeyError:
......
...@@ -32,9 +32,6 @@ class PartitionTable(neo.pt.PartitionTable): ...@@ -32,9 +32,6 @@ class PartitionTable(neo.pt.PartitionTable):
self._id += 1 self._id += 1
return self._id return self._id
def getPartition(self, oid_or_tid):
return unpack('!Q', oid_or_tid)[0] % self.getPartitions()
def make(self, node_list): def make(self, node_list):
"""Make a new partition table from scratch.""" """Make a new partition table from scratch."""
# start with the first PTID # start with the first PTID
......
...@@ -136,12 +136,13 @@ class PartitionTable(object): ...@@ -136,12 +136,13 @@ class PartitionTable(object):
return [] return []
def getCellListForTID(self, tid, readable=False, writable=False): def getCellListForTID(self, tid, readable=False, writable=False):
return self.getCellList(self.getPartitionFromIndex(tid), return self.getCellList(self.getPartition(tid), readable, writable)
readable, writable)
def getCellListForOID(self, oid, readable=False, writable=False): def getCellListForOID(self, oid, readable=False, writable=False):
return self.getCellList(self.getPartitionFromIndex(oid), return self.getCellList(self.getPartition(oid), readable, writable)
readable, writable)
def getPartition(self, oid_or_tid):
return u64(oid_or_tid) % self.getPartitions()
def isAssigned(self, oid, uuid): def isAssigned(self, oid, uuid):
""" Check if the oid is assigned to the given node """ """ Check if the oid is assigned to the given node """
...@@ -150,12 +151,6 @@ class PartitionTable(object): ...@@ -150,12 +151,6 @@ class PartitionTable(object):
return True return True
return False return False
def getPartitionFromIndex(self, index):
return self._getPartitionFromIndex(u64(index))
def _getPartitionFromIndex(self, index):
return index % self.np
def setCell(self, offset, node, state): def setCell(self, offset, node, state):
if state == CellStates.DISCARDED: if state == CellStates.DISCARDED:
return self.removeCell(offset, node) return self.removeCell(offset, node)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment