int fieldCount = input.readUnsignedShort();
Value[] values = new Value[fieldCount];
for (int i = 0; i < fieldCount; i++) {
int valueLength = input.readInt();
PgField field = fields[i];
Value value;
if (valueLength < 0) {
value = new DefaultValue(field, null);
} else {
String strVal;
switch (field.getColumnType()) {
case INTEGER:
switch (field.getFormatCode()) {
case BINARY:
value = new DefaultValue(field, input.readInt());
break;
case TEXT:
strVal = input.readString(valueLength, charset);
value = new DefaultValue(field, Integer.valueOf(strVal));
break;
default:
throw new IllegalStateException("Unable to decode format of " + field.getFormatCode());
}
break;
case BIGINT:
switch (field.getFormatCode()) {
case BINARY:
value = new DefaultValue(field, (long)input.readInt() << 32 | input.readInt());
break;
case TEXT:
strVal = input.readString(valueLength, charset);
value = new DefaultValue(field, Long.valueOf(strVal));
break;
default:
throw new IllegalStateException("Unable to decode format of " + field.getFormatCode());
}
break;
case VARCHAR:
strVal = input.readString(valueLength, charset);
value = new DefaultValue(field, strVal);
break;
default:
// Advance buffer
input.skip(valueLength);
// TODO Handle remaining ADBCJ types
throw new IllegalStateException("Unable to decode column of type " + field.getColumnType());
}
}
values[i] = value;
}
return new DataRowMessage(values);