@@ -1304,6 +1304,47 @@ public Object getCoordinates() throws TileDBError {
1304
1304
return getBuffer (tiledb .tiledb_coords ());
1305
1305
}
1306
1306
1307
+ /**
1308
+ * @return The number of elements in the result NIO buffers. This is a map from the attribute name
1309
+ * to a pair of values.
1310
+ * <p>The first is number of elements for var size attributes, and the second is number of
1311
+ * elements in the data buffer. For fixed sized attributes (and coordinates), the first is
1312
+ * always 0.
1313
+ * @param typeSize the typeSize of the attribute/dimension
1314
+ * @exception TileDBError A TileDB exception
1315
+ */
1316
+ public HashMap <String , Pair <Long , Long >> resultBufferElementsNIO (int typeSize )
1317
+ throws TileDBError {
1318
+ HashMap <String , Pair <Long , Long >> result = new HashMap <String , Pair <Long , Long >>();
1319
+ for (Map .Entry <String , Pair <ByteBuffer , ByteBuffer >> entry : byteBuffers_ .entrySet ()) {
1320
+ String name = entry .getKey ();
1321
+
1322
+ // Fixed-sized
1323
+ if (entry .getValue ().getFirst () == null ) {
1324
+ BigInteger val_nbytes = buffer_sizes_ .get (name ).getSecond ().getitem (0 );
1325
+ Long nelements = val_nbytes .divide (BigInteger .valueOf (typeSize )).longValue ();
1326
+ result .put (name , new Pair <>(0l , nelements ));
1327
+ }
1328
+ // Var-sized
1329
+ else {
1330
+ Pair <uint64_tArray , uint64_tArray > buffer_size = buffer_sizes_ .get (name );
1331
+
1332
+ BigInteger off_nbytes = buffer_size .getFirst ().getitem (0 );
1333
+ Long off_nelements =
1334
+ off_nbytes
1335
+ .divide (BigInteger .valueOf (4 ))
1336
+ .longValue (); // long in 32 bits is 4 bytes//todo make this operate according to the
1337
+ // sm. config parameter
1338
+
1339
+ ByteBuffer val_buffer = entry .getValue ().getSecond ();
1340
+ BigInteger val_nbytes = buffer_size .getSecond ().getitem (0 );
1341
+ Long val_nelements = val_nbytes .divide (BigInteger .valueOf (typeSize )).longValue ();
1342
+ result .put (name , new Pair <Long , Long >(off_nelements , val_nelements ));
1343
+ }
1344
+ }
1345
+ return result ;
1346
+ }
1347
+
1307
1348
/**
1308
1349
* @return The number of elements in the result buffers. This is a map from the attribute name to
1309
1350
* a pair of values.
@@ -1379,12 +1420,23 @@ public synchronized void resetBuffers() {
1379
1420
for (Pair <NativeArray , NativeArray > buffer : buffers_ .values ()) {
1380
1421
buffer .getSecond ().close ();
1381
1422
}
1423
+ for (Pair <ByteBuffer , ByteBuffer > buffer : byteBuffers_ .values ()) {
1424
+ buffer .getSecond ().clear ();
1425
+ }
1426
+ byteBuffers_ .clear ();
1382
1427
buffers_ .clear ();
1428
+
1383
1429
for (Pair <NativeArray , NativeArray > var_buffer : buffers_ .values ()) {
1384
1430
var_buffer .getFirst ().close ();
1385
1431
var_buffer .getSecond ().close ();
1386
1432
}
1433
+ for (Pair <ByteBuffer , ByteBuffer > var_buffer : byteBuffers_ .values ()) {
1434
+ var_buffer .getFirst ().clear ();
1435
+ var_buffer .getSecond ().clear ();
1436
+ }
1437
+ byteBuffers_ .clear ();
1387
1438
buffers_ .clear ();
1439
+
1388
1440
for (Pair <uint64_tArray , uint64_tArray > size_pair : buffer_sizes_ .values ()) {
1389
1441
size_pair .getFirst ().delete ();
1390
1442
size_pair .getSecond ().delete ();
0 commit comments