1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* For details of the HDF libraries, see the HDF Documentation at:
* http://hdfgroup.org/HDF5/doc/
*
*/
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hdf5.h"
#include "h5util.h"
#include "h5dImp.h"
extern JavaVM *jvm;
extern jobject visit_callback;
#ifdef __cplusplus
#ifdef _WINDOWS
#include <direct.h>
#endif
#define CBENVPTR (cbenv)
#define CBENVPAR
#define JVMPTR (jvm)
#define JVMPAR
#define JVMPAR2
#else
#define CBENVPTR (*cbenv)
#define CBENVPAR cbenv,
#define JVMPTR (*jvm)
#define JVMPAR jvm
#define JVMPAR2 jvm,
#endif
/********************/
/* Local Prototypes */
/********************/
static herr_t H5DreadVL_asstr (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf);
static herr_t H5DreadVL_str (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf);
static herr_t H5DreadVL_array (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf);
static herr_t H5DwriteVL_asstr (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf);
static herr_t H5DwriteVL_str (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf);
static herr_t H5DwriteVL_array (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf);
/********************/
/* Local Macros */
/********************/
#define PIN_BYTE_ARRAY() { \
if (isCriticalPinning) \
buffP = (jbyte*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \
else \
buffP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy); \
}
#define UNPIN_BYTE_ARRAY(mode) { \
if (isCriticalPinning) \
ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \
else \
ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, mode); \
}
#define PIN_SHORT_ARRAY() { \
if (isCriticalPinning) \
buffP = (jshort*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \
else \
buffP = ENVPTR->GetShortArrayElements(ENVPAR buf, &isCopy); \
}
#define UNPIN_SHORT_ARRAY(mode) { \
if (isCriticalPinning) \
ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \
else \
ENVPTR->ReleaseShortArrayElements(ENVPAR buf, buffP, mode); \
}
#define PIN_INT_ARRAY() { \
if (isCriticalPinning) \
buffP = (jint*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \
else \
buffP = ENVPTR->GetIntArrayElements(ENVPAR buf, &isCopy); \
}
#define UNPIN_INT_ARRAY(mode) { \
if (isCriticalPinning) \
ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \
else \
ENVPTR->ReleaseIntArrayElements(ENVPAR buf, buffP, mode); \
}
#define PIN_LONG_ARRAY() { \
if (isCriticalPinning) \
buffP = (jlong*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \
else \
buffP = ENVPTR->GetLongArrayElements(ENVPAR buf,&isCopy); \
}
#define UNPIN_LONG_ARRAY(mode) { \
if (isCriticalPinning) \
ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \
else \
ENVPTR->ReleaseLongArrayElements(ENVPAR buf, buffP, mode); \
}
#define PIN_FLOAT_ARRAY() { \
if (isCriticalPinning) \
buffP = (jfloat*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \
else \
buffP = ENVPTR->GetFloatArrayElements(ENVPAR buf, &isCopy); \
}
#define UNPIN_FLOAT_ARRAY(mode) { \
if (isCriticalPinning) \
ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \
else \
ENVPTR->ReleaseFloatArrayElements(ENVPAR buf, buffP, mode); \
}
#define PIN_DOUBLE_ARRAY() { \
if (isCriticalPinning) \
buffP = (jdouble*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \
else \
buffP = ENVPTR->GetDoubleArrayElements(ENVPAR buf, &isCopy); \
}
#define UNPIN_DOUBLE_ARRAY(mode) { \
if (isCriticalPinning) \
ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \
else \
ENVPTR->ReleaseDoubleArrayElements(ENVPAR buf, buffP, mode); \
}
/*
* Class: hdf_hdf5lib_H5
* Method: _H5Dcreate
* Signature: (JLjava/lang/String;JJJ)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5__1H5Dcreate
(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type_id,
jlong space_id, jlong create_plist_id)
{
hid_t dset_id = -1;
const char *fileName;
PIN_JAVA_STRING(name, fileName);
if (fileName != NULL) {
dset_id = H5Dcreate2((hid_t)loc_id, fileName, (hid_t)type_id, (hid_t)space_id, H5P_DEFAULT, (hid_t)create_plist_id, H5P_DEFAULT);
UNPIN_JAVA_STRING(name, fileName);
if (dset_id < 0)
h5libraryError(env);
}
return (jlong)dset_id;
} /* end Java_hdf_hdf5lib_H5__1H5Dcreate */
/*
* Class: hdf_hdf5lib_H5
* Method: _H5Dopen
* Signature: (JLjava/lang/String;)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5__1H5Dopen
(JNIEnv *env, jclass clss, jlong loc_id, jstring name)
{
hid_t dset_id = -1;
const char *fileName;
PIN_JAVA_STRING(name, fileName);
if (fileName != NULL) {
dset_id = H5Dopen2((hid_t)loc_id, fileName, H5P_DEFAULT);
UNPIN_JAVA_STRING(name, fileName);
if (dset_id < 0)
h5libraryError(env);
}
return (jlong)dset_id;
} /* end Java_hdf_hdf5lib_H5__1H5Dopen */
/*
* Class: hdf_hdf5lib_H5
* Method: _H5Dget_space
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5__1H5Dget_1space
(JNIEnv *env, jclass clss, jlong dataset_id)
{
hid_t retVal = -1;
retVal = H5Dget_space((hid_t)dataset_id);
if (retVal < 0)
h5libraryError(env);
return (jlong)retVal;
} /* end Java_hdf_hdf5lib_H5__1H5Dget_1space */
/*
* Class: hdf_hdf5lib_H5
* Method: _H5Dget_type
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5__1H5Dget_1type
(JNIEnv *env, jclass clss, jlong dataset_id)
{
hid_t retVal = -1;
retVal = H5Dget_type((hid_t)dataset_id);
if (retVal < 0)
h5libraryError(env);
return (jlong)retVal;
} /* end Java_hdf_hdf5lib_H5__1H5Dget_1type */
/*
* Class: hdf_hdf5lib_H5
* Method: _H5Dget_create_plist
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5__1H5Dget_1create_1plist
(JNIEnv *env, jclass clss, jlong dataset_id)
{
hid_t retVal = -1;
retVal = H5Dget_create_plist((hid_t)dataset_id);
if (retVal < 0)
h5libraryError(env);
return (jlong)retVal;
} /* end Java_hdf_hdf5lib_H5__1H5Dget_1create_1plist */
static htri_t
H5Tdetect_variable_str
(hid_t tid) {
htri_t ret_val = 0;
if (H5Tget_class(tid) == H5T_COMPOUND) {
unsigned i;
unsigned nm = (unsigned)H5Tget_nmembers(tid);
for(i = 0; i < nm; i++) {
htri_t status = 0;
hid_t mtid = 0;
if((mtid = H5Tget_member_type(tid, i)) < 0)
return -1; /* exit immediately on error */
if((status = H5Tdetect_variable_str(mtid)) < 0)
return status; /* exit immediately on error */
ret_val |= status;
H5Tclose (mtid);
} /* end for */
} /* end if */
else
ret_val = H5Tis_variable_str(tid);
return ret_val;
} /* end H5Tdetect_variable_str */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dread
* Signature: (JJJJJ[BZ)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Dread
(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
jlong file_space_id, jlong xfer_plist_id, jbyteArray buf, jboolean isCriticalPinning)
{
herr_t status = -1;
jbyte *buffP;
jboolean isCopy;
htri_t data_class;
if (buf == NULL) {
h5nullArgument(env, "H5Dread: buf is NULL");
} /* end if */
else {
PIN_BYTE_ARRAY();
if (buffP == NULL) {
h5JNIFatalError(env, "H5Dread: buf not pinned");
} /* end if */
else {
status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id,
(hid_t)file_space_id, (hid_t)xfer_plist_id, buffP);
if (status < 0) {
UNPIN_BYTE_ARRAY(JNI_ABORT);
h5libraryError(env);
} /* end if */
else {
UNPIN_BYTE_ARRAY(0); /* update java buffer for return */
} /* end else */
} /* end else */
} /* end else */
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dread */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dwrite
* Signature: (JJJJJ[BZ)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Dwrite
(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
jlong file_space_id, jlong xfer_plist_id, jbyteArray buf, jboolean isCriticalPinning)
{
herr_t status = -1;
jbyte *buffP;
jboolean isCopy;
htri_t data_class;
if (buf == NULL) {
h5nullArgument(env, "H5Dwrite: buf is NULL");
} /* end if */
else {
PIN_BYTE_ARRAY();
if (buffP == NULL) {
h5JNIFatalError(env, "H5Dwrite: buf not pinned");
} /* end if */
else {
status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id,
(hid_t)file_space_id, (hid_t)xfer_plist_id, buffP);
UNPIN_BYTE_ARRAY(JNI_ABORT); /* no need to update buffer */
if (status < 0)
h5libraryError(env);
} /* end else */
} /* end else */
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dwrite */
/*
* Class: hdf_hdf5lib_H5
* Method: _H5Dclose
* Signature: (J)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5__1H5Dclose
(JNIEnv *env, jclass clss, jlong dataset_id)
{
herr_t retVal = -1;
retVal = H5Dclose((hid_t)dataset_id);
if (retVal < 0)
h5libraryError(env);
return (jint)retVal;
} /* end Java_hdf_hdf5lib_H5__1H5Dclose */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dget_storage_size
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Dget_1storage_1size
(JNIEnv *env, jclass clss, jlong dataset_id)
{
hsize_t retVal = (hsize_t)-1;
if (dataset_id < 0) {
h5badArgument(env, "H5Dget_storage_size: not a dataset");
} /* end if */
else {
retVal = H5Dget_storage_size((hid_t)dataset_id);
} /* end else */
return (jlong)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Dget_1storage_1size */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dvlen_reclaim
* Signature: (JJJ[B)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Dvlen_1reclaim
(JNIEnv *env, jclass clss, jlong type_id, jlong space_id,
jlong xfer_plist_id, jbyteArray buf)
{
herr_t status = -1;
jbyte *byteP;
jboolean isCopy;
if (buf == NULL) {
h5nullArgument(env, "H5Dvlen_reclaim: buf is NULL");
} /* end if */
else {
byteP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy);
if (byteP == NULL) {
h5JNIFatalError(env, "H5Dvlen_reclaim: buf not pinned");
} /* end if */
else {
status = H5Dvlen_reclaim((hid_t)type_id, (hid_t)space_id, (hid_t)xfer_plist_id, byteP);
ENVPTR->ReleaseByteArrayElements(ENVPAR buf, byteP, JNI_ABORT);
if (status < 0)
h5libraryError(env);
} /* end else */
} /* end else */
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dvlen_1reclaim */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dread_short
* Signature: (JJJJJ[SZ)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Dread_1short
(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
jlong file_space_id, jlong xfer_plist_id, jshortArray buf, jboolean isCriticalPinning)
{
herr_t status = -1;
jshort *buffP;
jboolean isCopy;
htri_t data_class;
if (buf == NULL) {
h5nullArgument(env, "H5Dread_short: buf is NULL");
} /* end if */
else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
h5JNIFatalError(env, "H5Dread: H5Tdetect_class() failed");
} /* end else if */
else if(data_class == 1) {
h5badArgument(env, "H5Dread_short: buf does not support variable length type");
} /* end else if */
else {
/* recursive detect any vlen string in type (compound, array ...) */
if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
h5JNIFatalError(env, "H5Dread_short: H5Tdetect_variable_str() failed");
} /* end if */
else if(data_class == 1) {
h5badArgument(env, "H5Dread_short: buf does not support variable length type");
} /* end else if */
else {
PIN_SHORT_ARRAY();
if (buffP == NULL) {
h5JNIFatalError(env, "H5Dread_short: buf not pinned");
} /* end if */
else {
status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id,
(hid_t)file_space_id, (hid_t)xfer_plist_id, buffP);
if (status < 0) {
UNPIN_SHORT_ARRAY(JNI_ABORT);
h5libraryError(env);
} /* end if */
else {
UNPIN_SHORT_ARRAY(0);
} /* end else */
} /* end else */
} /* end else */
} /* end else */
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dread_1short */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dwrite_short
* Signature: (JJJJJ[SZ)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Dwrite_1short
(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
jlong file_space_id, jlong xfer_plist_id, jshortArray buf, jboolean isCriticalPinning)
{
herr_t status = -1;
jshort *buffP;
jboolean isCopy;
htri_t data_class;
if (buf == NULL ) {
h5nullArgument(env, "H5Dwrite_short: buf is NULL");
} /* end if */
else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
h5JNIFatalError(env, "H5Dwrite_short: H5Tdetect_class() failed");
} /* end else if */
else if(data_class == 1) {
h5badArgument(env, "H5Dwrite_short: buf does not support variable length type");
} /* end else if */
else {
/* recursive detect any vlen string in type (compound, array ...) */
if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
h5JNIFatalError(env, "H5Dwrite_short: H5Tdetect_variable_str() failed");
} /* end if */
else if(data_class == 1) {
h5badArgument(env, "H5Dwrite_short: buf does not support variable length type");
} /* end else if */
else {
PIN_SHORT_ARRAY();
if (buffP == NULL) {
h5JNIFatalError(env, "H5Dwrite_short: buf not pinned");
} /* end if */
else {
status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id,
(hid_t)file_space_id, (hid_t)xfer_plist_id, buffP);
UNPIN_SHORT_ARRAY(JNI_ABORT);
if (status < 0)
h5libraryError(env);
} /* end else */
} /* end else */
} /* end else */
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1short */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dread_int
* Signature: (JJJJJ[IZ)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Dread_1int
(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
jlong file_space_id, jlong xfer_plist_id, jintArray buf, jboolean isCriticalPinning)
{
herr_t status = -1;
jint *buffP;
jboolean isCopy;
htri_t data_class;
if (buf == NULL) {
h5nullArgument(env, "H5Dread_int: buf is NULL");
} /* end if */
else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
h5JNIFatalError(env, "H5Dread_int: H5Tdetect_class() failed");
} /* end else if */
else if(data_class == 1) {
h5badArgument(env, "H5Dread_int: buf does not support variable length type");
} /* end else if */
else {
/* recursive detect any vlen string in type (compound, array ...) */
if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
h5JNIFatalError(env, "H5Dread_int: H5Tdetect_variable_str() failed");
} /* end if */
else if(data_class == 1) {
h5badArgument(env, "H5Dread_int: buf does not support variable length type");
} /* end else if */
else {
PIN_INT_ARRAY();
if (buffP == NULL) {
h5JNIFatalError(env, "H5Dread_int: buf not pinned");
} /* end if */
else {
status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id,
(hid_t)file_space_id, (hid_t)xfer_plist_id, buffP);
if (status < 0) {
UNPIN_INT_ARRAY(JNI_ABORT);
h5libraryError(env);
} /* end if */
else {
UNPIN_INT_ARRAY(0);
} /* end else */
} /* end else */
} /* end else */
} /* end else */
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dread_1int */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dwrite_int
* Signature: (JJJJJ[IZ)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Dwrite_1int
(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
jlong file_space_id, jlong xfer_plist_id, jintArray buf, jboolean isCriticalPinning)
{
herr_t status = -1;
jint *buffP;
jboolean isCopy;
htri_t data_class;
if (buf == NULL) {
h5nullArgument(env, "H5Dwrite_int: buf is NULL");
} /* end if */
else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
h5JNIFatalError(env, "H5Dwrite_int: H5Tdetect_class() failed");
} /* end else if */
else if(data_class == 1) {
h5badArgument(env, "H5Dwrite_int: buf does not support variable length type");
} /* end else if */
else {
/* recursive detect any vlen string in type (compound, array ...) */
if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
h5JNIFatalError(env, "H5Dwrite_int: H5Tdetect_variable_str() failed");
} /* end if */
else if(data_class == 1) {
h5badArgument(env, "H5Dwrite_int: buf does not support variable length type");
} /* end else if */
else {
PIN_INT_ARRAY();
if (buffP == NULL) {
h5JNIFatalError(env, "H5Dwrite_int: buf not pinned");
} /* end if */
else {
status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id,
(hid_t)file_space_id, (hid_t)xfer_plist_id, buffP);
UNPIN_INT_ARRAY(JNI_ABORT);
if (status < 0)
h5libraryError(env);
} /* end else */
} /* end else */
} /* end else */
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1int */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dread_long
* Signature: (JJJJJ[JZ)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Dread_1long
(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
jlong file_space_id, jlong xfer_plist_id, jlongArray buf, jboolean isCriticalPinning)
{
herr_t status = -1;
jlong *buffP;
jboolean isCopy;
htri_t data_class;
if (buf == NULL) {
h5nullArgument(env, "H5Dread_long: buf is NULL");
} /* end if */
else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
h5JNIFatalError(env, "H5Dread_long: H5Tdetect_class() failed");
} /* end else if */
else if(data_class == 1) {
h5badArgument(env, "H5Dread_long: buf does not support variable length type");
} /* end else if */
else {
/* recursive detect any vlen string in type (compound, array ...) */
if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
h5JNIFatalError(env, "H5Dread_long: H5Tdetect_variable_str() failed");
} /* end if */
else if(data_class == 1) {
h5badArgument(env, "H5Dread_long: buf does not support variable length type");
} /* end else if */
else {
PIN_LONG_ARRAY();
if (buffP == NULL) {
h5JNIFatalError(env, "H5Dread_long: buf not pinned");
} /* end if */
else {
status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id,
(hid_t)file_space_id, (hid_t)xfer_plist_id, buffP);
if (status < 0) {
UNPIN_LONG_ARRAY(JNI_ABORT);
h5libraryError(env);
} /* end if */
else {
UNPIN_LONG_ARRAY(0);
} /* end else */
} /* end else */
} /* end else */
} /* end else */
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dread_1long */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dwrite_long
* Signature: (JJJJJ[JZ)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Dwrite_1long
(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
jlong file_space_id, jlong xfer_plist_id, jlongArray buf, jboolean isCriticalPinning)
{
herr_t status = -1;
jlong *buffP;
jboolean isCopy;
htri_t data_class;
if (buf == NULL) {
h5nullArgument(env, "H5Dwrite_long: buf is NULL");
} /* end if */
else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
h5JNIFatalError(env, "H5Dwrite_long: H5Tdetect_class() failed");
} /* end else if */
else if(data_class == 1) {
h5badArgument(env, "H5Dwrite_long: buf does not support variable length type");
} /* end else if */
else {
/* recursive detect any vlen string in type (compound, array ...) */
if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
h5JNIFatalError(env, "H5Dwrite_long: H5Tdetect_variable_str() failed");
} /* end if */
else if(data_class == 1) {
h5badArgument(env, "H5Dwrite_long: buf does not support variable length type");
} /* end else if */
else {
PIN_LONG_ARRAY();
if (buffP == NULL) {
h5JNIFatalError(env, "H5Dwrite_long: buf not pinned");
} /* end if */
else {
status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id,
(hid_t)file_space_id, (hid_t)xfer_plist_id, buffP);
UNPIN_LONG_ARRAY(JNI_ABORT);
if (status < 0)
h5libraryError(env);
} /* end else */
} /* end else */
} /* end else */
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1long */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dread_float
* Signature: (JJJJJ[FZ)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Dread_1float
(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
jlong file_space_id, jlong xfer_plist_id, jfloatArray buf, jboolean isCriticalPinning)
{
herr_t status = -1;
jfloat *buffP;
jboolean isCopy;
htri_t data_class;
if (buf == NULL) {
h5nullArgument(env, "H5Dread_float: buf is NULL");
} /* end if */
else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
h5JNIFatalError(env, "H5Dread_float: H5Tdetect_class() failed");
} /* end else if */
else if(data_class == 1) {
h5badArgument(env, "H5Dread_float: buf does not support variable length type");
} /* end else if */
else {
/* recursive detect any vlen string in type (compound, array ...) */
if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
h5JNIFatalError(env, "H5Dread_float: H5Tdetect_variable_str() failed");
} /* end if */
else if(data_class == 1) {
h5badArgument(env, "H5Dread_float: buf does not support variable length type");
} /* end else if */
else {
PIN_FLOAT_ARRAY();
if (buffP == NULL) {
h5JNIFatalError(env, "H5Dread_float: buf not pinned");
} /* end if */
else {
status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id,
(hid_t)file_space_id, (hid_t)xfer_plist_id, buffP);
if (status < 0) {
UNPIN_FLOAT_ARRAY(JNI_ABORT);
h5libraryError(env);
} /* end if */
else {
UNPIN_FLOAT_ARRAY(0);
} /* end else */
} /* end else */
} /* end else */
} /* end else */
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dread_1float */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dwrite_float
* Signature: (JJJJJ[FZ)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Dwrite_1float
(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
jlong file_space_id, jlong xfer_plist_id, jfloatArray buf, jboolean isCriticalPinning)
{
herr_t status = -1;
jfloat *buffP;
jboolean isCopy;
htri_t data_class;
if (buf == NULL) {
h5nullArgument(env, "H5Dwrite_float: buf is NULL");
} /* end if */
else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
h5JNIFatalError(env, "H5Dwrite_float: H5Tdetect_class() failed");
} /* end else if */
else if(data_class == 1) {
h5badArgument(env, "H5Dwrite_float: buf does not support variable length type");
} /* end else if */
else {
/* recursive detect any vlen string in type (compound, array ...) */
if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
h5JNIFatalError(env, "H5Dwrite_float: H5Tdetect_variable_str() failed");
} /* end if */
else if(data_class == 1) {
h5badArgument(env, "H5Dwrite_float: buf does not support variable length type");
} /* end else if */
else {
PIN_FLOAT_ARRAY();
if (buffP == NULL) {
h5JNIFatalError(env, "H5Dwrite_float: buf not pinned");
} /* end if */
else {
status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id,
(hid_t)file_space_id, (hid_t)xfer_plist_id, buffP);
UNPIN_FLOAT_ARRAY(JNI_ABORT);
if (status < 0)
h5libraryError(env);
} /* end else */
} /* end else */
} /* end else */
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1float */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dread_double
* Signature: (JJJJJ[DZ)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Dread_1double
(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
jlong file_space_id, jlong xfer_plist_id, jdoubleArray buf, jboolean isCriticalPinning)
{
herr_t status = -1;
jdouble *buffP;
jboolean isCopy;
htri_t data_class;
if (buf == NULL) {
h5nullArgument(env, "H5Dread_double: buf is NULL");
} /* end if */
else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
h5JNIFatalError(env, "H5Dread_double: H5Tdetect_class() failed");
} /* end else if */
else if(data_class == 1) {
h5badArgument(env, "H5Dread_double: buf does not support variable length type");
} /* end else if */
else {
/* recursive detect any vlen string in type (compound, array ...) */
if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
h5JNIFatalError(env, "H5Dread_double: H5Tdetect_variable_str() failed");
} /* end if */
else if(data_class == 1) {
h5badArgument(env, "H5Dread_double: buf does not support variable length type");
} /* end else if */
else {
PIN_DOUBLE_ARRAY();
if (buffP == NULL) {
h5JNIFatalError(env, "H5Dread_double: buf not pinned");
} /* end if */
else {
status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id,
(hid_t)file_space_id, (hid_t)xfer_plist_id, buffP);
if (status < 0) {
UNPIN_DOUBLE_ARRAY(JNI_ABORT);
h5libraryError(env);
} /* end if */
else {
UNPIN_DOUBLE_ARRAY(0);
} /* end else */
} /* end else */
} /* end else */
} /* end else */
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dread_1double */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dwrite_double
* Signature: (JJJJJ[DZ)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Dwrite_1double
(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
jlong file_space_id, jlong xfer_plist_id, jdoubleArray buf, jboolean isCriticalPinning)
{
herr_t status = -1;
jdouble *buffP;
jboolean isCopy;
htri_t data_class;
if (buf == NULL) {
h5nullArgument(env, "H5Dwrite_double: buf is NULL");
} /* end if */
else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) {
h5JNIFatalError(env, "H5Dwrite_double: H5Tdetect_class() failed");
} /* end else if */
else if(data_class == 1) {
h5badArgument(env, "H5Dwrite_double: buf does not support variable length type");
} /* end else if */
else {
/* recursive detect any vlen string in type (compound, array ...) */
if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) {
h5JNIFatalError(env, "H5Dwrite_double: H5Tdetect_variable_str() failed");
} /* end if */
else if(data_class == 1) {
h5badArgument(env, "H5Dwrite_double: buf does not support variable length type");
} /* end else if */
else {
PIN_DOUBLE_ARRAY();
if (buffP == NULL) {
h5JNIFatalError(env, "H5Dwrite_double: buf not pinned");
} /* end if */
else {
status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id,
(hid_t)file_space_id, (hid_t)xfer_plist_id, buffP);
UNPIN_DOUBLE_ARRAY(JNI_ABORT);
if (status < 0)
h5libraryError(env);
} /* end else */
} /* end else */
} /* end else */
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1double */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dread_string
* Signature: (JJJJJ[Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Dread_1string
(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
jlong file_space_id, jlong xfer_plist_id, jobjectArray j_buf)
{
herr_t status = -1;
char *c_buf;
char *cstr;
size_t str_len;
jsize i;
jsize n;
size_t pos;
jstring jstr;
c_buf = cstr = NULL;
if (j_buf == NULL) {
h5nullArgument(env, "H5Dread_string: buf is NULL");
} /* end if */
else if ((n = ENVPTR->GetArrayLength(ENVPAR j_buf)) <= 0) {
h5nullArgument(env, "H5Dread_string: buf length <= 0");
} /* end else if */
else if ((str_len = H5Tget_size((hid_t)mem_type_id)) <=0) {
h5libraryError(env);
} /* end else if */
else {
if ((cstr = (char*)HDmalloc(str_len + 1)) == NULL) {
h5JNIFatalError(env, "H5Dread_string: memory allocation failed.");
} /* end if */
else {
if ((c_buf = (char*)HDmalloc((size_t)n * str_len)) == NULL) {
if (cstr)
HDfree(cstr);
cstr = NULL;
h5JNIFatalError(env, "H5Dread_string: memory allocation failed.");
} /* end if */
else {
status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id,
(hid_t)file_space_id, (hid_t)xfer_plist_id, c_buf);
if (status < 0) {
if (cstr)
HDfree(cstr);
cstr = NULL;
if (c_buf)
HDfree(c_buf);
c_buf = NULL;
h5libraryError(env);
} /* end if */
else {
pos = 0;
for (i = 0; i < n; i++) {
HDmemcpy(cstr, c_buf+pos, str_len);
cstr[str_len] = '\0';
jstr = ENVPTR->NewStringUTF(ENVPAR cstr);
ENVPTR->SetObjectArrayElement(ENVPAR j_buf, i, jstr);
pos += str_len;
} /* end for */
} /* end else */
if (c_buf)
HDfree(c_buf);
} /* end else cbuf allocation*/
if (cstr)
HDfree(cstr);
} /* end else cstr allocation*/
} /* end else */
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dread_1string */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dwrite_string
* Signature: (JJJJJ[Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Dwrite_1string
(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
jlong file_space_id, jlong xfer_plist_id, jobjectArray j_buf)
{
herr_t status = -1;
char *c_buf;
jsize str_len;
jsize i;
jsize n;
if (j_buf == NULL) {
h5nullArgument(env, "H5Dwrite_string: buf is NULL");
} /* end if */
else if ((n = ENVPTR->GetArrayLength(ENVPAR j_buf)) <= 0) {
h5nullArgument(env, "H5Dwrite_string: buf length <= 0");
} /* end else if */
else if ((str_len = (jsize)H5Tget_size((hid_t)mem_type_id)) <=0) {
h5libraryError(env);
} /* end else if */
else {
if ((c_buf = (char*)HDmalloc((size_t)n * (size_t)str_len)) == NULL) {
h5JNIFatalError(env, "H5Dwrite_string: memory allocation failed.");
} /* end if */
else {
for (i = 0; i < n; i++) {
jstring obj = (jstring)ENVPTR->GetObjectArrayElement(ENVPAR (jobjectArray)j_buf, i);
if (obj != 0) {
jsize length = ENVPTR->GetStringUTFLength(ENVPAR obj);
const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0);
if (utf8) {
strncpy(&c_buf[i * str_len], utf8, str_len);
} /* end if */
ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8);
ENVPTR->DeleteLocalRef(ENVPAR obj);
} /* end if */
} /* end for */
status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id,
(hid_t)file_space_id, (hid_t)xfer_plist_id, c_buf);
if (c_buf)
HDfree(c_buf);
c_buf = NULL;
if (status < 0) {
h5libraryError(env);
} /* end if */
} /* end else */
} /* end else */
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1string */
/*
* Class: hdf_hdf5lib_H5
* Method: H5DreadVL
* Signature: (JJJJJ[Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5DreadVL
(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
jlong file_space_id, jlong xfer_plist_id, jobjectArray buf)
{
herr_t status = -1;
htri_t isStr = 0;
htri_t isVlenStr = 0;
htri_t isComplex = 0;
if (buf == NULL) {
h5nullArgument(env, "H5DreadVL: buf is NULL");
} /* end if */
else {
isStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING);
if (H5Tget_class((hid_t)mem_type_id) == H5T_COMPOUND) {
unsigned i;
int nm = H5Tget_nmembers(mem_type_id);
for(i = 0; i <nm; i++) {
hid_t nested_tid = H5Tget_member_type((hid_t)mem_type_id, i);
isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND) ||
H5Tdetect_class((hid_t)nested_tid, H5T_VLEN);
H5Tclose(nested_tid);
}
}
else if (H5Tget_class((hid_t)mem_type_id) == H5T_VLEN) {
isVlenStr = 1; /* strings created by H5Tvlen_create(H5T_C_S1) */
}
if (isStr == 0 || isComplex>0 || isVlenStr) {
status = H5DreadVL_asstr(env, (hid_t)dataset_id, (hid_t)mem_type_id,
(hid_t)mem_space_id, (hid_t)file_space_id,
(hid_t)xfer_plist_id, buf);
}
else if (isStr > 0) {
status = H5DreadVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id,
(hid_t)mem_space_id, (hid_t)file_space_id,
(hid_t)xfer_plist_id, buf);
}
} /* end else */
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dread_1VL */
herr_t
H5DreadVL_asstr
(JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf)
{
jint i;
jint n;
jstring jstr;
h5str_t h5str;
hvl_t *rdata;
size_t size;
size_t max_len = 0;
herr_t status = -1;
/* Get size of string array */
n = ENVPTR->GetArrayLength(ENVPAR buf);
/* we will need to read n number of hvl_t structures */
rdata = (hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t));
if (rdata == NULL) {
h5JNIFatalError(env, "H5DreadVL_asstr: failed to allocate buff for read");
} /* end if */
else {
status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, rdata);
if (status < 0) {
H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, rdata);
HDfree(rdata);
h5JNIFatalError(env, "H5DreadVL_asstr: failed to read data");
} /* end if */
else {
/* calculate the largest size of all the hvl_t structures read */
max_len = 1;
for (i=0; i < n; i++) {
if ((rdata + i)->len > max_len)
max_len = (rdata + i)->len;
}
/* create one malloc to hold largest element */
size = H5Tget_size(tid) * max_len;
HDmemset(&h5str, 0, sizeof(h5str_t));
h5str_new(&h5str, 4 * size);
if (h5str.s == NULL) {
H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, rdata);
HDfree(rdata);
h5JNIFatalError(env, "H5DreadVL_asstr: failed to allocate buf");
} /* end if */
else {
H5T_class_t tclass = H5Tget_class(tid);
/* convert each element to char string */
for (i=0; i < n; i++) {
h5str.s[0] = '\0';
h5str_vlsprintf(&h5str, did, tid, rdata+i, 0);
jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s);
ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr);
} /* end for */
h5str_free(&h5str);
H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, rdata);
HDfree(rdata);
} /* end else */
} /* end else */
} /* end else */
return status;
}
/**
* Read VLEN data into array of arrays.
* Object[] buf contains VL arrays of data points
* Currently only deal with variable length of atomic data types
*/
/* old version */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dread_VLStrings
* Signature: (JJJJJ[Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Dread_1VLStrings
(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
jlong file_space_id, jlong xfer_plist_id, jobjectArray buf)
{
herr_t status = -1;
htri_t isVlenStr=0;
if (buf == NULL) {
h5nullArgument(env, "H5Dread_VLStrings: buf is NULL");
} /* end if */
else {
isVlenStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING);
if (isVlenStr) {
status = H5DreadVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id,
(hid_t)mem_space_id, (hid_t)file_space_id,
(hid_t)xfer_plist_id, buf);
} /* end if */
else
h5badArgument(env, "H5Dread_VLStrings: type is not variable length String");
} /* end else */
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dread_1VLStrings */
herr_t
H5DreadVL_str
(JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf)
{
char **strs;
jstring jstr;
jint i;
jint n;
herr_t status = -1;
n = ENVPTR->GetArrayLength(ENVPAR buf);
strs =(char**)HDcalloc((size_t)n, sizeof(char*));
if (strs == NULL) {
h5JNIFatalError(env, "H5DreadVL_str: failed to allocate buff for read variable length strings");
} /* end if */
else {
status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, strs);
if (status < 0) {
H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, strs);
HDfree(strs);
h5JNIFatalError(env, "H5DreadVL_str: failed to read variable length strings");
} /* end if */
else {
for (i=0; i < n; i++) {
jstr = ENVPTR->NewStringUTF(ENVPAR strs[i]);
ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr);
H5free_memory (strs[i]);
} /* end for */
/*
for repeatedly reading a dataset with a large number of strs (e.g., 1,000,000 strings,
H5Dvlen_reclaim() may crash on Windows because the Java GC will not be able to collect
free space in time. Instead, use "H5free_memory(strs[i])" above to free individual strings
after it is done.
H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, strs);
*/
HDfree(strs);
} /* end else */
} /* end else */
return status;
} /* end H5DreadVL_str */
/*
* Class: hdf_hdf5lib_H5
* Method: H5DwriteVL
* Signature: (JJJJJ[Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5DwriteVL
(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
jlong file_space_id, jlong xfer_plist_id, jobjectArray buf)
{
herr_t status = -1;
htri_t isStr = 0;
htri_t isVlenStr = 0;
htri_t isComplex = 0;
if (buf == NULL) {
h5nullArgument(env, "H5DwriteVL: buf is NULL");
} /* end if */
else {
isStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING);
if (H5Tget_class((hid_t)mem_type_id) == H5T_COMPOUND) {
unsigned i;
int nm = H5Tget_nmembers(mem_type_id);
for(i = 0; i <nm; i++) {
hid_t nested_tid = H5Tget_member_type((hid_t)mem_type_id, i);
isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND) ||
H5Tdetect_class((hid_t)nested_tid, H5T_VLEN);
H5Tclose(nested_tid);
}
}
else if (H5Tget_class((hid_t)mem_type_id) == H5T_VLEN) {
isVlenStr = 1; /* strings created by H5Tvlen_create(H5T_C_S1) */
}
if (isStr == 0 || isComplex>0 || isVlenStr) {
h5unimplemented(env, "H5DwriteVL: VL types, which are not string type, not implemented");
status = -1;
#ifdef notdef
status = H5DwriteVL_asstr(env, (hid_t)dataset_id, (hid_t)mem_type_id,
(hid_t)mem_space_id, (hid_t)file_space_id,
(hid_t)xfer_plist_id, buf);
#endif
}
else if (isStr > 0) {
status = H5DwriteVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id,
(hid_t)mem_space_id, (hid_t)file_space_id,
(hid_t)xfer_plist_id, buf);
}
} /* end else */
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1VL */
herr_t
H5DwriteVL_asstr
(JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf)
{
herr_t status = -1;
hvl_t *wdata;
jsize size;
jint i;
jint n;
/* Get size of string array */
n = ENVPTR->GetArrayLength(ENVPAR buf);
wdata = (hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t));
if (wdata == NULL) {
h5JNIFatalError(env, "H5DwriteVL_asstr: failed to allocate buff for write");
} /* end if */
else {
for (i = 0; i < n; ++i) {
jstring obj = (jstring) ENVPTR->GetObjectArrayElement(ENVPAR (jobjectArray)buf, i);
if (obj != 0) {
jsize length = ENVPTR->GetStringUTFLength(ENVPAR obj);
const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0);
if (utf8) {
h5str_vlconvert(utf8, did, tid, wdata+i, 0);
} /* end if */
ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8);
ENVPTR->DeleteLocalRef(ENVPAR obj);
} /* end if */
} /* end for (i = 0; i < size; ++i) */
status = H5Dwrite(did, tid, mem_sid, file_sid, xfer_plist_id, wdata);
/* now free memory*/
for (i = 0; i < n; i++) {
if(wdata+i) {
HDfree(wdata+i);
} /* end if */
} /* end for */
HDfree(wdata);
if (status < 0)
h5libraryError(env);
} /* end else */
return status;
} /* end H5DwriteVL_asstr */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dwrite_VLStrings
* Signature: (JJJJJ[Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Dwrite_1VLStrings
(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
jlong file_space_id, jlong xfer_plist_id, jobjectArray buf)
{
herr_t status = -1;
htri_t isVlenStr=0;
if (buf == NULL) {
h5nullArgument(env, "H5Dwrite_VLStrings: buf is NULL");
} /* end if */
else {
isVlenStr = H5Tis_variable_str((hid_t)mem_type_id);
if (isVlenStr) {
status = H5DwriteVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id,
(hid_t)mem_space_id, (hid_t)file_space_id,
(hid_t)xfer_plist_id, buf);
} /* end if */
else
h5badArgument(env, "H5Dwrite_VLStrings: type is not variable length String");
} /* end else */
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1VLStrings */
herr_t
H5DwriteVL_str
(JNIEnv *env, hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t xfer_plist_id, jobjectArray buf)
{
herr_t status = -1;
char **wdata;
jsize size;
jsize i;
size = ENVPTR->GetArrayLength(ENVPAR (jarray) buf);
wdata = (char**)HDmalloc((size_t)size * sizeof (char*));
if (!wdata) {
h5JNIFatalError(env, "H5DwriteVL_str: cannot allocate buffer");
} /* end if */
else {
HDmemset(wdata, 0, (size_t)size * sizeof(char*));
for (i = 0; i < size; ++i) {
jstring obj = (jstring) ENVPTR->GetObjectArrayElement(ENVPAR (jobjectArray)buf, i);
if (obj != 0) {
jsize length = ENVPTR->GetStringUTFLength(ENVPAR obj);
const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0);
if (utf8) {
wdata[i] = (char*)HDmalloc((size_t)length + 1);
if (wdata[i]) {
HDmemset(wdata[i], 0, (size_t)length + 1);
HDstrncpy(wdata[i], utf8, (size_t)length + 1);
} /* end if */
} /* end if */
ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8);
ENVPTR->DeleteLocalRef(ENVPAR obj);
} /* end if */
} /* end for (i = 0; i < size; ++i) */
status = H5Dwrite(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, wdata);
/* now free memory*/
for (i = 0; i < size; i++) {
if(wdata[i]) {
HDfree(wdata[i]);
} /* end if */
} /* end for */
HDfree(wdata);
if (status < 0)
h5libraryError(env);
} /* end else */
return status;
} /* end H5DwriteVL_str */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dread_reg_ref
* Signature: (JJJJJ[Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref
(JNIEnv *env, jclass clss,
jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
jlong file_space_id, jlong xfer_plist_id, jobjectArray buf)
{
herr_t status = -1;
h5str_t h5str;
size_t size;
hdset_reg_ref_t *ref_data;
jint i;
jint n;
jstring jstr;
hid_t region = -1;
hid_t did = (hid_t) dataset_id;
hid_t tid = (hid_t) mem_type_id;
hid_t mem_sid = (hid_t) mem_space_id;
hid_t file_sid = (hid_t) file_space_id;
n = ENVPTR->GetArrayLength(ENVPAR buf);
size = sizeof(hdset_reg_ref_t); /*H5Tget_size(tid);*/
ref_data = (hdset_reg_ref_t*)HDmalloc(size * (size_t)n);
if (ref_data == NULL) {
h5JNIFatalError(env, "H5Dread_reg_ref: failed to allocate buff for read");
return -1;
} /* end if */
status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, ref_data);
if (status < 0) {
HDfree(ref_data);
h5JNIFatalError(env, "H5Dread_reg_ref: failed to read data");
return -1;
} /* end if */
HDmemset(&h5str, 0, sizeof(h5str_t));
h5str_new(&h5str, 1024);
for (i=0; i<n; i++) {
h5str.s[0] = '\0';
h5str_sprintf(&h5str, did, tid, ref_data[i], 0, 0);
jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s);
ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr);
} /* end for */
h5str_free(&h5str);
HDfree(ref_data);
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dread_reg_ref_data
* Signature: (JJJJJ[Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref_1data
(JNIEnv *env, jclass clss,
jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
jlong file_space_id, jlong xfer_plist_id, jobjectArray buf)
{
herr_t status = -1;
h5str_t h5str;
size_t size;
hdset_reg_ref_t *ref_data;
jint i;
jint n;
jstring jstr;
hid_t region_obj;
H5S_sel_type region_type;
hid_t region = -1;
hid_t did = (hid_t) dataset_id;
hid_t tid = (hid_t) mem_type_id;
hid_t mem_sid = (hid_t) mem_space_id;
hid_t file_sid = (hid_t) file_space_id;
n = ENVPTR->GetArrayLength(ENVPAR buf);
size = sizeof(hdset_reg_ref_t); /*H5Tget_size(tid);*/
ref_data = (hdset_reg_ref_t*)HDmalloc(size * (size_t)n);
if (ref_data == NULL) {
h5JNIFatalError(env, "H5Dread_reg_ref_data: failed to allocate buff for read");
return -1;
} /* end if */
status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, ref_data);
if (status < 0) {
HDfree(ref_data);
h5JNIFatalError(env, "H5Dread_reg_ref_data: failed to read data");
return -1;
} /* end if */
HDmemset(&h5str, 0, sizeof(h5str_t));
h5str_new(&h5str, 1024);
for (i=0; i<n; i++) {
h5str.s[0] = '\0';
/* get name of the dataset the region reference points to using H5Rget_name */
region_obj = H5Rdereference2(did, H5P_DEFAULT, H5R_DATASET_REGION, ref_data[i]);
if (region_obj >= 0) {
region = H5Rget_region(did, H5R_DATASET_REGION, ref_data[i]);
if (region >= 0) {
region_type = H5Sget_select_type(region);
if(region_type==H5S_SEL_POINTS) {
h5str_dump_region_points_data(&h5str, region, region_obj);
} /* end if */
else {
h5str_dump_region_blocks_data(&h5str, region, region_obj);
} /* end else */
H5Sclose(region);
} /* end if */
H5Dclose(region_obj);
} /* end if */
jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s);
ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr);
} /* end for */
h5str_free(&h5str);
HDfree(ref_data);
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref_1data */
/*
* Class: hdf_hdf5lib_H5
* Method: _H5Dcreate2
* Signature: (JLjava/lang/String;JJJJJ)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5__1H5Dcreate2
(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type_id,
jlong space_id, jlong link_plist_id, jlong create_plist_id, jlong access_plist_id)
{
hid_t dset_id = -1;
const char *fileName;
PIN_JAVA_STRING(name, fileName);
if (fileName != NULL) {
dset_id = H5Dcreate2((hid_t)loc_id, fileName, (hid_t)type_id, (hid_t)space_id, (hid_t)link_plist_id, (hid_t)create_plist_id, (hid_t)access_plist_id);
UNPIN_JAVA_STRING(name, fileName);
if (dset_id < 0)
h5libraryError(env);
}
return (jlong)dset_id;
} /* end Java_hdf_hdf5lib_H5__1H5Dcreate2 */
/*
* Class: hdf_hdf5lib_H5
* Method: _H5Dopen2
* Signature: (JLjava/lang/String;J)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5__1H5Dopen2
(JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_plist)
{
hid_t dset_id = -1;
const char *fileName;
PIN_JAVA_STRING(name, fileName);
if (fileName != NULL) {
dset_id = H5Dopen2((hid_t)loc_id, fileName, (hid_t)access_plist);
UNPIN_JAVA_STRING(name, fileName);
if (dset_id < 0)
h5libraryError(env);
}
return (jlong)dset_id;
} /* end Java_hdf_hdf5lib_H5__1H5Dopen2 */
/*
* Class: hdf_hdf5lib_H5
* Method: _H5Dcreate_anon
* Signature: (JJJJJ)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5__1H5Dcreate_1anon
(JNIEnv *env, jclass clss, jlong loc_id, jlong type_id, jlong space_id, jlong dcpl_id, jlong dapl_id)
{
hid_t dset_id = -1;
dset_id = H5Dcreate_anon((hid_t)loc_id, (hid_t)type_id, (hid_t)space_id, (hid_t)dcpl_id, (hid_t)dapl_id);
if (dset_id < 0)
h5libraryError(env);
return (jlong)dset_id;
} /* end Java_hdf_hdf5lib_H5__1H5Dcreate_1anon */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dget_space_status
* Signature: (J)I;
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Dget_1space_1status
(JNIEnv *env, jclass clss, jlong loc_id)
{
H5D_space_status_t space_status = H5D_SPACE_STATUS_ERROR;
if (H5Dget_space_status((hid_t)loc_id, &space_status) < 0)
h5libraryError(env);
return (jint)space_status;
} /* end Java_hdf_hdf5lib_H5_H5Dget_1space_1status */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dget_access_plist
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Dget_1access_1plist
(JNIEnv *env, jclass clss, jlong loc_id)
{
hid_t retVal = -1;
retVal = H5Dget_access_plist((hid_t)loc_id);
if (retVal < 0)
h5libraryError(env);
return (jlong)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Dget_1access_1plist */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dget_offset
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Dget_1offset
(JNIEnv *env, jclass clss, jlong loc_id)
{
haddr_t offset = HADDR_UNDEF;
offset = H5Dget_offset((hid_t)loc_id);
if (offset == HADDR_UNDEF)
h5libraryError(env);
return (jlong)offset;
} /* end Java_hdf_hdf5lib_H5_H5Dget_1offset */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dvlen_get_buf_size
* Signature: (JJJ)J
*/
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Dvlen_1get_1buf_1size
(JNIEnv *env, jclass clss, jlong dataset_id, jlong type_id, jlong space_id)
{
hsize_t sz = 0;
if (H5Dvlen_get_buf_size((hid_t)dataset_id, (hid_t)type_id, (hid_t)space_id, &sz) < 0)
h5libraryError(env);
return (jlong)sz;
} /* end Java_hdf_hdf5lib_H5_H5Dvlen_1get_1buf_1size_1long */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dfill
* Signature: ([BJ[BJJ)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Dfill
(JNIEnv *env, jclass clss, jbyteArray fill, jlong fill_type_id, jbyteArray buf, jlong buf_type_id, jlong space_id)
{
herr_t status;
jbyte *fillP;
jbyte *buffP;
jboolean isCopy1;
jboolean isCopy2;
if (buf == NULL) {
h5nullArgument(env, "H5Dfill: buf is NULL");
} /* end if */
else {
buffP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy2);
if (buffP == NULL) {
h5JNIFatalError(env, "H5Dfill: buf not pinned");
} /* end if */
else {
if(fill) {
fillP = ENVPTR->GetByteArrayElements(ENVPAR fill, &isCopy1);
if (fillP == NULL) {
ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, JNI_ABORT);
h5JNIFatalError( env, "H5Dfill: fill not pinned");
return;
} /* end if */
} /* end if */
else
fillP = NULL;
status = H5Dfill((const void*)fillP, (hid_t)fill_type_id, (void*)buffP, (hid_t)buf_type_id, (hid_t)space_id);
if(fillP) {
/* free the buffer without copying back */
ENVPTR->ReleaseByteArrayElements(ENVPAR fill, fillP, JNI_ABORT);
} /* end if */
if (status < 0) {
ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, JNI_ABORT);
h5libraryError(env);
} /* end if */
else {
if (isCopy2 == JNI_TRUE) {
ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, 0);
} /* end if */
} /* end else */
}
}
} /* end Java_hdf_hdf5lib_H5_H5Dfill */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dset_extent
* Signature: (J[J)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Dset_1extent
(JNIEnv *env, jclass clss, jlong loc_id, jlongArray buf)
{
herr_t status;
hsize_t *dims;
jlong *buffP;
jsize rank;
jboolean isCopy;
int i = 0;
if (buf == NULL) {
h5nullArgument(env, "H5Dset_extent: buf is NULL");
} /* end if */
else {
rank = ENVPTR->GetArrayLength(ENVPAR buf);
if (rank <= 0) {
h5JNIFatalError(env, "H5Dset_extent: rank <=0");
} /* end if */
else {
buffP = ENVPTR->GetLongArrayElements(ENVPAR buf, &isCopy);
if (buffP == NULL) {
h5JNIFatalError( env, "H5Dset_extent: buf not pinned");
} /* end if */
else {
dims = (hsize_t*)HDmalloc((size_t)rank * sizeof(hsize_t));
for (i = 0; i< rank; i++)
dims[i] = (hsize_t)buffP[i];
status = H5Dset_extent((hid_t)loc_id, (hsize_t*)dims);
HDfree (dims);
/* free the buffer without copying back */
ENVPTR->ReleaseLongArrayElements(ENVPAR buf, buffP, JNI_ABORT);
if (status < 0) {
h5libraryError(env);
} /* end if */
} /* end else */
} /* end else */
}
} /* end Java_hdf_hdf5lib_H5_H5Dset_1extent */
static herr_t
H5D_iterate_cb
(void* elem, hid_t elem_id, unsigned ndim, const hsize_t *point, void *op_data) {
JNIEnv *cbenv;
jint status;
jclass cls;
jmethodID mid;
jbyteArray elemArray;
jlongArray pointArray;
jsize size;
if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) != 0) {
JVMPTR->DetachCurrentThread(JVMPAR);
return -1;
} /* end if */
cls = CBENVPTR->GetObjectClass(CBENVPAR visit_callback);
if (cls == 0) {
JVMPTR->DetachCurrentThread(JVMPAR);
return -1;
} /* end if */
mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "([BJI[JLhdf/hdf5lib/callbacks/H5D_iterate_t;)I");
if (mid == 0) {
JVMPTR->DetachCurrentThread(JVMPAR);
return -1;
} /* end if */
if (elem == NULL) {
JVMPTR->DetachCurrentThread(JVMPAR);
return -1;
} /* end if */
if (point == NULL) {
JVMPTR->DetachCurrentThread(JVMPAR);
return -1;
} /* end if */
size = (jsize)H5Tget_size(elem_id);
elemArray = CBENVPTR->NewByteArray(CBENVPAR size);
if (elemArray == NULL) {
JVMPTR->DetachCurrentThread(JVMPAR);
return -1;
} /* end if */
CBENVPTR->SetByteArrayRegion(CBENVPAR elemArray, 0, size, (jbyte *)elem);
pointArray = CBENVPTR->NewLongArray(CBENVPAR 2);
if (pointArray == NULL) {
JVMPTR->DetachCurrentThread(JVMPAR);
return -1;
} /* end if */
CBENVPTR->SetLongArrayRegion(CBENVPAR pointArray, 0, 2, (const jlong *)point);
status = CBENVPTR->CallIntMethod(CBENVPAR visit_callback, mid, (void*)elemArray, elem_id, ndim, pointArray, op_data);
CBENVPTR->GetByteArrayRegion(CBENVPAR elemArray, 0, size, (jbyte *)elem);
JVMPTR->DetachCurrentThread(JVMPAR);
return status;
} /* end H5D_iterate_cb */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Diterate
* Signature: ([BJJLjava/lang/Object;Ljava/lang/Object;)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Diterate
(JNIEnv *env, jclass clss, jbyteArray buf, jlong buf_type, jlong space,
jobject callback_op, jobject op_data)
{
herr_t status = -1;
jboolean isCopy;
jbyte *buffP;
ENVPTR->GetJavaVM(ENVPAR &jvm);
visit_callback = callback_op;
if (op_data == NULL) {
h5nullArgument(env, "H5Diterate: op_data is NULL");
} /* end if */
else if (callback_op == NULL) {
h5nullArgument(env, "H5Diterate: callback_op is NULL");
} /* end if */
else if (buf == NULL) {
h5nullArgument(env, "H5Diterate: buf is NULL");
} /* end if */
else {
buffP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy);
if (buffP == NULL) {
h5JNIFatalError(env, "H5Diterate: buf not pinned");
} /* end if */
else {
status = H5Diterate((void*)buffP, (hid_t)buf_type, (hid_t)space, (H5D_operator_t)H5D_iterate_cb, (void*)op_data);
if (status < 0) {
ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, JNI_ABORT);
h5libraryError(env);
} /* end if */
else {
if (isCopy == JNI_TRUE) {
ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, 0);
} /* end if */
} /* end else */
} /* end else */
}
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Diterate */
/*
* Class: hdf_hdf5lib_H5
* Method: H5Dflush
* Signature: (J)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Dflush
(JNIEnv *env, jclass clss, jlong loc_id)
{
if (H5Dflush((hid_t)loc_id) < 0)
h5libraryError(env);
}
/*
* Class: hdf_hdf5lib_H5
* Method: H5Drefresh
* Signature: (J)V
*/
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Drefresh
(JNIEnv *env, jclass clss, jlong loc_id)
{
if (H5Drefresh((hid_t)loc_id) < 0)
h5libraryError(env);
}
#ifdef __cplusplus
} /* end extern "C" */
#endif /* __cplusplus */
|