Commit 51e7ce6f authored by Jørgen Lind's avatar Jørgen Lind
Browse files

Rename VDSHandle to VDS

parent 216b6c78
......@@ -35,6 +35,7 @@ set (PRIVATE_HEADER_FILES
IO/IOManager.h
IO/IOManagerAWS.h
IO/IOManagerAzure.h
VDS/VDS.h
VDS/VolumeDataPartition.h
VDS/VolumeDataChannelMapping.h
VDS/VolumeDataLayer.h
......
......@@ -17,7 +17,7 @@
#include "OpenVDS/OpenVDS.h"
#include <OpenVDSHandle.h>
#include <VDS/VDS.h>
#include <VDS/ParseVDSJson.h>
......@@ -35,9 +35,9 @@
namespace OpenVDS
{
VDSHandle* Open(IOManager *ioManager, Error& error)
VDS* Open(IOManager *ioManager, Error& error)
{
std::unique_ptr<VDSHandle> ret(new VDSHandle(ioManager));
std::unique_ptr<VDS> ret(new VDS(ioManager));
error = Error();
if (!DownloadAndParseVolumeDataLayoutAndLayerStatus(*ret.get(), error))
......@@ -49,7 +49,7 @@ VDSHandle* Open(IOManager *ioManager, Error& error)
return ret.release();
}
VDSHandle *Open(const OpenOptions &options, Error &error)
VDS *Open(const OpenOptions &options, Error &error)
{
error = Error();
IOManager* ioManager = IOManager::CreateIOManager(options, error);
......@@ -59,26 +59,26 @@ VDSHandle *Open(const OpenOptions &options, Error &error)
return Open(ioManager, error);
}
VolumeDataLayout *GetLayout(VDSHandle *handle)
VolumeDataLayout *GetLayout(VDS *vds)
{
if (!handle)
if (!vds)
return nullptr;
return handle->VolumeDataLayout.get();
return vds->VolumeDataLayout.get();
}
VolumeDataAccessManager *GetDataAccessManager(VDSHandle *handle)
VolumeDataAccessManager *GetDataAccessManager(VDS *vds)
{
if (!handle)
if (!vds)
return nullptr;
return handle->DataAccessManager.get();
return vds->DataAccessManager.get();
}
const char *AddDescriptorString(std::string const &descriptorString, VDSHandle &handle)
const char *AddDescriptorString(std::string const &descriptorString, VDS &vds)
{
char *data = new char[descriptorString.size() + 1];
memcpy(data, descriptorString.data(), descriptorString.size());
data[descriptorString.size()] = 0;
handle.DescriptorStrings.emplace_back(data);
vds.DescriptorStrings.emplace_back(data);
return data;
}
......@@ -119,33 +119,32 @@ MetadataManager *FindMetadataManager(LayerMetadataContainer const &layerMetadata
return (it != layerMetadataContainer.managers.end()) ? it->second.get() : nullptr;
}
MetadataManager *CreateMetadataManager(VDSHandle &handle, std::string const &layerName, MetadataStatus const &metadataStatus)
MetadataManager *CreateMetadataManager(VDS &vds, std::string const &layerName, MetadataStatus const &metadataStatus)
{
std::unique_lock<std::mutex> metadataManagersMutexLock(handle.LayerMetadataContainer.mutex);
std::unique_lock<std::mutex> metadataManagersMutexLock(vds.LayerMetadataContainer.mutex);
assert(handle.LayerMetadataContainer.managers.find(layerName) == handle.LayerMetadataContainer.managers.end());
int pageLimit = handle.AxisDescriptors.size() <= 3 ? 64 : 1024;
return handle.LayerMetadataContainer.managers.insert(std::make_pair(layerName, std::unique_ptr<MetadataManager>(new MetadataManager(handle.IoManager.get(), layerName, metadataStatus, pageLimit)))).first->second.get();
assert(vds.LayerMetadataContainer.managers.find(layerName) == vds.LayerMetadataContainer.managers.end());
int pageLimit = vds.AxisDescriptors.size() <= 3 ? 64 : 1024;
return vds.LayerMetadataContainer.managers.insert(std::make_pair(layerName, std::unique_ptr<MetadataManager>(new MetadataManager(vds.IoManager.get(), layerName, metadataStatus, pageLimit)))).first->second.get();
}
void CreateVolumeDataLayout(VDSHandle &handle)
void CreateVolumeDataLayout(VDS &vds)
{
//handle.volumeDataLayout.reset(new VolumeDataLayout(handle.channelDescriptors)
int32_t dimensionality = int32_t(handle.AxisDescriptors.size());
int32_t dimensionality = int32_t(vds.AxisDescriptors.size());
// Check if input layouts are valid so we can create a new layout
if (dimensionality < 2)
{
handle.VolumeDataLayout.reset();
vds.VolumeDataLayout.reset();
return;
}
handle.VolumeDataLayout.reset(
vds.VolumeDataLayout.reset(
new VolumeDataLayoutImpl(
handle,
handle.LayoutDescriptor,
handle.AxisDescriptors,
handle.ChannelDescriptors,
vds,
vds.LayoutDescriptor,
vds.AxisDescriptors,
vds.ChannelDescriptors,
0, //MIA for now
{ 1, 0 }, //MIA for now
VolumeDataHash::GetUniqueHash(),
......@@ -169,23 +168,23 @@ void CreateVolumeDataLayout(VDSHandle &handle)
assert(nChunkDimensionality == 2 || nChunkDimensionality == 3);
int32_t physicalLODLevels = (nChunkDimensionality == 3 || handle.LayoutDescriptor.IsCreate2DLODs()) ? GetLODCount(handle.LayoutDescriptor) : 1;
int32_t brickSize = GetInternalCubeSizeLOD0(handle.LayoutDescriptor) * (nChunkDimensionality == 2 ? handle.LayoutDescriptor.GetBrickSizeMultiplier2D() : 1);
int32_t physicalLODLevels = (nChunkDimensionality == 3 || vds.LayoutDescriptor.IsCreate2DLODs()) ? GetLODCount(vds.LayoutDescriptor) : 1;
int32_t brickSize = GetInternalCubeSizeLOD0(vds.LayoutDescriptor) * (nChunkDimensionality == 2 ? vds.LayoutDescriptor.GetBrickSizeMultiplier2D() : 1);
handle.VolumeDataLayout->CreateLayers(dimensionGroup, brickSize, physicalLODLevels, handle.ProduceStatuses[DimensionGroupUtil::GetDimensionsNDFromDimensionGroup(dimensionGroup)]);
vds.VolumeDataLayout->CreateLayers(dimensionGroup, brickSize, physicalLODLevels, vds.ProduceStatuses[DimensionGroupUtil::GetDimensionsNDFromDimensionGroup(dimensionGroup)]);
}
}
VDSHandle* Create(IOManager *ioManager, VolumeDataLayoutDescriptor const &layoutDescriptor, std::vector<VolumeDataAxisDescriptor> const &axisDescriptors, std::vector<VolumeDataChannelDescriptor> const &channelDescriptors, MetadataContainer const &metadataContainer, Error &error)
VDS* Create(IOManager *ioManager, VolumeDataLayoutDescriptor const &layoutDescriptor, std::vector<VolumeDataAxisDescriptor> const &axisDescriptors, std::vector<VolumeDataChannelDescriptor> const &channelDescriptors, MetadataContainer const &metadataContainer, Error &error)
{
error = Error();
std::unique_ptr<VDSHandle> handle(new VDSHandle(ioManager));
std::unique_ptr<VDS> vds(new VDS(ioManager));
handle->LayoutDescriptor = layoutDescriptor;
vds->LayoutDescriptor = layoutDescriptor;
for(auto axisDescriptor : axisDescriptors)
{
handle->AxisDescriptors.push_back(VolumeDataAxisDescriptor(axisDescriptor.GetNumSamples(), AddDescriptorString(axisDescriptor.GetName(), *handle), AddDescriptorString(axisDescriptor.GetUnit(), *handle), axisDescriptor.GetCoordinateMin(), axisDescriptor.GetCoordinateMax()));
vds->AxisDescriptors.push_back(VolumeDataAxisDescriptor(axisDescriptor.GetNumSamples(), AddDescriptorString(axisDescriptor.GetName(), *vds), AddDescriptorString(axisDescriptor.GetUnit(), *vds), axisDescriptor.GetCoordinateMin(), axisDescriptor.GetCoordinateMax()));
}
for(auto channelDescriptor : channelDescriptors)
......@@ -199,34 +198,34 @@ VDSHandle* Create(IOManager *ioManager, VolumeDataLayoutDescriptor const &layout
if(channelDescriptor.IsUseNoValue())
{
handle->ChannelDescriptors.push_back(VolumeDataChannelDescriptor(channelDescriptor.GetFormat(), channelDescriptor.GetComponents(), AddDescriptorString(channelDescriptor.GetName(), *handle), AddDescriptorString(channelDescriptor.GetUnit(), *handle), channelDescriptor.GetValueRangeMin(), channelDescriptor.GetValueRangeMax(), channelDescriptor.GetMapping(), channelDescriptor.GetMappedValueCount(), flags, channelDescriptor.GetNoValue(), channelDescriptor.GetIntegerScale(), channelDescriptor.GetIntegerOffset()));
vds->ChannelDescriptors.push_back(VolumeDataChannelDescriptor(channelDescriptor.GetFormat(), channelDescriptor.GetComponents(), AddDescriptorString(channelDescriptor.GetName(), *vds), AddDescriptorString(channelDescriptor.GetUnit(), *vds), channelDescriptor.GetValueRangeMin(), channelDescriptor.GetValueRangeMax(), channelDescriptor.GetMapping(), channelDescriptor.GetMappedValueCount(), flags, channelDescriptor.GetNoValue(), channelDescriptor.GetIntegerScale(), channelDescriptor.GetIntegerOffset()));
}
else
{
handle->ChannelDescriptors.push_back(VolumeDataChannelDescriptor(channelDescriptor.GetFormat(), channelDescriptor.GetComponents(), AddDescriptorString(channelDescriptor.GetName(), *handle), AddDescriptorString(channelDescriptor.GetUnit(), *handle), channelDescriptor.GetValueRangeMin(), channelDescriptor.GetValueRangeMax(), channelDescriptor.GetMapping(), channelDescriptor.GetMappedValueCount(), flags, channelDescriptor.GetIntegerScale(), channelDescriptor.GetIntegerOffset()));
vds->ChannelDescriptors.push_back(VolumeDataChannelDescriptor(channelDescriptor.GetFormat(), channelDescriptor.GetComponents(), AddDescriptorString(channelDescriptor.GetName(), *vds), AddDescriptorString(channelDescriptor.GetUnit(), *vds), channelDescriptor.GetValueRangeMin(), channelDescriptor.GetValueRangeMax(), channelDescriptor.GetMapping(), channelDescriptor.GetMappedValueCount(), flags, channelDescriptor.GetIntegerScale(), channelDescriptor.GetIntegerOffset()));
}
}
handle->MetadataContainer = metadataContainer;
vds->MetadataContainer = metadataContainer;
handle->ProduceStatuses.clear();
handle->ProduceStatuses.resize(int(Dimensions_45) + 1, VolumeDataLayer::ProduceStatus_Unavailable);
vds->ProduceStatuses.clear();
vds->ProduceStatuses.resize(int(Dimensions_45) + 1, VolumeDataLayer::ProduceStatus_Unavailable);
CreateVolumeDataLayout(*handle);
CreateVolumeDataLayout(*vds);
if (error.Code)
return nullptr;
if (!SerializeAndUploadVolumeDataLayout(*handle, error))
if (!SerializeAndUploadVolumeDataLayout(*vds, error))
return nullptr;
handle->DataAccessManager.reset(new VolumeDataAccessManagerImpl(*handle.get()));
handle->RequestProcessor.reset(new VolumeDataRequestProcessor(*handle->DataAccessManager.get()));
vds->DataAccessManager.reset(new VolumeDataAccessManagerImpl(*vds.get()));
vds->RequestProcessor.reset(new VolumeDataRequestProcessor(*vds->DataAccessManager.get()));
return handle.release();
return vds.release();
}
VDSHandle* Create(const OpenOptions& options, VolumeDataLayoutDescriptor const& layoutDescriptor, std::vector<VolumeDataAxisDescriptor> const& axisDescriptors, std::vector<VolumeDataChannelDescriptor> const& channelDescriptors, MetadataContainer const& metadataContainer, Error& error)
VDS* Create(const OpenOptions& options, VolumeDataLayoutDescriptor const& layoutDescriptor, std::vector<VolumeDataAxisDescriptor> const& axisDescriptors, std::vector<VolumeDataChannelDescriptor> const& channelDescriptors, MetadataContainer const& metadataContainer, Error& error)
{
error = Error();
IOManager* ioManager = IOManager::CreateIOManager(options, error);
......@@ -236,9 +235,9 @@ VDSHandle* Create(const OpenOptions& options, VolumeDataLayoutDescriptor const&
return Create(ioManager, layoutDescriptor, axisDescriptors, channelDescriptors, metadataContainer, error);
}
void Close(VDSHandle *handle)
void Close(VDS *vds)
{
delete handle;
delete vds;
}
}
......@@ -69,7 +69,7 @@ enum class Access
Read = 1 << 0,
Write = 1 << 1
};
struct VDSHandle;
typedef struct VDS *VDSHandle;
class VolumeDataLayout;
class VolumeDataAccessManager;
class VolumeDataPageAccessor;
......@@ -86,7 +86,7 @@ class VolumeDataPageAccessor;
/// <returns>
/// The VDS handle that can be used to get the VolumeDataLayout and the VolumeDataAccessManager
/// </returns>
OPENVDS_EXPORT VDSHandle* Open(const OpenOptions& options, Error& error);
OPENVDS_EXPORT VDSHandle Open(const OpenOptions& options, Error& error);
/// <summary>
/// Open an existing VDS
......@@ -100,7 +100,7 @@ OPENVDS_EXPORT VDSHandle* Open(const OpenOptions& options, Error& error);
/// <returns>
/// The VDS handle that can be used to get the VolumeDataLayout and the VolumeDataAccessManager
/// </returns>
OPENVDS_EXPORT VDSHandle* Open(IOManager*ioManager, Error &error);
OPENVDS_EXPORT VDSHandle Open(IOManager*ioManager, Error &error);
/// <summary>
/// Create a new VDS
......@@ -114,7 +114,7 @@ OPENVDS_EXPORT VDSHandle* Open(IOManager*ioManager, Error &error);
/// <returns>
/// The VDS handle that can be used to get the VolumeDataLayout and the VolumeDataAccessManager
/// </returns>
OPENVDS_EXPORT VDSHandle* Create(const OpenOptions& options, VolumeDataLayoutDescriptor const& layoutDescriptor, std::vector<VolumeDataAxisDescriptor> const& axisDescriptors, std::vector<VolumeDataChannelDescriptor> const& channelDescriptors, MetadataContainer const& metadataContainer, Error& error);
OPENVDS_EXPORT VDSHandle Create(const OpenOptions& options, VolumeDataLayoutDescriptor const& layoutDescriptor, std::vector<VolumeDataAxisDescriptor> const& axisDescriptors, std::vector<VolumeDataChannelDescriptor> const& channelDescriptors, MetadataContainer const& metadataContainer, Error& error);
/// <summary>
/// Create a new VDS
......@@ -128,7 +128,7 @@ OPENVDS_EXPORT VDSHandle* Create(const OpenOptions& options, VolumeDataLayoutDes
/// <returns>
/// The VDS handle that can be used to get the VolumeDataLayout and the VolumeDataAccessManager
/// </returns>
OPENVDS_EXPORT VDSHandle* Create(IOManager* ioManager, VolumeDataLayoutDescriptor const &layoutDescriptor, std::vector<VolumeDataAxisDescriptor> const &axisDescriptors, std::vector<VolumeDataChannelDescriptor> const &channelDescriptors, MetadataContainer const &metadataContainer, Error &error);
OPENVDS_EXPORT VDSHandle Create(IOManager* ioManager, VolumeDataLayoutDescriptor const &layoutDescriptor, std::vector<VolumeDataAxisDescriptor> const &axisDescriptors, std::vector<VolumeDataChannelDescriptor> const &channelDescriptors, MetadataContainer const &metadataContainer, Error &error);
/// <summary>
/// Close a VDS and free up all associated resources
......@@ -136,10 +136,10 @@ OPENVDS_EXPORT VDSHandle* Create(IOManager* ioManager, VolumeDataLayoutDescripto
/// <param name="handle">
/// The handle to close
/// </param>
OPENVDS_EXPORT void Close(VDSHandle *handle);
OPENVDS_EXPORT void Close(VDSHandle handle);
OPENVDS_EXPORT VolumeDataLayout *GetLayout(VDSHandle *handle);
OPENVDS_EXPORT VolumeDataAccessManager *GetDataAccessManager(VDSHandle *handle);
OPENVDS_EXPORT VolumeDataLayout *GetLayout(VDSHandle handle);
OPENVDS_EXPORT VolumeDataAccessManager *GetDataAccessManager(VDSHandle handle);
}
#endif //OPENVDS_H
......@@ -26,7 +26,7 @@ namespace OpenVDS {
class VolumeDataPageAccessor;
class VolumeDataLayout;
struct VDSHandle;
struct VDS;
template <typename INDEX, typename T> class VolumeDataReadAccessor;
template <typename INDEX, typename T> class VolumeDataReadWriteAccessor;
......
......@@ -79,7 +79,7 @@ main(int argc, char *argv[])
std::string
key = !prefix.empty() ? prefix + "/" + persistentID : persistentID;
std::unique_ptr<OpenVDS::VDSHandle, decltype(&OpenVDS::Close)> vds(OpenVDS::Open(OpenVDS::AWSOpenOptions(bucket, key, region), openError), &OpenVDS::Close);
std::unique_ptr<OpenVDS::VDS, decltype(&OpenVDS::Close)> vds(OpenVDS::Open(OpenVDS::AWSOpenOptions(bucket, key, region), openError), &OpenVDS::Close);
if(openError.Code != 0)
{
......
......@@ -857,7 +857,7 @@ main(int argc, char *argv[])
std::string
key = !prefix.empty() ? prefix + "/" + persistentID : persistentID;
std::unique_ptr<OpenVDS::VDSHandle, decltype(&OpenVDS::Close)> vds(OpenVDS::Create(OpenVDS::AWSOpenOptions(bucket, key, region), layoutDescriptor, axisDescriptors, channelDescriptors, metadataContainer, createError), &OpenVDS::Close);
std::unique_ptr<OpenVDS::VDS, decltype(&OpenVDS::Close)> vds(OpenVDS::Create(OpenVDS::AWSOpenOptions(bucket, key, region), layoutDescriptor, axisDescriptors, channelDescriptors, metadataContainer, createError), &OpenVDS::Close);
if(createError.Code != 0)
{
......
......@@ -435,7 +435,7 @@ bool ParseJSONFromBuffer(const std::vector<uint8_t> &json, Json::Value &root, Er
return false;
}
bool ParseVolumeDataLayout(const std::vector<uint8_t> &json, VDSHandle &handle, Error &error)
bool ParseVolumeDataLayout(const std::vector<uint8_t> &json, VDS &vds, Error &error)
{
Json::Value root;
......@@ -450,7 +450,7 @@ bool ParseVolumeDataLayout(const std::vector<uint8_t> &json, VDSHandle &handle,
Json::Value
layoutDescriptor = root["layoutDescriptor"];
handle.LayoutDescriptor = VolumeDataLayoutDescriptor(BrickSizeFromJson(layoutDescriptor["brickSize"]),
vds.LayoutDescriptor = VolumeDataLayoutDescriptor(BrickSizeFromJson(layoutDescriptor["brickSize"]),
layoutDescriptor["negativeMargin"].asInt(),
layoutDescriptor["positiveMargin"].asInt(),
layoutDescriptor["brickSize2DMultiplier"].asInt(),
......@@ -463,23 +463,23 @@ bool ParseVolumeDataLayout(const std::vector<uint8_t> &json, VDSHandle &handle,
{
VolumeDataAxisDescriptor
volumeDataAxisDescriptor(axisDescriptor["numSamples"].asInt(),
AddDescriptorString(axisDescriptor["name"].asString(), handle),
AddDescriptorString(axisDescriptor["unit"].asString(), handle),
AddDescriptorString(axisDescriptor["name"].asString(), vds),
AddDescriptorString(axisDescriptor["unit"].asString(), vds),
axisDescriptor["coordinateMin"].asFloat(),
axisDescriptor["coordinateMax"].asFloat());
handle.AxisDescriptors.push_back(volumeDataAxisDescriptor);
vds.AxisDescriptors.push_back(volumeDataAxisDescriptor);
}
for (const Json::Value &channelDescriptor : root["channelDescriptors"])
{
if (channelDescriptor["useNoValue"].asBool())
{
handle.ChannelDescriptors.push_back(VolumeDataChannelDescriptor(
vds.ChannelDescriptors.push_back(VolumeDataChannelDescriptor(
VoxelFormatFromJson(channelDescriptor["format"]),
VoxelComponentsFromJson(channelDescriptor["components"]),
AddDescriptorString(channelDescriptor["name"].asString(), handle),
AddDescriptorString(channelDescriptor["unit"].asString(), handle),
AddDescriptorString(channelDescriptor["name"].asString(), vds),
AddDescriptorString(channelDescriptor["unit"].asString(), vds),
channelDescriptor["valueRange"][0].asFloat(),
channelDescriptor["valueRange"][1].asFloat(),
ChannelMappingFromJson(channelDescriptor["channelMapping"]),
......@@ -493,11 +493,11 @@ bool ParseVolumeDataLayout(const std::vector<uint8_t> &json, VDSHandle &handle,
}
else
{
handle.ChannelDescriptors.push_back(VolumeDataChannelDescriptor(
vds.ChannelDescriptors.push_back(VolumeDataChannelDescriptor(
VoxelFormatFromJson(channelDescriptor["format"]),
VoxelComponentsFromJson(channelDescriptor["components"]),
AddDescriptorString(channelDescriptor["name"].asString(), handle),
AddDescriptorString(channelDescriptor["unit"].asString(), handle),
AddDescriptorString(channelDescriptor["name"].asString(), vds),
AddDescriptorString(channelDescriptor["unit"].asString(), vds),
channelDescriptor["valueRange"][0].asFloat(),
channelDescriptor["valueRange"][1].asFloat(),
ChannelMappingFromJson(channelDescriptor["channelMapping"]),
......@@ -514,59 +514,59 @@ bool ParseVolumeDataLayout(const std::vector<uint8_t> &json, VDSHandle &handle,
{
MetadataKey key = { MetadataTypeFromJson(metadata["type"]), metadata["category"].asString(), metadata["name"].asString() };
handle.MetadataContainer.keys.push_back(key);
vds.MetadataContainer.keys.push_back(key);
if (metadata["type"].asString() == "Int")
{
handle.MetadataContainer.intData[key] = metadata["value"].asInt();
vds.MetadataContainer.intData[key] = metadata["value"].asInt();
}
else if (metadata["type"].asString() == "IntVector2")
{
handle.MetadataContainer.intVector2Data[key] = { metadata["value"][0].asInt(), metadata["value"][1].asInt()};
vds.MetadataContainer.intVector2Data[key] = { metadata["value"][0].asInt(), metadata["value"][1].asInt()};
}
else if (metadata["type"].asString() == "IntVector3")
{
handle.MetadataContainer.intVector3Data[key] = { metadata["value"][0].asInt(), metadata["value"][1].asInt(), metadata["value"][2].asInt() };
vds.MetadataContainer.intVector3Data[key] = { metadata["value"][0].asInt(), metadata["value"][1].asInt(), metadata["value"][2].asInt() };
}
else if (metadata["type"].asString() == "IntVector4")
{
handle.MetadataContainer.intVector4Data[key] = { metadata["value"][0].asInt(), metadata["value"][1].asInt(), metadata["value"][2].asInt(), metadata["value"][3].asInt() };
vds.MetadataContainer.intVector4Data[key] = { metadata["value"][0].asInt(), metadata["value"][1].asInt(), metadata["value"][2].asInt(), metadata["value"][3].asInt() };
}
else if (metadata["type"].asString() == "Float")
{
handle.MetadataContainer.floatData[key] = metadata["value"].asFloat();
vds.MetadataContainer.floatData[key] = metadata["value"].asFloat();
}
else if (metadata["type"].asString() == "FloatVector2")
{
handle.MetadataContainer.floatVector2Data[key] = { metadata["value"][0].asFloat(), metadata["value"][1].asFloat() };
vds.MetadataContainer.floatVector2Data[key] = { metadata["value"][0].asFloat(), metadata["value"][1].asFloat() };
}
else if (metadata["type"].asString() == "FloatVector3")
{
handle.MetadataContainer.floatVector3Data[key] = { metadata["value"][0].asFloat(), metadata["value"][1].asFloat(), metadata["value"][2].asFloat() };
vds.MetadataContainer.floatVector3Data[key] = { metadata["value"][0].asFloat(), metadata["value"][1].asFloat(), metadata["value"][2].asFloat() };
}
else if (metadata["type"].asString() == "FloatVector4")
{
handle.MetadataContainer.floatVector4Data[key] = { metadata["value"][0].asFloat(), metadata["value"][1].asFloat(), metadata["value"][2].asFloat(), metadata["value"][3].asFloat() };
vds.MetadataContainer.floatVector4Data[key] = { metadata["value"][0].asFloat(), metadata["value"][1].asFloat(), metadata["value"][2].asFloat(), metadata["value"][3].asFloat() };
}
else if (metadata["type"].asString() == "Double")
{
handle.MetadataContainer.doubleData[key] = metadata["value"].asDouble();
vds.MetadataContainer.doubleData[key] = metadata["value"].asDouble();
}
else if (metadata["type"].asString() == "DoubleVector2")
{
handle.MetadataContainer.doubleVector2Data[key] = { metadata["value"][0].asDouble(), metadata["value"][1].asDouble() };
vds.MetadataContainer.doubleVector2Data[key] = { metadata["value"][0].asDouble(), metadata["value"][1].asDouble() };
}
else if (metadata["type"].asString() == "DoubleVector3")
{
handle.MetadataContainer.doubleVector3Data[key] = { metadata["value"][0].asDouble(), metadata["value"][1].asDouble(), metadata["value"][2].asDouble() };
vds.MetadataContainer.doubleVector3Data[key] = { metadata["value"][0].asDouble(), metadata["value"][1].asDouble(), metadata["value"][2].asDouble() };
}
else if (metadata["type"].asString() == "DoubleVector4")
{
handle.MetadataContainer.doubleVector4Data[key] = { metadata["value"][0].asDouble(), metadata["value"][1].asDouble(), metadata["value"][2].asDouble(), metadata["value"][3].asDouble() };
vds.MetadataContainer.doubleVector4Data[key] = { metadata["value"][0].asDouble(), metadata["value"][1].asDouble(), metadata["value"][2].asDouble(), metadata["value"][3].asDouble() };
}
else if (metadata["type"].asString() == "String")
{
handle.MetadataContainer.stringData[key] = metadata["value"].asString();
vds.MetadataContainer.stringData[key] = metadata["value"].asString();
}
else if (metadata["type"].asString() == "BLOB")
{
......@@ -574,7 +574,7 @@ bool ParseVolumeDataLayout(const std::vector<uint8_t> &json, VDSHandle &handle,
int len = (int)strlen(value);
std::vector<uint8_t> &data = handle.MetadataContainer.blobData[key];
std::vector<uint8_t> &data = vds.MetadataContainer.blobData[key];
data.clear();
bool success = Base64Decode(value, len, data);
......@@ -679,10 +679,10 @@ static MetadataStatus MetadataStatusFromJSON(Json::Value const &metadataStatusJs
return metadataStatus;
}
bool ParseLayerStatus(const std::vector<uint8_t> &json, VDSHandle &handle, Error &error)
bool ParseLayerStatus(const std::vector<uint8_t> &json, VDS &vds, Error &error)
{
handle.ProduceStatuses.clear();
handle.ProduceStatuses.resize(int(Dimensions_45) + 1, VolumeDataLayer::ProduceStatus_Unavailable);
vds.ProduceStatuses.clear();
vds.ProduceStatuses.resize(int(Dimensions_45) + 1, VolumeDataLayer::ProduceStatus_Unavailable);
Json::Value root;
if (!ParseJSONFromBuffer(json, root, error))
......@@ -709,9 +709,9 @@ bool ParseLayerStatus(const std::vector<uint8_t> &json, VDSHandle &handle, Error
int
lod = layerStatus["lod"].asInt();
if (lod == 0 && handle.ProduceStatuses[dimensionsND] == VolumeDataLayer::ProduceStatus_Unavailable)
if (lod == 0 && vds.ProduceStatuses[dimensionsND] == VolumeDataLayer::ProduceStatus_Unavailable)
{
handle.ProduceStatuses[dimensionsND] = produceStatus;
vds.ProduceStatuses[dimensionsND] = produceStatus;
}
MetadataStatus
......@@ -740,14 +740,14 @@ bool ParseLayerStatus(const std::vector<uint8_t> &json, VDSHandle &handle, Error
if (hasChunkMetadataPages)
{
std::unique_lock<std::mutex> metadataManagersMutexLock(handle.LayerMetadataContainer.mutex);
auto &managers = handle.LayerMetadataContainer.managers;
std::unique_lock<std::mutex> metadataManagersMutexLock(vds.LayerMetadataContainer.mutex);
auto &managers = vds.LayerMetadataContainer.managers;
if (managers.find(layerName) == handle.LayerMetadataContainer.managers.end())
if (managers.find(layerName) == vds.LayerMetadataContainer.managers.end())
{
int pageLimit = handle.AxisDescriptors.size() <= 3 ? 64 : 1024;
int pageLimit = vds.AxisDescriptors.size() <= 3 ? 64 : 1024;
handle.LayerMetadataContainer.managers.insert(std::make_pair(layerName, std::unique_ptr<MetadataManager>(new MetadataManager(handle.IoManager.get(), layerName, metadataStatus, pageLimit))));
vds.LayerMetadataContainer.managers.insert(std::make_pair(layerName, std::unique_ptr<MetadataManager>(new MetadataManager(vds.IoManager.get(), layerName, metadataStatus, pageLimit))));
}
}
}
......@@ -1144,13 +1144,13 @@ public:
Error *error;
};
bool DownloadAndParseVolumeDataLayoutAndLayerStatus(VDSHandle& handle, Error& error)
bool DownloadAndParseVolumeDataLayoutAndLayerStatus(VDS& vds, Error& error)
{
std::vector<uint8_t> volumedatalayout_json;
std::shared_ptr<SyncTransferHandler> syncTransferHandler = std::make_shared<SyncTransferHandler>();
syncTransferHandler->error = &error;
syncTransferHandler->data = &volumedatalayout_json;
auto request = handle.IoManager->Download("VolumeDataLayout", syncTransferHandler);
auto request = vds.IoManager->Download("VolumeDataLayout", syncTransferHandler);
request->WaitForFinish();
if (!request->IsSuccess(error) || volumedatalayout_json.empty())
{
......@@ -1159,7 +1159,7 @@ bool DownloadAndParseVolumeDataLayoutAndLayerStatus(VDSHandle& handle, Error& er
}
std::vector<uint8_t> layerstatus_json;
syncTransferHandler->data = &layerstatus_json;
request = handle.IoManager->Download("LayerStatus", syncTransferHandler);
request = vds.IoManager->Download("LayerStatus", syncTransferHandler);
request->WaitForFinish();
if (!request->IsSuccess(error) || layerstatus_json.empty())
{
......@@ -1169,9 +1169,9 @@ bool DownloadAndParseVolumeDataLayoutAndLayerStatus(VDSHandle& handle, Error& er
try
{
if (!ParseVolumeDataLayout(volumedatalayout_json, handle, error))
if (!ParseVolumeDataLayout(volumedatalayout_json, vds, error))
return false;
if (!ParseLayerStatus(layerstatus_json, handle, error))
if (!ParseLayerStatus(layerstatus_json, vds, error))
return false;
}
catch (Json::Exception& e)
......@@ -1181,16 +1181,16 @@ bool DownloadAndParseVolumeDataLayoutAndLayerStatus(VDSHandle& handle, Error& er
return false;
}
CreateVolumeDataLayout(handle);
CreateVolumeDataLayout(vds);
return true;
}
bool SerializeAndUploadVolumeDataLayout(VDSHandle& handle, Error& error)
bool SerializeAndUploadVolumeDataLayout(VDS& vds, Error& error)
{
Json::Value volumeDataLayoutJson = SerializeVolumeDataLayout(*handle.VolumeDataLayout, handle.MetadataContainer);
Json::Value volumeDataLayoutJson = SerializeVolumeDataLayout(*vds.VolumeDataLayout, vds.MetadataContainer);
auto serializedVolumeDataLayout = std::make_shared<std::vector<uint8_t>>(WriteJson(volumeDataLayoutJson));
auto request = handle.IoManager->UploadJson("VolumeDataLayout", serializedVolumeDataLayout);
auto request = vds.IoManager->UploadJson("VolumeDataLayout", serializedVolumeDataLayout);
request->WaitForFinish();
......@@ -1203,11 +1203,11 @@ bool SerializeAndUploadVolumeDataLayout(VDSHandle& handle, Error& error)
return true;
}
bool SerializeAndUploadLayerStatus(VDSHandle& handle, Error& error)
bool SerializeAndUploadLayerStatus(VDS& vds, Error& error)
{
Json::Value layerStatusArrayJson = SerializeLayerStatusArray(*handle.VolumeDataLayout, handle.LayerMetadataContainer);
Json::Value layerStatusArrayJson = SerializeLayerStatusArray(*vds.VolumeDataLayout, vds.LayerMetadataContainer);
auto serializedLayerStatus = std::make_shared<std::vector<uint8_t>>(WriteJson(layerStatusArrayJson));
auto request = handle.IoManager->UploadJson("LayerStatus", serializedLayerStatus);
auto request = vds.IoManager->UploadJson("LayerStatus", serializedLayerStatus);
request->WaitForFinish();
......
......@@ -19,13 +19,13 @@
#define PARSEVDSJSON_H
#include <OpenVDS/OpenVDS.h>
#include <OpenVDSHandle.h>
#include <VDS/VDS.h>
namespace OpenVDS
{
bool DownloadAndParseVolumeDataLayoutAndLayerStatus(VDSHandle &handle, Error &error);
bool SerializeAndUploadVolumeDataLayout(VDSHandle& handle, Error& error);
bool SerializeAndUploadLayerStatus(VDSHandle& handle, Error& error);
bool DownloadAndParseVolumeDataLayoutAndLayerStatus(VDS &handle, Error &error);
bool SerializeAndUploadVolumeDataLayout(VDS& handle, Error& error);
bool SerializeAndUploadLayerStatus(VDS& handle, Error& error);
}
#endif //PARSEVDSJSON_H