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.
Your intuition regarding pairs (files, offsets) is correct.
, . , , " " . , (, ), , .
, , , , , . : B-tree B + . , , . , , , , .
, "" XML, , .
: , , . , , . , relational , , , . , , .
, , :
. , .
. 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 , , . . - .
- .
, , , .
XML .
, XML-, YAML.
, , , , OpenOffice, , ( , zip OO).
; , Boost C. , .
, XML YAML, . , , , , , . , . - , . , , A1, A2, A3..., (, href=) .
, , , XML YAML - , .
, .
, .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 .
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?
Source: https://habr.com/ru/post/1727966/More articles:How can I generate multiple Perl program files programmatically? - perlWhat is a deployment descriptor, and do I really need to take care of this when using Netbeans? - javahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1727963/telerik-radwindow-javascript-return-values-to-aspnet&usg=ALkJrhhftqH08RWNEy-I2dnHsVB2mBPalQCRUD SP Generator for SQL Server 2008 (R2) - sql-serverhow to change xmldataprovider source in wpf at runtime? - c #Row level audit in MySQL - databaseSymPy: How to return an expression in terms of other expressions (expressions)? - pythonHow to get a modular variable in a function from another module? - pythonjQuery MultiSelect, how to get information about selected parameters - jqueryDjango: Why is my CharField not getting the vTextField class? - djangoAll Articles