Extract data.

@param $data
@return iterable
@throws EtlException
4193
private function extract($data): iterable
    {
        $items = null === $this->extract ? $data : ($this->extract)($data, $this);

        if (null === $items) {
            $items = new \EmptyIterator();
        }

        if (!\is_iterable($items)) {
            throw new EtlException('Could not extract data.');
        }

        try {
            foreach ($items as $key => $item) {
                try {
                    $this->shouldSkip = false;
                    $this->eventDispatcher->dispatch(new ItemEvent(EtlEvents::EXTRACT, $item, $key, $this));
                    yield $key => $item;
                } catch (\Exception $e) {
                    continue;
                }
            }
        } catch (\Throwable $e) {
            /** @var ItemExceptionEvent $event */
            $event = $this->eventDispatcher->dispatch(new ItemExceptionEvent(EtlEvents::EXTRACT_EXCEPTION, $item ?? null, $key ?? null, $this, $e));
            if ($event->shouldThrowException()) {
                throw $e;
            }
        }
    }
941082
protected function extractSingleItemData(array $data) {
        if ($this->singleResponseKey && !array_key_exists($this->singleResponseKey, $data)) {
            throw new Exception('Invalid response, missing field ' . $this->singleResponseKey);
        }

        return ($this->singleResponseKey) ? $data[$this->singleResponseKey] : $data;
    }
94752
public static function parseData($data)
    {
        $parsed = array();
        foreach (explode(' ', $data) as $pair) {
            if (strpos($pair, ':') > 0) {
                list($key, $value) = array_map('trim', explode(':', $pair));
                $parsed[$key] = $value;
            }
        }

        return $parsed;
    }
1047359
public function extractMantissa($data) {
        $signAndExponent = $this->extractSignAndExponentFromData($data);
        $mask = ~$signAndExponent;
        $mantissa = $data & $mask;
        return $mantissa;
    }
1280579
public function byData($data)
    {
        \UArray::doConvertToArray($data);
        $model = new $this;
        $model->id = $this->entity->extractId($data);
        foreach ($data as $name => $seed) {
            $attribute = $model->getAttribute($name);
            if (is_object($attribute)) {
                $attribute->setSeed($seed);
            } else {
                $model->set($name, $seed);
            }
        }
        $model->initialize();
        return $model;
    }
832438
public function extract($data = [], $fields = [])
    {
        foreach ($fields as $field) {
            if (isset($data[$field])) {
                $this->set($field, $data[$field]);
            } else {
                $this->set($field, null);
            }
        }

        return $this;
    }
874694
private function deserializeData($data)
    {
        $result = $this->get('jms_serializer')->deserialize(
            $data,
            $this->getTargetGroupRepository()->getClassName(),
            'json',
            DeserializationContext::create()
                ->setSerializeNull(true)
        );

        return $result;
    }
1186440
public function run($data = []) {
		$filterCollection = ScenarioHelper::forgeCollection($this->filters);
		$data =  ScenarioHelper::runAll($filterCollection, $data);
		return $data;
	}
833094
public function extract($rules)
    {
        $data = [];

        foreach ($this->_nodes as $node) {
            $selector = new Selector($this->_document, $node);
            $data[] = $selector->extract($rules);
        }

        return $data;
    }
969600
public function transform($data)
    {
        if (is_array($data)) {
            return $data;
        }

        if (is_object($data) && $data instanceof Arrayable) {
            return $data->toArray();
        }

        return (array) $data;
    }
443782
public function setExtraData($data)
    {
        if (is_a($data, Arrayable::class)) {
            $data = $data->toArray();
        }

        if ( ! is_array($data)) {
            $data = [ $data ];
        }

        $this->extraData = $data;

        return $this;
    }
499685
protected function getData($data):array{

		if(is_array($data)){
			return $data;
		}
		elseif($data instanceof Traversable){
			return iterator_to_array($data); // @codeCoverageIgnore
		}

		$msg = 'invalid data';
		$this->logger->error($msg);

		throw new InvalidArgumentException($msg);
	}
11303
public function extractUrlAliasFromData($data)
    {
        $urlAlias = new UrlAlias();

        list($type, $destination) = $this->matchTypeAndDestination($data['action']);
        $urlAlias->id = $data['parent'] . '-' . $data['text_md5'];
        $urlAlias->pathData = $this->normalizePathData($data['raw_path_data']);
        $urlAlias->languageCodes = $this->languageMaskGenerator->extractLanguageCodesFromMask($data['lang_mask']);
        $urlAlias->alwaysAvailable = $this->languageMaskGenerator->isAlwaysAvailable($data['lang_mask']);
        $urlAlias->isHistory = isset($data['is_path_history']) ? $data['is_path_history'] : !$data['is_original'];
        $urlAlias->isCustom = (bool)$data['is_alias'];
        $urlAlias->forward = $data['is_alias'] && $data['alias_redirects'];
        $urlAlias->destination = $destination;
        $urlAlias->type = $type;

        return $urlAlias;
    }
524145
protected function extractNextDataString($data, $lastPosition) {
        $substring = substr($data, $lastPosition);
        $reader = new BinnReader();
        $container = $reader->readNext($substring);
        $substring = $container->getByteString();
        $substringLength = strlen($substring);
        $nextIndex = $lastPosition + $substringLength;
        unset($reader);
        unset($container);
        unset($substringLength);
        return [$substring, $nextIndex];
    }
1044755
protected function _read_data($data) {
        // 检查字段映射
        if(!empty($this->_map) && C('READ_DATA_MAP')) {
            foreach ($this->_map as $key=>$val){
                if(isset($data[$val])) {
                    $data[$key] =   $data[$val];
                    unset($data[$val]);
                }
            }
        }
        return $data;
    }
323811
public function extractRelations(array &$data)
    {
        //Fetch all relations
        $relations = array_intersect_key($data, $this->schema);

        foreach ($relations as $name => $relation) {
            $this->relations[$name] = $relation;
            unset($data[$name]);
        }
    }
920743
protected function mapData($data)
    {
        $values = array();

        foreach ($data->buckets as $bucket) {
            $values[$bucket->key] = $bucket->doc_count;
        }

        return $values;
    }