use of com.hazelcast.nio.serialization.FieldKind in project hazelcast by hazelcast.
the class CompactInternalGenericRecord method getBoolean.
@Override
public boolean getBoolean(@Nonnull String fieldName) {
FieldDescriptor fd = getFieldDefinition(fieldName);
FieldKind fieldKind = fd.getKind();
switch(fieldKind) {
case BOOLEAN:
return getBoolean(fd);
case NULLABLE_BOOLEAN:
return getVariableSizeAsNonNull(fd, ObjectDataInput::readBoolean, "Boolean");
default:
throw unexpectedFieldKind(BOOLEAN, fieldName);
}
}
use of com.hazelcast.nio.serialization.FieldKind in project hazelcast by hazelcast.
the class CompactInternalGenericRecord method getInt32.
@Override
public int getInt32(@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 getVariableSizeAsNonNull(fd, ObjectDataInput::readInt, "Int32");
default:
throw unexpectedFieldKind(fieldKind, fieldName);
}
}
use of com.hazelcast.nio.serialization.FieldKind in project hazelcast by hazelcast.
the class CompactInternalGenericRecord method getInt8.
@Override
public byte getInt8(@Nonnull String fieldName) {
FieldDescriptor fd = getFieldDefinition(fieldName);
FieldKind fieldKind = fd.getKind();
switch(fieldKind) {
case INT8:
try {
return in.readByte(readFixedSizePosition(fd));
} catch (IOException e) {
throw illegalStateException(e);
}
case NULLABLE_INT8:
return getVariableSizeAsNonNull(fd, ObjectDataInput::readByte, "Int8");
default:
throw unexpectedFieldKind(fieldKind, fieldName);
}
}
use of com.hazelcast.nio.serialization.FieldKind in project hazelcast by hazelcast.
the class CompactInternalGenericRecord method getFixedSizeFieldFromArray.
private <T> T getFixedSizeFieldFromArray(@Nonnull String fieldName, FieldKind fieldKind, Reader<T> reader, int index) {
checkNotNegative(index, "Array indexes can not be negative");
int position = readVariableSizeFieldPosition(fieldName, fieldKind);
if (position == NULL_OFFSET) {
return null;
}
if (readLength(position) <= index) {
return null;
}
int currentPos = in.position();
try {
FieldKind singleKind = FieldOperations.getSingleKind(fieldKind);
int kindSize = FieldOperations.fieldOperations(singleKind).kindSizeInBytes();
in.position(INT_SIZE_IN_BYTES + position + index * kindSize);
return reader.read(in);
} catch (IOException e) {
throw illegalStateException(e);
} finally {
in.position(currentPos);
}
}
use of com.hazelcast.nio.serialization.FieldKind in project hazelcast by hazelcast.
the class Schema method readData.
@Override
public void readData(ObjectDataInput in) throws IOException {
typeName = in.readString();
int fieldDefinitionsSize = in.readInt();
fieldDefinitionMap = new TreeMap<>(Comparator.naturalOrder());
for (int i = 0; i < fieldDefinitionsSize; i++) {
String name = in.readString();
FieldKind kind = FieldKind.get(in.readInt());
FieldDescriptor descriptor = new FieldDescriptor(name, kind);
fieldDefinitionMap.put(name, descriptor);
}
init();
}
Aggregations