summaryrefslogtreecommitdiffstats
path: root/doc/html/TechNotes/MoveDStruct.html
blob: cca0879e3bb2abfb5ceeb0225fd57c8c028a525e (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
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
  <head>
    <title>Relocating a File Data Structure</title>
  </head>

  <body>

<!-- #BeginLibraryItem "/ed_libs/copyright-html.lbi" -->
  <!-- separator -->
  <!--
  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  * 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://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html.  If you do not have     *
  * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 -->
  <!-- separator -->
  <!-- #EndLibraryItem -->
   
  <h1>Relocating a File Data Structure</h1>

      <p>Since file data structures can be cached in memory by the H5AC
	package it becomes problematic to move such a data structure in
	the file. One cannot just copy a portion of the file from one
	location to another because:

      <ol>
	<li>the file might not contain the latest information, and</li>
	<li>the H5AC package might not realize that the object's
	  address has changed and attempt to write the object to disk
	  at the old address.</li>
      </ol>
      
      <p>Here's a correct method to move data from one location to
	another.  The example code assumes that one is moving a B-link
	tree node from <code>old_addr</code> to <code>new_addr</code>.
	
      <ol>
	<li>Make sure the disk is up-to-date with respect to the
	  cache.  There is no need to remove the item from the cache,
	  hence the final argument to <code>H5AC_flush</code> is
	  <code>FALSE</code>.
	  <br><br>
	  <code>
	    H5AC_flush (f, H5AC_BT, old_addr, FALSE);<br>
	  </code>
	  <br>
	</li>
	
	<li>Read the data from the old address and write it to the new
	  address.
	  <br><br>
	  <code>
	    H5F_block_read (f, old_addr, size, buf);<br>
	    H5F_block_write (f, new_addr, size, buf);<br>
	  </code>
	  <br>
	</li>
	  
	<li>Notify the cache that the address of the object changed.
	  <br><br>
	  <code>
	    H5AC_rename (f, H5AC_BT, old_addr, new_addr);<br>
	  </code>
	  <br>
	</li>
      </ol>
	  


      <hr>
      <address><a href="mailto:robb@maya.nuance.com">Robb Matzke</a></address>
<!-- Created: Mon Jul 14 15:09:06 EST 1997 -->
<!-- hhmts start -->
Last modified: Mon Jul 14 15:38:29 EST 
<!-- hhmts end -->
  </body>
</html>