@param array $records
@param array $config

@return array
500317
protected function getStatements($records, $config)
    {
        $statements = [];
        foreach ($records as $record) {
            $duration = null;
            $memory   = null;

            $isSuccess = (LogLevel::INFO === strtolower($record['level_name']));

            $detailsCount = count($config['details']);
            $parameters   = explode($config['outerGlue'], $record['message'], $detailsCount + 1);
            if (count($parameters) === ($detailsCount + 1)) {
                $parameters = array_map('trim', $parameters);
                $_details   = [];
                foreach (array_splice($parameters, 0, $detailsCount) as $string) {
                    list($key, $value) = array_map('trim', explode($config['innerGlue'], $string, 2));
                    $_details[$key] = $value;
                }

                $details = [];
                foreach ($config['details'] as $key => $detail) {
                    if (isset($_details[$detail['name']])) {
                        $value = $_details[$detail['name']];
                        if ('time' === $key) {
                            if (substr_count($value, 'ms')) {
                                $value = (float) $value / 1000;
                            } else {
                                $value = (float) $value;
                            }
                        } else {
                            $suffixes = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
                            $suffix   = substr($value, -2);
                            $i        = array_search($suffix, $suffixes, true);
                            $i        = (false === $i) ? 0 : $i;

                            $value = ((float) $value) * pow(1024, $i);
                        }
                        $details[$key] = $value;
                    }
                }

                if (isset($details['time'])) {
                    $duration = $details['time'];
                }
                if (isset($details['memDelta'])) {
                    $memory = $details['memDelta'];
                }

                $message = end($parameters);

                if ($isSuccess) {
                    $this->queryCount++;
                }
            } else {
                $message = $record['message'];
            }

            $statement = [
                'sql'          => $message,
                'is_success'   => $isSuccess,
                'duration'     => $duration,
                'duration_str' => $this->getDataFormatter()->formatDuration($duration),
                'memory'       => $memory,
                'memory_str'   => $this->getDataFormatter()->formatBytes($memory),
            ];

            if (false === $isSuccess) {
                $statement['sql']           = '';
                $statement['error_code']    = $record['level'];
                $statement['error_message'] = $message;
            }

            $statements[] = $statement;
        }
        return $statements;
    }
1159277
function(records,config) {
    
    //the hell is this doing here
    this.id = new Date();

    if ( records instanceof Array ) {
        this.records = records;
    } else {
        var dataField = records.data;
        var data = records.datasource;
        this.records =  data[dataField];
    }
    this.config = config;
    if ( this.config ) {
        this.propertyConfigMap = {};
        this.config.cols.forEach( col => {
            this.propertyConfigMap[col.property] = col;
        });
    }

    //indexRecords.call(this);
}
339866
protected function get_list_of_favourites_from_records(array $records) {
        $list = [];
        foreach ($records as $index => $record) {
            $list[$index] = $this->get_favourite_from_record($record);
        }
        return $list;
    }
430681
private function generateDocument(array $tables, Config $config)
    {
        $document = new Document();
        $reportsEl = $document->createRoot('reports');
        $reportsEl->setAttribute('name', 'table');
        $reportEl = $reportsEl->appendElement('report');
        $classMap = array_merge(
            $this->classMap,
            $config['class_map']
        );

        if (isset($config['title'])) {
            $reportEl->setAttribute('title', $config['title']);
        }

        if (isset($config['description'])) {
            $reportEl->appendElement('description', $config['description']);
        }

        foreach ($tables as $breakHash => $table) {
            $tableEl = $reportEl->appendElement('table');

            // Build the col(umn) definitions.
            foreach ($table as $row) {
                $colsEl = $tableEl->appendElement('cols');

                foreach ($row->getNames() as $colName) {
                    $colEl = $colsEl->appendElement('col');
                    $colEl->setAttribute('name', $colName);

                    // column labels are the column names by default.
                    // the user may override by column name or column index.
                    $colLabel = $colName;

                    if (isset($config['labels'][$colName])) {
                        $colLabel = $config['labels'][$colName];
                    }

                    $colEl->setAttribute('label', $colLabel);
                }

                break;
            }

            if ($breakHash) {
                $tableEl->setAttribute('title', $breakHash);
            }

            $groupEl = $tableEl->appendElement('group');
            $groupEl->setAttribute('name', 'body');

            foreach ($table as $row) {
                $rowEl = $groupEl->appendElement('row');

                // apply formatter options
                foreach ($row->getFormatParams() as $paramName => $paramValue) {
                    $paramEl = $rowEl->appendElement('formatter-param', $paramValue);
                    $paramEl->setAttribute('name', $paramName);
                }

                foreach ($row as $key => $value) {
                    $cellEl = $rowEl->appendElement('cell', $value);
                    $cellEl->setAttribute('name', $key);

                    if (isset($classMap[$key])) {
                        $cellEl->setAttribute('class', implode(' ', $classMap[$key]));
                    }
                }
            }
        }

        return $document;
    }
625981
protected function _getRecords(array $records, TableSchema $schema)
    {
        $fields = $values = $types = [];
        $columns = $schema->columns();
        foreach ($records as $record) {
            $fields = array_merge($fields, array_intersect(array_keys($record), $columns));
        }
        $fields = array_values(array_unique($fields));
        foreach ($fields as $field) {
            $types[$field] = $schema->column($field)['type'];
        }
        $default = array_fill_keys($fields, null);
        foreach ($records as $record) {
            $values[] = array_merge($default, $record);
        }

        return [$fields, $values, $types];
    }
859796
private function _hasOne(array $config): Record
    {
        //配置信息
        $tableClass = $config['table'];
        $primaryKey = $config['primaryKey'];
        $foreignKey = $config['foreignKey'];
        $orderBy = isset($config['orderBy']) ? $config['orderBy'] : null;

        //取主键的值
        $primaryValue = $this->$primaryKey;

        /**
         * 子对象表
         * @var $tableInstance Table
         */
        $tableInstance = $tableClass::instance();

        //在子对象表中查询关联记录
        $row = $tableInstance->row('*', [$foreignKey => $primaryValue], $orderBy);

        //转换成具体行对象
        $recordClass = 'R' . substr($tableClass, 1);
        return new $recordClass($row->toArray());
    }
305856
public function handleBatch(array $records)
	{
		foreach ($records as $key => $record) {
	        if ($this->isHandling($record)) {
	        	$record = $this->processRecord($record);
	    		$records['records'][] = $record;
	    	}

			unset($records[$key]);
	    }

	    $records['formatted'] = $this->getFormatter()->formatBatch($records['records'] ?? []);

	    $this->write($records);

	    return false === $this->bubble;
	}
611328
private function makeWriters(array $config): array
    {
        $writers = [];

        foreach ($config as $name => $binding) {
            $writers[$name] = $binding->resolve($this->factory);
        }

        return $writers;
    }
1087129
protected function mergeRecords(array $records)
    {
        foreach ($records as $key => $record) {
            if (null === $id = array_get($record, static::ID_FIELD)) {
                throw new InternalServerErrorException('No ' .
                    static::ID_FIELD .
                    ' field found in supplied record(s). Cannot merge record(s) for PATCH operation.');
            }

            $rs = $this->getConnection()->getDocument($this->transactionTable, $id);
            $record = array_merge($rs, $record);
            $records[$key] = $record;
        }

        return $records;
    }
310268
public function fillRecordWithRelations(Record $record)
    {
        foreach ($this->getWith() as $relation) {
            $relation->fillRecord($record);
        }

        return $record;
    }
87596
public static function import($records)
    {
        $objects = array();
        $className = get_called_class();
        $defaults = self::schema()->defaults();

        foreach ($records as $record) {
            $objects []= $className::fromArray()
                ->load(array_merge($defaults, $record))->markSaved(false)->save();
        }

        return $objects;
    }
205621
public static function withKeys($records, $keys)
    {
        if (!self::iterable($records)) {
            return array();
        }
        
        $out = array();
        foreach ($records as $n => $record) {
            if (!self::iterable($record)) {
                $out[$n] = $record;
                continue;
            }
            $out[$n] = array();
            
            foreach ($record as $k => $v) {
                if (!in_array($k, $keys)) {
                    continue;
                }
                $out[$n][$k] = $v;
            }
        }
        return $out;
    }
1051983
public static function filterRecords(array $records, $filter)
    {
        if (is_string($filter))
        {
            $filter = new PropertyFilter($filter);
        }

        $result = [ ];
        foreach ($records as $record)
        {
            if ($filter->match($record))
            {
                $result[$record->getId()] = $record;
            }
        }

        return $result;
    }
453543
public function multiUpdate($records)
    {
        $ids = [];

        foreach ($records as $record) {
            try {
                $updatedRecord = $this->update($record);
                $ids[] = $updatedRecord[$this->getIdentifier()];
            } catch (\Throwable $e) {
                // TODO: need to log record that was not updated
                continue;
            }
        }

        return $ids;
    }
187427
protected function formatSyncList(array $records)
    {
        $results = array();

        foreach ($records as $id => $attributes)
        {
            if ( ! is_array($attributes))
            {
                list($id, $attributes) = array($attributes, array());
            }

            $results[$id] = $attributes;
        }

        return $results;
    }
1088441
protected function processRecords(array $records)
    {
        $record = new Record();
        $formatter = $this->getFormatter();
        if ($this->isInstanceOf($formatter, FormatterInterface::class)) {
            $formatter->formatRecords($records, $record);
        }

        $this->write($record);

        return $this->bubble;
    }
31801
public function load(array $files, Config $config = null)
    {
        if (is_null($config)) {
            $config = new Config();
        }

        if (!$this->isValidFileList($files)) {
            throw new \RuntimeException('Invalid config file list given. At least one config file must exist.');
        }

        foreach ($files as $file) {
            if ($this->isFileExisting($file)) {
                $config->merge(
                    $this->loadFile($file)
                );
            }
        }

        return $config;
    }