/** * @param array $row * @return array */ public function compactRow(array $row) { $keys = array_merge($this->shallow->getPrimaryKeyColumns(), $this->sort); $extra = array_diff(array_keys($row), $keys); foreach ($extra as $key) { unset($row[$key]); } return $this->inner->compactRow($row); }
/** * {@inheritDoc} */ public function onAfterUpdate($object, array $old, array $new, array $metadata) { $oldIndexed = ObjectManager::splitFromRow($old, $this->indexed); $newIndexed = ObjectManager::splitFromRow($new, $this->indexed); if (!$oldIndexed) { throw new DataModelException('Un-indexable row: ' . FormatJson::encode($oldIndexed), 'process-data'); } if (!$newIndexed) { throw new DataModelException('Un-indexable row: ' . FormatJson::encode($newIndexed), 'process-data'); } $oldCompacted = $this->rowCompactor->compactRow(UUID::convertUUIDs($old, 'alphadecimal')); $newCompacted = $this->rowCompactor->compactRow(UUID::convertUUIDs($new, 'alphadecimal')); if (ObjectManager::arrayEquals($oldIndexed, $newIndexed)) { if (ObjectManager::arrayEquals($oldCompacted, $newCompacted)) { // Nothing changed in the index return; } // object representation in feature bucket has changed $this->replaceInIndex($oldIndexed, $oldCompacted, $newCompacted); } else { // object has moved from one feature bucket to another $this->removeFromIndex($oldIndexed, $oldCompacted); $this->addToIndex($newIndexed, $newCompacted); } }