Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Forever310
druid
提交
22e368e7
D
druid
项目概览
Forever310
/
druid
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
druid
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
22e368e7
编写于
6月 12, 2014
作者:
X
Xavier Léauté
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add dimension/column selector to incremental index
上级
cde86d81
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
90 addition
and
7 deletion
+90
-7
processing/src/main/java/io/druid/segment/incremental/IncrementalIndex.java
...n/java/io/druid/segment/incremental/IncrementalIndex.java
+90
-7
未找到文件。
processing/src/main/java/io/druid/segment/incremental/IncrementalIndex.java
浏览文件 @
22e368e7
...
...
@@ -46,6 +46,7 @@ import io.druid.segment.DimensionSelector;
import
io.druid.segment.FloatColumnSelector
;
import
io.druid.segment.ObjectColumnSelector
;
import
io.druid.segment.TimestampColumnSelector
;
import
io.druid.segment.data.IndexedInts
;
import
io.druid.segment.serde.ComplexMetricExtractor
;
import
io.druid.segment.serde.ComplexMetricSerde
;
import
io.druid.segment.serde.ComplexMetrics
;
...
...
@@ -53,6 +54,7 @@ import org.joda.time.DateTime;
import
org.joda.time.Interval
;
import
javax.annotation.Nullable
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Iterator
;
import
java.util.LinkedHashMap
;
...
...
@@ -186,7 +188,7 @@ public class IncrementalIndex implements Iterable<Row>
dims
=
newDims
;
}
TimeAndDims
key
=
new
TimeAndDims
(
Math
.
max
(
gran
.
truncate
(
row
.
getTimestampFromEpoch
()),
minTimestamp
),
dims
);
final
TimeAndDims
key
=
new
TimeAndDims
(
Math
.
max
(
gran
.
truncate
(
row
.
getTimestampFromEpoch
()),
minTimestamp
),
dims
);
Aggregator
[]
aggs
=
facts
.
get
(
key
);
if
(
aggs
==
null
)
{
...
...
@@ -248,8 +250,34 @@ public class IncrementalIndex implements Iterable<Row>
};
}
final
ComplexMetricSerde
serde
=
ComplexMetrics
.
getSerdeForType
(
typeName
);
final
List
<
String
>
dimensionValues
=
in
.
getDimension
(
columnName
);
if
(
dimensionValues
!=
null
)
{
return
new
ObjectColumnSelector
<
Object
>()
{
@Override
public
Class
classOfObject
()
{
return
Object
.
class
;
}
@Override
public
Object
get
()
{
final
String
[]
dimVals
=
dimensionValues
.
toArray
(
new
String
[]{});
if
(
dimVals
.
length
==
1
)
{
return
dimVals
[
0
];
}
else
if
(
dimVals
.
length
==
0
)
{
return
null
;
}
else
{
return
dimVals
;
}
}
};
}
final
ComplexMetricSerde
serde
=
ComplexMetrics
.
getSerdeForType
(
typeName
);
if
(
serde
==
null
)
{
throw
new
ISE
(
"Don't know how to handle type[%s]"
,
typeName
);
}
...
...
@@ -273,12 +301,67 @@ public class IncrementalIndex implements Iterable<Row>
}
@Override
public
DimensionSelector
makeDimensionSelector
(
String
dimension
)
public
DimensionSelector
makeDimensionSelector
(
final
String
dimension
)
{
// we should implement this, but this is going to be rewritten soon anyways
throw
new
UnsupportedOperationException
(
"Incremental index aggregation does not support dimension selectors"
);
final
String
dimensionName
=
dimension
.
toLowerCase
();
final
List
<
String
>
dimensionValues
=
in
.
getDimension
(
dimensionName
);
if
(
dimensionValues
==
null
)
{
return
null
;
}
final
IncrementalIndex
.
DimDim
dimValLookup
=
getDimension
(
dimensionName
);
final
int
maxId
=
dimValLookup
.
size
();
return
new
DimensionSelector
()
{
@Override
public
IndexedInts
getRow
()
{
final
ArrayList
<
Integer
>
vals
=
Lists
.
newArrayList
();
for
(
String
dimVal
:
dimensionValues
)
{
int
id
=
dimValLookup
.
getId
(
dimVal
);
vals
.
add
(
id
);
}
return
new
IndexedInts
()
{
@Override
public
int
size
()
{
return
vals
.
size
();
}
@Override
public
int
get
(
int
index
)
{
return
vals
.
get
(
index
);
}
@Override
public
Iterator
<
Integer
>
iterator
()
{
return
vals
.
iterator
();
}
};
}
@Override
public
int
getValueCardinality
()
{
return
maxId
;
}
@Override
public
String
lookupName
(
int
id
)
{
return
dimValLookup
.
getValue
(
id
);
}
@Override
public
int
lookupId
(
String
name
)
{
return
dimValLookup
.
getId
(
name
);
}
};
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录