codernity avatar codernity committed 1bd683b

Documentation updated

Comments (0)

Files changed (3)

docs/codes/big_demo_embedded.py

+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+
+from CodernityDB.database import Database
+from CodernityDB.tree_index import TreeBasedIndex
+
+
+class SimpleTreeIndex(TreeBasedIndex):
+
+    def __init__(self, *args, **kwargs):
+        kwargs['node_capacity'] = 13
+        kwargs['key_format'] = 'I'
+        super(SimpleTreeIndex, self).__init__(*args, **kwargs)
+
+    def make_key_value(self, data):
+        a_val = data.get('a')
+        if a_val is not None:
+            return a_val, None
+        return None
+
+    def make_key(self, key):
+        return key
+
+
+def main():
+    db = Database('/tmp/big_emb')
+    db.create()
+    db.add_index(SimpleTreeIndex(db.path, 'tree'))
+
+    for a in xrange(100):
+        db.insert(dict(a=a, demo=True))
+
+    for c in db.get_many('tree', start=3, end=10, limit=-1, inclusive_end=True, inclusive_start=True):
+        print c
+
+    db.close()
+
+
+if __name__ == '__main__':
+    main()

docs/codes/demo_embedded.py

+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from CodernityDB.database import Database
+
+
+def main():
+    db = Database('/tmp/test_emb')
+    db.create()
+
+    for x in range(100):
+        db.insert(dict(x=x))
+
+    for curr in db.all('id'):
+        print curr
+
+
+if __name__ == '__main__':
+    main()

docs/examples.rst

 Examples
 ========
 
-Embeded mode
+Embedded mode
 
 .. literalinclude:: codes/demo_embedded.py
    :linenos:
 
 Even this will work with no code changes
 
-Embeded mode
+Embedded mode
 
 .. literalinclude:: codes/big_demo_embedded.py
    :linenos:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.