@param ParentChildMap $map

@return array
503030
protected function getDataFromMap(ParentChildMap $map) : array
    {
        /** @var Row[] $parentRows */
        $parentRows = [];
        /** @var object[] $children */
        $children = [];

        foreach ($map->getItems() as $key => $item) {
            if ($item->getChild()) {
                $parentRows[$key] = $item->getParent();
                $children[$key]   = $item->getChild();
            }
        }

        return array($parentRows, $children);
    }
573575
Map<Integer, Integer> initParentMap() {
        Map<Integer, Integer> parentMap = new LinkedHashMap<>(numWorkers);
        for(int r = 0; r < numWorkers; r++) {
            parentMap.put(r, ((r + 1) / 2 - 1) );
        }
        return parentMap;
    }
1125190
public static function getTreeChild($data, $parent_id, $key = 'parent_id', $id_key = 'id') {
		$result = [];
		$args   = [$parent_id];
		do {
			$kids = [];
			$flag = false;
			foreach ($args as $fid) {
				for ($i = count($data) - 1; $i >=0 ; $i --) {
					$node = $data[$i];
					if ($node[$key] == $fid) {
						array_splice($data, $i , 1);
						$result[] = $node[$id_key];
						$kids[]   = $node[$id_key];
						$flag     = true;
					}
				}
			}
			$args = $kids;
		} while($flag === true);
		return $result;
	}
1146498
private function getCoreConfigMap(array $map)
    {
        $result = [];

        foreach ($map as $key => $path) {
            $value = $this->coreConfig->getConfigByPath($path)->getData('value');
            if ($value !== null) {
                $result[$key] = $this->castToType($value, $key);
            }
        }

        return $result;
    }
595241
protected function getRawIncludeMap(): array
    {
        $map = [];

        foreach ($this->includes as $includeKey => $definition) {
            if (\is_int($includeKey)) {
                $includeKey = $definition;
                $definition = null;
            }

            $settings = [];
            if (!empty($definition)) {
                $parts = preg_split('/\s*\|\s*/', $definition);
                foreach ($parts as $part) {
                    if (!preg_match('/^([^:]+)(:(.+))?$/', $part, $match)) {
                        throw new ParseDefinitionException("Unable to parse field definition for '{$includeKey}''");
                    }
                    // If only list() was viable ...
                    $directive = $match[1];
                    $val = $match[3] ?? null;
                    switch ($directive) {
                        case 'default':
                            $settings['default'] = true;
                            break;
                        case 'relation':
                            $settings['relation'] = !empty($val) ?
                                preg_split('/s*,\s*/', $val) : [$includeKey];
                            break;
                        case 'method':
                            if (!empty($val)) {
                                $settings['method'] = $val;
                            }
                            break;
                        case 'item':
                            $settings['resource_type'] = 'item';
                            break;
                        case 'collection':
                            $settings['resource_type'] = 'collection';
                            break;
                        default:
                            throw new ParseDefinitionException("Invalid key '{$directive}' for {$includeKey}");
                    }
                }
            }

            if (!isset($settings['relation'])) {
                $settings['relation'] = [];
            }
            if (!isset($settings['method'])) {
                $settings['method'] = 'include'.StrHelper::studlyCase($includeKey);
            }
            if (!isset($settings['default'])) {
                $settings['default'] = false;
            }
            if (!isset($settings['resource_type'])) {
                $settings['resource_type'] = null;
            }

            $map[$includeKey] = $settings;
        }

        return $map;
    }
129221
public function load(LoadingContext $context, ParentChildMap $map)
    {
        if (!$map->getItems()) {
            return;
        }
        
        $select = $this->getRelationSelectFromParentRows($map, $parentIdColumnName);

        $this->loadFromSelect($context, $map, $select, $select->getTableAlias(), $parentIdColumnName);
    }
175651
public function collect(Map $map, array $markerShapes = [])
    {
        foreach ($this->markerCollector->collect($map) as $marker) {
            if ($marker->hasShape()) {
                $markerShapes = $this->collectValue($marker->getShape(), $markerShapes);
            }
        }

        return $markerShapes;
    }
82019
private function explodeChildren($id, array $childrenMap)
    {
        if (! isset($childrenMap[$id])) {
            return [];
        }

        // Indexing items by their value
        $indexed = [];

        foreach ($childrenMap[$id] as $childName) {
            $indexed[$childName] = $childName;
        }

        return array_map(
            function ($childId) use ($childrenMap) {
                return $this->explodeChildren($childId, $childrenMap);
            },
            $indexed
        );
    }
1372862
public static Map getOrCreateChildMap(Map parent, String key) {
        Object o = parent.get(key);
        if(o instanceof Map) {
            return (Map)o;
        }
        return new LinkedHashMap();
    }
579162
public function collect(Map $map, array $polygons = [])
    {
        return $this->collectValues($map->getOverlayManager()->getPolygons(), $polygons);
    }
1060338
public function collect(Map $map, array $polylines = [])
    {
        return $this->collectValues($map->getOverlayManager()->getPolylines(), $polylines);
    }
999838
public function collect(Map $map, array $rectangles = [])
    {
        return $this->collectValues($map->getOverlayManager()->getRectangles(), $rectangles);
    }
273501
protected function getParentChildKeys($key)
    {
        $parts = explode('.', $key);
        $child = array_pop($parts);
        return [implode('.', $parts), $child];
    }
1363415
static public function getAllIdChilds($id)
    {
        $map = self::getMapParentId();
        
        $childId = array();
        
        if (isset( $map[$id] ))
        {
            foreach ($map[$id] as $val)
            {
                $childId = array_merge($childId,self::getAllIdChilds($val));
            }
            unset($val);
            
            return $childId;
        }
        else
        {
            return array( $id );
        }              
    }
755427
public function render(Map $map)
    {
        $formatter = $this->getFormatter();
        $jsonBuilder = $this->getJsonBuilder();

        $options = $map->getMapOptions();
        unset($options['mapTypeId']);

        if (!$map->isAutoZoom()) {
            if (!isset($options['zoom'])) {
                $options['zoom'] = 3;
            }
        } else {
            unset($options['zoom']);
        }

        $this->controlManagerRenderer->render($map->getControlManager(), $jsonBuilder);

        $jsonBuilder
            ->setValue(
                '[mapTypeId]',
                $this->mapTypeIdRenderer->render($map->getMapOption('mapTypeId') ?: MapTypeId::ROADMAP),
                false
            )
            ->setValues($options);

        return $formatter->renderObjectAssignment($map, $formatter->renderObject('Map', [
            $formatter->renderCall(
                $formatter->renderProperty('document', 'getElementById'),
                [$formatter->renderEscape($map->getHtmlId())]
            ),
            $jsonBuilder->build(),
        ]));
    }
222221
protected function buildJsonAttributes(array $map): array
    {
        $result = [];

        foreach ($map as $jsonKey => $value) {
            if ($value !== null) {
                $result[$jsonKey] = $value;
            }
        }

        return $result;
    }
1253189
protected function insertRelated(PersistenceContext $context, ParentChildrenMap $map)
    {
        $primaryKey = $map->getPrimaryKeyColumn();
        /** @var Row[] $parents */
        $parents = [];
        /** @var object[] $children */
        $children          = [];
        $childRows         = [];
        $childKeyParentMap = [];

        foreach ($map->getItems() as $key => $item) {
            $parents[$key] = $item->getParent();

            foreach ($item->getChildren() as $childKey => $child) {
                $uniqueKey                     = $key . '|' . $childKey;
                $children[$uniqueKey]          = $child;
                $childKeyParentMap[$uniqueKey] = $key;
                $childRows[$uniqueKey]         = new Row($this->childrenTable);
            }
        }

        // Since all the rows are deleted then reinserted, we have to disable lazy loading
        // for all child relations as these will have been deleted via the foreign key
        // and need to be re-inserted
        $this->disableLazyLoadingForRelations(function () use ($context, $children, $childRows) {
            $this->mapper->persistAllToRows($context, $children, $childRows);
        });

        $rowGroups = [];

        foreach ($childKeyParentMap as $rowKey => $parentKey) {
            $rowGroups[$parentKey][] = $childRows[$rowKey];
        }

        foreach ($map->getItems() as $key => $item) {
            $parentRow = $item->getParent();
            $childRows = isset($rowGroups[$key]) ? $rowGroups[$key] : [];

            if ($parentRow->hasColumn($primaryKey)) {
                $this->setForeignKey($childRows, $this->foreignKeyToParent->getName(), $parentRow->getColumn($primaryKey));
            } else {
                $parentRow->onInsertPrimaryKey(function ($id) use ($childRows) {
                    $this->setForeignKey($childRows, $this->foreignKeyToParent->getName(), $id);
                });
            }
        }
    }