How do pointers to disk work?

Suppose I want to store a complex data structure (tree, say) on disk. The internal pointers that connect the nodes in my data structures are pointers, but I can't just write these pointers to disk, because when I read the data structure, the memory cells will be changed.

So what is the correct way to store pointers to disk? Is the answer as simple as (File, Offset), or is there something I am missing? I can understand how pointers can be converted to pairs (File, offset) and vice versa, but are there any subtleties that I should follow?

Edit: I should mention that I am particularly interested in how the database will do this internally, for a b-tree. I probably posed the question more general than it should, although I really appreciate the answers based on XML.

+3
source share
5 answers

Your intuition regarding pairs (files, offsets) is correct.

, . , , " " . , (, ), , .

, , , , , . : B-tree B + . , , . , , , , .

, "" XML, , .

: , , . , , . , relational , , , . , , .

, , :

  • /
  • ( )




. , .

+3

. node , .

:

  • ,
  • , node,

. - , inode .

-, unsigned ints , int. , node... node .

XML XPath/XPointers.

<Node id="someNode">
    <value>...</value>
    <children>
        <child xpath="/node[id=1]" />
        <child xpath="/node[id=29]" />

, (eww). , , :

<value>/path/to/mappable.bin</value>

XML- , C .

XML , , . . - .

- .

+1

-

, , , .

XML .

, XML-, YAML.

, , , , OpenOffice, , ( , zip OO).

; , Boost C. , .

, XML YAML, . , , , , , . , . - , . , , A1, A2, A3..., (, href=) .

, , , XML YAML - , .

+1

, .

, .
Nested Set Model, .

, :


[meta-data][data]

[meta-data] = [ length ][ list-of-Nested-Set-Model-Locations ] [ list-of-data-records ] = [ lft-#1 ][ rgt-#1 ][ lft-#2 ][ rgt-#2 ] ... [data] = [length][ payload / data-itself ]

, JSON () XML .

+1

Can you redeem your tree in memory? This sounds like a normal java issue sending an object over a network. Objects have links to other things, but the address of the pointer will change once from the address space of the program. Could you serialize your tree in XML or JSON form?

0
source

Source: https://habr.com/ru/post/1727966/


All Articles