聚合
@param $csv_name
@param $key
@return array
517800
public function groupBy($csv_name, $key)
    {
        $data = $this->all[$csv_name];
        $types = [];
        foreach ($data as $value) {
            if (!array_key_exists($value[$key], $types)) {
                $types[$value[$key]] = [$value];
            } else {
                $types[$value[$key]][] = $value;
            }
        }
        return $types;
    }
88225
public function getContactsTransactionalDataByKey($name, $key)
    {
        $url = $this->getApiEndpoint() . self::REST_TRANSACTIONAL_DATA . $name . '/'
            . $key;
        $this->setUrl($url)
            ->setVerb('GET');

        return $this->execute();
    }
435590
public function getFieldValues(string $field_name)
    {
        try {
            $field = [];
            $result = $this->stmt->fetchAll(\PDO::FETCH_ASSOC);
            if (array_key_exists($field_name, $result[0])) {
                foreach ($result as $row) {
                    $field[] = $row[$field_name];
                }
            } else {
                throw new \Exception("Field '$field_name' is not present in the current result set.\n");
            }
            return $field;
        } catch (\PDOException $e) {
            die('Error: ' . $e->getMessage());
        } catch (\Exception $e) {
            die("Error: " . $e->getMessage());
        }
    }
1275485
public final function &getSharedArray($key)
    {
        if (!isset($this->sharedData[$key])){
            $this->sharedData[$key] = [];
        }

        return $this->sharedData[$key];
    }
1159568
protected function getRule(string $name, string $key, array $parent_names = []): array
    {
        if (isset($this->rules[$key])) {
            return $this->rules[$key];
        }
        if ($this->total_rules === 1 || !$parent_names) {
            return $this->rules['*']; // Done here.
        }
        foreach (array_map('strtolower', $parent_names) as $_parent_key) {
            if (isset($this->rules[$_parent_key])) {
                return $this->rules[$_parent_key];
            }
        } // unset($_parent_key); // Housekeeping.

        return $this->rules['*'];
    }
274939
function loadKeyValueCSV (filename, callback) {
  var out = {}

  csv()
  .from.path(filename, {
    delimiter: '\t'
  })
  .on('record', function (data, index) {
    if (data[0].match(/^[\w\d]/)) {
      out[data[0]] = data[1]
    }
  })
  .on('end', function (count) {
    callback(null, out)
  })
  .on('error', function (err) {
    callback(err)
  })
}
1252753
public function getSettingJoined($name, $key = null)
	{
		if( debug_assert($this->settingExistsJoined($name),'Tried to retrieve not existing joined setting.') )
		{
			if($key)
			{
				if(isset($this->_settingsJoined[$name][$key]))
				{
					return $this->_settingsJoined[$name][$key];
				}
			}
			else
			{
				return $this->_settingsJoined[$name];
			}
		}
		return null;
	}
330988
public function index(string $name = ''): array
    {
        //获取原始索引信息
        $indexes = $this->getIndex($name);
        $ret = [];

        //逐个处理
        foreach ($indexes as $index) {
            //索引名称
            $name = $index['Key_name'];

            //列名
            $col = $index['Column_name'];

            //列信息
            $columnInfo = [
                'name' => $col,
                'null' => $index['Null'] ? true : false,//列中是否含有NULL
                'subPart' => $index['Sub_part'],//如果列只是被部分地编入索引，则为被编入索引的字符的数目。如果整列被编入索引，则为NULL
            ];

            //索引中的第一列,则创建
            if ($index['Seq_in_index'] == 1) {
                $ret[$name] = [
                    'tableName' => $index['Table'], //所属表名
                    'isUnique' => !$index['Non_unique'], //是否唯一索引
                    'collation' => $index['Collation'], //这个有A和NULL, A是不区分大小写?
                    'columns' => [$col => $columnInfo],//本索引中包含的列
                    'cardinality' => $index['Cardinality'], //索引中唯一值的数目的估计值。
                    'packed' => $index['Packed'],//指示关键字如何被压缩。如果没有被压缩，则为NULL。
                    'type' => $index['Index_type'],//用过的索引方法（BTREE, FULLTEXT, HASH, RTREE）。
                    'comment' => $index['Comment'],//说明
                ];
            } else {
                //索引中的后继列,则只增加列信息
                $ret[$name]['columns'][$col] = $columnInfo;
            }
        }

        return $ret;
    }
401635
public static function groupBy($data, $key)
    {
        $res = [];
        for ($i = 0, $l = sizeof($data); $i < $l; $i++) {
            $item = $data[$i];
            $value = empty($item[$key]) ? __undefined : $item[$key];
            if (empty($res[$value])) {
                $res[$value] = [];
            }
            $res[$value][] = $item;
        }
        return $res;
    }
620113
public function fromCSV()
    {
        $output = $this->file();
        $base = $this->base();
        $file = fopen($base.$output, 'r');

        if (!$file) {
            return [];
        }

        $results = [];
        $row = 0;
        while (($data = fgetcsv($file, 0, ',')) !== false) {
            $row++;
            // Skip column names
            if ($row == 1) {
                continue;
            }
            /**
             * data[0] = ORIGINAL
             * data[1] = TRANSLATION
             * data[2] = CONTEXT
             */
            $translation = $this->translateCSV($data);
            if (!empty($translation)) {
                $results[$translation[0]] = $translation[1];
            }
        }

        return $results;
    }
424970
private function getFile(string $key): array
    {
        if (!preg_match('/^\w+$/', $key)) {
            $key = md5($key);
        }

        // 返回唯一Key,缓存内容的文件名,缓存语句的文件名
        return [$key, $this->path() . $key . '.cache', $this->path() . $key . '.sql'];
    }
1041503
private function _getSecondaryKeys($data, $key = null)
    {
        if ($key) {
            $data = ArrayHelper::getValue($data, $key, []);
        }

        return ArrayHelper::getColumn($data, $this->relSecondaryKey);
    }
185026
public function getFieldAsArray(string $name): array
    {
        $result = $this->getFieldDefinition($name);

        $result['name'] = $name;

        if (empty($result['caption'])) {
            $result['caption'] = $this->_($result['name']);
        }

        $value = $this->$name;
        $type = @$result['type'];

        if (($type == 'date' || $type == 'datetime' || $type == 'time') && is_object($value)) {
            $value = $value->format($this->translate('form.' . $type));
        }

        $result['value'] = $value;
        $result['uid'] = 'id' . uniqid();

        if (isset($result['options']) && is_array($result['options'])) {
            $options = array();

            foreach ($result['options'] as $option => $label) {
                $options[] = array('option' => $option, 'label' => $label);
            }

            $result['options'] = $options;
        }

        return $result;
    }
1135656
private function tokenizeKey($key)
    {
        $containerName = $this->containerName;
        if (false === $this->multiContainerMode) {
            return [$containerName, $key];
        }

        if (false === ($index = strpos($key, '/'))) {
            throw new \InvalidArgumentException(sprintf(
                'Failed to establish container name from key "%s", container name is required in multi-container mode',
                $key
            ));
        }
        $containerName = substr($key, 0, $index);
        $key = substr($key, $index + 1);

        return [$containerName, $key];
    }
702155
protected function splitNamespaceAndKey($key)
    {
        if (strpos($key, '::') !== false) {
            list($namespace, $key) = explode('::', $key, 2);

            return [$namespace, $key];
        }

        return ['', $key];
    }
1095206
public static tmtrafficpolicy_csvserver_binding[] get(nitro_service service, String name) throws Exception{
		tmtrafficpolicy_csvserver_binding obj = new tmtrafficpolicy_csvserver_binding();
		obj.set_name(name);
		tmtrafficpolicy_csvserver_binding response[] = (tmtrafficpolicy_csvserver_binding[]) obj.get_resources(service);
		return response;
	}
715796
protected function getData($key)
    {
        $path = $this->path($key);
        if (!$this->fileSystem->isFile($path)) {
            return ['data' => null, 'time' => null];
        }

        $content    = $this->fileSystem->get($path);
        $expire     = substr($content, 0, 10);

        if (time() > $expire) {
            $this->delete($key);
            return ['data' => null, 'time' => null];
        }

        $data = unserialize(substr($content, 10));


        return ['data'=>$data, 'time' => ($expire - time())];
    }