flatten在英文的意思弄平整的意思,这个操作符在不同的场景有不同的功能。
1. flatten tuple
flatten会把tuple内容打开,下面举例:
-- A结构:(a, (b, c))
B = foreach A GENERATE $0, flatten($1)
B返回结果(a,b,c)
B = foreach A GENERATE $0, flatten($1)
B返回结果(a,b,c)
2. flatten bag
flatten会把bag内容打开,每个tuple是一行,即列转换为行
-- A结构:({(b,c),(d,e)})
B = foreach A generate flatten($0)
B返回结果
(b,c)
(d,e)
B = foreach A generate flatten($0)
B返回结果
(b,c)
(d,e)
官方文档原文内容
The FLATTEN operator looks like a UDF syntactically, but it is actually an operator that changes the structure of tuples and bags in a way that a UDF cannot. Flatten un-nests tuples as well as bags. The idea is the same, but the operation and result is different for each type of structure.
For tuples, flatten substitutes the fields of a tuple in place of the tuple. For example, consider a relation that has a tuple of the form (a, (b, c)). The expression GENERATE $0, flatten($1), will cause that tuple to become (a, b, c).
For bags, the situation becomes more complicated. When we un-nest a bag, we create new tuples. If we have a relation that is made up of tuples of the form ({(b,c),(d,e)}) and we apply GENERATE flatten($0), we end up with two tuples (b,c) and (d,e). When we remove a level of nesting in a bag, sometimes we cause a cross product to happen. For example, consider a relation that has a tuple of the form (a, {(b,c), (d,e)}), commonly produced by the GROUP operator. If we apply the expression GENERATE $0, flatten($1) to this tuple, we will create new tuples: (a, b, c) and (a, d, e).
For tuples, flatten substitutes the fields of a tuple in place of the tuple. For example, consider a relation that has a tuple of the form (a, (b, c)). The expression GENERATE $0, flatten($1), will cause that tuple to become (a, b, c).
For bags, the situation becomes more complicated. When we un-nest a bag, we create new tuples. If we have a relation that is made up of tuples of the form ({(b,c),(d,e)}) and we apply GENERATE flatten($0), we end up with two tuples (b,c) and (d,e). When we remove a level of nesting in a bag, sometimes we cause a cross product to happen. For example, consider a relation that has a tuple of the form (a, {(b,c), (d,e)}), commonly produced by the GROUP operator. If we apply the expression GENERATE $0, flatten($1) to this tuple, we will create new tuples: (a, b, c) and (a, d, e).
相关推荐
geojson-flatten 将文件中的MultiPoint,MultiPolygon,MultiLineString和GeometryCollection几何图形展平为简单的非复杂几何图形。 如果传入FeatureCollection,则返回FeatureCollection。 如果传入单个功能,则...
Laravel开发-flatten 用于照明框架的包,它将页面扁平化为纯HTML
flatten是numpy.ndarray.flatten的一个函数,即返回一个一维数组。这篇文章主要介绍了Python中flatten( )函数,需要的朋友可以参考下
flatten()函数用法 flatten是numpy.ndarray.flatten的一个函数,即返回一个折叠成一维的数组。但是该函数只能适用于numpy对象,即array或者mat,普通的list列表是不行的。 其官方文档是这样描述的 Parameters: ...
命令行工具。拷贝多个目录下的指定文件到目标目录
MojoHaus Flatten Maven插件 这是 。 1.0.x分支: 快速开始 这个插件会生成您pom.xml的扁平版本,并使maven可以安装和部署该版本,而不是原始pom.xml。 <groupId>org.codehaus.mojo <artifactId>flatten-...
资源分类:Python库 所属语言:Python 资源全名:flatten_json-0.1.12.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
lighthouse3d里面glsl教程3的例子
flatten_gds.tcl
Flatten Maven插件 生产发布 开发发布 安装 相似的插件 插件功能 取代公开的身份 解决依赖版本范围 根据范围排除依赖项 可选地包括传递依赖 根据xml标签名称删除pom.xml成员 用生成的pom.xml.flatten切换项目pom....
import { flatten } from "array-flatten" ; flatten ( [ 1 , [ 2 , [ 3 , [ 4 , [ 5 ] , 6 ] , 7 ] , 8 ] , 9 ] ) ; //=> [1, 2, 3, 4, 5, 6, 7, 8, 9] ( function ( ) { flatten ( arguments ) ; //=> [1, 2, 3] ...
本文实例讲述了C#中GraphicsPath的Flatten方法。分享给大家供大家参考。具体实现方法如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System....
flatten-js是一个JavaScript库,用于处理抽象的几何形状,例如点,矢量,线,射线,线段,圆,弧和多边形。 形状可以组织成“平面集”-支持空间查询的可搜索容器。 flatten-js提供了许多有用的方法和算法,例如查找...
例如,我有一个padding过的矩阵,那么它一定是带masking的,然后我想要把它Flatten,再输入到Dense层。然而Keras的Flatten层不支持masking。 Keras原本Flatten的实现 class Flatten(Layer): def __init__(self, **...
js代码-flatten
import flatten , { isLast } from 'object-flatten'const flattened = flatten ( isLast , { margin : { auto : { marginLeft : 'auto' , marginRight : 'auto' } }} ) 这将返回一个展平的对象: { 'margin.auto' ...
JSONPath_flatten
前端大厂最新面试题-flatten.docx