Jump to content
McObject Forums

Search the Community

Showing results for tags 'Storage'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • McObject Embedded Databases
    • Perst
  • Root2


  • Steven Graves' Blog

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL







Found 2 results

  1. Hi support, I have a problem reading back XML created by Perst. My root object contains an index with two string keys. The database seems to operate Ok, I can successfully export it as XML. The resulting XML looks Ok either. But I got the following exception when I try to read it back: org.garret.perst.StorageError: Incompatible key type at org.garret.perst.impl.Btree.checkKey(Btree.java:109) at org.garret.perst.impl.Btree.insert(Btree.java:180) at org.garret.perst.impl.XMLImporter.createIndex(XMLImporter.java:509) at org.garret.perst.impl.XMLImporter.importDatabase(XMLImporter.java:60) at org.garret.perst.impl.StorageImpl.importXML(StorageImpl.java:2643) at testperst.TestRepository.testXmlImport(TestRepository.java:43) ... I use perst-436.jar. My root class is as follows: package testperst; import org.eclipse.jdt.annotation.NonNull; import org.garret.perst.IPersistent; import org.garret.perst.Index; import org.garret.perst.Key; import org.garret.perst.Persistent; import org.garret.perst.Storage; public class MyRoot extends Persistent { public MyRoot() { } public MyRoot(@NonNull Storage storage) { super(storage); rootIndex = storage.createIndex(new @NonNull Class [] {String.class, String.class}, true); } public void put(@NonNull IPersistent o, @NonNull String a, @NonNull String { @NonNull Key key = new Key(new Object[]{a, b}); rootIndex.put(key, o); } private Index rootIndex; } The test class is: package testperst; import java.io.BufferedReader; public class TestRepository { @Test public void testInitDB() throws Exception { Storage db = getStorage(); getRootIndex(db); db.close(); } @Test public void testXmlExport() throws Exception { Storage db = getStorage(); assert db != null; try { Writer writer = new BufferedWriter(new FileWriter("/tmp/testPerst.xml")); db.exportXML(writer); writer.close(); } catch (IOException x) { System.err.println("Export failed: " + x); } db.close(); } @Test public void testXmlImport() throws Exception { Storage db = getStorage(); assert db != null; try { Reader reader = new BufferedReader(new FileReader("/tmp/testPerst.xml")); db.importXML(reader); reader.close(); } catch (IOException x) { System.err.println("Import failed: " + x); throw x; } db.close(); } private @NonNull Storage getStorage() { Storage db = StorageFactory.getInstance().createStorage(); db.open("test.dbs", Storage.DEFAULT_PAGE_POOL_SIZE); getRootIndex(db); return db; } private @NonNull MyRoot getRootIndex(@NonNull Storage db) { MyRoot o = (MyRoot) db.getRoot(); if(o == null) { o = new MyRoot(db); o.put(new Persistent(), "key1", "key2"); db.setRoot(o); } return o; } } The XML is: <?xml version="1.0" encoding="UTF-8"?> <database root="4100"> <testperst.MyRoot id="4100"> <rootIndex><ref id="4103"/></rootIndex> </testperst.MyRoot> <org.garret.perst.impl.BtreeCompoundIndex id="4103" unique="1" type0="String" type1="String"> <ref id="4097" key0="key1" key1="key2"/> </org.garret.perst.impl.BtreeCompoundIndex> <org.garret.perst.Persistent id="4097"> </org.garret.perst.Persistent> </database> Regards, Vladimir
  2. When I create a new database I go through the normal process of instantiating a root object that defines/instantiates the indices for the database and then assigning it to Storage.Root. I've done this many, many times and have never run into a problem. However, after I changed a couple of indices (as part of the normal development process), I receive a Stack Overflow error when I assign the newly created root to the Storage.Root attribute. I'm using C#, .Net 4, Perst verstion 4.36 (latest). My problem: the stack overflow occurs in such a way that I am unable to catch the error to see the stack trace. I'm looking for potential places to look for the problem. It appears to be due to the changes I've made to the indices (some new, some modified). What is new is that a couple of the indices are of type CompoundIndex. The code I use for these are as follows: Example of a CompoundIndex defined in root class (which extends Persistent): (in class VctIdx, i.e., the 'root' class for database)/** * Unique Key: * #1: 'From' Concept Uid* #2: Rel Type Uid* #3: Relationship Uid*/public CompoundIndex<Relationship> RelOutByTypeIdx; Example of instantiating this index when the root object is instantiated: vctIdx.RelOutByTypeIdx = vctIdx.Storage.CreateIndex<Relationship>(new Type[] { typeof(string), typeof(string), typeof(string) }, true); Everything compiles just fine. I only receive run time overflow error. Stack overflow error occurs when I assign the newly instantiated root to the root of the Storage object, as follows: private void initDb(){try{db = StorageFactory.Instance.CreateStorage();// set concurrent iterator property in database// to enable deletion during traversal of iteratorsdb.SetProperty("perst.concurrent.iterator", true);// newer B-tree implementation for improved performancedb.SetProperty("perst.alternative.btree", true);// perform database gc in separate thread to avoid blocking applicationdb.SetProperty("perst.background.gc", true);// do NOT support multiple applications accessing this database (default = false)// db.SetProperty("perst.multiclient.support", true);db.Open(perstDbCompleteFileName, pagePoolSize);vctIdx = (VctIdx)db.Root; if (vctIdx == null){vctIdx = new VctIdx(db, this);try{db.Root = vctIdx; <<== Overflow occurs when this statement executed, but not caught in try/catch block}catch (StackOverflowException overflow){string msg = "Stack overflow assigning VctIdx instance to the root to the ontology database";throw new StackOverflowException(msg, overflow);}}}catch (Exception ex){string msg = "Error initializing database";throw new Exception(msg, ex);}}  Of course other index types exist other than the one example above; all are either FieldIndex or MultiFieldIndex. The only nuance to these is that a FieldIndex may be 'thick'.