Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public static MapWritable getCurrentValue(List<String> deviceIdList, int current
public static void readFieldsValue(MapWritable mapWritable, List<Field> fields, List<String> measurementIds) throws InterruptedException {
int index = 0;
for (Field field : fields) {
if (field.isNull()) {
if (field.getDataType() == null) {
logger.info("Current value is null");
mapWritable.put(new Text(measurementIds.get(index)), NullWritable.get());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ private String getValueByName(String columnName) throws SQLException {
for (Field field : record.getFields()) {
i++;
if (i == tmp - 1) {
return field.isNull() ? null : field.getStringValue();
return field.getDataType() == null ? null : field.getStringValue();
}
}
return null;
Expand Down
1 change: 0 additions & 1 deletion jdbc/src/main/java/org/apache/iotdb/jdbc/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ static List<RowRecord> convertRowRecords(TSQueryDataSet tsQueryDataSet,
boolean is_empty = BytesUtils.byteToBool(byteBuffer.get());
if (is_empty) {
field = new Field(null);
field.setNull();
} else {
TSDataType dataType = TSDataType.valueOf(type);
field = new Field(dataType);
Expand Down
12 changes: 6 additions & 6 deletions jdbc/src/test/java/org/apache/iotdb/jdbc/UtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,37 +201,37 @@ public void testConvertRowRecords() throws IOException {
for (Field f : fields) {
if (j == 0) {
if (input[index][3 * j + 3] == null) {
assertTrue(f.isNull());
assertTrue(f.getDataType() == null);
} else {
assertEquals(input[index][3 * j + 3], f.getBoolV());
}
} else if (j == 1) {
if (input[index][3 * j + 3] == null) {
assertTrue(f.isNull());
assertTrue(f.getDataType() == null);
} else {
assertEquals(input[index][3 * j + 3], f.getIntV());
}
} else if (j == 2) {
if (input[index][3 * j + 3] == null) {
assertTrue(f.isNull());
assertTrue(f.getDataType() == null);
} else {
assertEquals(input[index][3 * j + 3], f.getLongV());
}
} else if (j == 3) {
if (input[index][3 * j + 3] == null) {
assertTrue(f.isNull());
assertTrue(f.getDataType() == null);
} else {
assertEquals(input[index][3 * j + 3], f.getFloatV());
}
} else if (j == 4) {
if (input[index][3 * j + 3] == null) {
assertTrue(f.isNull());
assertTrue(f.getDataType() == null);
} else {
assertEquals(input[index][3 * j + 3], f.getDoubleV());
}
} else {
if (input[index][3 * j + 3] == null) {
assertTrue(f.isNull());
assertTrue(f.getDataType() == null);
} else {
assertEquals(input[index][3 * j + 3], f.getStringValue());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ private QueryDataSet processShowTTLQuery(ShowTTLPlan showTTLPlan) {
ttl.setLongV(mNode.getDataTTL());
} else {
ttl = new Field(null);
ttl.setNull();
}
rowRecord.addField(sg);
rowRecord.addField(ttl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ static List<RowRecord> convertRowRecords(TSQueryDataSet tsQueryDataSet,
boolean is_empty = BytesUtils.byteToBool(byteBuffer.get());
if (is_empty) {
field = new Field(null);
field.setNull();
} else {
TSDataType dataType = TSDataType.valueOf(type);
field = new Field(dataType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ abstract class Converter {
def toSqlValue(field: Field): Any = {
if (field == null)
return null
if (field.isNull)
if (field.getDataType == null)
null
else field.getDataType match {
case TSDataType.BOOLEAN => field.getBoolV
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public class Field {
private float floatV;
private double doubleV;
private Binary binaryV;
private boolean isNull;

public Field(TSDataType dataType) {
this.dataType = dataType;
Expand Down Expand Up @@ -99,7 +98,7 @@ public void setBinaryV(Binary binaryV) {
* @return value string
*/
public String getStringValue() {
if (isNull || dataType == null) {
if (dataType == null) {
return "null";
}
switch (dataType) {
Expand All @@ -125,16 +124,8 @@ public String toString() {
return getStringValue();
}

public void setNull() {
this.isNull = true;
}

public boolean isNull() {
return this.isNull;
}

public Object getObjectValue(TSDataType dataType) {
if (isNull) {
if (this.dataType == null) {
return null;
}
switch (dataType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ public RowRecord next() throws IOException {
Field field = new Field(dataTypes.get(i));

if (!hasDataRemaining.get(i)) {
field.setNull();
record.addField(field);
record.addField(new Field(null));
continue;
}

Expand All @@ -133,14 +132,11 @@ public RowRecord next() throws IOException {
} else {
timeHeapPut(data.currentTime());
}

record.addField(field);
} else {
field.setNull();
record.addField(new Field(null));
}

record.addField(field);
}

return record;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,11 @@ public void setDataTypes(List<TSDataType> dataTypes) {
}

protected Field getField(Object value, TSDataType dataType) {
Field field = new Field(dataType);

if (value == null) {
field.setNull();
return field;
return new Field(null);
}

Field field = new Field(dataType);
switch (dataType) {
case DOUBLE:
field.setDoubleV((double) value);
Expand Down