use of io.pravega.segmentstore.storage.metadata.BaseMetadataStore.TransactionData in project pravega by pravega.
the class SltsMetadataSerializer method serialize.
@Override
public ByteBuffer serialize(String value) {
ByteBuffer buf;
try {
// Convert string to map with fields and values.
Map<String, String> data = parseStringData(value);
// Use the map to build TransactionData. If the field/key queried does not exist we throw an IllegalArgumentException.
// The value is handled by checking if a unique field corresponding to any specific implementation of StorageMetadata exists.
// The correct instance of StorageMetadata is then generated.
TransactionData transactionData = TransactionData.builder().key(getAndRemoveIfExists(data, TRANSACTION_DATA_KEY)).version(Long.parseLong(getAndRemoveIfExists(data, TRANSACTION_DATA_VERSION))).value(generateStorageMetadataValue(data)).build();
buf = SERIALIZER.serialize(transactionData).asByteBuffer();
} catch (IOException e) {
throw new RuntimeException(e);
}
return buf;
}
use of io.pravega.segmentstore.storage.metadata.BaseMetadataStore.TransactionData in project pravega by pravega.
the class SltsMetadataSerializer method deserialize.
@Override
public String deserialize(ByteBuffer serializedValue) {
StringBuilder stringValueBuilder;
try {
TransactionData data = SERIALIZER.deserialize(new ByteArraySegment(serializedValue).getReader());
stringValueBuilder = new StringBuilder();
appendField(stringValueBuilder, TRANSACTION_DATA_KEY, data.getKey());
appendField(stringValueBuilder, TRANSACTION_DATA_VERSION, String.valueOf(data.getVersion()));
handleStorageMetadataValue(stringValueBuilder, data.getValue());
} catch (IOException e) {
throw new RuntimeException(e);
}
return stringValueBuilder.toString();
}
Aggregations