| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| 5 | <title>Store 'hashes'</title> |
| 6 | <meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> |
| 7 | <link rel="home" href="index.html" title="Redland RDF Library Manual"> |
| 8 | <link rel="up" href="redland-storage-modules.html" title="Storage Modules"> |
| 9 | <link rel="prev" href="redland-storage-modules.html" title="Storage Modules"> |
| 10 | <link rel="next" href="redland-storage-module-memory.html" title="Store 'memory'"> |
| 11 | <meta name="generator" content="GTK-Doc V1.18 (XML mode)"> |
| 12 | <link rel="stylesheet" href="style.css" type="text/css"> |
| 13 | </head> |
| 14 | <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
| 15 | <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"> |
| 16 | <td><a accesskey="p" href="redland-storage-modules.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td> |
| 17 | <td><a accesskey="u" href="redland-storage-modules.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td> |
| 18 | <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td> |
| 19 | <th width="100%" align="center">Redland RDF Library Manual</th> |
| 20 | <td><a accesskey="n" href="redland-storage-module-memory.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td> |
| 21 | </tr></table> |
| 22 | <div class="section"> |
| 23 | <div class="titlepage"><div><div><h2 class="title" style="clear: both"> |
| 24 | <a name="redland-storage-module-hashes"></a>Store 'hashes'</h2></div></div></div> |
| 25 | <p>This module is always present (cannot be removed) and provides |
| 26 | indexed storage using Redland <a class="xref" href="redland-storage.html" title="Triple stores"><span class="refentrytitle"><a name="redland-storage.top_of_page"></a>Triple stores</span>(3)</a> to |
| 27 | store various combinations of subject, predicate and object for |
| 28 | faster access. Context nodes are also stored in a hash when used. |
| 29 | The hashes may be in-memory (always available) or persistent via |
| 30 | Sleepycat/Berkeley DB (BDB) versions 2-4. It is the most mature and |
| 31 | primary persistent store and suitable for large models, tested in the |
| 32 | 2-3 million range..</p> |
| 33 | <p>The main option requiring setting is the |
| 34 | <code class="literal">hash-type</code> which must be one of the supported |
| 35 | Redland hashes. Hash type <code class="literal">memory</code> is always |
| 36 | available and if BDB has been compiled in, <code class="literal">bdb</code> is |
| 37 | also available. Option <code class="literal">dir</code> can be used to set the |
| 38 | destination directory for the BDB files when used. Boolean option |
| 39 | <code class="literal">new</code> can be set to force creation or truncation |
| 40 | of a persistent hashed store. The storage |
| 41 | name must be given for hash type <code class="literal">bdb</code> since |
| 42 | it is used for a filename. |
| 43 | </p> |
| 44 | <p>The module provides optional contexts support enabled when |
| 45 | boolean storage option <code class="literal">contexts</code> is set. This |
| 46 | can be used with any hash type.</p> |
| 47 | <p>Examples:</p> |
| 48 | <pre class="programlisting"> |
| 49 | /* A new BDB hashed persistent store in the current directory */ |
| 50 | storage=librdf_new_storage(world, "hashes", "db1", |
| 51 | "new='yes',hash-type='bdb',dir='.'"); |
| 52 | |
| 53 | /* Hashed in-memory store */ |
| 54 | storage=librdf_new_storage(world, "hashes", NULL, |
| 55 | "hash-type='memory'"); |
| 56 | |
| 57 | /* An existing BDB hashed persistent store in dir /somewhere */ |
| 58 | storage=librdf_new_storage(world, "hashes", "dv2", |
| 59 | "hash-type='bdb',dir='/somewhere'"); |
| 60 | |
| 61 | /* An existing BDB hashed store with contexts */ |
| 62 | storage=librdf_new_storage(world, "hashes", "db3", |
| 63 | "hash-type='bdb',contexts='yes'"); |
| 64 | </pre> |
| 65 | <p>In Python:</p> |
| 66 | <pre class="programlisting"> |
| 67 | from RDF import * |
| 68 | ... |
| 69 | # Create a new BDB store |
| 70 | storage = HashStorage("db4", options="new='yes',hash-type='bdb'") |
| 71 | </pre> |
| 72 | <p>In Perl:</p> |
| 73 | <pre class="programlisting"> |
| 74 | use RDF::Redland; |
| 75 | ... |
| 76 | # Open an existing BDB store |
| 77 | $storage=new RDF::Redland::Storage("hashes", "db5", |
| 78 | "hash-type='bdb',dir='.'"); |
| 79 | </pre> |
| 80 | <p>Summary:</p> |
| 81 | <div class="itemizedlist"><ul class="itemizedlist" type="disc"> |
| 82 | <li class="listitem"><p>Persistent or in-memory</p></li> |
| 83 | <li class="listitem"><p>Suitable for larger models</p></li> |
| 84 | <li class="listitem"><p>Indexed</p></li> |
| 85 | <li class="listitem"><p>Large disk usage with BDB</p></li> |
| 86 | <li class="listitem"><p>Optional contexts (with option <code class="literal">contexts</code> set)</p></li> |
| 87 | </ul></div> |
| 88 | </div> |
| 89 | <div class="footer"> |
| 90 | <hr> |
| 91 | Generated by GTK-Doc V1.18</div> |
| 92 | </body> |
| 93 | </html> |