• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

apache / iotdb / #9614

pending completion
#9614

push

travis_ci

web-flow
Fix default label when no tag (#10568)

78964 of 164811 relevant lines covered (47.91%)

0.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.78
/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/row/PipeRowCollector.java
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one
3
 * or more contributor license agreements.  See the NOTICE file
4
 * distributed with this work for additional information
5
 * regarding copyright ownership.  The ASF licenses this file
6
 * to you under the Apache License, Version 2.0 (the
7
 * "License"); you may not use this file except in compliance
8
 * with the License.  You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing,
13
 * software distributed under the License is distributed on an
14
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
 * KIND, either express or implied.  See the License for the
16
 * specific language governing permissions and limitations
17
 * under the License.
18
 */
19

20
package org.apache.iotdb.db.pipe.event.common.row;
21

22
import org.apache.iotdb.commons.pipe.config.PipeConfig;
23
import org.apache.iotdb.db.pipe.event.common.tablet.PipeRawTabletInsertionEvent;
24
import org.apache.iotdb.pipe.api.access.Row;
25
import org.apache.iotdb.pipe.api.collector.RowCollector;
26
import org.apache.iotdb.pipe.api.event.dml.insertion.TabletInsertionEvent;
27
import org.apache.iotdb.pipe.api.exception.PipeException;
28
import org.apache.iotdb.tsfile.write.record.Tablet;
29
import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
30

31
import java.util.ArrayList;
32
import java.util.Arrays;
33
import java.util.List;
34

35
public class PipeRowCollector implements RowCollector {
1✔
36

37
  private final List<TabletInsertionEvent> tabletInsertionEventList = new ArrayList<>();
1✔
38
  private Tablet tablet = null;
1✔
39
  private boolean isAligned = false;
1✔
40

41
  @Override
42
  public void collectRow(Row row) {
43
    if (!(row instanceof PipeRow)) {
1✔
44
      throw new PipeException("Row can not be customized");
×
45
    }
46

47
    final PipeRow pipeRow = (PipeRow) row;
1✔
48
    final MeasurementSchema[] measurementSchemaArray = pipeRow.getMeasurementSchemaList();
1✔
49

50
    if (tablet == null) {
1✔
51
      final String deviceId = pipeRow.getDeviceId();
1✔
52
      final List<MeasurementSchema> measurementSchemaList =
1✔
53
          new ArrayList<>(Arrays.asList(measurementSchemaArray));
1✔
54
      tablet =
1✔
55
          new Tablet(
56
              deviceId,
57
              measurementSchemaList,
58
              PipeConfig.getInstance().getPipeDataStructureTabletRowSize());
1✔
59
      isAligned = pipeRow.isAligned();
1✔
60
      tablet.initBitMaps();
1✔
61
    }
62

63
    final int rowIndex = tablet.rowSize;
1✔
64
    tablet.addTimestamp(rowIndex, row.getTime());
1✔
65
    for (int i = 0; i < row.size(); i++) {
1✔
66
      final Object value = row.getObject(i);
1✔
67
      if (value instanceof org.apache.iotdb.pipe.api.type.Binary) {
1✔
68
        tablet.addValue(
×
69
            measurementSchemaArray[i].getMeasurementId(),
×
70
            rowIndex,
71
            PipeBinaryTransformer.transformToBinary((org.apache.iotdb.pipe.api.type.Binary) value));
×
72
      } else {
73
        tablet.addValue(measurementSchemaArray[i].getMeasurementId(), rowIndex, value);
1✔
74
      }
75
      if (row.isNull(i)) {
1✔
76
        tablet.bitMaps[i].mark(rowIndex);
×
77
      }
78
    }
79
    tablet.rowSize++;
1✔
80

81
    if (tablet.rowSize == tablet.getMaxRowNumber()) {
1✔
82
      collectTabletInsertionEvent();
×
83
    }
84
  }
1✔
85

86
  private void collectTabletInsertionEvent() {
87
    if (tablet != null) {
1✔
88
      tabletInsertionEventList.add(new PipeRawTabletInsertionEvent(tablet, isAligned));
1✔
89
    }
90
    this.tablet = null;
1✔
91
  }
1✔
92

93
  public Iterable<TabletInsertionEvent> convertToTabletInsertionEvents() {
94
    collectTabletInsertionEvent();
1✔
95
    return tabletInsertionEventList;
1✔
96
  }
97
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc