Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Iotdb
提交
fc03f2d6
I
Iotdb
项目概览
apache
/
Iotdb
12 个月 前同步成功
通知
25
Star
3344
Fork
916
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
Iotdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fc03f2d6
编写于
8月 20, 2019
作者:
J
jack870131
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bugs in RowBatch
上级
521be407
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
50 addition
and
49 deletion
+50
-49
docs/Documentation/UserGuide/7-TsFile/2-Usage.md
docs/Documentation/UserGuide/7-TsFile/2-Usage.md
+4
-4
tsfile/example/src/main/java/org/apache/iotdb/tsfile/TsFileWriteWithRowBatch.java
...java/org/apache/iotdb/tsfile/TsFileWriteWithRowBatch.java
+3
-3
tsfile/src/main/java/org/apache/iotdb/tsfile/write/chunk/ChunkGroupWriterImpl.java
...apache/iotdb/tsfile/write/chunk/ChunkGroupWriterImpl.java
+7
-6
tsfile/src/main/java/org/apache/iotdb/tsfile/write/chunk/ChunkWriterImpl.java
.../org/apache/iotdb/tsfile/write/chunk/ChunkWriterImpl.java
+14
-14
tsfile/src/main/java/org/apache/iotdb/tsfile/write/chunk/IChunkWriter.java
...ava/org/apache/iotdb/tsfile/write/chunk/IChunkWriter.java
+7
-7
tsfile/src/main/java/org/apache/iotdb/tsfile/write/page/PageWriter.java
...n/java/org/apache/iotdb/tsfile/write/page/PageWriter.java
+14
-14
tsfile/src/test/java/org/apache/iotdb/tsfile/write/TsFileReadWriteTest.java
...va/org/apache/iotdb/tsfile/write/TsFileReadWriteTest.java
+1
-1
未找到文件。
docs/Documentation/UserGuide/7-TsFile/2-Usage.md
浏览文件 @
fc03f2d6
...
...
@@ -208,7 +208,7 @@ import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
* It uses the interface:
* public void addMeasurement(MeasurementSchema MeasurementSchema) throws WriteProcessException
*/
public class TsFileWrite {
public class TsFileWrite
WithTSRecord
{
public static void main(String args[]) {
try {
...
...
@@ -295,7 +295,7 @@ public class TsFileWriteWithRowBatch {
RowBatch rowBatch = fileSchema.createRowBatch("device_1");
long[] timestamps = rowBatch.timestamps;
Object[]
sensors = rowBatch.sensor
s;
Object[]
values = rowBatch.value
s;
long timestamp = 1;
long value = 1000000L;
...
...
@@ -304,11 +304,11 @@ public class TsFileWriteWithRowBatch {
int row = rowBatch.batchSize++;
timestamps[row] = timestamp++;
for (int i = 0; i < sensorNum; i++) {
long[] sensor = (long[])
sensor
s[i];
long[] sensor = (long[])
value
s[i];
sensor[row] = value;
}
// write RowBatch to TsFile
if (rowBatch.batchSize == rowBatch.get
BatchMax
Size()) {
if (rowBatch.batchSize == rowBatch.get
MaxBatch
Size()) {
tsFileWriter.write(rowBatch);
rowBatch.reset();
}
...
...
tsfile/example/src/main/java/org/apache/iotdb/tsfile/TsFileWriteWithRowBatch.java
浏览文件 @
fc03f2d6
...
...
@@ -59,7 +59,7 @@ public class TsFileWriteWithRowBatch {
RowBatch
rowBatch
=
fileSchema
.
createRowBatch
(
"device_1"
);
long
[]
timestamps
=
rowBatch
.
timestamps
;
Object
[]
sensors
=
rowBatch
.
sensor
s
;
Object
[]
values
=
rowBatch
.
value
s
;
long
timestamp
=
1
;
long
value
=
1000000L
;
...
...
@@ -68,11 +68,11 @@ public class TsFileWriteWithRowBatch {
int
row
=
rowBatch
.
batchSize
++;
timestamps
[
row
]
=
timestamp
++;
for
(
int
i
=
0
;
i
<
sensorNum
;
i
++)
{
long
[]
sensor
=
(
long
[])
sensor
s
[
i
];
long
[]
sensor
=
(
long
[])
value
s
[
i
];
sensor
[
row
]
=
value
;
}
// write RowBatch to TsFile
if
(
rowBatch
.
batchSize
==
rowBatch
.
get
BatchMax
Size
())
{
if
(
rowBatch
.
batchSize
==
rowBatch
.
get
MaxBatch
Size
())
{
tsFileWriter
.
write
(
rowBatch
);
rowBatch
.
reset
();
}
...
...
tsfile/src/main/java/org/apache/iotdb/tsfile/write/chunk/ChunkGroupWriterImpl.java
浏览文件 @
fc03f2d6
...
...
@@ -91,24 +91,25 @@ public class ChunkGroupWriterImpl implements IChunkGroupWriter {
private
void
writeByDataType
(
RowBatch
rowBatch
,
String
measurementId
,
TSDataType
dataType
,
int
index
)
throws
IOException
{
int
batchSize
=
rowBatch
.
batchSize
;
switch
(
dataType
)
{
case
INT32:
chunkWriters
.
get
(
measurementId
).
write
(
rowBatch
.
timestamps
,
(
int
[])
rowBatch
.
values
[
index
]);
chunkWriters
.
get
(
measurementId
).
write
(
rowBatch
.
timestamps
,
(
int
[])
rowBatch
.
values
[
index
]
,
batchSize
);
break
;
case
INT64:
chunkWriters
.
get
(
measurementId
).
write
(
rowBatch
.
timestamps
,
(
long
[])
rowBatch
.
values
[
index
]);
chunkWriters
.
get
(
measurementId
).
write
(
rowBatch
.
timestamps
,
(
long
[])
rowBatch
.
values
[
index
]
,
batchSize
);
break
;
case
FLOAT:
chunkWriters
.
get
(
measurementId
).
write
(
rowBatch
.
timestamps
,
(
float
[])
rowBatch
.
values
[
index
]);
chunkWriters
.
get
(
measurementId
).
write
(
rowBatch
.
timestamps
,
(
float
[])
rowBatch
.
values
[
index
]
,
batchSize
);
break
;
case
DOUBLE:
chunkWriters
.
get
(
measurementId
).
write
(
rowBatch
.
timestamps
,
(
double
[])
rowBatch
.
values
[
index
]);
chunkWriters
.
get
(
measurementId
).
write
(
rowBatch
.
timestamps
,
(
double
[])
rowBatch
.
values
[
index
]
,
batchSize
);
break
;
case
BOOLEAN:
chunkWriters
.
get
(
measurementId
).
write
(
rowBatch
.
timestamps
,
(
boolean
[])
rowBatch
.
values
[
index
]);
chunkWriters
.
get
(
measurementId
).
write
(
rowBatch
.
timestamps
,
(
boolean
[])
rowBatch
.
values
[
index
]
,
batchSize
);
break
;
case
TEXT:
chunkWriters
.
get
(
measurementId
).
write
(
rowBatch
.
timestamps
,
(
Binary
[])
rowBatch
.
values
[
index
]);
chunkWriters
.
get
(
measurementId
).
write
(
rowBatch
.
timestamps
,
(
Binary
[])
rowBatch
.
values
[
index
]
,
batchSize
);
break
;
default
:
throw
new
UnSupportedDataTypeException
(
...
...
tsfile/src/main/java/org/apache/iotdb/tsfile/write/chunk/ChunkWriterImpl.java
浏览文件 @
fc03f2d6
...
...
@@ -200,85 +200,85 @@ public class ChunkWriterImpl implements IChunkWriter {
}
@Override
public
void
write
(
long
[]
timestamps
,
int
[]
values
)
{
public
void
write
(
long
[]
timestamps
,
int
[]
values
,
int
batchSize
)
{
this
.
time
=
timestamps
[
timestamps
.
length
-
1
];
valueCountInOnePage
+=
timestamps
.
length
;
if
(
minTimestamp
==
Long
.
MIN_VALUE
)
{
minTimestamp
=
timestamps
[
0
];
}
dataPageWriter
.
write
(
timestamps
,
values
);
dataPageWriter
.
write
(
timestamps
,
values
,
batchSize
);
pageStatistics
.
updateStats
(
values
);
checkPageSizeAndMayOpenANewPage
();
}
@Override
public
void
write
(
long
[]
timestamps
,
long
[]
values
)
{
public
void
write
(
long
[]
timestamps
,
long
[]
values
,
int
batchSize
)
{
this
.
time
=
timestamps
[
timestamps
.
length
-
1
];
valueCountInOnePage
+=
timestamps
.
length
;
if
(
minTimestamp
==
Long
.
MIN_VALUE
)
{
minTimestamp
=
timestamps
[
0
];
}
dataPageWriter
.
write
(
timestamps
,
values
);
dataPageWriter
.
write
(
timestamps
,
values
,
batchSize
);
pageStatistics
.
updateStats
(
values
);
checkPageSizeAndMayOpenANewPage
();
}
@Override
public
void
write
(
long
[]
timestamps
,
boolean
[]
values
)
{
public
void
write
(
long
[]
timestamps
,
boolean
[]
values
,
int
batchSize
)
{
this
.
time
=
timestamps
[
timestamps
.
length
-
1
];
valueCountInOnePage
+=
timestamps
.
length
;
if
(
minTimestamp
==
Long
.
MIN_VALUE
)
{
minTimestamp
=
timestamps
[
0
];
}
dataPageWriter
.
write
(
timestamps
,
values
);
dataPageWriter
.
write
(
timestamps
,
values
,
batchSize
);
pageStatistics
.
updateStats
(
values
);
checkPageSizeAndMayOpenANewPage
();
}
@Override
public
void
write
(
long
[]
timestamps
,
float
[]
values
)
{
public
void
write
(
long
[]
timestamps
,
float
[]
values
,
int
batchSize
)
{
this
.
time
=
timestamps
[
timestamps
.
length
-
1
];
valueCountInOnePage
+=
timestamps
.
length
;
if
(
minTimestamp
==
Long
.
MIN_VALUE
)
{
minTimestamp
=
timestamps
[
0
];
}
dataPageWriter
.
write
(
timestamps
,
values
);
dataPageWriter
.
write
(
timestamps
,
values
,
batchSize
);
pageStatistics
.
updateStats
(
values
);
checkPageSizeAndMayOpenANewPage
();
}
@Override
public
void
write
(
long
[]
timestamps
,
double
[]
values
)
{
public
void
write
(
long
[]
timestamps
,
double
[]
values
,
int
batchSize
)
{
this
.
time
=
timestamps
[
timestamps
.
length
-
1
];
valueCountInOnePage
+=
timestamps
.
length
;
if
(
minTimestamp
==
Long
.
MIN_VALUE
)
{
minTimestamp
=
timestamps
[
0
];
}
dataPageWriter
.
write
(
timestamps
,
values
);
dataPageWriter
.
write
(
timestamps
,
values
,
batchSize
);
pageStatistics
.
updateStats
(
values
);
checkPageSizeAndMayOpenANewPage
();
}
@Override
public
void
write
(
long
[]
timestamps
,
BigDecimal
[]
values
)
{
public
void
write
(
long
[]
timestamps
,
BigDecimal
[]
values
,
int
batchSize
)
{
this
.
time
=
timestamps
[
timestamps
.
length
-
1
];
valueCountInOnePage
+=
timestamps
.
length
;
if
(
minTimestamp
==
Long
.
MIN_VALUE
)
{
minTimestamp
=
timestamps
[
0
];
}
dataPageWriter
.
write
(
timestamps
,
values
);
dataPageWriter
.
write
(
timestamps
,
values
,
batchSize
);
pageStatistics
.
updateStats
(
values
);
checkPageSizeAndMayOpenANewPage
();
}
@Override
public
void
write
(
long
[]
timestamps
,
Binary
[]
values
)
{
public
void
write
(
long
[]
timestamps
,
Binary
[]
values
,
int
batchSize
)
{
this
.
time
=
timestamps
[
timestamps
.
length
-
1
];
valueCountInOnePage
+=
timestamps
.
length
;
if
(
minTimestamp
==
Long
.
MIN_VALUE
)
{
minTimestamp
=
timestamps
[
0
];
}
dataPageWriter
.
write
(
timestamps
,
values
);
dataPageWriter
.
write
(
timestamps
,
values
,
batchSize
);
pageStatistics
.
updateStats
(
values
);
checkPageSizeAndMayOpenANewPage
();
}
...
...
tsfile/src/main/java/org/apache/iotdb/tsfile/write/chunk/IChunkWriter.java
浏览文件 @
fc03f2d6
...
...
@@ -68,37 +68,37 @@ public interface IChunkWriter {
/**
* write time series
*/
void
write
(
long
[]
timestamps
,
int
[]
values
);
void
write
(
long
[]
timestamps
,
int
[]
values
,
int
batchSize
);
/**
* write time series
*/
void
write
(
long
[]
timestamps
,
long
[]
values
);
void
write
(
long
[]
timestamps
,
long
[]
values
,
int
batchSize
);
/**
* write time series
*/
void
write
(
long
[]
timestamps
,
boolean
[]
values
);
void
write
(
long
[]
timestamps
,
boolean
[]
values
,
int
batchSize
);
/**
* write time series
*/
void
write
(
long
[]
timestamps
,
float
[]
values
);
void
write
(
long
[]
timestamps
,
float
[]
values
,
int
batchSize
);
/**
* write time series
*/
void
write
(
long
[]
timestamps
,
double
[]
values
);
void
write
(
long
[]
timestamps
,
double
[]
values
,
int
batchSize
);
/**
* write time series
*/
void
write
(
long
[]
timestamps
,
BigDecimal
[]
values
);
void
write
(
long
[]
timestamps
,
BigDecimal
[]
values
,
int
batchSize
);
/**
* write time series
*/
void
write
(
long
[]
timestamps
,
Binary
[]
values
);
void
write
(
long
[]
timestamps
,
Binary
[]
values
,
int
batchSize
);
/**
* flush data to TsFileIOWriter.
...
...
tsfile/src/main/java/org/apache/iotdb/tsfile/write/page/PageWriter.java
浏览文件 @
fc03f2d6
...
...
@@ -124,8 +124,8 @@ public class PageWriter {
/**
* write time series into encoder
*/
public
void
write
(
long
[]
timestamps
,
boolean
[]
values
)
{
for
(
int
i
=
0
;
i
<
timestamps
.
length
;
i
++)
{
public
void
write
(
long
[]
timestamps
,
boolean
[]
values
,
int
batchSize
)
{
for
(
int
i
=
0
;
i
<
batchSize
;
i
++)
{
timeEncoder
.
encode
(
timestamps
[
i
],
timeOut
);
valueEncoder
.
encode
(
values
[
i
],
valueOut
);
}
...
...
@@ -134,8 +134,8 @@ public class PageWriter {
/**
* write time series into encoder
*/
public
void
write
(
long
[]
timestamps
,
int
[]
values
)
{
for
(
int
i
=
0
;
i
<
timestamps
.
length
;
i
++)
{
public
void
write
(
long
[]
timestamps
,
int
[]
values
,
int
batchSize
)
{
for
(
int
i
=
0
;
i
<
batchSize
;
i
++)
{
timeEncoder
.
encode
(
timestamps
[
i
],
timeOut
);
valueEncoder
.
encode
(
values
[
i
],
valueOut
);
}
...
...
@@ -144,8 +144,8 @@ public class PageWriter {
/**
* write time series into encoder
*/
public
void
write
(
long
[]
timestamps
,
long
[]
values
)
{
for
(
int
i
=
0
;
i
<
timestamps
.
length
;
i
++)
{
public
void
write
(
long
[]
timestamps
,
long
[]
values
,
int
batchSize
)
{
for
(
int
i
=
0
;
i
<
batchSize
;
i
++)
{
timeEncoder
.
encode
(
timestamps
[
i
],
timeOut
);
valueEncoder
.
encode
(
values
[
i
],
valueOut
);
}
...
...
@@ -154,8 +154,8 @@ public class PageWriter {
/**
* write time series into encoder
*/
public
void
write
(
long
[]
timestamps
,
float
[]
values
)
{
for
(
int
i
=
0
;
i
<
timestamps
.
length
;
i
++)
{
public
void
write
(
long
[]
timestamps
,
float
[]
values
,
int
batchSize
)
{
for
(
int
i
=
0
;
i
<
batchSize
;
i
++)
{
timeEncoder
.
encode
(
timestamps
[
i
],
timeOut
);
valueEncoder
.
encode
(
values
[
i
],
valueOut
);
}
...
...
@@ -164,8 +164,8 @@ public class PageWriter {
/**
* write time series into encoder
*/
public
void
write
(
long
[]
timestamps
,
double
[]
values
)
{
for
(
int
i
=
0
;
i
<
timestamps
.
length
;
i
++)
{
public
void
write
(
long
[]
timestamps
,
double
[]
values
,
int
batchSize
)
{
for
(
int
i
=
0
;
i
<
batchSize
;
i
++)
{
timeEncoder
.
encode
(
timestamps
[
i
],
timeOut
);
valueEncoder
.
encode
(
values
[
i
],
valueOut
);
}
...
...
@@ -174,8 +174,8 @@ public class PageWriter {
/**
* write time series into encoder
*/
public
void
write
(
long
[]
timestamps
,
BigDecimal
[]
values
)
{
for
(
int
i
=
0
;
i
<
timestamps
.
length
;
i
++)
{
public
void
write
(
long
[]
timestamps
,
BigDecimal
[]
values
,
int
batchSize
)
{
for
(
int
i
=
0
;
i
<
batchSize
;
i
++)
{
timeEncoder
.
encode
(
timestamps
[
i
],
timeOut
);
valueEncoder
.
encode
(
values
[
i
],
valueOut
);
}
...
...
@@ -184,8 +184,8 @@ public class PageWriter {
/**
* write time series into encoder
*/
public
void
write
(
long
[]
timestamps
,
Binary
[]
values
)
{
for
(
int
i
=
0
;
i
<
timestamps
.
length
;
i
++)
{
public
void
write
(
long
[]
timestamps
,
Binary
[]
values
,
int
batchSize
)
{
for
(
int
i
=
0
;
i
<
batchSize
;
i
++)
{
timeEncoder
.
encode
(
timestamps
[
i
],
timeOut
);
valueEncoder
.
encode
(
values
[
i
],
valueOut
);
}
...
...
tsfile/src/test/java/org/apache/iotdb/tsfile/write/TsFileReadWriteTest.java
浏览文件 @
fc03f2d6
...
...
@@ -155,7 +155,7 @@ public class TsFileReadWriteTest {
FileSchema
fileSchema
=
new
FileSchema
();
fileSchema
.
registerMeasurement
(
new
MeasurementSchema
(
"sensor_1"
,
TSDataType
.
INT64
,
TSEncoding
.
TS_2DIFF
));
int
rowNum
=
1024
*
1024
;
int
rowNum
=
1024
*
1024
*
13
+
1023
;
int
sensorNum
=
1
;
TsFileWriter
tsFileWriter
=
new
TsFileWriter
(
f
,
fileSchema
);
RowBatch
rowBatch
=
fileSchema
.
createRowBatch
(
"device_1"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录