use of org.locationtech.geowave.core.store.data.field.FieldReader in project geowave by locationtech.
the class DataStoreProperty method fromBinary.
@SuppressWarnings("unchecked")
@Override
public void fromBinary(final byte[] bytes) {
final ByteBuffer buffer = ByteBuffer.wrap(bytes);
final byte[] keyBytes = new byte[VarintUtils.readUnsignedInt(buffer)];
buffer.get(keyBytes);
final byte[] classBytes = new byte[VarintUtils.readUnsignedInt(buffer)];
buffer.get(classBytes);
final byte[] valueBytes = new byte[VarintUtils.readUnsignedInt(buffer)];
buffer.get(valueBytes);
key = StringUtils.stringFromBinary(keyBytes);
final String className = StringUtils.stringFromBinary(classBytes);
try {
final Class<?> valueClass = Class.forName(className);
if (Persistable.class.isAssignableFrom(valueClass)) {
value = PersistenceUtils.fromBinary(valueBytes);
} else {
final FieldReader<Object> reader = (FieldReader<Object>) FieldUtils.getDefaultReaderForClass(valueClass);
value = reader.readField(valueBytes);
}
} catch (final ClassNotFoundException e) {
throw new RuntimeException("Unable to find class for property: " + className);
}
}
use of org.locationtech.geowave.core.store.data.field.FieldReader in project geowave by locationtech.
the class Literal method fromBinary.
@SuppressWarnings("unchecked")
@Override
public void fromBinary(final byte[] bytes) {
final ByteBuffer buffer = ByteBuffer.wrap(bytes);
final byte nullByte = buffer.get();
if (nullByte == 0) {
literal = null;
return;
}
final byte[] classBytes = new byte[VarintUtils.readUnsignedInt(buffer)];
buffer.get(classBytes);
final byte[] valueBytes = new byte[VarintUtils.readUnsignedInt(buffer)];
buffer.get(valueBytes);
final String className = StringUtils.stringFromBinary(classBytes);
try {
final Class<?> valueClass = Class.forName(className);
final FieldReader<Object> reader = (FieldReader<Object>) FieldUtils.getDefaultReaderForClass(valueClass);
literal = (V) reader.readField(valueBytes);
} catch (final ClassNotFoundException e) {
throw new RuntimeException("Unable to find class for literal: " + className);
}
}
Aggregations