summaryrefslogtreecommitdiffstats
path: root/src/H5V.c
blob: 5da1eeb1d03eab51e122bab4dbb68e094e8751c5 (plain)
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
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * 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 files COPYING and Copyright.html.  COPYING can be found at the root   *
 * of the source code distribution tree; Copyright.html can be found at the  *
 * root level of an installed copy of the electronic HDF5 document set and   *
 * is linked from the top-level documents page.  It can also be found at     *
 * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
 * access to either file, you may request a copy from help@hdfgroup.org.     *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/****************/
/* Module Setup */
/****************/

/* Interface initialization */
#define H5_INTERFACE_INIT_FUNC	H5V_init_interface


/***********/
/* Headers */
/***********/
#include "H5private.h"		/* Generic Functions			*/
#include "H5Eprivate.h"		/* Error handling		  	*/
#include "H5ESprivate.h"        /* Event Stacks                         */
#include "H5Iprivate.h"		/* IDs			  		*/
#include "H5Lprivate.h"		/* Links        		  	*/
#include "H5VMprivate.h"	/* Memory management			*/
#include "H5Vprivate.h" 	/* Views				*/
#include "H5VLprivate.h"	/* VOL plugins				*/
#include "H5VLiod_client.h"	/* IOD VOL plugin			*/

#ifdef H5_HAVE_EFF

/****************/
/* Local Macros */
/****************/


/******************/
/* Local Typedefs */
/******************/


/********************/
/* Package Typedefs */
/********************/


/********************/
/* Local Prototypes */
/********************/


/*********************/
/* Package Variables */
/*********************/


/*****************************/
/* Library Private Variables */
/*****************************/


/*******************/
/* Local Variables */
/*******************/


/* VIEW ID class */
static const H5I_class_t H5I_VIEW_CLS[1] = {{
    H5I_VIEW,                   /* ID class value */
    0,                          /* Class flags */
    0,                          /* # of reserved IDs for class */
    (H5I_free_t)H5V_close,      /* Callback routine for closing objects of this class */
    NULL                        /* Callback routine for closing auxilary objects of this class */
}};


/*-------------------------------------------------------------------------
 * Function:	H5V_init
 *
 * Purpose:	Initialize the interface from some other package.
 *
 * Return:	Success:	non-negative
 *		Failure:	negative
 *
 * Programmer:	Mohamad Chaarawi
 *              July 2013
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5V_init(void)
{
    herr_t ret_value = SUCCEED;   /* Return value */

    FUNC_ENTER_NOAPI(FAIL)
    /* FUNC_ENTER() does all the work */

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* end H5V_init() */


/*--------------------------------------------------------------------------
NAME
   H5V_init_interface -- Initialize interface-specific information
USAGE
    herr_t H5V_init_interface()

RETURNS
    Non-negative on success/Negative on failure
DESCRIPTION
    Initializes any interface-specific data or routines.

--------------------------------------------------------------------------*/
static herr_t
H5V_init_interface(void)
{
    herr_t ret_value = SUCCEED;   /* Return value */

    FUNC_ENTER_NOAPI_NOINIT

    /*
     * Create attribute ID type.
     */
    if(H5I_register_type(H5I_VIEW_CLS) < 0)
        HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to initialize interface")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* end H5V_init_interface() */


/*--------------------------------------------------------------------------
 NAME
    H5V_term_interface
 PURPOSE
    Terminate various H5V objects
 USAGE
    void H5V_term_interface()
 RETURNS
 DESCRIPTION
    Release any other resources allocated.
 GLOBAL VARIABLES
 COMMENTS, BUGS, ASSUMPTIONS
     Can't report errors...
 EXAMPLES
 REVISION LOG
--------------------------------------------------------------------------*/
int
H5V_term_interface(void)
{
    int	n = 0;

    FUNC_ENTER_NOAPI_NOINIT_NOERR

    if(H5_interface_initialize_g) {
	if((n = H5I_nmembers(H5I_VIEW))>0) {
	    (void)H5I_clear_type(H5I_VIEW, FALSE, FALSE);
	} else {
	    (void)H5I_dec_type_ref(H5I_VIEW);
	    H5_interface_initialize_g = 0;
	    n = 1;
	}
    }
    FUNC_LEAVE_NOAPI(n)
} /* H5V_term_interface() */

/*-------------------------------------------------------------------------
 * Function:    H5Pset_view_elmt_scope
 *
 * Purpose:     Sets the view creation property for the scope of 
 *              constructing an element region.
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:  Mohamad Chaarawi
 *              February, 2014
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5Pset_view_elmt_scope(hid_t vcpl_id, hid_t space_id)
{
    H5P_genplist_t *plist;
    H5S_t *space = NULL, *new_space = NULL;
    hid_t new_space_id;
    herr_t ret_value = SUCCEED;	/* Return value */

    FUNC_ENTER_API(FAIL)
    H5TRACE2("e", "ii", vcpl_id, space_id);

    /* Check arguments */
    if(NULL == (plist = H5P_object_verify(vcpl_id, H5P_VIEW_CREATE)))
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a view create property list");

    /* Get the current view create property list for the region scope */
    if(H5P_get(plist, H5V_CRT_ELMT_SCOPE_NAME, &space_id) < 0)
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get dataspace")

    /* Close the current dataspace if set */
    if((space_id != -1) && (H5I_dec_ref(space_id) < 0))
	HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close atom for dataspace")

    if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
	HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dataspace")

    /* Copy */
    if(NULL == (new_space = H5S_copy(space, FALSE, TRUE)))
        HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy dataspace")

    /* Atomize */
    if((new_space_id = H5I_register (H5I_DATASPACE, new_space, TRUE)) < 0)
        HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom")

    /* Set the view create property list for the region scope */
    if(H5P_set(plist, H5V_CRT_ELMT_SCOPE_NAME, &new_space_id) < 0)
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set dataspace scope for vcpl")

done:
    FUNC_LEAVE_API(ret_value)
} /* end H5Pset_view_elmt_scope() */


/*-------------------------------------------------------------------------
 * Function:    H5Pget_view_elmt_scope
 *
 * Purpose:     Gets the view creation property for the scope of 
 *              constructing an element region.
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:  Mohamad Chaarawi
 *              February, 2014
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5Pget_view_elmt_scope(hid_t vcpl_id, hid_t *_space_id)
{
    H5P_genplist_t *plist; /* Property list pointer */
    hid_t space_id;
    herr_t ret_value=SUCCEED; /* Return value */

    FUNC_ENTER_API(FAIL)
    H5TRACE2("e", "i*i", vcpl_id, _space_id);

    if(NULL == _space_id)
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid return pointer")

    /* Get the plist structure */
    if(NULL == (plist = H5P_object_verify(vcpl_id, H5P_VIEW_CREATE)))
        HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")

    if(H5P_get(plist, H5V_CRT_ELMT_SCOPE_NAME, &space_id) < 0)
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get dataspace scope for view")

    if(space_id >= 0) {
        H5S_t *space = NULL, *new_space = NULL;

        if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
            HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dataspace")

        /* Copy */
        if(NULL == (new_space = H5S_copy(space, FALSE, TRUE)))
            HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy dataspace")

        /* Atomize */
        if((space_id = H5I_register (H5I_DATASPACE, new_space, TRUE)) < 0)
            HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom")
    }

    *_space_id = space_id;

done:
    FUNC_LEAVE_API(ret_value);
} /* end H5Pget_view_elmt_scope() */


/*-------------------------------------------------------------------------
 * Function:	H5Vcreate_ff
 *
 * Purpose:     The H5Vcreate routine creates a new view object from a
 *              query object. The view looks under loc_id and applies 
 *              the query there.
 *
 * Return:	Success:	non-negative
 *		Failure:	negative
 *
 * Programmer:	Mohamad Chaarawi
 *              February 2014
 *
 *-------------------------------------------------------------------------
 */
hid_t
H5Vcreate_ff(hid_t loc_id, hid_t query_id, hid_t vcpl_id, hid_t rcxt_id, hid_t estack_id)
{
    H5_priv_request_t  *request = NULL; /* private request struct inserted in event queue */
    void    **req = NULL;       /* pointer to plugin generate requests (Stays NULL if plugin does not support async */
    void    *view = NULL;       /* pointer to view object created */
    void    *obj = NULL;        /* object token of loc_id */
    H5VL_t  *vol_plugin;        /* VOL plugin information */
    hid_t ret_value;

    FUNC_ENTER_API(FAIL)
    H5TRACE5("i", "iiiii", loc_id, query_id, vcpl_id, rcxt_id, estack_id);

    /* Get correct property list */
    if(H5P_DEFAULT == vcpl_id)
        vcpl_id = H5P_VIEW_CREATE_DEFAULT;
    else
        if(TRUE != H5P_isa_class(vcpl_id, H5P_VIEW_CREATE))
            HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not view creation property list")

    /* get the object */
    if(NULL == (obj = (void *)H5VL_get_object(loc_id)))
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object/file identifier")
    /* get the plugin pointer */
    if(NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")

    if(vol_plugin->cls->value != IOD)
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "only IOD plugin supports VIEW objects for now")

    if(estack_id != H5_EVENT_STACK_NULL) {
        /* create the private request */
        if(NULL == (request = (H5_priv_request_t *)H5MM_calloc(sizeof(H5_priv_request_t))))
            HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
        request->req = NULL;
        req = &request->req;
        request->next = NULL;
        request->vol_plugin = vol_plugin;
        vol_plugin->nrefs ++;
    }

    /* call the IOD specific private routine to create a view object */
    if(NULL == (view = H5VL_iod_view_create(obj, query_id, vcpl_id, rcxt_id, req)))
        HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create view")

    if(request && *req) {
        if(H5ES_insert(estack_id, request) < 0)
            HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "failed to insert request in event stack")
    }

    /* Get an atom for the view */
    if((ret_value = H5I_register2(H5I_VIEW, view, vol_plugin, TRUE)) < 0)
	HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize view handle")

done:
    if (ret_value < 0 && view)
        if(H5V_close (view) < 0)
            HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release view")
    FUNC_LEAVE_API(ret_value)
} /* end H5Vcreate_ff */


/*-------------------------------------------------------------------------
 * Function:	H5Vget_query
 *
 * Purpose:     Returns the query used to construct the view. 
 *              Returned query must be closed with H5Qclose().
 *
 * Return:	Success:	non-negative
 *		Failure:	negative
 *
 * Programmer:	Mohamad Chaarawi
 *              February 2014
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5Vget_query(hid_t view_id, hid_t *query_id)
{
    H5VL_iod_view_t *view = NULL;
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_API(FAIL)
    H5TRACE2("e", "i*i", view_id, query_id);

    if(NULL == query_id)
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid return pointer")

    /* Check args */
    if(NULL == (view = (H5VL_iod_view_t *)H5I_object_verify(view_id, H5I_VIEW)))
	HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an view ID");

    if(H5I_inc_ref(view->query_id, TRUE) < 0)
        HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, FAIL, "can't increment ID ref count");

    *query_id = view->query_id;

done:
    FUNC_LEAVE_API(ret_value)
} /* end H5Vget_query */


/*-------------------------------------------------------------------------
 * Function:	H5Vget_counts
 *
 * Purpose:     Returns the query used to construct the view. 
 *              Returned query must be closed with H5Qclose().
 *
 * Return:	Success:	non-negative
 *		Failure:	negative
 *
 * Programmer:	Mohamad Chaarawi
 *              February 2014
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5Vget_counts(hid_t view_id, hsize_t *attr_count, hsize_t *obj_count, hsize_t *elem_region_count)
{
    H5VL_iod_view_t *view = NULL;
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_API(FAIL)
    H5TRACE4("e", "i*h*h*h", view_id, attr_count, obj_count, elem_region_count);

    /* Check args */
    if(NULL == (view = (H5VL_iod_view_t *)H5I_object_verify(view_id, H5I_VIEW)))
	HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an view ID");

    if(view->common.request) {
        if(H5VL_IOD_PENDING == view->common.request->state) {
            if(H5VL_iod_request_wait(view->common.file, view->common.request) < 0)
                HGOTO_ERROR(H5E_DATASET,  H5E_CANTGET, FAIL, "can't wait on operation");
        }
    }

    if(NULL != attr_count)
        *attr_count = view->attr_info.count;
    if(NULL != obj_count)
        *obj_count = view->obj_info.count;
    if(NULL != elem_region_count)
        *elem_region_count = view->region_info.count;

done:
    FUNC_LEAVE_API(ret_value)
} /* end H5Vget_counts */


/*-------------------------------------------------------------------------
 * Function:	H5Vget_location_ff
 *
 * Purpose:     Returns the root location where the view was constructed on. 
 *              Musr be closed with H5Oclose (or corresponding object close op).
 *
 * Return:	Success:	non-negative
 *		Failure:	negative
 *
 * Programmer:	Mohamad Chaarawi
 *              February 2014
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5Vget_location_ff(hid_t view_id, hid_t *loc_id, hid_t estack_id)
{
    H5VL_t *vol_plugin = NULL;          /* VOL plugin pointer this event queue should use */
    H5_priv_request_t  *request = NULL; /* private request struct inserted in event queue */
    void **req = NULL; /* pointer to plugin generate requests (Stays NULL if plugin does not support async */
    H5I_type_t opened_type;
    void  *opened_obj = NULL;
    H5VL_iod_view_t *view = NULL;
    H5TR_t tr;
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_API(FAIL)
    H5TRACE3("e", "i*ii", view_id, loc_id, estack_id);

    if(NULL == loc_id)
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid return pointer")

    /* Check args */
    if(NULL == (view = (H5VL_iod_view_t *)H5I_object_verify(view_id, H5I_VIEW)))
	HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an view ID");

    /* get the plugin pointer */
    if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(view_id)))
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information");

    if(estack_id != H5_EVENT_STACK_NULL) {
        /* create the private request */
        if(NULL == (request = (H5_priv_request_t *)H5MM_calloc(sizeof(H5_priv_request_t))))
            HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
        request->req = NULL;
        req = &request->req;
        request->next = NULL;
        request->vol_plugin = vol_plugin;
        vol_plugin->nrefs ++;
    }

    tr.file = view->common.file;
    tr.trans_num = view->c_version;
    tr.req_info.request = NULL;
    tr.req_info.head = NULL;
    tr.req_info.tail = NULL;
    tr.req_info.num_req = 0;

   if(NULL == (opened_obj = H5VL_iod_obj_open_token(view->loc_info.buf, 
                                                    &tr, &opened_type, req)))
        HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object");

    if(request && *req) {
        /* insert in stack */
        if(H5ES_insert(estack_id, request) < 0)
            HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "failed to insert request in event stack");
    }

    vol_plugin->nrefs ++;
    /* create hid_t for opened object */
    if ((*loc_id = H5VL_object_register(opened_obj, opened_type, vol_plugin, TRUE)) < 0)
        HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle")

done:
    FUNC_LEAVE_API(ret_value)
} /* end H5Vget_location_ff */


/*-------------------------------------------------------------------------
 * Function:	H5Vget_elem_regions_ff
 *
 * Purpose:     Returns the root location where the view was constructed on. 
 *              Musr be closed with H5Oclose (or corresponding object close op).
 *
 * Return:	Success:	non-negative
 *		Failure:	negative
 *
 * Programmer:	Mohamad Chaarawi
 *              February 2014
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5Vget_elem_regions_ff(hid_t view_id, hsize_t start, hsize_t count, hid_t dataset_id[], 
                       hid_t dataspace_id[], hid_t estack_id)
{
    H5VL_t *vol_plugin = NULL;          /* VOL plugin pointer this event queue should use */
    H5VL_iod_view_t *view = NULL;
    hsize_t i, k = 0;
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_API(FAIL)
    H5TRACE6("e", "ihh*i*ii", view_id, start, count, dataset_id, dataspace_id,
             estack_id);

    /* Check args */
    if(NULL == (view = (H5VL_iod_view_t *)H5I_object_verify(view_id, H5I_VIEW)))
	HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an view ID");

    if(view->common.request) {
        if(H5VL_IOD_PENDING == view->common.request->state) {
            if(H5VL_iod_request_wait(view->common.file, view->common.request) < 0)
                HGOTO_ERROR(H5E_DATASET,  H5E_CANTGET, FAIL, "can't wait on operation");
        }
    }

    if(start >= view->region_info.count || start+count > view->region_info.count)
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "start/count out of range")

    /* get the plugin pointer */
    if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(view_id)))
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information");

    for(i=start; i<count; i++) {
        H5_priv_request_t  *request = NULL; /* private request struct inserted in event queue */
        void **req = NULL; /* pointer to plugin generate requests (Stays NULL if plugin does not support async */
        H5I_type_t opened_type;
        void  *opened_obj = NULL;
        H5TR_t tr;

        if(estack_id != H5_EVENT_STACK_NULL) {
            /* create the private request */
            if(NULL == (request = (H5_priv_request_t *)H5MM_calloc(sizeof(H5_priv_request_t))))
                HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
            request->req = NULL;
            req = &request->req;
            request->next = NULL;
            request->vol_plugin = vol_plugin;
            vol_plugin->nrefs ++;
        }

        tr.file = view->common.file;
        tr.trans_num = view->c_version;
        tr.req_info.request = NULL;
        tr.req_info.head = NULL;
        tr.req_info.tail = NULL;
        tr.req_info.num_req = 0;

        if(NULL == (opened_obj = H5VL_iod_obj_open_token(view->region_info.tokens[i].buf, 
                                                         &tr, &opened_type, req)))
            HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object");

        HDassert(H5I_DATASET == opened_type);

        if(request && *req) {
            /* insert in stack */
            if(H5ES_insert(estack_id, request) < 0)
                HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "failed to insert request in event stack");
        }

        vol_plugin->nrefs ++;
        /* create hid_t for opened object */
        if ((dataset_id[k] = H5VL_object_register(opened_obj, opened_type, vol_plugin, TRUE)) < 0)
            HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle");

        if(H5I_inc_ref(view->region_info.regions[i], TRUE) < 0)
            HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, FAIL, "can't increment ID ref count");        
        dataspace_id[k] = view->region_info.regions[i];

        k++;
    }
done:
    FUNC_LEAVE_API(ret_value)
} /* end H5Vget_elem_regions_ff */


/*-------------------------------------------------------------------------
 * Function:	H5Vclose
 *
 * Purpose: 
 *      The H5Vclose routine terminates access to a view, given by
 *      view_id.
 *
 * Return:	Success:	non-negative
 *		Failure:	negative
 *
 * Programmer:	Mohamad Chaarawi
 *              February 2014
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5Vclose(hid_t view_id)
{
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_API(FAIL)
    H5TRACE1("e", "i", view_id);

    /* Check args */
    if(NULL == H5I_object_verify(view_id,H5I_VIEW))
	HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an view ID")

    if(H5I_dec_app_ref(view_id) < 0)
    	HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close view")

done:
    FUNC_LEAVE_API(ret_value)
} /* end H5Vclose_ff */


/*-------------------------------------------------------------------------
 * Function:	H5V_close
 *
 * Purpose:	Closes the specified view.
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Mohamad Chaarawi
 *		February 2014
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5V_close(void *view)
{
    herr_t ret_value = SUCCEED;

    FUNC_ENTER_NOAPI_NOINIT

    if((ret_value = H5VL_iod_view_close((H5VL_iod_view_t *)view)) < 0)
	HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close view")

done:
    FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5V_close() */

#endif /* H5_HAVE_EFF */