Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VOL refactor and cleanup #4856

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 0 additions & 56 deletions doxygen/dox/VOLConnGuide.dox
Original file line number Diff line number Diff line change
Expand Up @@ -4110,62 +4110,6 @@ Retrieves a pointer to the VOL object from an HDF5 file or object identifier.
Returns a copy of the <em>dtype_id</em> parameter but with the location set to be in the file. Returns a negative
value (#H5I_INVALID_HID) on errors.

\subsubsection subsubsecVOLNewConnpeek_name H5VLpeek_connector_id_by_name
<table>
<tr>
<th>Signature:</th>
</tr>
<tr>
<td>
\code
hid_t H5VLpeek_connector_id_by_name(const char *name);
\endcode
</td>
</tr>
<tr>
<th>Arguments:</th>
</tr>
<tr>
<td>
\code
name (IN): name of the connector to query.
\endcode
</td>
</tr>
</table>
Retrieves the ID for a registered VOL connector based on a connector name. This is done without duplicating
the ID and transferring ownership to the caller (as it normally the case in the HDF5 library). The ID returned
from this operation should not be closed. This is intended for use by VOL connectors to find their own ID.
Returns a negative value (#H5I_INVALID_HID) on errors.

\subsubsection subsubsecVOLNewConnpeek_value H5VLpeek_connector_id_by_value
<table>
<tr>
<th>Signature:</th>
</tr>
<tr>
<td>
\code
hid_t H5VLpeek_connector_id_by_value(H5VL_class_value_t value);
\endcode
</td>
</tr>
<tr>
<th>Arguments:</th>
</tr>
<tr>
<td>
\code
value (IN): value of the connector to query.
\endcode
</td>
</tr>
</table>
Retrieves the ID for a registered VOL connector based on a connector value. This is done without duplicating
the ID and transferring ownership to the caller (as it normally the case in the HDF5 library). The ID returned
from this operation should not be closed. This is intended for use by VOL connectors to find their own ID.
Returns a negative value (#H5I_INVALID_HID) on errors.

\subsection subsecVOLNewPass H5VLconnector_passthru.h
This functionality is intended for VOL connector authors who are writing pass-through connectors and
includes helper functions that are useful for writing such connectors. Callback equivalent functions can be
Expand Down
35 changes: 35 additions & 0 deletions fortran/src/H5VLff.F90
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,41 @@ END FUNCTION H5VLunregister_connector

END SUBROUTINE H5VLunregister_connector_f

!>
!! \ingroup FH5VL
!!
!! \brief Determines whether two connector identifiers refer to the same connector.
!!
!! \param conn_id1 A valid identifier of the first connector to check
!! \param conn_id2 A valid identifier of the second connector to check
!! \param are_same Whether connector IDs refer to the same connector
!! \param hdferr \fortran_error
!!
!! See C API: @ref H5VLcmp_connector_cls()
!!
SUBROUTINE H5VLcmp_connector_cls_f(are_same, conn_id1, conn_id2, hdferr)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This routine is necessary because it's possible to have VOL connector IDs that are different, but point to the same underlying VOL connector class.

IMPLICIT NONE
LOGICAL, INTENT(OUT) :: are_same
INTEGER(HID_T), INTENT(IN) :: conn_id1
INTEGER(HID_T), INTENT(IN) :: conn_id2
INTEGER, INTENT(OUT) :: hdferr
INTEGER :: are_same_c

INTERFACE
INTEGER(C_INT) FUNCTION H5VLcmp_connector_cls(cmp_value, conn_id1, conn_id2) BIND(C, NAME='H5VLcmp_connector_cls')
IMPORT :: HID_T, C_INT
INTEGER(C_INT), INTENT(OUT) :: cmp_value
INTEGER(HID_T), VALUE :: conn_id1
INTEGER(HID_T), VALUE :: conn_id2
END FUNCTION H5VLcmp_connector_cls
END INTERFACE

are_same = .FALSE.
hdferr = INT(H5VLcmp_connector_cls(are_same_c, conn_id1, conn_id2))
IF(are_same_c .EQ. 0) are_same = .TRUE.

END SUBROUTINE H5VLcmp_connector_cls_f

!>
!! \ingroup FH5VL
!!
Expand Down
1 change: 1 addition & 0 deletions fortran/src/hdf5_fortrandll.def.in
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ H5VL_mp_H5VLGET_CONNECTOR_ID_BY_NAME_F
H5VL_mp_H5VLGET_CONNECTOR_ID_BY_VALUE_F
H5VL_mp_H5VLGET_CONNECTOR_NAME_F
H5VL_mp_H5VLCLOSE_F
H5VL_mp_H5VLCMP_CONNECTOR_CLS_F
H5VL_mp_H5VLUNREGISTER_CONNECTOR_F
H5VL_mp_H5VLNATIVE_ADDR_TO_TOKEN_F
H5VL_mp_H5VLNATIVE_TOKEN_TO_ADDR_F
Expand Down
17 changes: 13 additions & 4 deletions fortran/test/vol_connector.F90
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ SUBROUTINE test_registration_by_fapl(total_error)
INTEGER(hid_t) :: file_id
INTEGER(hid_t) :: fapl_id
TYPE(C_PTR) :: f_ptr
LOGICAL :: are_same = .FALSE.

CALL H5VLis_connector_registered_by_name_f( "FAKE_VOL_CONNECTOR_NAME", is_registered, error)

Expand Down Expand Up @@ -189,22 +190,30 @@ SUBROUTINE test_registration_by_fapl(total_error)

CALL H5Pget_vol_id_f(fapl_id, vol_id_out, error)
CALL check("H5Pget_vol_id_f",error,total_error)
CALL VERIFY("H5Pget_vol_id_f", vol_id_out, vol_id, total_error)
CALL H5VLcmp_connector_cls_f(are_same, vol_id, vol_id_out, error)
CALL check("H5VLcmp_connector_cls_f",error,total_error)
CALL VERIFY("H5VLcmp_connector_cls_f", are_same, .TRUE., total_error)

f_ptr = C_NULL_PTR
CALL H5Pset_vol_f(fapl_id, vol_id, error, f_ptr)
CALL check("H5Pset_vol_f",error,total_error)

CALL H5Pget_vol_id_f(fapl_id, vol_id_out, error)
CALL check("H5Pget_vol_id_f",error,total_error)
CALL VERIFY("H5Pget_vol_id_f", vol_id_out, vol_id, total_error)
are_same = .FALSE.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use new routine instead of directly comparing IDs.

CALL H5VLcmp_connector_cls_f(are_same, vol_id, vol_id_out, error)
CALL check("H5VLcmp_connector_cls_f",error,total_error)
CALL VERIFY("H5VLcmp_connector_cls_f", are_same, .TRUE., total_error)
ENDIF

CALL H5VLget_connector_id_by_name_f(NATIVE_VOL_CONNECTOR_NAME, vol_id_out, error)
CALL check("H5VLget_connector_id_by_name_f",error,total_error)
CALL VERIFY("H5VLget_connector_id_by_name_f", vol_id_out, vol_id, total_error)
CALL H5Fcreate_f("voltest.h5",H5F_ACC_TRUNC_F, file_id, error, H5P_DEFAULT_F, fapl_id)
are_same = .FALSE.
CALL H5VLcmp_connector_cls_f(are_same, vol_id, vol_id_out, error)
CALL check("H5VLcmp_connector_cls_f",error,total_error)
CALL VERIFY("H5VLcmp_connector_cls_f", are_same, .TRUE., total_error)

CALL H5Fcreate_f("voltest.h5",H5F_ACC_TRUNC_F, file_id, error, H5P_DEFAULT_F, fapl_id)
CALL check("H5F_create_f",error,total_error)

CALL H5VLclose_f(vol_id_out, error)
Expand Down
18 changes: 18 additions & 0 deletions java/src/hdf/hdf5lib/H5.java
Original file line number Diff line number Diff line change
Expand Up @@ -15497,6 +15497,24 @@ public synchronized static native String H5VLget_connector_name(long object_id)
public synchronized static native void H5VLunregister_connector(long connector_id)
throws HDF5LibraryException;

/**
* @ingroup JH5VL
*
* H5VLcmp_connector_cls Determines whether two connector identifiers refer to the same connector.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This routine is necessary because it's possible to have VOL connector IDs that are different, but point to the same underlying VOL connector class.

*
* @param conn_id1
* IN: Identifier of connector to compare.
* @param conn_id2
* IN: Identifier of connector to compare.
*
* @return true if the connector identifiers refer to the same connector, else false.
*
* @exception HDF5LibraryException
* Error from the HDF5 Library.
**/
public synchronized static native boolean H5VLcmp_connector_cls(long conn_id1, long conn_id2)
throws HDF5LibraryException;

// /////// unimplemented ////////
// hid_t H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id);

Expand Down
2 changes: 1 addition & 1 deletion java/src/jni/h5Constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -3500,7 +3500,7 @@ Java_hdf_hdf5lib_HDF5Constants_H5VL_1CAP_1FLAG_1THREADSAFE(JNIEnv *env, jclass c
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE(JNIEnv *env, jclass cls)
{
return H5VL_NATIVE;
return H5VLget_connector_id_by_value(H5VL_NATIVE_VALUE);
}
JNIEXPORT jobject JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE_1NAME(JNIEnv *env, jclass cls)
Expand Down
24 changes: 24 additions & 0 deletions java/src/jni/h5vlImp.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extern "C" {
#include "hdf5.h"
#include "h5jni.h"
#include "h5vlImp.h"
#include "H5VLconnector_passthru.h"

/*
* Class: hdf_hdf5lib_H5
Expand Down Expand Up @@ -272,6 +273,29 @@ Java_hdf_hdf5lib_H5_H5VLunregister_1connector(JNIEnv *env, jclass clss, jlong co
return;
} /* end Java_hdf_hdf5lib_H5_H5VLunregister_1connector */

/*
* Class: hdf_hdf5lib_H5
* Method: H5VLcmp_connector_cls
* Signature: (JJ)Z
*/
JNIEXPORT jboolean JNICALL
Java_hdf_hdf5lib_H5_H5VLcmp_1connector_1cls(JNIEnv *env, jclass clss, jlong conn_id1, jlong conn_id2)
{
int cmp_value = 0;
jboolean bval = JNI_FALSE;
herr_t retValue = FAIL;

UNUSED(clss);

if ((retValue = H5VLcmp_connector_cls(&cmp_value, (hid_t)conn_id1, (hid_t)conn_id2)) < 0)
H5_LIBRARY_ERROR(ENVONLY);

bval = (cmp_value == 0) ? JNI_TRUE : JNI_FALSE;

done:
return bval;
} /* end Java_hdf_hdf5lib_H5_H5VLcmp_connector_cls */

#ifdef __cplusplus
} /* end extern "C" */
#endif /* __cplusplus */
7 changes: 7 additions & 0 deletions java/src/jni/h5vlImp.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5VLclose(JNIEnv *, jclass, jlong);
*/
JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5VLunregister_1connector(JNIEnv *, jclass, jlong);

/*
* Class: hdf_hdf5lib_H5
* Method: H5VLcmp_connector_cls
* Signature: (JJ)Z
*/
JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5VLcmp_1connector_1cls(JNIEnv *, jclass, jlong, jlong);

#ifdef __cplusplus
} /* end extern "C" */
#endif /* __cplusplus */
Expand Down
9 changes: 6 additions & 3 deletions java/test/TestH5VL.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public void testH5VLget_connector_id()
*/
String connector = System.getenv("HDF5_VOL_CONNECTOR");
if (connector == null)
assertEquals(HDF5Constants.H5VL_NATIVE, native_id);
assertTrue("H5.H5VLcmp_connector_cls(H5VL_NATIVE_NAME, native_id)",
H5.H5VLcmp_connector_cls(HDF5Constants.H5VL_NATIVE, native_id));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use new routine instead of directly comparing IDs.

}
catch (Throwable err) {
err.printStackTrace();
Expand All @@ -122,7 +123,8 @@ public void testH5VLget_connector_id_by_name()
try {
long native_id = H5.H5VLget_connector_id_by_name(HDF5Constants.H5VL_NATIVE_NAME);
assertTrue("H5.H5VLget_connector_id_by_name H5VL_NATIVE_NAME", native_id >= 0);
assertEquals(HDF5Constants.H5VL_NATIVE, native_id);
assertTrue("H5.H5VLcmp_connector_cls(H5VL_NATIVE_NAME, native_id)",
H5.H5VLcmp_connector_cls(HDF5Constants.H5VL_NATIVE, native_id));
}
catch (Throwable err) {
err.printStackTrace();
Expand All @@ -136,7 +138,8 @@ public void testH5VLget_connector_id_by_value()
try {
long native_id = H5.H5VLget_connector_id_by_value(HDF5Constants.H5VL_NATIVE_VALUE);
assertTrue("H5.H5VLget_connector_id_by_value H5VL_NATIVE_VALUE", native_id >= 0);
assertEquals(HDF5Constants.H5VL_NATIVE, native_id);
assertTrue("H5.H5VLcmp_connector_cls(H5VL_NATIVE_NAME, native_id)",
H5.H5VLcmp_connector_cls(HDF5Constants.H5VL_NATIVE, native_id));
}
catch (Throwable err) {
err.printStackTrace();
Expand Down
Loading
Loading