yanze chen created IOTDB-1853:
---------------------------------
Summary: More than one TimeseriesMetadata in TsFile
Key: IOTDB-1853
URL: https://issues.apache.org/jira/browse/IOTDB-1853
Project: Apache IoTDB
Issue Type: Bug
Components: Core/TsFile
Reporter: yanze chen
Assignee: yanze chen
Fix For: master branch
There are more than one TimeseriesMetadata in TsFile.
client code:
{code:java}
public class Main{
private static final String ROOT_SG1_D1_VECTOR1 = "root.sg_2.d1.vector";
private Session session;
private static int rowNum = 1000000;
private static int colNum = 1000;
private static int startTest = 1;
@Before
public void setUp() throws Exception {
session = new Session("192.168.130.37", 6667, "root", "root");
session.open();
}
@After
public void tearDown() throws Exception {
session.close();
}
@Test
public void testResult() throws StatementExecutionException,
IoTDBConnectionException {
SessionDataSet dataSet = session.executeQueryStatement("select s0001 from
root.sg_2.d1.vector");
HashSet<Long> set = new HashSet<>();
System.out.println("multiple points:");
while (dataSet.hasNext()) {
long v = dataSet.next().getFields().get(0).getLongV();
if (set.contains(v)) {
System.out.println(v);
} else {
set.add(v);
}
}
dataSet.closeOperationHandle();
}
@Test
public void createTimeSeries() throws StatementExecutionException,
IoTDBConnectionException {
System.out.println("insert" + colNum);
insertTabletWithAlignedTimeseriesMethod(rowNum, colNum);
session.executeNonQueryStatement("flush");
}
/** Method 1 for insert tablet with aligned timeseries */
private void insertTabletWithAlignedTimeseriesMethod(int rowNum, int
columnNum)
throws IoTDBConnectionException, StatementExecutionException {
// The schema of measurements of one device
// only measurementId and data type in MeasurementSchema take effects in
Tablet
List<IMeasurementSchema> schemaList = new ArrayList<>();
String[] measurements = new String[columnNum];
TSDataType[] dataTypes = new TSDataType[columnNum];
for (int i = 0; i < columnNum; i++) {
measurements[i] = "s" + getIndexString(i + 1, columnNum);
dataTypes[i] = TSDataType.INT64;
}
schemaList.add(new VectorMeasurementSchema("vector", measurements,
dataTypes));
Tablet tablet = new Tablet(ROOT_SG1_D1_VECTOR1, schemaList);
tablet.setAligned(true);
long timestamp = 0;
for (long row = 0; row < rowNum; row++) {
int rowIndex = tablet.rowSize++;
tablet.addTimestamp(rowIndex, timestamp);
for (int i = 0; i < columnNum; i++) {
tablet.addValue(schemaList.get(0).getSubMeasurementsList().get(i),
rowIndex, row * 10L + i);
}
if (tablet.rowSize == tablet.getMaxRowNumber()) {
session.insertTablet(tablet, true);
tablet.reset();
}
timestamp++;
}
if (tablet.rowSize != 0) {
session.insertTablet(tablet);
tablet.reset();
}
}
private String getIndexString(int index, int total) {
StringBuilder sb = new StringBuilder(String.valueOf(index));
String totalStr = String.valueOf(total);
while (sb.length() < totalStr.length()) {
sb.insert(0, "0");
}
return sb.toString();
}
}
{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)