use of com.hazelcast.nio.serialization.FieldKind in project hazelcast by hazelcast.
the class CompactStreamSerializer method writeGenericRecord.
void writeGenericRecord(BufferObjectDataOutput output, CompactGenericRecord record, boolean includeSchemaOnBinary) throws IOException {
Schema schema = record.getSchema();
putToSchemaService(includeSchemaOnBinary, schema);
writeSchema(output, includeSchemaOnBinary, schema);
DefaultCompactWriter writer = new DefaultCompactWriter(this, output, schema, includeSchemaOnBinary);
Collection<FieldDescriptor> fields = schema.getFields();
for (FieldDescriptor fieldDescriptor : fields) {
String fieldName = fieldDescriptor.getFieldName();
FieldKind fieldKind = fieldDescriptor.getKind();
fieldOperations(fieldKind).writeFieldFromRecordToWriter(writer, record, fieldName);
}
writer.end();
}
use of com.hazelcast.nio.serialization.FieldKind in project hazelcast by hazelcast.
the class CompactInternalGenericRecord method getNullableInt64.
@Nullable
@Override
public Long getNullableInt64(@Nonnull String fieldName) {
FieldDescriptor fd = getFieldDefinition(fieldName);
FieldKind fieldKind = fd.getKind();
switch(fieldKind) {
case INT64:
try {
return in.readLong(readFixedSizePosition(fd));
} catch (IOException e) {
throw illegalStateException(e);
}
case NULLABLE_INT64:
return getVariableSize(fd, ObjectDataInput::readLong);
default:
throw unexpectedFieldKind(fieldKind, fieldName);
}
}
use of com.hazelcast.nio.serialization.FieldKind in project hazelcast by hazelcast.
the class CompactInternalGenericRecord method getFloat32.
@Override
public float getFloat32(@Nonnull String fieldName) {
FieldDescriptor fd = getFieldDefinition(fieldName);
FieldKind fieldKind = fd.getKind();
switch(fieldKind) {
case FLOAT32:
try {
return in.readFloat(readFixedSizePosition(fd));
} catch (IOException e) {
throw illegalStateException(e);
}
case NULLABLE_FLOAT32:
return getVariableSizeAsNonNull(fd, ObjectDataInput::readFloat, "Float32");
default:
throw unexpectedFieldKind(fieldKind, fieldName);
}
}
use of com.hazelcast.nio.serialization.FieldKind in project hazelcast by hazelcast.
the class CompactInternalGenericRecord method getNullableInt32.
@Nullable
@Override
public Integer getNullableInt32(@Nonnull String fieldName) {
FieldDescriptor fd = getFieldDefinition(fieldName);
FieldKind fieldKind = fd.getKind();
switch(fieldKind) {
case INT32:
try {
return in.readInt(readFixedSizePosition(fd));
} catch (IOException e) {
throw illegalStateException(e);
}
case NULLABLE_INT32:
return getVariableSize(fd, ObjectDataInput::readInt);
default:
throw unexpectedFieldKind(fieldKind, fieldName);
}
}
use of com.hazelcast.nio.serialization.FieldKind in project hazelcast by hazelcast.
the class CompactInternalGenericRecord method getArrayOfPrimitive.
private <T> T getArrayOfPrimitive(@Nonnull String fieldName, Reader<T> reader, FieldKind primitiveKind, FieldKind nullableKind, String methodSuffix) {
FieldDescriptor fd = getFieldDefinition(fieldName);
FieldKind fieldKind = fd.getKind();
if (fieldKind == primitiveKind) {
return getVariableSize(fd, reader);
} else if (fieldKind == nullableKind) {
return getNullableArrayAsPrimitiveArray(fd, reader, methodSuffix);
}
throw unexpectedFieldKind(fieldKind, fieldName);
}
Aggregations