RowIterable and RowScanner now support additional data types

This commit is contained in:
David Noble
2019-09-23 22:45:15 -07:00
parent 6783b569f8
commit fee303551e
2 changed files with 100 additions and 34 deletions

View File

@@ -155,10 +155,18 @@ public class RowIterable implements AutoCloseable, Iterable<DataItem> {
switch (type.layoutCode()) {
case NULL: {
result = this.reader.readNull(this.value);
break;
}
case BOOLEAN: {
result = this.reader.readBoolean(this.value);
break;
}
case INT_8: {
result = this.reader.readInt8(this.value);
break;
}
case INT_16: {
result = this.reader.readInt16(this.value);
break;
@@ -171,10 +179,18 @@ public class RowIterable implements AutoCloseable, Iterable<DataItem> {
result = this.reader.readInt64(this.value);
break;
}
case VAR_INT: {
result = this.reader.readVarInt(this.value);
break;
}
case UINT_8: {
result = this.reader.readUInt8(this.value);
break;
}
case UINT_16: {
result = this.reader.readUInt16(this.value);
break;
}
case UINT_32: {
result = this.reader.readUInt32(this.value);
break;
@@ -183,28 +199,44 @@ public class RowIterable implements AutoCloseable, Iterable<DataItem> {
result = this.reader.readUInt64(this.value);
break;
}
case BINARY: {
result = this.reader.readBinary(this.value);
case VAR_UINT: {
result = this.reader.readVarUInt(this.value);
break;
}
case FLOAT_32: {
result = this.reader.readFloat32(this.value);
break;
}
case FLOAT_64: {
result = this.reader.readFloat64(this.value);
break;
}
case FLOAT_128: {
result = this.reader.readFloat128(this.value);
break;
}
case DECIMAL: {
result = this.reader.readDecimal(this.value);
break;
}
case GUID: {
result = this.reader.readGuid(this.value);
break;
}
case NULL:
case BOOLEAN_FALSE:
case INT_8:
case UINT_16:
case VAR_INT:
case VAR_UINT:
case FLOAT_32:
case FLOAT_64:
case FLOAT_128:
case DECIMAL:
case DATE_TIME:
case UNIX_DATE_TIME:
case DATE_TIME: {
result = this.reader.readDateTime(this.value);
break;
}
case UNIX_DATE_TIME: {
result = this.reader.readUnixDateTime(this.value);
break;
}
case BINARY: {
result = this.reader.readBinary(this.value);
break;
}
case UTF_8: {
result = Result.SUCCESS;
result = this.reader.readUtf8String(this.value);
break;
}
case NULLABLE_SCOPE:
@@ -262,6 +294,7 @@ public class RowIterable implements AutoCloseable, Iterable<DataItem> {
case MONGODB_OBJECT_ID: {
throw new IllegalStateException(lenientFormat("unsupported layout type: %s", type));
}
case BOOLEAN_FALSE:
case END_SCOPE:
case INVALID: {
throw new IllegalStateException(lenientFormat("unexpected layout type: %s", type));

View File

@@ -104,10 +104,18 @@ public class RowScanner implements AutoCloseable {
switch (type.layoutCode()) {
case NULL: {
result = reader.readNull(value);
break;
}
case BOOLEAN: {
result = reader.readBoolean(value);
break;
}
case INT_8: {
result = reader.readInt8(value);
break;
}
case INT_16: {
result = reader.readInt16(value);
break;
@@ -120,10 +128,18 @@ public class RowScanner implements AutoCloseable {
result = reader.readInt64(value);
break;
}
case VAR_INT: {
result = reader.readVarInt(value);
break;
}
case UINT_8: {
result = reader.readUInt8(value);
break;
}
case UINT_16: {
result = reader.readUInt16(value);
break;
}
case UINT_32: {
result = reader.readUInt32(value);
break;
@@ -132,28 +148,44 @@ public class RowScanner implements AutoCloseable {
result = reader.readUInt64(value);
break;
}
case BINARY: {
result = reader.readBinary(value);
case VAR_UINT: {
result = reader.readVarUInt(value);
break;
}
case FLOAT_32: {
result = reader.readFloat32(value);
break;
}
case FLOAT_64: {
result = reader.readFloat64(value);
break;
}
case FLOAT_128: {
result = reader.readFloat128(value);
break;
}
case DECIMAL: {
result = reader.readDecimal(value);
break;
}
case GUID: {
result = reader.readGuid(value);
break;
}
case NULL:
case BOOLEAN_FALSE:
case INT_8:
case UINT_16:
case VAR_INT:
case VAR_UINT:
case FLOAT_32:
case FLOAT_64:
case FLOAT_128:
case DECIMAL:
case DATE_TIME:
case UNIX_DATE_TIME:
case DATE_TIME: {
result = reader.readDateTime(value);
break;
}
case UNIX_DATE_TIME: {
result = reader.readUnixDateTime(value);
break;
}
case BINARY: {
result = reader.readBinary(value);
break;
}
case UTF_8: {
result = Result.SUCCESS;
result = reader.readUtf8String(value);
break;
}
case NULLABLE_SCOPE:
@@ -212,13 +244,14 @@ public class RowScanner implements AutoCloseable {
continue;
}
case END_SCOPE: {
throw new IllegalStateException(lenientFormat("unexpected layout type: %s", type));
}
case INVALID:
case MONGODB_OBJECT_ID: {
throw new IllegalStateException(lenientFormat("unsupported layout type: %s", type));
}
case BOOLEAN_FALSE:
case END_SCOPE:
case INVALID: {
throw new IllegalStateException(lenientFormat("unexpected layout type: %s", type));
}
default: {
throw new IllegalStateException(lenientFormat("unknown layout type: %s", type));
}