From d5a07a57c50171cffc26533d41d44aa95eaa0cff Mon Sep 17 00:00:00 2001 From: "morten.ofstad" Date: Tue, 23 Aug 2022 17:08:45 +0200 Subject: [PATCH 1/2] Add support for writing metadata to a VDS after it has been created. --- src/OpenVDS/OpenVDS.cpp | 8 ++ src/OpenVDS/OpenVDS/MetadataContainer.h | 2 +- src/OpenVDS/OpenVDS/OpenVDS.h | 14 ++ src/OpenVDS/OpenVDS/OpenVDSInterface.h | 2 + src/OpenVDS/VDS/VDS.h | 131 ++++++++++++++++++- src/OpenVDS/VDS/VolumeDataStoreIOManager.cpp | 8 ++ tests/OpenVDS/OpenVDSIntegrationTest.cpp | 60 +++++++++ 7 files changed, 223 insertions(+), 2 deletions(-) diff --git a/src/OpenVDS/OpenVDS.cpp b/src/OpenVDS/OpenVDS.cpp index 0a492774..35b4f117 100644 --- a/src/OpenVDS/OpenVDS.cpp +++ b/src/OpenVDS/OpenVDS.cpp @@ -854,6 +854,7 @@ public: VDSHandle Create(IOManager* ioManager, VolumeDataLayoutDescriptor const &layoutDescriptor, VectorWrapper axisDescriptors, VectorWrapper channelDescriptors, MetadataReadAccess const &metadata, CompressionMethod compressionMethod, float compressionTolerance, LogLevel logLevel, ErrorHandler errorHandler, Error *errorPtr=nullptr) final override; VolumeDataLayout *GetLayout(VDSHandle handle) final override; IVolumeDataAccessManager *GetAccessManagerInterface(VDSHandle handle) final override; + MetadataWriteAccess *GetMetadataWriteAccessInterface(VDSHandle handle) final override; CompressionMethod GetCompressionMethod(VDSHandle handle) final override; float GetCompressionTolerance(VDSHandle handle) final override; void Close(VDSHandle handle) final override; @@ -997,6 +998,13 @@ IVolumeDataAccessManager *OpenVDSInterfaceImpl::GetAccessManagerInterface(VDS *v return vds->accessManager.get(); } +MetadataWriteAccess *OpenVDSInterfaceImpl::GetMetadataWriteAccessInterface(VDS *vds) +{ + if (!vds) + return nullptr; + return &vds->metadataContainer; +} + bool OpenVDSInterfaceImpl::IsCompressionMethodSupported(CompressionMethod compressionMethod) { return VolumeDataStore::IsCompressionMethodSupported(compressionMethod); diff --git a/src/OpenVDS/OpenVDS/MetadataContainer.h b/src/OpenVDS/OpenVDS/MetadataContainer.h index 1810b87c..f9ed54cc 100644 --- a/src/OpenVDS/OpenVDS/MetadataContainer.h +++ b/src/OpenVDS/OpenVDS/MetadataContainer.h @@ -134,7 +134,7 @@ public: case MetadataType::BLOB: std::vector data; metadataReadAccess->GetMetadataBLOB(key.GetCategory(), key.GetName(), data); - SetMetadataBLOB(key.GetCategory(), key.GetName(), data); + SetMetadataBLOB(key.GetCategory(), key.GetName(), data.data(), data.size()); break; } } diff --git a/src/OpenVDS/OpenVDS/OpenVDS.h b/src/OpenVDS/OpenVDS/OpenVDS.h index 02fe3dfa..00b3c0e7 100644 --- a/src/OpenVDS/OpenVDS/OpenVDS.h +++ b/src/OpenVDS/OpenVDS/OpenVDS.h @@ -999,6 +999,20 @@ inline VolumeDataAccessManager GetAccessManager(VDSHandle handle) return VolumeDataAccessManager(volumeDataAccessManagerInterface); } +/// +/// Get the MetadataWriteAccess interface for a VDS +/// +/// +/// The handle of the VDS +/// +/// +/// The MetadataWriteAccess interface of the VDS +/// +inline MetadataWriteAccess *GetMetadataWriteAccessInterface(VDSHandle handle) +{ + return GetOpenVDSInterface(OPENVDS_VERSION).GetMetadataWriteAccessInterface(handle); +} + /// /// Get the primary CompressionMethod for a VDS /// diff --git a/src/OpenVDS/OpenVDS/OpenVDSInterface.h b/src/OpenVDS/OpenVDS/OpenVDSInterface.h index 182355a8..ef42242c 100644 --- a/src/OpenVDS/OpenVDS/OpenVDSInterface.h +++ b/src/OpenVDS/OpenVDS/OpenVDSInterface.h @@ -35,6 +35,7 @@ typedef struct VDSError Error; class VolumeDataLayout; class MetadataReadAccess; +class MetadataWriteAccess; class VolumeDataAccessManager; class VolumeDataPageAccessor; class VolumeDataLayoutDescriptor; @@ -131,6 +132,7 @@ public: virtual VDSHandle Create(IOManager* ioManager, VolumeDataLayoutDescriptor const &layoutDescriptor, VectorWrapper axisDescriptors, VectorWrapper channelDescriptors, MetadataReadAccess const &metadata, CompressionMethod compressionMethod, float compressionTolerance, LogLevel logLevel, ErrorHandler errorHandler, Error *error=nullptr) = 0; virtual VolumeDataLayout *GetLayout(VDSHandle handle) = 0; virtual IVolumeDataAccessManager *GetAccessManagerInterface(VDSHandle handle) = 0; + virtual MetadataWriteAccess *GetMetadataWriteAccessInterface(VDSHandle handle) = 0; virtual CompressionMethod GetCompressionMethod(VDSHandle handle) = 0; virtual float GetCompressionTolerance(VDSHandle handle) = 0; virtual void Close(VDSHandle handle) = 0; diff --git a/src/OpenVDS/VDS/VDS.h b/src/OpenVDS/VDS/VDS.h index 3103ef4d..b5567b6d 100644 --- a/src/OpenVDS/VDS/VDS.h +++ b/src/OpenVDS/VDS/VDS.h @@ -37,6 +37,7 @@ #include #include #include +#include namespace OpenVDS { @@ -57,6 +58,133 @@ public: void ReleaseVolumeDataAccessManager(VolumeDataAccessManagerImpl *); +class VDSMetadataContainer : public MetadataContainer +{ + mutable std::mutex m_mutex; + bool m_dirty; + +public: + VDSMetadataContainer() : m_dirty(false) {} + + bool IsDirty() const { std::unique_lock lock(m_mutex); return m_dirty; } + void ClearDirtyFlag() { std::unique_lock lock(m_mutex); m_dirty = false; } + + bool IsMetadataIntAvailable(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::IsMetadataIntAvailable(category, name); } + bool IsMetadataIntVector2Available(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::IsMetadataIntVector2Available(category, name); } + bool IsMetadataIntVector3Available(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::IsMetadataIntVector3Available(category, name); } + bool IsMetadataIntVector4Available(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::IsMetadataIntVector4Available(category, name); } + bool IsMetadataFloatAvailable(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::IsMetadataFloatAvailable(category, name); } + bool IsMetadataFloatVector2Available(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::IsMetadataFloatVector2Available(category, name); } + bool IsMetadataFloatVector3Available(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::IsMetadataFloatVector3Available(category, name); } + bool IsMetadataFloatVector4Available(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::IsMetadataFloatVector4Available(category, name); } + bool IsMetadataDoubleAvailable(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::IsMetadataDoubleAvailable(category, name); } + bool IsMetadataDoubleVector2Available(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::IsMetadataDoubleVector2Available(category, name); } + bool IsMetadataDoubleVector3Available(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::IsMetadataDoubleVector3Available(category, name); } + bool IsMetadataDoubleVector4Available(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::IsMetadataDoubleVector4Available(category, name); } + bool IsMetadataStringAvailable(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::IsMetadataStringAvailable(category, name); } + bool IsMetadataBLOBAvailable(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::IsMetadataBLOBAvailable(category, name); } + + int GetMetadataInt(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::GetMetadataInt(category, name); } + IntVector2 GetMetadataIntVector2(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::GetMetadataIntVector2(category, name); } + IntVector3 GetMetadataIntVector3(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::GetMetadataIntVector3(category, name); } + IntVector4 GetMetadataIntVector4(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::GetMetadataIntVector4(category, name); } + + float GetMetadataFloat(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::GetMetadataFloat(category, name); } + FloatVector2 GetMetadataFloatVector2(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::GetMetadataFloatVector2(category, name); } + FloatVector3 GetMetadataFloatVector3(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::GetMetadataFloatVector3(category, name); } + FloatVector4 GetMetadataFloatVector4(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::GetMetadataFloatVector4(category, name); } + + double GetMetadataDouble(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::GetMetadataDouble(category, name); } + DoubleVector2 GetMetadataDoubleVector2(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::GetMetadataDoubleVector2(category, name); } + DoubleVector3 GetMetadataDoubleVector3(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::GetMetadataDoubleVector3(category, name); } + DoubleVector4 GetMetadataDoubleVector4(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::GetMetadataDoubleVector4(category, name); } + + const char* GetMetadataString(const char* category, const char* name) const override { std::unique_lock lock(m_mutex); return MetadataContainer::GetMetadataString(category, name); } + void GetMetadataBLOB(const char* category, const char* name, const void **data, size_t *size) const override { std::unique_lock lock(m_mutex); return MetadataContainer::GetMetadataBLOB(category, name, data, size); } + + MetadataKeyRange GetMetadataKeys() const override { std::unique_lock lock(m_mutex); return MetadataContainer::GetMetadataKeys(); } + + void SetMetadataInt(const char* category, const char* name, int value) override { std::unique_lock lock(m_mutex); m_dirty = true; return MetadataContainer::SetMetadataInt(category, name, value); } + void SetMetadataIntVector2(const char* category, const char* name, IntVector2 value) override { std::unique_lock lock(m_mutex); m_dirty = true; return MetadataContainer::SetMetadataIntVector2(category, name, value); } + void SetMetadataIntVector3(const char* category, const char* name, IntVector3 value) override { std::unique_lock lock(m_mutex); m_dirty = true; return MetadataContainer::SetMetadataIntVector3(category, name, value); } + void SetMetadataIntVector4(const char* category, const char* name, IntVector4 value) override { std::unique_lock lock(m_mutex); m_dirty = true; return MetadataContainer::SetMetadataIntVector4(category, name, value); } + + void SetMetadataFloat(const char* category, const char* name, float value) override { std::unique_lock lock(m_mutex); m_dirty = true; return MetadataContainer::SetMetadataFloat(category, name, value); } + void SetMetadataFloatVector2(const char* category, const char* name, FloatVector2 value) override { std::unique_lock lock(m_mutex); m_dirty = true; return MetadataContainer::SetMetadataFloatVector2(category, name, value); } + void SetMetadataFloatVector3(const char* category, const char* name, FloatVector3 value) override { std::unique_lock lock(m_mutex); m_dirty = true; return MetadataContainer::SetMetadataFloatVector3(category, name, value); } + void SetMetadataFloatVector4(const char* category, const char* name, FloatVector4 value) override { std::unique_lock lock(m_mutex); m_dirty = true; return MetadataContainer::SetMetadataFloatVector4(category, name, value); } + + void SetMetadataDouble(const char* category, const char* name, double value) override { std::unique_lock lock(m_mutex); m_dirty = true; return MetadataContainer::SetMetadataDouble(category, name, value); } + void SetMetadataDoubleVector2(const char* category, const char* name, DoubleVector2 value) override { std::unique_lock lock(m_mutex); m_dirty = true; return MetadataContainer::SetMetadataDoubleVector2(category, name, value); } + void SetMetadataDoubleVector3(const char* category, const char* name, DoubleVector3 value) override { std::unique_lock lock(m_mutex); m_dirty = true; return MetadataContainer::SetMetadataDoubleVector3(category, name, value); } + void SetMetadataDoubleVector4(const char* category, const char* name, DoubleVector4 value) override { std::unique_lock lock(m_mutex); m_dirty = true; return MetadataContainer::SetMetadataDoubleVector4(category, name, value); } + + void SetMetadataString(const char* category, const char* name, const char* value) override { std::unique_lock lock(m_mutex); m_dirty = true; return MetadataContainer::SetMetadataString(category, name, value); } + void SetMetadataBLOB(const char* category, const char* name, const void *data, size_t size) override { std::unique_lock lock(m_mutex); m_dirty = true; return MetadataContainer::SetMetadataBLOB(category, name, data, size); } + + void CopyMetadata(const char* category, MetadataReadAccess const *metadataReadAccess) override + { + std::unique_lock lock(m_mutex); + + for (auto &key : metadataReadAccess->GetMetadataKeys()) + { + if (strcmp(key.GetCategory(), category) == 0) + { + switch(key.GetType()) + { + case MetadataType::Int: + MetadataContainer::SetMetadataInt(key.GetCategory(), key.GetName(), metadataReadAccess->GetMetadataInt(key.GetCategory(), key.GetName())); + break; + case MetadataType::IntVector2: + MetadataContainer::SetMetadataIntVector2(key.GetCategory(), key.GetName(), metadataReadAccess->GetMetadataIntVector2(key.GetCategory(), key.GetName())); + break; + case MetadataType::IntVector3: + MetadataContainer::SetMetadataIntVector3(key.GetCategory(), key.GetName(), metadataReadAccess->GetMetadataIntVector3(key.GetCategory(), key.GetName())); + break; + case MetadataType::IntVector4: + MetadataContainer::SetMetadataIntVector4(key.GetCategory(), key.GetName(), metadataReadAccess->GetMetadataIntVector4(key.GetCategory(), key.GetName())); + break; + case MetadataType::Float: + MetadataContainer::SetMetadataFloat(key.GetCategory(), key.GetName(), metadataReadAccess->GetMetadataFloat(key.GetCategory(), key.GetName())); + break; + case MetadataType::FloatVector2: + MetadataContainer::SetMetadataFloatVector2(key.GetCategory(), key.GetName(), metadataReadAccess->GetMetadataFloatVector2(key.GetCategory(), key.GetName())); + break; + case MetadataType::FloatVector3: + MetadataContainer::SetMetadataFloatVector3(key.GetCategory(), key.GetName(), metadataReadAccess->GetMetadataFloatVector3(key.GetCategory(), key.GetName())); + break; + case MetadataType::FloatVector4: + MetadataContainer::SetMetadataFloatVector4(key.GetCategory(), key.GetName(), metadataReadAccess->GetMetadataFloatVector4(key.GetCategory(), key.GetName())); + break; + case MetadataType::Double: + MetadataContainer::SetMetadataDouble(key.GetCategory(), key.GetName(), metadataReadAccess->GetMetadataDouble(key.GetCategory(), key.GetName())); + break; + case MetadataType::DoubleVector2: + MetadataContainer::SetMetadataDoubleVector2(key.GetCategory(), key.GetName(), metadataReadAccess->GetMetadataDoubleVector2(key.GetCategory(), key.GetName())); + break; + case MetadataType::DoubleVector3: + MetadataContainer::SetMetadataDoubleVector3(key.GetCategory(), key.GetName(), metadataReadAccess->GetMetadataDoubleVector3(key.GetCategory(), key.GetName())); + break; + case MetadataType::DoubleVector4: + MetadataContainer::SetMetadataDoubleVector4(key.GetCategory(), key.GetName(), metadataReadAccess->GetMetadataDoubleVector4(key.GetCategory(), key.GetName())); + break; + case MetadataType::String: + MetadataContainer::SetMetadataString(key.GetCategory(), key.GetName(), metadataReadAccess->GetMetadataString(key.GetCategory(), key.GetName())); + break; + case MetadataType::BLOB: + std::vector data; + metadataReadAccess->GetMetadataBLOB(key.GetCategory(), key.GetName(), data); + MetadataContainer::SetMetadataBLOB(key.GetCategory(), key.GetName(), data.data(), data.size()); + break; + } + } + } + } + + void ClearMetadata(const char* category, const char* name) override { std::unique_lock lock(m_mutex); m_dirty = true; return MetadataContainer::ClearMetadata(category, name); } + void ClearMetadata(const char* category) override { std::unique_lock lock(m_mutex); m_dirty = true; return MetadataContainer::ClearMetadata(category); } +}; + struct VDS { VDS(LogLevel level) @@ -78,7 +206,8 @@ struct VDS std::vector produceStatuses; - MetadataContainer metadataContainer; + VDSMetadataContainer + metadataContainer; std::unique_ptr volumeDataLayout; diff --git a/src/OpenVDS/VDS/VolumeDataStoreIOManager.cpp b/src/OpenVDS/VDS/VolumeDataStoreIOManager.cpp index 5ba790b7..a5dc1acc 100644 --- a/src/OpenVDS/VDS/VolumeDataStoreIOManager.cpp +++ b/src/OpenVDS/VDS/VolumeDataStoreIOManager.cpp @@ -897,6 +897,14 @@ bool VolumeDataStoreIOManager::Flush(bool writeUpdatedLayerStatus) m_vds.accessManager->AddUploadError(error, "LayerStatus"); return false; } + + if(m_vds.metadataContainer.IsDirty()) + { + if (!m_vds.volumeDataStore->WriteSerializedVolumeDataLayout(SerializeVolumeDataLayout(m_vds), error)) + return false; + + m_vds.metadataContainer.ClearDirtyFlag(); + } } return true; diff --git a/tests/OpenVDS/OpenVDSIntegrationTest.cpp b/tests/OpenVDS/OpenVDSIntegrationTest.cpp index a89ce44f..5a1c5654 100644 --- a/tests/OpenVDS/OpenVDSIntegrationTest.cpp +++ b/tests/OpenVDS/OpenVDSIntegrationTest.cpp @@ -16,6 +16,7 @@ ****************************************************************************/ #include +#include #include @@ -43,3 +44,62 @@ GTEST_TEST(OpenVDS_integration, OpenCloseVDSFile) OpenVDS::ScopedVDSHandle handle(OpenVDS::Open(OpenVDS::VDSFileOpenOptions(fileName), error)); ASSERT_TRUE(handle); } + +TEST(OpenVDS_integration, CreateAndModifyMetadata) +{ + const std::string + category = "Answers", + key = "LifeUniverseAndEverything"; + + const int + initialValue = 42, + modifiedValue = 2022; + + int negativeMargin = 4; + int positiveMargin = 4; + int brickSize2DMultiplier = 4; + auto LODLevels = OpenVDS::VolumeDataLayoutDescriptor::LODLevels_1; + auto layoutOptions = OpenVDS::VolumeDataLayoutDescriptor::Options_None; + OpenVDS::VolumeDataLayoutDescriptor layoutDescriptor(OpenVDS::VolumeDataLayoutDescriptor::BrickSize_32, negativeMargin, positiveMargin, brickSize2DMultiplier, LODLevels, layoutOptions); + + std::vector axisDescriptors; + axisDescriptors.emplace_back(100, "X", "", 1.0f, 100.f); + axisDescriptors.emplace_back(100, "Y", "", 1.f, 100.f); + axisDescriptors.emplace_back(100, "Z", "", 1.f, 100.f); + + std::vector channelDescriptors; + float rangeMin = 0.0f; + float rangeMax = 1.0f; + float integerScale = 0; + float integerOffset = 0; + channelDescriptors.push_back(OpenVDS::VolumeDataChannelDescriptor(OpenVDS::VolumeDataChannelDescriptor::Format_R32, OpenVDS::VolumeDataChannelDescriptor::Components_1, "", "", rangeMin, rangeMax, OpenVDS::VolumeDataMapping::Direct, 1, OpenVDS::VolumeDataChannelDescriptor::Default, 0.f, integerScale, integerOffset)); + + OpenVDS::MetadataContainer metadataContainer; + + metadataContainer.SetMetadataInt(category.c_str(), key.c_str(), initialValue); + + { + OpenVDS::Error error; + OpenVDS::ScopedVDSHandle handle = OpenVDS::Create("inmemory://CreateAndModifyMetadata", "", layoutDescriptor, axisDescriptors, channelDescriptors, metadataContainer, error); + + auto accessManager = OpenVDS::GetAccessManager(handle); + auto layout = accessManager.GetVolumeDataLayout(); + EXPECT_EQ(layout->GetMetadataInt(category.c_str(), key.c_str()), initialValue); + + auto metadataWriteAccess = OpenVDS::GetMetadataWriteAccessInterface(handle); + metadataWriteAccess->SetMetadataInt(category.c_str(), key.c_str(), modifiedValue); + + EXPECT_EQ(layout->GetMetadataInt(category.c_str(), key.c_str()), modifiedValue); + + accessManager.FlushUploadQueue(); + } + + { + OpenVDS::Error error; + OpenVDS::ScopedVDSHandle handle = OpenVDS::Open("inmemory://CreateAndModifyMetadata", "", error); + + auto accessManager = OpenVDS::GetAccessManager(handle); + auto layout = accessManager.GetVolumeDataLayout(); + EXPECT_EQ(layout->GetMetadataInt(category.c_str(), key.c_str()), modifiedValue); + } +} -- GitLab From 8f7cffd18fdad0c71250b50dabe282cf1e3f22c3 Mon Sep 17 00:00:00 2001 From: "morten.ofstad" Date: Wed, 24 Aug 2022 14:28:41 +0200 Subject: [PATCH 2/2] Update Java/Python API with the addition of GetMetadataWriteAccessInterface. --- java/cpp/src/OpenVDS.cpp | 16 ++ .../openvds/MetadataWriteAccess.java | 140 +++++++++++++++--- .../src/org/opengroup/openvds/OpenVDS.java | 13 ++ java/tools/javagen.py | 2 +- python/openvds/PyGlobal.cpp | 1 + python/openvds/generated_docstrings.h | 47 +++--- 6 files changed, 171 insertions(+), 48 deletions(-) diff --git a/java/cpp/src/OpenVDS.cpp b/java/cpp/src/OpenVDS.cpp index 4839d80c..7a699d7b 100644 --- a/java/cpp/src/OpenVDS.cpp +++ b/java/cpp/src/OpenVDS.cpp @@ -3125,6 +3125,22 @@ JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_OpenVDS_GetAccessManagerImpl return 0; } +JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_OpenVDS_GetMetadataWriteAccessInterfaceImpl + (JNIEnv * env, jclass cls, jlong handle) +{ + JNIEnvGuard + envGuard(env); + + CPPJNI_TRY + { + auto result = OpenVDS::GetMetadataWriteAccessInterface(CPPJNI_cast(handle)); + auto context = CPPJNI_createNonOwningObjectContext(result); + return context->handle(); + } + CPPJNI_CATCH + return 0; +} + JNIEXPORT jlong JNICALL Java_org_opengroup_openvds_OpenVDS_GetCompressionMethodImpl (JNIEnv * env, jclass cls, jlong handle) { diff --git a/java/java/src/org/opengroup/openvds/MetadataWriteAccess.java b/java/java/src/org/opengroup/openvds/MetadataWriteAccess.java index 2766b12d..e95b6e22 100644 --- a/java/java/src/org/opengroup/openvds/MetadataWriteAccess.java +++ b/java/java/src/org/opengroup/openvds/MetadataWriteAccess.java @@ -26,104 +26,208 @@ import java.nio.ByteBuffer; * Interface for write access to Metadata * */ -public interface MetadataWriteAccess { +public class MetadataWriteAccess extends ManagedBase { + + ///AUTOGEN-OK: CXX_METHOD SetMetadataInt void (const char *, const char *, int) FUNCTIONPROTO + native private void SetMetadataIntImpl(long native_object, String category, String name, int value); /** * Sets a metadata int with the given category and name to the given value * */ - public void setMetadataInt(String category, String name, int value); + public void setMetadataInt(String category, String name, int value) { + SetMetadataIntImpl(getNativeObject(), ManagedBase.requireNonNull(category, "category may not be null"), ManagedBase.requireNonNull(name, "name may not be null"), value); + } + + ///AUTOGEN-OK: CXX_METHOD SetMetadataIntVector2 void (const char *, const char *, OpenVDS::Vector) FUNCTIONPROTO + native private void SetMetadataIntVector2Impl(long native_object, String category, String name, ByteBuffer value, long value_byteoffset); /** * Sets a metadata IntVector2 with the given category and name to the given value * */ - public void setMetadataIntVector2(String category, String name, IntVector2 value); + public void setMetadataIntVector2(String category, String name, IntVector2 value) { + SetMetadataIntVector2Impl(getNativeObject(), ManagedBase.requireNonNull(category, "category may not be null"), ManagedBase.requireNonNull(name, "name may not be null"), ManagedBase.requireNonNull(value, "value may not be null").getBackingByteBuffer(), ManagedBase.requireNonNull(value, "value may not be null").getByteBufferOffset()); + } + + ///AUTOGEN-OK: CXX_METHOD SetMetadataIntVector3 void (const char *, const char *, OpenVDS::Vector) FUNCTIONPROTO + native private void SetMetadataIntVector3Impl(long native_object, String category, String name, ByteBuffer value, long value_byteoffset); /** * Sets a metadata IntVector3 with the given category and name to the given value * */ - public void setMetadataIntVector3(String category, String name, IntVector3 value); + public void setMetadataIntVector3(String category, String name, IntVector3 value) { + SetMetadataIntVector3Impl(getNativeObject(), ManagedBase.requireNonNull(category, "category may not be null"), ManagedBase.requireNonNull(name, "name may not be null"), ManagedBase.requireNonNull(value, "value may not be null").getBackingByteBuffer(), ManagedBase.requireNonNull(value, "value may not be null").getByteBufferOffset()); + } + + ///AUTOGEN-OK: CXX_METHOD SetMetadataIntVector4 void (const char *, const char *, OpenVDS::Vector) FUNCTIONPROTO + native private void SetMetadataIntVector4Impl(long native_object, String category, String name, ByteBuffer value, long value_byteoffset); /** * Sets a metadata IntVector4 with the given category and name to the given value * */ - public void setMetadataIntVector4(String category, String name, IntVector4 value); + public void setMetadataIntVector4(String category, String name, IntVector4 value) { + SetMetadataIntVector4Impl(getNativeObject(), ManagedBase.requireNonNull(category, "category may not be null"), ManagedBase.requireNonNull(name, "name may not be null"), ManagedBase.requireNonNull(value, "value may not be null").getBackingByteBuffer(), ManagedBase.requireNonNull(value, "value may not be null").getByteBufferOffset()); + } + + ///AUTOGEN-OK: CXX_METHOD SetMetadataFloat void (const char *, const char *, float) FUNCTIONPROTO + native private void SetMetadataFloatImpl(long native_object, String category, String name, float value); /** * Sets a metadata float with the given category and name to the given value * */ - public void setMetadataFloat(String category, String name, float value); + public void setMetadataFloat(String category, String name, float value) { + SetMetadataFloatImpl(getNativeObject(), ManagedBase.requireNonNull(category, "category may not be null"), ManagedBase.requireNonNull(name, "name may not be null"), value); + } + + ///AUTOGEN-OK: CXX_METHOD SetMetadataFloatVector2 void (const char *, const char *, OpenVDS::Vector) FUNCTIONPROTO + native private void SetMetadataFloatVector2Impl(long native_object, String category, String name, ByteBuffer value, long value_byteoffset); /** * Sets a metadata FloatVector2 with the given category and name to the given value * */ - public void setMetadataFloatVector2(String category, String name, FloatVector2 value); + public void setMetadataFloatVector2(String category, String name, FloatVector2 value) { + SetMetadataFloatVector2Impl(getNativeObject(), ManagedBase.requireNonNull(category, "category may not be null"), ManagedBase.requireNonNull(name, "name may not be null"), ManagedBase.requireNonNull(value, "value may not be null").getBackingByteBuffer(), ManagedBase.requireNonNull(value, "value may not be null").getByteBufferOffset()); + } + + ///AUTOGEN-OK: CXX_METHOD SetMetadataFloatVector3 void (const char *, const char *, OpenVDS::Vector) FUNCTIONPROTO + native private void SetMetadataFloatVector3Impl(long native_object, String category, String name, ByteBuffer value, long value_byteoffset); /** * Sets a metadata FloatVector3 with the given category and name to the given value * */ - public void setMetadataFloatVector3(String category, String name, FloatVector3 value); + public void setMetadataFloatVector3(String category, String name, FloatVector3 value) { + SetMetadataFloatVector3Impl(getNativeObject(), ManagedBase.requireNonNull(category, "category may not be null"), ManagedBase.requireNonNull(name, "name may not be null"), ManagedBase.requireNonNull(value, "value may not be null").getBackingByteBuffer(), ManagedBase.requireNonNull(value, "value may not be null").getByteBufferOffset()); + } + + ///AUTOGEN-OK: CXX_METHOD SetMetadataFloatVector4 void (const char *, const char *, OpenVDS::Vector) FUNCTIONPROTO + native private void SetMetadataFloatVector4Impl(long native_object, String category, String name, ByteBuffer value, long value_byteoffset); /** * Sets a metadata FloatVector4 with the given category and name to the given value * */ - public void setMetadataFloatVector4(String category, String name, FloatVector4 value); + public void setMetadataFloatVector4(String category, String name, FloatVector4 value) { + SetMetadataFloatVector4Impl(getNativeObject(), ManagedBase.requireNonNull(category, "category may not be null"), ManagedBase.requireNonNull(name, "name may not be null"), ManagedBase.requireNonNull(value, "value may not be null").getBackingByteBuffer(), ManagedBase.requireNonNull(value, "value may not be null").getByteBufferOffset()); + } + + ///AUTOGEN-OK: CXX_METHOD SetMetadataDouble void (const char *, const char *, double) FUNCTIONPROTO + native private void SetMetadataDoubleImpl(long native_object, String category, String name, double value); /** * Sets a metadata double with the given category and name to the given value * */ - public void setMetadataDouble(String category, String name, double value); + public void setMetadataDouble(String category, String name, double value) { + SetMetadataDoubleImpl(getNativeObject(), ManagedBase.requireNonNull(category, "category may not be null"), ManagedBase.requireNonNull(name, "name may not be null"), value); + } + + ///AUTOGEN-OK: CXX_METHOD SetMetadataDoubleVector2 void (const char *, const char *, OpenVDS::Vector) FUNCTIONPROTO + native private void SetMetadataDoubleVector2Impl(long native_object, String category, String name, ByteBuffer value, long value_byteoffset); /** * Sets a metadata DoubleVector2 with the given category and name to the given value * */ - public void setMetadataDoubleVector2(String category, String name, DoubleVector2 value); + public void setMetadataDoubleVector2(String category, String name, DoubleVector2 value) { + SetMetadataDoubleVector2Impl(getNativeObject(), ManagedBase.requireNonNull(category, "category may not be null"), ManagedBase.requireNonNull(name, "name may not be null"), ManagedBase.requireNonNull(value, "value may not be null").getBackingByteBuffer(), ManagedBase.requireNonNull(value, "value may not be null").getByteBufferOffset()); + } + + ///AUTOGEN-OK: CXX_METHOD SetMetadataDoubleVector3 void (const char *, const char *, OpenVDS::Vector) FUNCTIONPROTO + native private void SetMetadataDoubleVector3Impl(long native_object, String category, String name, ByteBuffer value, long value_byteoffset); /** * Sets a metadata DoubleVector3 with the given category and name to the given value * */ - public void setMetadataDoubleVector3(String category, String name, DoubleVector3 value); + public void setMetadataDoubleVector3(String category, String name, DoubleVector3 value) { + SetMetadataDoubleVector3Impl(getNativeObject(), ManagedBase.requireNonNull(category, "category may not be null"), ManagedBase.requireNonNull(name, "name may not be null"), ManagedBase.requireNonNull(value, "value may not be null").getBackingByteBuffer(), ManagedBase.requireNonNull(value, "value may not be null").getByteBufferOffset()); + } + + ///AUTOGEN-OK: CXX_METHOD SetMetadataDoubleVector4 void (const char *, const char *, OpenVDS::Vector) FUNCTIONPROTO + native private void SetMetadataDoubleVector4Impl(long native_object, String category, String name, ByteBuffer value, long value_byteoffset); /** * Sets a metadata DoubleVector4 with the given category and name to the given value * */ - public void setMetadataDoubleVector4(String category, String name, DoubleVector4 value); + public void setMetadataDoubleVector4(String category, String name, DoubleVector4 value) { + SetMetadataDoubleVector4Impl(getNativeObject(), ManagedBase.requireNonNull(category, "category may not be null"), ManagedBase.requireNonNull(name, "name may not be null"), ManagedBase.requireNonNull(value, "value may not be null").getBackingByteBuffer(), ManagedBase.requireNonNull(value, "value may not be null").getByteBufferOffset()); + } + + ///AUTOGEN-OK: CXX_METHOD SetMetadataString void (const char *, const char *, const char *) FUNCTIONPROTO + native private void SetMetadataStringImpl(long native_object, String category, String name, String value); /** * Sets a metadata string with the given category and name to the given value * */ - public void setMetadataString(String category, String name, String value); + public void setMetadataString(String category, String name, String value) { + SetMetadataStringImpl(getNativeObject(), ManagedBase.requireNonNull(category, "category may not be null"), ManagedBase.requireNonNull(name, "name may not be null"), ManagedBase.requireNonNull(value, "value may not be null")); + } + + ///AUTOGEN-OK: CXX_METHOD SetMetadataBLOB void (const char *, const char *, const void *, uint64_t) FUNCTIONPROTO + native private void SetMetadataBLOBImpl(long native_object, String category, String name, ByteBuffer data); /** * Sets a metadata BLOB with the given category and name to the given value * */ - public void setMetadataBLOB(String category, String name, ByteBuffer data); - public void copyMetadata(String category, MetadataReadAccess metadataReadAccess); + public void setMetadataBLOB(String category, String name, ByteBuffer data) { + SetMetadataBLOBImpl(getNativeObject(), ManagedBase.requireNonNull(category, "category may not be null"), ManagedBase.requireNonNull(name, "name may not be null"), ManagedBuffer.ensureByteBufferValid(data)); + } + + ///AUTOGEN-OK: CXX_METHOD CopyMetadata void (const char *, const OpenVDS::MetadataReadAccess *) FUNCTIONPROTO + native private void CopyMetadataImpl(long native_object, String category, long metadataReadAccess); + public void copyMetadata(String category, MetadataReadAccess metadataReadAccess) { + CopyMetadataImpl(getNativeObject(), ManagedBase.requireNonNull(category, "category may not be null"), ManagedBase.requireNonNull(metadataReadAccess, "metadataReadAccess may not be null").getNativeObject()); + } + + ///AUTOGEN-OK: CXX_METHOD ClearMetadata void (const char *, const char *) FUNCTIONPROTO + native private void ClearMetadataImpl(long native_object, String category, String name); /** * Clear the metadata with the given category and name * */ - public void clearMetadata(String category, String name); + public void clearMetadata(String category, String name) { + ClearMetadataImpl(getNativeObject(), ManagedBase.requireNonNull(category, "category may not be null"), ManagedBase.requireNonNull(name, "name may not be null")); + } + + ///AUTOGEN-OK: CXX_METHOD ClearMetadata void (const char *) FUNCTIONPROTO + native private void ClearMetadata2Impl(long native_object, String category); /** * Clear the metadata with the given category * */ - public void clearMetadata(String category); + public void clearMetadata(String category) { + ClearMetadata2Impl(getNativeObject(), ManagedBase.requireNonNull(category, "category may not be null")); + } + + MetadataWriteAccess(long nativeobject) { + super(nativeobject); + } + native private long dtorImpl(long nativeobject, boolean isDisposing); + + @Override + protected void onDisposing(long native_object, boolean isDisposing) { + dtorImpl(native_object, isDisposing); + } + + static MetadataWriteAccess fromNativeObject(long nativeobject) { + if (nativeobject == 0) { + return null; + } + return new MetadataWriteAccess(nativeobject); + } + + } diff --git a/java/java/src/org/opengroup/openvds/OpenVDS.java b/java/java/src/org/opengroup/openvds/OpenVDS.java index 6f2616ec..ed62302c 100644 --- a/java/java/src/org/opengroup/openvds/OpenVDS.java +++ b/java/java/src/org/opengroup/openvds/OpenVDS.java @@ -592,6 +592,19 @@ Available schemes are s3:// azure:// return VolumeDataAccessManager.fromNativeObject(GetAccessManagerImpl(ManagedBase.requireNonNull(handle, "handle may not be null").getNativeObject())); } + ///AUTOGEN-OK: FUNCTION_DECL GetMetadataWriteAccessInterface OpenVDS::MetadataWriteAccess *(OpenVDS::VDS *) FUNCTIONPROTO + native private static long GetMetadataWriteAccessInterfaceImpl(long handle); + + /** + * Get the MetadataWriteAccess interface for a VDS + * + * @param handle The handle of the VDS + * @return The MetadataWriteAccess interface of the VDS + */ + public static MetadataWriteAccess getMetadataWriteAccessInterface(VDS handle) { + return MetadataWriteAccess.fromNativeObject(GetMetadataWriteAccessInterfaceImpl(ManagedBase.requireNonNull(handle, "handle may not be null").getNativeObject())); + } + ///AUTOGEN-OK: FUNCTION_DECL GetCompressionMethod OpenVDS::CompressionMethod (OpenVDS::VDS *) FUNCTIONPROTO native private static long GetCompressionMethodImpl(long handle); diff --git a/java/tools/javagen.py b/java/tools/javagen.py index 2a7f02ce..bf2591e0 100644 --- a/java/tools/javagen.py +++ b/java/tools/javagen.py @@ -181,7 +181,7 @@ _bytebuffer_backed = { _interfaces = { # "OpenVDS::MetadataReadAccess", - "OpenVDS::MetadataWriteAccess", +# "OpenVDS::MetadataWriteAccess", } _smart_ptr_types = [ diff --git a/python/openvds/PyGlobal.cpp b/python/openvds/PyGlobal.cpp index 45e23dcc..7252557a 100644 --- a/python/openvds/PyGlobal.cpp +++ b/python/openvds/PyGlobal.cpp @@ -278,6 +278,7 @@ PyGlobal::initModule(py::module& m) m.def("getLayout" , static_cast(&GetLayout), py::arg("handle").none(false), py::call_guard(), OPENVDS_DOCSTRING(GetLayout)); m.def("getAccessManagerInterface" , static_cast(&GetAccessManagerInterface), py::arg("handle").none(false), py::call_guard(), OPENVDS_DOCSTRING(GetAccessManagerInterface)); m.def("getAccessManager" , static_cast(&GetAccessManager), py::arg("handle").none(false), py::call_guard(), OPENVDS_DOCSTRING(GetAccessManager)); + m.def("getMetadataWriteAccessInterface", static_cast(&GetMetadataWriteAccessInterface), py::arg("handle").none(false), py::call_guard(), OPENVDS_DOCSTRING(GetMetadataWriteAccessInterface)); m.def("getCompressionMethod" , static_cast(&GetCompressionMethod), py::arg("handle").none(false), py::call_guard(), OPENVDS_DOCSTRING(GetCompressionMethod)); m.def("getCompressionTolerance" , static_cast(&GetCompressionTolerance), py::arg("handle").none(false), py::call_guard(), OPENVDS_DOCSTRING(GetCompressionTolerance)); m.def("close" , static_cast(&Close), py::arg("handle").none(false), py::call_guard(), OPENVDS_DOCSTRING(Close)); diff --git a/python/openvds/generated_docstrings.h b/python/openvds/generated_docstrings.h index 79651bb5..bd873ac4 100644 --- a/python/openvds/generated_docstrings.h +++ b/python/openvds/generated_docstrings.h @@ -998,6 +998,19 @@ Returns: -------- The VolumeDataLayout of the VDS)doc"; +static const char *__doc_OpenVDS_GetMetadataWriteAccessInterface = +R"doc(Get the MetadataWriteAccess interface for a VDS + +Parameters: +----------- + +handle : + The handle of the VDS + +Returns: +-------- + The MetadataWriteAccess interface of the VDS)doc"; + static const char *__doc_OpenVDS_GetOpenVDSInterface = R"doc()doc"; static const char *__doc_OpenVDS_GetOpenVDSName = @@ -2529,28 +2542,16 @@ static const char *__doc_OpenVDS_Length_2 = R"doc()doc"; static const char *__doc_OpenVDS_LogLevel = R"doc()doc"; -static const char *__doc_OpenVDS_LogLevel_2 = R"doc()doc"; - static const char *__doc_OpenVDS_LogLevel_Error = R"doc()doc"; -static const char *__doc_OpenVDS_LogLevel_Error_2 = R"doc()doc"; - static const char *__doc_OpenVDS_LogLevel_Info = R"doc()doc"; -static const char *__doc_OpenVDS_LogLevel_Info_2 = R"doc()doc"; - static const char *__doc_OpenVDS_LogLevel_None = R"doc()doc"; -static const char *__doc_OpenVDS_LogLevel_None_2 = R"doc()doc"; - static const char *__doc_OpenVDS_LogLevel_Trace = R"doc()doc"; -static const char *__doc_OpenVDS_LogLevel_Trace_2 = R"doc()doc"; - static const char *__doc_OpenVDS_LogLevel_Warning = R"doc()doc"; -static const char *__doc_OpenVDS_LogLevel_Warning_2 = R"doc()doc"; - static const char *__doc_OpenVDS_M4 = R"doc()doc"; static const char *__doc_OpenVDS_M4_data = R"doc()doc"; @@ -2880,6 +2881,8 @@ static const char *__doc_OpenVDS_MetadataType_String = R"doc()doc"; static const char *__doc_OpenVDS_MetadataWriteAccess = R"doc(Interface for write access to Metadata)doc"; +static const char *__doc_OpenVDS_MetadataWriteAccess_2 = R"doc()doc"; + static const char *__doc_OpenVDS_MetadataWriteAccess_ClearMetadata = R"doc()doc"; static const char *__doc_OpenVDS_MetadataWriteAccess_ClearMetadata_2 = R"doc()doc"; @@ -3110,6 +3113,8 @@ static const char *__doc_OpenVDS_OpenVDSInterface_GetGlobalState = R"doc()doc"; static const char *__doc_OpenVDS_OpenVDSInterface_GetLayout = R"doc()doc"; +static const char *__doc_OpenVDS_OpenVDSInterface_GetMetadataWriteAccessInterface = R"doc()doc"; + static const char *__doc_OpenVDS_OpenVDSInterface_IsCompressionMethodSupported = R"doc()doc"; static const char *__doc_OpenVDS_OpenVDSInterface_IsSupportedProtocol = R"doc()doc"; @@ -3130,20 +3135,6 @@ static const char *__doc_OpenVDS_OpenVDSInterface_RetryableClose = R"doc()doc"; static const char *__doc_OpenVDS_OpenVDSInterface_RetryableClose_2 = R"doc()doc"; -static const char *__doc_OpenVDS_OpenVDSLogging = -R"doc(The OpenVDS Logging interface is used to provide a callback for -applications to get logging output from the library)doc"; - -static const char *__doc_OpenVDS_OpenVDSLogging_OpenVDSLogging = R"doc()doc"; - -static const char *__doc_OpenVDS_OpenVDSLogging_OpenVDSLogging_2 = R"doc()doc"; - -static const char *__doc_OpenVDS_OpenVDSLogging_callback = R"doc()doc"; - -static const char *__doc_OpenVDS_OpenVDSLogging_level = R"doc()doc"; - -static const char *__doc_OpenVDS_OpenVDSLogging_userHandle = R"doc()doc"; - static const char *__doc_OpenVDS_OpenVDSVersioningInterface = R"doc(The OpenVDS versioning interface is a stable base class for the OpenVDS global interface that can be used to check what version of the @@ -4522,9 +4513,7 @@ static const char *__doc_OpenVDS_VolumeDataAccessManager_m_IVolumeDataAccessMana static const char *__doc_OpenVDS_VolumeDataAccessManager_operator_assign = R"doc()doc"; -static const char *__doc_OpenVDS_VolumeDataAxisDescriptor = -R"doc(Describes the number of samples, name, unit and coordinates -(annotation) of an axis (dimension) of the volume)doc"; +static const char *__doc_OpenVDS_VolumeDataAxisDescriptor = R"doc()doc"; static const char *__doc_OpenVDS_VolumeDataAxisDescriptor_2 = R"doc()doc"; -- GitLab