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

apache / iotdb / #10019

07 Sep 2023 04:50AM UTC coverage: 47.489% (-0.2%) from 47.655%
#10019

push

travis_ci

web-flow
Pipe: Fix ConcurrentModificationException caused by concurrently iterating through CachedSchemaPatternMatcher.extractors when an PipeHeartbeatEvent is being assigned (#11074)

* try to fix ConcurrentModificationException when assigning PipeHeartbeatEvent

* Update CachedSchemaPatternMatcher.java

---------

Co-authored-by: 马子坤 <55695098+DanielWang2035@users.noreply.github.com>

1 of 1 new or added line in 1 file covered. (100.0%)

80551 of 169622 relevant lines covered (47.49%)

0.47 hits per line

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

80.85
/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/TSDataType.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.tsfile.file.metadata.enums;
21

22
import org.apache.iotdb.tsfile.exception.write.UnSupportedDataTypeException;
23

24
import java.io.DataOutputStream;
25
import java.io.FileOutputStream;
26
import java.io.IOException;
27
import java.io.InputStream;
28
import java.nio.ByteBuffer;
29

30
public enum TSDataType {
1✔
31
  /** BOOLEAN. */
32
  BOOLEAN((byte) 0),
1✔
33

34
  /** INT32. */
35
  INT32((byte) 1),
1✔
36

37
  /** INT64. */
38
  INT64((byte) 2),
1✔
39

40
  /** FLOAT. */
41
  FLOAT((byte) 3),
1✔
42

43
  /** DOUBLE. */
44
  DOUBLE((byte) 4),
1✔
45

46
  /** TEXT. */
47
  TEXT((byte) 5),
1✔
48

49
  /** VECTOR. */
50
  VECTOR((byte) 6),
1✔
51

52
  /** UNKNOWN. */
53
  UNKNOWN((byte) 7);
1✔
54

55
  private final byte type;
56

57
  TSDataType(byte type) {
1✔
58
    this.type = type;
1✔
59
  }
1✔
60

61
  /**
62
   * give an integer to return a data type.
63
   *
64
   * @param type -param to judge enum type
65
   * @return -enum type
66
   */
67
  public static TSDataType deserialize(byte type) {
68
    return getTsDataType(type);
1✔
69
  }
70

71
  public byte getType() {
72
    return type;
1✔
73
  }
74

75
  public static TSDataType getTsDataType(byte type) {
76
    switch (type) {
1✔
77
      case 0:
78
        return TSDataType.BOOLEAN;
1✔
79
      case 1:
80
        return TSDataType.INT32;
1✔
81
      case 2:
82
        return TSDataType.INT64;
1✔
83
      case 3:
84
        return TSDataType.FLOAT;
1✔
85
      case 4:
86
        return TSDataType.DOUBLE;
1✔
87
      case 5:
88
        return TSDataType.TEXT;
1✔
89
      case 6:
90
        return TSDataType.VECTOR;
1✔
91
      case 7:
92
        return TSDataType.UNKNOWN;
×
93
      default:
94
        throw new IllegalArgumentException("Invalid input: " + type);
1✔
95
    }
96
  }
97

98
  public static TSDataType deserializeFrom(ByteBuffer buffer) {
99
    return deserialize(buffer.get());
1✔
100
  }
101

102
  public static TSDataType deserializeFrom(InputStream stream) throws IOException {
103
    return deserialize((byte) stream.read());
×
104
  }
105

106
  public static int getSerializedSize() {
107
    return Byte.BYTES;
1✔
108
  }
109

110
  public void serializeTo(ByteBuffer byteBuffer) {
111
    byteBuffer.put(serialize());
1✔
112
  }
1✔
113

114
  public void serializeTo(DataOutputStream outputStream) throws IOException {
115
    outputStream.write(serialize());
1✔
116
  }
1✔
117

118
  public void serializeTo(FileOutputStream outputStream) throws IOException {
119
    outputStream.write(serialize());
×
120
  }
×
121

122
  public int getDataTypeSize() {
123
    switch (this) {
1✔
124
      case BOOLEAN:
125
        return 1;
1✔
126
      case INT32:
127
      case FLOAT:
128
        return 4;
1✔
129
        // For text: return the size of reference here
130
      case TEXT:
131
      case INT64:
132
      case DOUBLE:
133
      case VECTOR:
134
        return 8;
1✔
135
      default:
136
        throw new UnSupportedDataTypeException(this.toString());
×
137
    }
138
  }
139

140
  /**
141
   * get type byte.
142
   *
143
   * @return byte number
144
   */
145
  public byte serialize() {
146
    return type;
1✔
147
  }
148

149
  /**
150
   * numeric datatype judgement.
151
   *
152
   * @return whether it is a numeric datatype
153
   * @throws UnSupportedDataTypeException when meets unSupported DataType
154
   */
155
  public boolean isNumeric() {
156
    switch (this) {
1✔
157
      case INT32:
158
      case INT64:
159
      case FLOAT:
160
      case DOUBLE:
161
        return true;
1✔
162
        // For text: return the size of reference here
163
      case BOOLEAN:
164
      case TEXT:
165
      case VECTOR:
166
        return false;
×
167
      default:
168
        throw new UnSupportedDataTypeException(this.toString());
×
169
    }
170
  }
171

172
  /**
173
   * comparable datatype judgement.
174
   *
175
   * @return whether it is a comparable datatype
176
   * @throws UnSupportedDataTypeException when meets unSupported DataType
177
   */
178
  public boolean isComparable() {
179
    switch (this) {
1✔
180
      case INT32:
181
      case INT64:
182
      case FLOAT:
183
      case DOUBLE:
184
      case TEXT:
185
      case BOOLEAN:
186
        return true;
1✔
187
      case VECTOR:
188
        return false;
×
189
      default:
190
        throw new UnSupportedDataTypeException(this.toString());
×
191
    }
192
  }
193
}
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

© 2026 Coveralls, Inc