summaryrefslogtreecommitdiffstats
path: root/relmddif
diff options
context:
space:
mode:
Diffstat (limited to 'relmddif')
-rw-r--r--relmddif/Makefile.am49
-rw-r--r--relmddif/dbiterid.hh33
-rw-r--r--relmddif/dbmddobj.hh254
-rw-r--r--relmddif/dbmddobj.pgc546
-rw-r--r--relmddif/dbmddset.hh176
-rw-r--r--relmddif/dbmddset.pgc314
-rw-r--r--relmddif/dbmddsetcommon.cc281
-rw-r--r--relmddif/mddid.hh36
-rw-r--r--relmddif/test/Makefile77
-rw-r--r--relmddif/test/dbiteritest.C67
-rw-r--r--relmddif/test/dbmddcollidt.C111
-rw-r--r--relmddif/test/dbmddcolloidentryt.C101
-rw-r--r--relmddif/test/dbobjtest.C150
-rw-r--r--relmddif/test/intervaltest.C120
-rw-r--r--relmddif/test/mdditest.C312
15 files changed, 2627 insertions, 0 deletions
diff --git a/relmddif/Makefile.am b/relmddif/Makefile.am
new file mode 100644
index 0000000..d225fc4
--- /dev/null
+++ b/relmddif/Makefile.am
@@ -0,0 +1,49 @@
+# -*-Makefile-*- (for Emacs)
+# This file is part of rasdaman community.
+#
+# Rasdaman community is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Rasdaman community is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+#
+# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+# rasdaman GmbH.
+#
+# For more information please see <http://www.rasdaman.org>
+# or contact Peter Baumann via <baumann@rasdaman.com>.
+#
+#
+# MAKEFILE FOR:
+# mddif
+#
+# COMMENTS:
+# uses O2
+#
+##################################################################
+
+AM_CXXFLAGS=@BASEDBCXXFLAGS@
+AM_LDFLAGS=@BASEDBLDFLAGS@
+
+.SUFFIXES= .@EMBEDDEDSQLEXT@ .@EMBEDDEDSQLOUT@
+.@EMBEDDEDSQLEXT@.@EMBEDDEDSQLOUT@:
+ $(EMBEDDEDSQLPRECOMPILER) $@ $<
+
+noinst_LIBRARIES=librelmddif.a
+librelmddif_a_SOURCES=dbmddsetcommon.cc dbmddobj.hh dbmddset.hh dbiterid.hh mddid.hh
+EXTRA_librelmddif_a_SOURCES= dbmddobj.pgc dbmddset.pgc
+librelmddif_a_LIBADD=dbmddobj.$(OBJEXT) dbmddset.$(OBJEXT)
+librelmddif_a_DEPENDENCIES=dbmddobj.$(OBJEXT) dbmddset.$(OBJEXT)
+
+BUILT_SOURCES=dbmddobj.@EMBEDDEDSQLOUT@ dbmddset.@EMBEDDEDSQLOUT@
+
+CLEANFILES=dbmddobj.@EMBEDDEDSQLOUT@ dbmddset.@EMBEDDEDSQLOUT@ \
+ client.bm client.dbg client.log ir.out core
+
diff --git a/relmddif/dbiterid.hh b/relmddif/dbiterid.hh
new file mode 100644
index 0000000..b41583b
--- /dev/null
+++ b/relmddif/dbiterid.hh
@@ -0,0 +1,33 @@
+/*
+* This file is part of rasdaman community.
+*
+* Rasdaman community is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* Rasdaman community is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+*
+* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+rasdaman GmbH.
+*
+* For more information please see <http://www.rasdaman.org>
+* or contact Peter Baumann via <baumann@rasdaman.com>.
+*/
+#ifndef _DBITERID_HH_
+#define _DBITERID_HH_
+
+class DBMDDObj;
+#include "dbobjectiterator.hh"
+
+typedef DBObjectIterator<DBMDDObj> DBIter;
+typedef DBIter* DBIterId;
+
+#endif
+
diff --git a/relmddif/dbmddobj.hh b/relmddif/dbmddobj.hh
new file mode 100644
index 0000000..4497373
--- /dev/null
+++ b/relmddif/dbmddobj.hh
@@ -0,0 +1,254 @@
+/*
+* This file is part of rasdaman community.
+*
+* Rasdaman community is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* Rasdaman community is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+*
+* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+rasdaman GmbH.
+*
+* For more information please see <http://www.rasdaman.org>
+* or contact Peter Baumann via <baumann@rasdaman.com>.
+*/
+#ifndef _DBMDDOBJ_HH_
+#define _DBMDDOBJ_HH_
+
+#include <iostream>
+class ObjectBroker;
+class BaseType;
+class MDDBaseType;
+class OIdIf;
+class r_Minterval;
+class r_Error;
+class DBMinterval;
+
+#include "mddid.hh"
+#include "relindexif/indexid.hh"
+#include "reladminif/dbobject.hh"
+#include "raslib/mddtypes.hh"
+#include "relstorageif/storageid.hh"
+#include "relstorageif/dbstoragelayout.hh"
+
+//@ManMemo: Module: {\bf relmddif}
+/*@Doc:
+A {\tt DBMDDObj} object links all neccessary persistent data for an MDD
+object. One DBMDDObj can be inserted in multiple MDD Collections. It will
+only be deleted from the database when there are no more references in MDD
+Collections. This is done through persistent reference counting.
+
+The DBMDDObj stores the following data:
+-MDDBaseType: type information on the data that is stored in it.
+-Definition domain: the spatial domain this object may extend to. This
+ domain may have open boundaries.
+-Index: a refernce to the index which holds the actual data.
+-Storagelayout: has asorted methods for modifying how the data is stored in the database.
+The definition domain is stored in an extensible but inefficient way.
+*/
+
+class DBMDDObj : public DBObject
+ {
+ public:
+ DBMDDObj( const MDDBaseType* type,
+ const r_Minterval& domain,
+ const DBObjectId& i,
+ const DBStorageLayoutId& s,
+ const OId& theMDDObj) throw (r_Error);
+ /*@Doc:
+ type: it contains the basetype which will be used to create perstiles.
+ domain: the definition domain. the extend to which the mdd object may grow.
+ i: the index structure which should be used. there has to be some way to use DBRef<IndexDS>.
+ s: the storage layout object.
+ theMDDObj: this oid may not be assigned to an mdd object yet!
+ */
+
+ DBMDDObj( const MDDBaseType* newMDDType,
+ const r_Minterval& domain,
+ const DBObjectId& newObjIx,
+ const DBStorageLayoutId& newSL);
+ /*@Doc:
+ newMDDType: it contains the basetype which will be used to create perstiles.
+ domain: the definition domain. the extend to which the mdd object may grow.
+ newObjIx: the index structure which should be used. there has to be some way to use DBRef<IndexDS>.
+ s: the storage layout object.
+ The oid is generated by the object itself.
+ */
+
+ const MDDBaseType* getMDDBaseType() const;
+ /*@Doc:
+ return the mddbasetype for this object.
+ */
+
+ DBStorageLayoutId getDBStorageLayout() const;
+ /*@Doc:
+ return the storage layout object for this mdd object.
+ */
+
+ const char* getCellTypeName() const;
+ /*@Doc:
+ Returns the name of the base type of this MDD object cells.
+ */
+
+ const BaseType* getCellType() const;
+ /*@Doc:
+ Returns the base type of this MDD object cells.
+ */
+
+ r_Dimension dimensionality() const;
+ /*@Doc:
+ Returns dimensionality of the object.
+ */
+
+ r_Minterval getDefinitionDomain() const;
+ /*@Doc:
+ Returns the definition domain of the object.
+ */
+
+ r_Bytes getHeaderSize() const;
+ /*@Doc:
+ Returns the size of the header for an MDD object.
+ The size returned by this funtion is an approximation to
+ the size of the actual physical storage space used by the
+ base DBMS. In the current implementation:
+ HeaderSize = MDDBaseType*Size + r_Minterval*Size +
+ DBMDDObjIxSize + DBObjectSize
+ This should be reviewed and renamed to
+ getPhysicalStorageSize
+ */
+
+ virtual void printStatus(unsigned int level = 0, std::ostream& stream = cout) const;
+ /*@Doc:
+ Prints the status of the object:
+ the name of the cell type
+ the definition domain
+ the index contents
+ */
+
+ void setIx(const DBObjectId& newObjIx);
+ /*@Doc:
+ make the mdd object use newObjIx instead of its old index structure.
+ the old index structure is not deleted from the database!
+ */
+
+ DBObjectId getDBIndexDS() const;
+ /*@Doc:
+ Returns the reference to the index.
+ */
+
+ DBMDDObj(const DBMDDObj& old);
+ /*@Doc:
+ Copy constructor should never be used.
+ Should raise a r_Error.
+ */
+
+ virtual ~DBMDDObj();
+ /*@Doc:
+ Validates the object and deletes the definition domain.
+ */
+
+ virtual void setPersistent(bool t = true) throw (r_Error);
+ /*@Doc:
+ Was overridden to pass changes to definition domain, storage layout and
+ to the index.
+ */
+
+ virtual void setCached(bool ic);
+ /*@Doc:
+ overrides DBObject to handle the DBMinterval
+ */
+
+ void incrementPersRefCount();
+ /*@Doc:
+ used by mddset to tell the mddobj that there is an
+ additional mddset ref to it
+ */
+
+ void decrementPersRefCount();
+ /*@Doc:
+ used by mddset to tell the mddobj that there is an mddset
+ ref less to it
+ */
+
+ int getPersRefCount() const;
+ /*@Doc:
+ returns the number of persistent references to this object.
+ when zero, the object may be deleted
+ */
+
+ virtual r_Bytes getMemorySize() const;
+ /*@Doc:
+ Calculates the size of this object in main memory.
+ */
+
+ protected:
+ friend class ObjectBroker;
+
+ DBMDDObj(const OId& id) throw (r_Error);
+ /*@Doc:
+ Constructs a DBMDDObj from the database.
+ */
+
+ virtual void insertInDb() throw (r_Error);
+ /*@Doc:
+
+ */
+
+ virtual void deleteFromDb() throw (r_Error);
+ /*@Doc:
+
+ */
+
+ virtual void readFromDb() throw (r_Error);
+ /*@Doc:
+
+ */
+
+ virtual void updateInDb() throw (r_Error);
+ /*@Doc:
+
+ */
+
+ private:
+
+ int persistentRefCount;
+ /*@Doc:
+ number of persistent references (by mddsets) to this object
+ */
+
+ DBMDDObj();
+ /*@Doc:
+ creates an empty object and does NOT register it
+ with ObjectBroker.
+ */
+
+ const MDDBaseType* mddType;
+ /*@Doc:
+ Type of this object.
+ */
+
+ DBMinterval* myDomain;
+ /*@Doc:
+ Definition domain for the object.
+ */
+
+ DBStorageLayoutId storageLayoutId;
+ /*@Doc:
+ StorageLayout OId
+ */
+
+ DBObjectId objIxId;
+ /*@Doc:
+ Index OId
+ */
+ };
+
+#endif
diff --git a/relmddif/dbmddobj.pgc b/relmddif/dbmddobj.pgc
new file mode 100644
index 0000000..58f41d0
--- /dev/null
+++ b/relmddif/dbmddobj.pgc
@@ -0,0 +1,546 @@
+// This is -*- C++ -*-
+
+/*
+* This file is part of rasdaman community.
+*
+* Rasdaman community is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* Rasdaman community is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+*
+* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+rasdaman GmbH.
+*
+* For more information please see <http://www.rasdaman.org>
+* or contact Peter Baumann via <baumann@rasdaman.com>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ *
+ *
+ * COMMENTS:
+ *
+ ************************************************************/
+
+
+#include "reladminif/oidif.hh"
+#include "reladminif/dbref.hh"
+#include "reladminif/sqlerror.hh"
+#include "reladminif/externs.h"
+#include "raslib/rmdebug.hh"
+#include "catalogmgr/typefactory.hh"
+#include "relcatalogif/mddbasetype.hh"
+#include "relcatalogif/basetype.hh"
+#include "reladminif/objectbroker.hh"
+#include "relcatalogif/dbminterval.hh"
+#include "relstorageif/dbstoragelayout.hh"
+#include "dbmddobj.hh"
+#include "relindexif/indexid.hh"
+#include "indexmgr/indexds.hh"
+
+#include "debug-srv.hh"
+
+
+DBMDDObj::DBMDDObj()
+ : DBObject(),
+ myDomain(NULL),
+ objIxId(),
+ mddType(NULL),
+ persistentRefCount(0),
+ storageLayoutId(new DBStorageLayout())
+{
+ RMDBGENTER(7, RMDebug::module_mddif, "DBMDDObj", "DBMDDObj()");
+ ENTER( "DBMDDObj::DBMDDObj" );
+
+ objecttype = OId::MDDOID;
+ myDomain = new DBMinterval();
+ myDomain->setPersistent(true);
+ storageLayoutId->setPersistent(true);
+
+ LEAVE( "DBMDDObj::DBMDDObj" );
+ RMDBGEXIT(7, RMDebug::module_mddif, "DBMDDObj", "DBMDDObj()");
+}
+
+DBMDDObj::DBMDDObj(const OId& id) throw (r_Error)
+ : DBObject(id),
+ myDomain(NULL),
+ objIxId(),
+ persistentRefCount(0),
+ mddType(NULL),
+ storageLayoutId((double)0)
+{
+ RMDBGENTER(7, RMDebug::module_mddif, "DBMDDObj", "DBMDDObj(" << myOId << ")");
+ ENTER( "DBMDDObj::DBMDDObj, id=" << id );
+
+ objecttype = OId::MDDOID;
+ readFromDb();
+
+ LEAVE( "DBMDDObj::DBMDDObj" );
+ RMDBGEXIT(7, RMDebug::module_mddif, "DBMDDObj", "DBMDDObj(" << myOId << ")");
+}
+
+DBMDDObj::DBMDDObj( const MDDBaseType* newMDDType,
+ const r_Minterval& domain,
+ const DBObjectId& newObjIx,
+ const DBStorageLayoutId& newSL,
+ const OId& newOId) throw (r_Error)
+ : DBObject(),
+ objIxId(newObjIx.getOId()),
+ mddType(newMDDType),
+ persistentRefCount(0),
+ storageLayoutId(newSL),
+ myDomain(NULL)
+{
+ RMDBGENTER(7, RMDebug::module_mddif, "DBMDDObj", "DBMDDObj(" << newMDDType->getName() << ", " << domain << ", Ix " << newObjIx.getOId() << ", Sl " << newSL.getOId() << ", " << newOId << ")");
+ ENTER( "DBMDDObj::DBMDDObj" );
+
+ objecttype = OId::MDDOID;
+ EXEC SQL BEGIN DECLARE SECTION;
+ long testoid1;
+ EXEC SQL END DECLARE SECTION;
+
+ testoid1 = newOId.getCounter();
+
+ TALK( "EXEC SQL SELECT MDDId INTO :testoid1 FROM RAS_MDDOBJECTS WHERE MDDId = " << testoid1 );
+ EXEC SQL SELECT
+ MDDId
+ INTO
+ :testoid1
+ FROM
+ RAS_MDDOBJECTS
+ WHERE
+ MDDId = :testoid1;
+ if (SQLCODE != SQLNODATAFOUND)
+ {
+ ((DBObjectId)newObjIx)->setPersistent(false);
+ ((DBObject*)newSL.ptr())->setPersistent(false);
+ if (SQLCODE == SQLOK)
+ {
+ RMDBGMIDDLE(1, RMDebug::module_mddif, "DBMDDObj", "OId is already there");
+ RMInit::logOut << "DBMDDObj::DBMDDObj(...) OId already exists" << endl;
+ throw r_Error(r_Error::r_Error_OIdNotUnique);
+ }
+ else
+ {
+ check("DBMDDObj(type, domain, index, layout, oid)");
+ generateException();
+ }
+ }
+ if (newMDDType->isPersistent())
+ mddType = newMDDType;
+ else
+ mddType = (const MDDBaseType*)TypeFactory::addMDDType(newMDDType);
+ myDomain = new DBMinterval(domain);
+ _isPersistent = true;
+ _isModified = true;
+ myOId = newOId;
+ setPersistent(true);
+
+ LEAVE( "DBMDDObj::DBMDDObj, " << newMDDType->getName() << ", " << domain << ", Ix " << newObjIx.getOId() << ", " << myOId << ") " << myOId );
+ RMDBGEXIT(7, RMDebug::module_mddif, "DBMDDObj", "DBMDDObj(" << newMDDType->getName() << ", " << domain << ", Ix " << newObjIx.getOId() << ", " << myOId << ") " << myOId);
+}
+
+
+DBMDDObj::DBMDDObj(const DBMDDObj& old)
+ : DBObject(old),
+ objIxId(),
+ mddType(NULL),
+ persistentRefCount(0),
+ storageLayoutId(),
+ myDomain(NULL)
+{
+ RMDBGENTER(7, RMDebug::module_mddif, "DBMDDObj", "DBMDDObj(const DBMDDObj&" << old.getOId() << ")");
+ ENTER( "DBMDDObj::DBMDDObj" );
+
+ if (old.myDomain)
+ {
+ if (old.myDomain->isPersistent())
+ {
+ myDomain = (DBMinterval*)ObjectBroker::getObjectByOId(old.myDomain->getOId());
+ }
+ else
+ {
+ myDomain = new DBMinterval(*old.myDomain);
+ myDomain->setPersistent(true);
+ }
+ }
+ else
+ {
+ myDomain = NULL;
+ }
+
+ objIxId = old.objIxId;
+ storageLayoutId = old.storageLayoutId;
+ persistentRefCount = old.persistentRefCount;
+ mddType = old.mddType;
+
+ LEAVE( "DBMDDObj::DBMDDObj" );
+ RMDBGEXIT(7, RMDebug::module_mddif, "DBMDDObj", "DBMDDObj(const DBMDDObj& " << old.getOId() << ")");
+}
+
+DBMDDObj::DBMDDObj(const MDDBaseType* newMDDType, const r_Minterval& domain, const DBObjectId& newObjIx, const DBStorageLayoutId& newSL)
+ : DBObject(),
+ objIxId(newObjIx),
+ mddType(NULL),
+ persistentRefCount(0),
+ storageLayoutId(newSL),
+ myDomain(NULL)
+{
+ RMDBGENTER(7, RMDebug::module_mddif, "DBMDDObj", "DBMDDObj(" << newMDDType->getName() << ", " << domain << ", Ix " << newObjIx.getOId() << ", Sl " << newSL.getOId() << ")");
+ ENTER( "DBMDDObj::DBMDDObj" );
+
+ objecttype = OId::MDDOID;
+ myDomain = new DBMinterval(domain);
+ mddType = newMDDType;
+/*only if it is a persistent mdd
+ if (newMDDType->isPersistent())
+ mddType = (MDDBaseType*)newMDDType;
+ else
+ mddType = (MDDBaseType*)TypeFactory::addMDDType(newMDDType);
+ setPersistent(true);
+*/
+
+ LEAVE( "DBMDDObj::DBMDDObj" );
+ RMDBGEXIT(7, RMDebug::module_mddif, "DBMDDObj", "DBMDDObj(" << newMDDType->getName() << ", " << domain << ", Ix " << newObjIx.getOId() << ") " << myOId);
+}
+
+DBMDDObj::~DBMDDObj()
+{
+ RMDBGENTER(7, RMDebug::module_mddif, "DBMDDObj", "~DBMDDObj() " << myOId);
+ ENTER( "DBMDDObj::~DBMDDObj" );
+
+ validate();
+ if (myDomain)
+ delete myDomain;
+ myDomain = NULL;
+
+ LEAVE( "DBMDDObj::~DBMDDObj" );
+ RMDBGEXIT(7, RMDebug::module_mddif, "DBMDDObj", "~DBMDDObj() " << myOId);
+}
+
+DBStorageLayoutId
+DBMDDObj::getDBStorageLayout() const
+{
+ return storageLayoutId;
+}
+
+r_Bytes
+DBMDDObj::getMemorySize() const
+{
+ return DBObject::getMemorySize() + sizeof(long) + sizeof(MDDBaseType*) + sizeof(DBMinterval*) + sizeof(OId) + myDomain->getMemorySize() + mddType->getMemorySize() + sizeof(OId);
+}
+
+const MDDBaseType*
+DBMDDObj::getMDDBaseType() const
+{
+ return mddType;
+}
+
+const BaseType*
+DBMDDObj::getCellType() const
+{
+ return mddType->getBaseType();
+}
+
+r_Dimension
+DBMDDObj::dimensionality() const
+{
+ return myDomain->dimension();
+}
+
+void
+DBMDDObj::setCached(bool ic)
+{
+ DBObject::setCached(ic);
+ if (myDomain)
+ myDomain->setCached(ic);
+}
+
+//this should only receive an setPersistent(false)
+void
+DBMDDObj::setPersistent(bool o) throw (r_Error)
+{
+ RMDBGENTER(7, RMDebug::module_mddif, "DBMDDObj", "setPersistent(" << (int)o << ") " << myOId);
+ ENTER( "DBMDDObj::setPersistent, o=" << o );
+
+ DBObject::setPersistent(o);
+ if (!o)
+ setCached(false);
+ if (myDomain)
+ myDomain->setPersistent(o);
+ DBObjectId testIx(objIxId);
+ if (testIx.is_null())
+ {
+ RMDBGMIDDLE(0, RMDebug::module_mddif, "DBMDDObj", "index object is not valid " << myOId << " index " << objIxId.getOId());
+ throw r_Error(INDEX_OF_MDD_IS_NULL);
+ }
+ else
+ {
+ testIx->setPersistent(o);
+ if (o)
+ {
+ objIxId.release();
+ }
+ }
+
+ if (storageLayoutId.is_null())
+ {
+ RMDBGMIDDLE(0, RMDebug::module_mddif, "DBMDDObj", "layout object is not valid " << myOId << " layout " << storageLayoutId.getOId());
+ RMInit::logOut << "DBMDDObj::setPersistent() layout object is not valid" << endl;
+ throw r_Error(STORAGE_OF_MDD_IS_NULL);
+ }
+ else
+ {
+ storageLayoutId->setPersistent(o);
+ }
+ if (o && !mddType->isPersistent())
+ mddType = (const MDDBaseType*)TypeFactory::addMDDType(mddType);
+
+ LEAVE( "DBMDDObj::setPersistent, o=" << o );
+ RMDBGEXIT(7, RMDebug::module_mddif, "DBMDDObj", "setPersistent(" << (int)o << ") " << myOId);
+}
+
+const char*
+DBMDDObj::getCellTypeName() const
+{
+ return mddType->getBaseType()->getTypeName();
+}
+
+r_Minterval
+DBMDDObj::getDefinitionDomain() const
+{
+ return *myDomain;
+}
+
+r_Bytes
+DBMDDObj::getHeaderSize() const
+{
+ r_Bytes sz = sizeof(MDDBaseType*) + sizeof(r_Minterval*) + sizeof(DBObjectId) + sizeof(DBObject) + sizeof(DBStorageLayoutId);
+ return sz;
+}
+
+void
+DBMDDObj::printStatus(unsigned int level, ostream& stream) const
+{
+ DBObject::printStatus(level, stream);
+ stream << *myDomain << endl;
+ mddType->printStatus(level + 1, stream);
+ DBObjectId testIx(objIxId);
+ if (!testIx.is_null())
+ testIx->printStatus(level + 1, stream);
+ else
+ stream << "index is invalid " << objIxId.getOId();
+ if (storageLayoutId.is_null())
+ stream << "storagelayout is invalid " << storageLayoutId.getOId();
+ else
+ storageLayoutId->printStatus(level + 1, stream);
+}
+
+void
+DBMDDObj::setIx(const DBObjectId& newIx)
+{
+ ENTER( "DBMDDObj::setIx" );
+
+ if (isPersistent())
+ {
+ if (objIxId.getOId() != newIx.getOId())
+ {
+ objIxId = newIx.getOId();
+ setModified();
+ }
+ }
+ else
+ {
+ objIxId = newIx;
+ }
+
+ LEAVE( "DBMDDObj::setIx" );
+}
+
+void
+DBMDDObj::updateInDb() throw (r_Error)
+{
+ RMDBGENTER(7, RMDebug::module_mddif, "DBMDDObj", "updateInDb() " << myOId);
+ ENTER( "DBMDDObj::updateInDb" );
+
+ EXEC SQL BEGIN DECLARE SECTION;
+ long mddoid3;
+ double objindex3;
+ long persRefCount3;
+ EXEC SQL END DECLARE SECTION;
+
+ objindex3 = objIxId.getOId();
+ mddoid3 = myOId.getCounter();
+ persRefCount3 = persistentRefCount;
+
+ TALK( "EXEC SQL UPDATE RAS_MDDOBJECTS SET PersRefCount = " << persRefCount3 << ", NodeOId = " << objindex3 << " WHERE MDDId = " << mddoid3 );
+ EXEC SQL UPDATE RAS_MDDOBJECTS SET PersRefCount = :persRefCount3, NodeOId = :objindex3
+ WHERE MDDId = :mddoid3;
+ if (SQLCODE != SQLOK)
+ {
+ check("DBMDDObj::updateInDb()\0");
+ generateException();
+ }
+
+ DBObject::updateInDb();
+
+ LEAVE( "DBMDDObj::updateInDb" );
+ RMDBGEXIT(7, RMDebug::module_mddif, "DBMDDObj", "updateInDb() " << myOId);
+}
+
+void
+DBMDDObj::insertInDb() throw (r_Error)
+{
+ RMDBGENTER(7, RMDebug::module_mddif, "DBMDDObj", "insertInDb() " << myOId);
+ ENTER( "DBMDDObj::insertInDb" );
+
+ EXEC SQL BEGIN DECLARE SECTION;
+ long mddoid;
+ double basetypeid;
+ double storage;
+ long domainid;
+ double objindex;
+ long persRefCount;
+ EXEC SQL END DECLARE SECTION;
+
+ storage = storageLayoutId->getOId();
+ objindex = objIxId.getOId();
+ mddoid = myOId.getCounter();
+ basetypeid = mddType->getOId();
+ domainid = myDomain->getOId().getCounter();
+ persRefCount = persistentRefCount;
+
+ TALK( "EXEC SQL INSERT INTO RAS_MDDOBJECTS ( MDDId, BaseTypeOId, DomainId, PersRefCount, NodeOId, StorageOId) VALUES ( " << mddoid << "," << basetypeid<< "," << domainid<< "," << persRefCount << "," << objindex << "," << storage << ")" );
+ EXEC SQL INSERT INTO RAS_MDDOBJECTS ( MDDId, BaseTypeOId, DomainId, PersRefCount, NodeOId, StorageOId)
+ VALUES ( :mddoid, :basetypeid, :domainid, :persRefCount, :objindex, :storage);
+ if (SQLCODE != SQLOK)
+ {
+ check("DBMDDObj::insertInDb()");
+ generateException();
+ }
+
+ DBObject::insertInDb();
+
+ LEAVE( "DBMDDObj::insertInDb" );
+ RMDBGEXIT(7, RMDebug::module_mddif, "DBMDDObj", "insertInDb() " << myOId);
+}
+
+void
+DBMDDObj::deleteFromDb() throw (r_Error)
+{
+ RMDBGENTER(7, RMDebug::module_mddif, "DBMDDObj", "deleteFromDb() " << myOId);
+ ENTER( "DBMDDObj::deleteFromDb" );
+
+ EXEC SQL BEGIN DECLARE SECTION;
+ long mddoid1;
+ EXEC SQL END DECLARE SECTION;
+
+ mddoid1 = myOId.getCounter();
+
+ TALK( "EXEC SQL DELETE FROM RAS_MDDOBJECTS WHERE MDDId = " << mddoid1 );
+ EXEC SQL DELETE FROM RAS_MDDOBJECTS WHERE MDDId = :mddoid1;
+ if (SQLCODE != SQLOK)
+ {
+ check("DBMDDObj::deleteFromDb()\0");
+ generateException();
+ }
+ DBObject::deleteFromDb();
+
+ LEAVE( "DBMDDObj::deleteFromDb" );
+ RMDBGEXIT(7, RMDebug::module_mddif, "DBMDDObj", "deleteFromDb() " << myOId);
+}
+
+void
+DBMDDObj::readFromDb() throw (r_Error)
+{
+ RMDBGENTER(7, RMDebug::module_mddif, "DBMDDObj", "readFromDb() " << myOId);
+ ENTER( "DBMDDObj::readFromDb" );
+
+#ifdef RMANBENCHMARK
+ DBObject::readTimer.resume();
+#endif
+ EXEC SQL BEGIN DECLARE SECTION;
+ long mddoid2;
+ double basetypeid2;
+ long domainid2;
+ double objindex2;
+ long persRefCount2;
+ double storage2;
+ EXEC SQL END DECLARE SECTION;
+
+ mddoid2 = myOId.getCounter();
+
+ TALK( "EXEC SQL SELECT BaseTypeOId, DomainId, PersRefCount, NodeOId, StorageOId INTO :basetypeid2, :domainid2, :persRefCount2, :objindex2, :storage2 FROM RAS_MDDOBJECTS WHERE MDDId = " << mddoid2 );
+
+ EXEC SQL SELECT BaseTypeOId, DomainId, PersRefCount, NodeOId, StorageOId
+ INTO :basetypeid2, :domainid2, :persRefCount2, :objindex2, :storage2
+ FROM RAS_MDDOBJECTS
+ WHERE MDDId = :mddoid2;
+ if (SQLCODE != SQLOK)
+ {
+ if (SQLCODE == SQLNODATAFOUND)
+ {
+ RMDBGMIDDLE(7, RMDebug::module_mddif, "DBMDDObj", "object not found");
+ throw r_Error(r_Error::r_Error_ObjectUnknown);
+ }
+ else
+ {
+ check("DBMDDObj::readFromDb()\0");
+ generateException();
+ }
+ }
+
+ objIxId = OId(objindex2);
+ storageLayoutId = OId(storage2);
+ persistentRefCount = persRefCount2;
+ mddType = (MDDBaseType*)ObjectBroker::getObjectByOId(OId(basetypeid2));
+ myDomain = (DBMinterval*)ObjectBroker::getObjectByOId(OId(domainid2, OId::DBMINTERVALOID));
+ myDomain->setCached(true);
+
+ DBObject::readFromDb();
+#ifdef RMANBENCHMARK
+ DBObject::readTimer.pause();
+#endif
+
+ LEAVE( "DBMDDObj::readFromDb" );
+ RMDBGEXIT(7, RMDebug::module_mddif, "DBMDDObj", "readFromDb() " << myOId);
+}
+
+
+DBObjectId
+DBMDDObj::getDBIndexDS() const
+{
+ return objIxId;
+}
+
+int
+DBMDDObj::getPersRefCount() const
+{
+ return persistentRefCount;
+}
+
+void
+DBMDDObj::incrementPersRefCount()
+{
+ persistentRefCount++;
+ setModified();
+}
+
+void
+DBMDDObj::decrementPersRefCount()
+{
+ persistentRefCount--;
+ if (persistentRefCount == 0)
+ setPersistent(false);
+ setModified();
+}
diff --git a/relmddif/dbmddset.hh b/relmddif/dbmddset.hh
new file mode 100644
index 0000000..7df6cd4
--- /dev/null
+++ b/relmddif/dbmddset.hh
@@ -0,0 +1,176 @@
+/*
+* This file is part of rasdaman community.
+*
+* Rasdaman community is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* Rasdaman community is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+*
+* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+rasdaman GmbH.
+*
+* For more information please see <http://www.rasdaman.org>
+* or contact Peter Baumann via <baumann@rasdaman.com>.
+*/
+#ifndef _MDDSET_HH_
+#define _MDDSET_HH_
+
+class MDDSet;
+class OId;
+class EOId;
+class r_Error;
+class DBMDDObj;
+class CollectionType;
+
+#include "reladminif/lists.h"
+#include "mddid.hh"
+#include "reladminif/dbnamedobject.hh"
+#include "reladminif/dbref.hh"
+
+//@ManMemo: Module: {\bf mddif}
+/*@Doc:
+ MDDSet is the persistent class for collections of MDD objects.
+
+ Each instance of MDDSet represents a collection stored in the base
+ DBMS.
+
+ This class should only be used by DBMDDColl.
+*/
+
+class DBMDDSet : public DBNamedObject
+ {
+ public:
+ DBMDDSet(const char* name, const CollectionType* type) throw (r_Error);
+ /*@Doc:
+ creates a new set
+ */
+
+ DBMDDSet(const char* name, const OId& id, const CollectionType* type) throw (r_Error);
+ /*@Doc:
+ creates a new set
+ */
+
+ static DBMDDSetId getDBMDDSet(const char* name) throw (r_Error);
+
+ static DBMDDSetId getDBMDDSet(const OId& id) throw (r_Error);
+
+ static bool deleteDBMDDSet(const OId& id);
+ /*@Doc:
+ returns succes
+ */
+
+ static bool deleteDBMDDSet(const char* name);
+ /*@Doc:
+ returns succes
+ */
+
+ virtual void printStatus(unsigned int level = 0, std::ostream& stream = std::cout) const;
+
+ virtual void setPersistent(bool state) throw (r_Error);
+ /*@Doc:
+ throws r_Error when the mdd set may not be made persistent.
+ */
+
+ void insert(DBMDDObjId newObj);
+ /*@Doc:
+ Inserts an object into the MDD Collection.
+ The persistent reference count of this DBMDDObj is updated.
+ */
+
+ DBMDDObjIdIter* newIterator() const;
+ /*@Doc:
+ Returns a new iterator for this collection.
+ */
+
+ unsigned int getCardinality() const;
+ /*@Doc:
+ Returns the number of elements in the collection.
+ */
+
+ void remove(DBMDDObjId& obj);
+ /*@Doc:
+ Removes an object from the MDD Collection.
+ The persistent reference count of this DBMDDObj is updated.
+ */
+
+ void removeAll();
+ /*@Doc:
+ Removes all objects from the MDD Collection.
+ The persistent reference count of the DBMDDObjs is updated.
+ */
+
+ void releaseAll();
+ /*@Doc:
+ Releases all dynamic memory used by this collection.
+ */
+
+ bool contains_element(const DBMDDObjId& elem) const;
+ /*@Doc:
+ */
+
+ virtual ~DBMDDSet( );
+ /*@Doc:
+ */
+
+ void deleteName();
+ /*@Doc:
+ sets the name of this object to a null string.
+ used by DatabaseIf::destroyRoot
+ */
+
+ virtual r_Bytes getMemorySize() const;
+ /*@Doc:
+ */
+
+ const CollectionType* getCollType() const;
+ /*@Doc:
+ Returns the collectiontype of this entry.
+ */
+
+ protected:
+ friend class ObjectBroker;
+
+ typedef std::set<DBMDDObjId, std::less<DBMDDObjId> > DBMDDObjIdSet;
+
+ DBMDDSet(const OId& id) throw (r_Error);
+ /*@Doc:
+ gets an existing coll from the db
+ */
+
+ virtual void updateInDb() throw(r_Error);
+ /*@Doc:
+ */
+
+ virtual void insertInDb() throw(r_Error);
+ /*@Doc:
+ */
+
+ virtual void readFromDb() throw(r_Error);
+ /*@Doc:
+ */
+
+ virtual void deleteFromDb() throw(r_Error);
+ /*@Doc:
+ */
+
+ private:
+ DBMDDObjIdSet mySet;
+ /*@Doc:
+ Memory representation of the list of oids of DBMDDObjs.
+ */
+
+ const CollectionType* collType;
+ /*@Doc:
+ Pointer to the collectiontype.
+ */
+ };
+
+#endif
diff --git a/relmddif/dbmddset.pgc b/relmddif/dbmddset.pgc
new file mode 100644
index 0000000..b92a884
--- /dev/null
+++ b/relmddif/dbmddset.pgc
@@ -0,0 +1,314 @@
+// This is -*- C++ -*-
+
+/*
+* This file is part of rasdaman community.
+*
+* Rasdaman community is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* Rasdaman community is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+*
+* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+rasdaman GmbH.
+*
+* For more information please see <http://www.rasdaman.org>
+* or contact Peter Baumann via <baumann@rasdaman.com>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * Code with embedded SQL for PostgreSQL DBMS
+ *
+ *
+ * COMMENTS:
+ * uses embedded SQL
+ *
+ ************************************************************/
+
+#include "debug-srv.hh"
+
+// general embedded SQL related definitions
+EXEC SQL include "../reladminif/sqlglobals.h";
+
+#include "dbmddset.hh"
+#include "raslib/rmdebug.hh"
+#include "reladminif/sqlerror.hh"
+#include "reladminif/objectbroker.hh"
+#include "relcatalogif/collectiontype.hh"
+
+DBMDDSet::DBMDDSet(const char* name, const OId& id, const CollectionType* type) throw (r_Error)
+ : DBNamedObject(id, name),
+ collType(type)
+{
+ RMDBGENTER(4, RMDebug::module_mddif, "DBMDDSet", "DBMDDSet(" << getName() << ", " << myOId << ", " << collType->getName() << ")");
+ ENTER( "DBMDDSet::DBMDDSet, name=" << name << ", oid=" << id );
+
+ if (name == NULL)
+ setName("unnamed collection");
+ if (type == NULL)
+ {
+ RMDBGONCE(0, RMDebug::module_mddif, "DBMDDSet", "DBMDDSet(" << name << ", NULL)")
+ throw r_Error(r_Error::r_Error_General);
+ }
+ if (!type->isPersistent())
+ {
+ r_Error t(RASTYPEUNKNOWN);
+ t.setTextParameter("type", type->getName());
+ RMDBGONCE(0, RMDebug::module_mddif, "DBMDDSet", "DBMDDSet(" << name << ", " << type->getName() << " not persistent)")
+ throw t;
+ }
+ DBMDDSet* set = NULL;
+ try
+ {
+ set = (DBMDDSet*)ObjectBroker::getObjectByName(OId::MDDCOLLOID, getName());
+ }
+ catch (r_Error& err)
+ {
+ if (err.get_kind() == r_Error::r_Error_ObjectUnknown)
+ set = NULL;
+ else
+ throw;
+ }
+ if (set)
+ {
+ RMDBGMIDDLE(5, RMDebug::module_mddif, "DBMDDSet", "already have a set with name " << getName());
+ RMInit::logOut << "DBMDDSet::DBMDDSet() mdd collection with name \"" << getName() << "\" exists already" << endl;
+ throw r_Error(r_Error::r_Error_NameNotUnique);
+ }
+ EXEC SQL BEGIN DECLARE SECTION;
+ long testoid1;
+ EXEC SQL END DECLARE SECTION;
+
+ testoid1 = id.getCounter();
+ TALK( "EXEC SQL SELECT MDDCollId INTO :testoid1 FROM RAS_MDDCOLLNAMES WHERE MDDCollId = " << testoid1 );
+ EXEC SQL SELECT MDDCollId INTO :testoid1 FROM RAS_MDDCOLLNAMES WHERE MDDCollId = :testoid1;
+ if (SQLCODE == SQLNODATAFOUND)
+ { //the code is most of the time 100
+ _isInDatabase = false;
+ _isPersistent = true;
+ _isModified = true;
+ objecttype = OId::MDDCOLLOID;
+ myOId = id;
+ ObjectBroker::registerDBObject(this);
+ }
+ else
+ {
+ if (SQLCODE == SQLOK)
+ {
+ RMDBGMIDDLE(2, RMDebug::module_mddif, "DBMDDSet", "already have a DBMDDSet with this OId " << id);
+ RMInit::logOut << "DBMDDSet::DBMDDSet() mdd collection with oid \"" << id << "\" exists already" << endl;
+ throw r_Error(r_Error::r_Error_OIdNotUnique);
+ }
+ else
+ {
+ check("DBMDDSet::DBMDDSet(name, oid, settype)");
+ generateException();
+ }
+ }
+
+ LEAVE( "DBMDDSet::DBMDDSet" );
+ RMDBGEXIT(4, RMDebug::module_mddif, "DBMDDSet", "DBMDDSet(" << name << ", " << id << ") " << myOId);
+}
+
+void
+DBMDDSet::insertInDb() throw (r_Error)
+{
+ RMDBGENTER(4, RMDebug::module_mddif, "DBMDDSet", "insertInDb() " << myOId);
+ ENTER( "DBMDDSet::insertInDb" );
+
+ EXEC SQL BEGIN DECLARE SECTION;
+ long mddoid;
+ long mddcolloid;
+ long colltypeoid;
+ char collname[VARCHAR_MAXLEN];
+ EXEC SQL END DECLARE SECTION;
+
+ mddcolloid = myOId.getCounter();
+ colltypeoid = collType->getOId().getCounter();
+
+ (void) strncpy( collname, (char*) getName(), (size_t) sizeof(collname) );
+
+ TALK( "EXEC SQL INSERT INTO RAS_MDDCOLLNAMES ( MDDCollName, MDDCollId, SetTypeId) VALUES( " << collname << "," << mddcolloid << "," << colltypeoid << ")" );
+
+ EXEC SQL INSERT INTO RAS_MDDCOLLNAMES ( MDDCollName, MDDCollId, SetTypeId)
+ VALUES ( :collname, :mddcolloid, :colltypeoid);
+ if (SQLCODE != SQLOK)
+ {
+ check("DBMDDSet::insertInDb() INSERT INTO RAS_MDDCOLLNAMES\0");
+ generateException();
+ }
+
+ for (DBMDDObjIdSet::iterator i = mySet.begin(); i != mySet.end(); i++)
+ {
+ mddoid = (*i).getOId().getCounter();
+ RMDBGMIDDLE(5, RMDebug::module_mddif, "DBMDDSet", "mddobject with id " << mddoid);
+ TALK( "EXEC SQL INSERT INTO RAS_MDDCOLLECTIONS ( MDDId, MDDCollId) VALUES( " << mddoid << "," << mddcolloid << ")" );
+ EXEC SQL INSERT INTO RAS_MDDCOLLECTIONS ( MDDId, MDDCollId)
+ VALUES ( :mddoid, :mddcolloid);
+ if (SQLCODE != SQLOK)
+ {
+ check("DBMDDSet::insertInDb() INSERT INTO RAS_MDDCOLLECTIONS\0");
+ generateException();
+ }
+ else
+ {
+ RMDBGMIDDLE(5, RMDebug::module_mddif, "DBMDDSet", "wrote mddobjoid\t: " << (*i).getOId());
+ }
+ }
+
+ DBObject::insertInDb();
+
+ LEAVE( "DBMDDSet::insertInDb" );
+ RMDBGEXIT(4, RMDebug::module_mddif, "DBMDDSet", "insertInDb() " << myOId);
+}
+
+void
+DBMDDSet::deleteFromDb() throw (r_Error)
+{
+ RMDBGENTER(4, RMDebug::module_mddif, "DBMDDSet", "deleteFromDb() " << myOId);
+ ENTER( "DBMDDSet::deleteFromDb" );
+
+ EXEC SQL BEGIN DECLARE SECTION;
+ long mddcolloid1;
+ EXEC SQL END DECLARE SECTION;
+
+ mddcolloid1 = myOId.getCounter();
+ TALK( "EXEC SQL DELETE FROM RAS_MDDCOLLNAMES WHERE MDDCollId = " << mddcolloid1 );
+ EXEC SQL DELETE FROM RAS_MDDCOLLNAMES WHERE MDDCollId = :mddcolloid1;
+ if (SQLCODE != SQLOK)
+ {
+ check("DBMDDSet::deleteFromDb() DELETE FROM RAS_MDDCOLLNAMES\0");
+ generateException();
+ }
+
+ TALK( "EXEC SQL DELETE FROM RAS_MDDCOLLECTIONS WHERE MDDCollId = " << mddcolloid1 );
+ EXEC SQL DELETE FROM RAS_MDDCOLLECTIONS WHERE MDDCollId = :mddcolloid1;
+ if (SQLCODE != SQLOK)
+ {
+ if (SQLCODE != SQLNODATAFOUND)
+ {
+ check("DBMDDSet::deleteFromDb() DELETE FROM RAS_MDDCOLLECTIONS\0");
+ generateException();
+ }
+ else
+ {
+ //there may be empty collections
+ }
+ }
+
+ DBObject::deleteFromDb();
+
+ LEAVE( "DBMDDSet::deleteFromDb" );
+ RMDBGEXIT(4, RMDebug::module_mddif, "DBMDDSet", "deleteFromDb() " << myOId);
+}
+
+void
+DBMDDSet::readFromDb() throw (r_Error)
+{
+ RMDBGENTER(4, RMDebug::module_mddif, "DBMDDSet", "readFromDb() " << myOId);
+ ENTER( "DBMDDSet::readFromDb" );
+
+#ifdef RMANBENCHMARK
+ DBObject::readTimer.resume();
+#endif
+ EXEC SQL BEGIN DECLARE SECTION;
+ long mddoid2;
+ long mddcolloid2;
+ long colltypeoid2;
+ char collname2[VARCHAR_MAXLEN];
+ EXEC SQL END DECLARE SECTION;
+
+ mddcolloid2 = myOId.getCounter();
+
+ TALK( "EXEC SQL SELECT MDDCollName, SetTypeId INTO :collname2, :colltypeoid2 FROM RAS_MDDCOLLNAMES WHERE MDDCollId = " << mddcolloid2 );
+
+ EXEC SQL SELECT MDDCollName, SetTypeId
+ INTO :collname2, :colltypeoid2
+ FROM RAS_MDDCOLLNAMES
+ WHERE MDDCollId = :mddcolloid2;
+ if (SQLCODE != SQLOK)
+ {
+ if (SQLCODE == SQLNODATAFOUND)
+ {
+ RMDBGMIDDLE(7, RMDebug::module_mddif, "DBMDDSet", "object not found");
+ LEAVE( "DBMDDSet::readFromDb(): object not found" );
+ throw r_Error(r_Error::r_Error_ObjectUnknown);
+ }
+ else
+ {
+ LEAVE( "DBMDDSet::readFromDb(): db access error: " << SQLCODE );
+ check("DBMDDSet::readFromDb() SELECT FROM RAS_MDDCOLLNAMES\0");
+ generateException();
+ }
+ }
+
+ setName(collname2);
+ collType = (const CollectionType*)ObjectBroker::getObjectByOId(OId(colltypeoid2, OId::SETTYPEOID));
+
+ TALK( "EXEC SQL DECLARE c CURSOR FOR SELECT MDDId FROM RAS_MDDCOLLECTIONS WHERE MDDCollId = " << mddcolloid2 << " ORDER BY MDDId" );
+ EXEC SQL DECLARE c CURSOR FOR
+ SELECT MDDId
+ FROM RAS_MDDCOLLECTIONS
+ WHERE MDDCollId = :mddcolloid2
+ ORDER BY MDDId;
+ if (SQLCODE != SQLOK)
+ {
+ LEAVE( "DBMDDSet::readFromDb(): db access error: " << SQLCODE );
+ check("DBMDDSet::readFromDb() DECLARE CURSOR");
+ generateException();
+ }
+
+ TALK( "EXEC SQL OPEN c" );
+ EXEC SQL OPEN c;
+ if (SQLCODE != SQLOK)
+ {
+ LEAVE( "DBMDDSet::readFromDb(): db access error: " << SQLCODE );
+ check("DBMDDSet::readFromDb() OPEN CURSOR");
+ generateException();
+ }
+
+ do
+ {
+ TALK( "EXEC SQL FETCH c INTO :mddoid2" );
+ EXEC SQL FETCH c INTO :mddoid2;
+ if (SQLCODE == SQLOK)
+ {
+ RMDBGMIDDLE(7, RMDebug::module_mddif, "DBMDDSet", "fetched mddobjectoid " << mddoid2);
+ mySet.insert(OId(mddoid2, OId::MDDOID));
+ }
+ else
+ {
+ if (SQLCODE == SQLNODATAFOUND)
+ {
+ //no more data to read
+ break;
+ }
+ else
+ {
+ LEAVE( "DBMDDSet::readFromDb(): db access error: " << SQLCODE );
+ check("DBMDDSet::readFromDb() FETCHING\0");
+ generateException();
+ }
+ }
+ } while (true);
+ TALK( "EXEC SQL CLOSE c" );
+ EXEC SQL CLOSE c;
+
+ DBObject::readFromDb();
+#ifdef RMANBENCHMARK
+ DBObject::readTimer.pause();
+#endif
+
+ LEAVE( "DBMDDSet::readFromDb" );
+ RMDBGEXIT(4, RMDebug::module_mddif, "DBMDDSet", "readFromDb() " << myOId);
+}
+
diff --git a/relmddif/dbmddsetcommon.cc b/relmddif/dbmddsetcommon.cc
new file mode 100644
index 0000000..4bd4dd7
--- /dev/null
+++ b/relmddif/dbmddsetcommon.cc
@@ -0,0 +1,281 @@
+/*
+* This file is part of rasdaman community.
+*
+* Rasdaman community is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* Rasdaman community is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+*
+* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+rasdaman GmbH.
+*
+* For more information please see <http://www.rasdaman.org>
+* or contact Peter Baumann via <baumann@rasdaman.com>.
+*/
+#include <iostream>
+#include <set>
+#include "dbmddset.hh"
+#include "raslib/rmdebug.hh"
+#include "reladminif/sqlerror.hh"
+#include "reladminif/externs.h"
+#include "dbmddobj.hh"
+#include "reladminif/objectbroker.hh"
+#include "reladminif/dbref.hh"
+#include "relcatalogif/collectiontype.hh"
+#include "reladminif/dbobjectiditerator.hh"
+#include "raslib/error.hh"
+
+void
+DBMDDSet::printStatus(unsigned int level, std::ostream& stream) const
+ {
+ char* indent = new char[level*2 +1];
+ for (int j = 0; j < level*2 ; j++)
+ indent[j] = ' ';
+ indent[level*2] = '\0';
+ DBObject::printStatus(level, stream);
+ stream << indent;
+ stream << "Collection Entries ";
+ for (DBMDDObjIdSet::const_iterator i = mySet.begin(); i != mySet.end(); i++)
+ {
+ if (isPersistent())
+ stream << (*i).getOId() << " ";
+ else
+ stream << (r_Ptr)(*i).ptr() << " ";
+ }
+ stream << endl;
+ delete[] indent;
+ indent=0;
+ }
+
+bool
+DBMDDSet::contains_element(const DBMDDObjId& elem) const
+ {
+ RMDBGENTER(4, RMDebug::module_mddif, "DBMDDSet", "contains_element(" << elem.getOId() << ") " << myOId);
+ bool retval = false;
+ DBMDDObjIdSet::const_iterator i = mySet.find(elem);
+ if (i != mySet.end())
+ {
+ retval = true;
+ }
+ RMDBGEXIT(4, RMDebug::module_mddif, "DBMDDSet", "contains_element(" << elem.getOId() << ") " << myOId << " " << retval);
+ return retval;
+ }
+
+void
+DBMDDSet::remove(DBMDDObjId& elem)
+ {
+ RMDBGENTER(4, RMDebug::module_mddif, "DBMDDSet", "remove(" << elem.getOId() << ")");
+ DBMDDObjIdSet::iterator i = mySet.find(elem);
+ if (i != mySet.end())
+ {
+ elem->decrementPersRefCount();
+ mySet.erase(i);
+ setModified();
+ }
+ RMDBGEXIT(4, RMDebug::module_mddif, "DBMDDSet", "remove(" << elem.getOId() << ")");
+ }
+
+void
+DBMDDSet::removeAll()
+ {
+ DBMDDObjId t;
+ while (!mySet.empty())
+ {
+ ((DBMDDObj*)(*(mySet.begin())).ptr())->decrementPersRefCount();
+ mySet.erase(mySet.begin());
+ }
+ setModified();
+ }
+
+DBMDDSet::~DBMDDSet()
+ {
+ RMDBGENTER(4, RMDebug::module_mddif, "DBMDDSet", "~DBMDDSet() " << myOId);
+ validate();
+ collType = NULL;
+ mySet.clear();
+ RMDBGEXIT(4, RMDebug::module_mddif, "DBMDDSet", "~DBMDDSet() " << myOId);
+ }
+
+const CollectionType*
+DBMDDSet::getCollType() const
+ {
+ RMDBGONCE(4, RMDebug::module_mddif, "DBMDDSet", "getCollType() " << myOId << "\t" << collType->getName());
+ return collType;
+ }
+
+
+r_Bytes
+DBMDDSet::getMemorySize() const
+ {
+ return DBNamedObject::getMemorySize() + sizeof(OIdSet) + mySet.size() * sizeof(OId);
+ }
+
+void
+DBMDDSet::insert(DBMDDObjId elem)
+ {
+ if (!contains_element(elem))
+ {
+ setModified();
+ elem->incrementPersRefCount();
+ mySet.insert(elem);
+ }
+ }
+
+DBMDDObjIdIter*
+DBMDDSet::newIterator() const
+ {
+ return new DBMDDObjIdIter(mySet);
+ }
+
+unsigned int
+DBMDDSet::getCardinality() const
+ {
+ return mySet.size();
+ }
+
+void
+DBMDDSet::deleteName()
+ {
+ setName("\0");
+ setModified();
+ }
+
+void
+DBMDDSet::releaseAll()
+ {
+ RMDBGONCE(1, RMDebug::module_mddif, "DBMDDSet", "releaseAll() " << myOId << "\tdoes not do anything");
+ }
+
+DBMDDSetId
+DBMDDSet::getDBMDDSet(const char* name) throw (r_Error)
+ {
+ RMDBGENTER(4, RMDebug::module_mddif, "DBMDDSet", "getDBMDDSet(" << name << ")");
+ DBMDDSetId set((DBMDDSet*)ObjectBroker::getObjectByName(OId::MDDCOLLOID, name));
+ RMDBGEXIT(4, RMDebug::module_mddif, "DBMDDSet", "getDBMDDSet(" << name << ")");
+ return set;
+ }
+
+DBMDDSetId
+DBMDDSet::getDBMDDSet(const OId& o) throw (r_Error)
+ {
+ RMDBGENTER(4, RMDebug::module_mddif, "DBMDDSet", "getDBMDDSet(" << o << ")");
+ DBMDDSetId set((DBMDDSet*)ObjectBroker::getObjectByOId(o));
+ RMDBGEXIT(4, RMDebug::module_mddif, "DBMDDSet", "getDBMDDSet(" << o << ")");
+ return set;
+ }
+
+bool
+DBMDDSet::deleteDBMDDSet(const OId& oid)
+ {
+ bool retval = true;
+ try {
+ DBObject* set = ObjectBroker::getObjectByOId(oid);
+ set->setPersistent(false);
+ }
+ catch (r_Error& e)
+ {
+ if (e.get_kind() == r_Error::r_Error_ObjectUnknown)
+ retval = false;
+ else
+ throw;
+ }
+ return retval;
+ }
+
+bool
+DBMDDSet::deleteDBMDDSet(const char* name)
+ {
+ bool retval = true;
+ try {
+ DBObject* set = ObjectBroker::getObjectByName(OId::MDDCOLLOID, name);
+ set->setPersistent(false);
+ }
+ catch (r_Error& e)
+ {
+ if (e.get_kind() == r_Error::r_Error_ObjectUnknown)
+ retval = false;
+ else
+ throw;
+ }
+ return retval;
+ }
+
+DBMDDSet::DBMDDSet(const char* name, const CollectionType* type) throw (r_Error)
+ : DBNamedObject(name),
+ collType(type)
+ {
+ if (name == NULL)
+ setName("unnamed collection");
+ if (type == NULL)
+ {
+ RMDBGONCE(0, RMDebug::module_mddif, "DBMDDSet", "DBMDDSet(" << name << ", NULL)")
+ RMInit::logOut << "DBMDDSet::DBMDDSet() the collection type is NULL" << endl;
+ throw r_Error(COLLECTIONTYPEISNULL);
+ }
+ objecttype = OId::MDDCOLLOID;
+ }
+
+void
+DBMDDSet::setPersistent(bool state) throw (r_Error)
+ {
+ DBMDDSet* set = NULL;
+ if (state)
+ {
+ if (!collType->isPersistent())
+ {
+ r_Error t(RASTYPEUNKNOWN);
+ t.setTextParameter("type", collType->getName());
+ RMDBGONCE(0, RMDebug::module_mddif, "DBMDDSet", "setPersistent(" << state << ") " << getName() << ", " << collType->getName() << " not persistent");
+ throw t;
+ }
+ try {
+ set = (DBMDDSet*)ObjectBroker::getObjectByName(OId::MDDCOLLOID, getName());
+ }
+ catch (r_Error& err)
+ {
+ if (err.get_kind() == r_Error::r_Error_ObjectUnknown)
+ set = NULL;
+ else
+ throw;
+ }
+ if (set)
+ {
+ RMDBGMIDDLE(6, RMDebug::module_mddif, "DBMDDSet", "already have a set with name " << getName());
+ RMInit::logOut << "DBMDDSet::DBMDDSet() mdd collection with name \"" << getName() << "\" exists already" << endl;
+ throw r_Error(r_Error::r_Error_NameNotUnique);
+ }
+ }
+ else {
+ removeAll();
+ }
+ DBNamedObject::setPersistent(state);
+ }
+
+DBMDDSet::DBMDDSet(const OId& id) throw (r_Error)
+ : DBNamedObject(id),
+ collType(0)
+ {
+ RMDBGENTER(4, RMDebug::module_mddif, "DBMDDSet", "DBMDDSet(" << myOId << ")");
+ objecttype = OId::MDDCOLLOID;
+ readFromDb();
+ RMDBGEXIT(4, RMDebug::module_mddif, "DBMDDSet", "DBMDDSet(" << myOId << ")");
+ }
+
+void
+DBMDDSet::updateInDb() throw (r_Error)
+ {
+ RMDBGENTER(4, RMDebug::module_mddif, "DBMDDSet", "updateInDb() " << myOId);
+ deleteFromDb();
+ insertInDb();
+ DBObject::updateInDb();
+ RMDBGEXIT(4, RMDebug::module_mddif, "DBMDDSet", "updateInDb() " << myOId);
+ }
+
diff --git a/relmddif/mddid.hh b/relmddif/mddid.hh
new file mode 100644
index 0000000..de721cf
--- /dev/null
+++ b/relmddif/mddid.hh
@@ -0,0 +1,36 @@
+/*
+* This file is part of rasdaman community.
+*
+* Rasdaman community is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* Rasdaman community is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+*
+* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+rasdaman GmbH.
+*
+* For more information please see <http://www.rasdaman.org>
+* or contact Peter Baumann via <baumann@rasdaman.com>.
+*/
+#ifndef _MDDID_HH_
+#define _MDDID_HH_
+
+class DBMDDObj;
+class DBMDDSet;
+
+template <class T> class DBRef;
+template <class T> class DBObjectIdIterator;
+
+typedef DBRef<DBMDDObj> DBMDDObjId;
+typedef DBRef<DBMDDSet> DBMDDSetId;
+typedef DBObjectIdIterator<DBMDDObj> DBMDDObjIdIter;
+
+#endif
diff --git a/relmddif/test/Makefile b/relmddif/test/Makefile
new file mode 100644
index 0000000..b5df243
--- /dev/null
+++ b/relmddif/test/Makefile
@@ -0,0 +1,77 @@
+# -*-Makefile-*-
+#
+# This file is part of rasdaman community.
+#
+# Rasdaman community is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Rasdaman community is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+#
+# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+# rasdaman GmbH.
+#
+# For more information please see <http://www.rasdaman.org>
+# or contact Peter Baumann via <baumann@rasdaman.com>. # Top Level makefile. This points to the various modules that have to be build
+# and/or deployed
+#
+# MAKEFILE FOR:
+# test programs of module relblobif
+#
+# COMMENTS:
+# List environment dependencies, known bugs, specialities etc.
+#
+##################################################################
+######################### Definitions ############################
+
+# standard include with general options
+include $(RMANBASE)/Makefile.inc
+
+# all test programs
+ALLTESTS = dbmddcollidt dbmddcolloidentryt mdditest dbiteritest dbobjtest intervaltest
+
+# source files
+CPPSOURCES =
+
+# object files
+OBJS = dbmddcollidt.o dbmddcolloidentryt.o mdditest.o dbobjtest.o dbiteritest.o intervaltest.o
+
+NEEDSTL = dbmddcollidt.C dbmddcolloidentryt.C mdditest.C dbiteritest.C intervaltest.C dbobjtest.C
+
+MISCCLEAN = client.bm client.dbg client.log ir.out core
+
+NEEDEDLIBS = $(RELBLOBIF) $(RELADMINIF) $(RASLIB) $(RELCATALOGIF) $(RELMDDIF) $(RASLIB) $(CACHETAMGR) $(RELINDEXIF) $(RELBLOBIF) $(RELADMINIF)
+
+########################### Targets ##############################
+
+# make all tests
+.PHONY: test
+test: $(ALLTESTS)
+
+########################### Dependencies #########################
+
+dbmddcollidt : dbmddcollidt.o $(NEEDEDLIBS)
+dbmddcollidt.o : dbmddcollidt.C
+
+dbmddcolloidentryt : dbmddcolloidentryt.o $(NEEDEDLIBS)
+dbmddcolloidentryt.o : dbmddcolloidentryt.C
+
+mdditest: mdditest.o $(NEEDEDLIBS)
+mdditest.o: mdditest.C
+
+intervaltest: intervaltest.o $(NEEDEDLIBS)
+intervaltest.o: intervaltest.C
+
+dbobjtest: dbobjtest.o $(NEEDEDLIBS)
+dbobjtest.o: dbobjtest.C
+
+dbitertest: dbitertest.o $(NEEDEDLIBS)
+dbitertest.o: dbitertest.C
+
diff --git a/relmddif/test/dbiteritest.C b/relmddif/test/dbiteritest.C
new file mode 100644
index 0000000..dc19894
--- /dev/null
+++ b/relmddif/test/dbiteritest.C
@@ -0,0 +1,67 @@
+/*
+* This file is part of rasdaman community.
+*
+* Rasdaman community is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* Rasdaman community is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+*
+* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+rasdaman GmbH.
+*
+* For more information please see <http://www.rasdaman.org>
+* or contact Peter Baumann via <baumann@rasdaman.com>.
+*/
+#include <stdlib.h>
+#include <iostream.h>
+#include <string.h>
+
+#include "adminif.hh"
+#include "databaseif.hh"
+#include "oidif.hh"
+#include "transactionif.hh"
+
+#include "alltypes.hh"
+#include "typefactory.hh"
+
+#include "dbmddcoll.hh"
+#include "dbmddcolloidentry.hh"
+#include "dbmddobj.hh"
+
+#include "raslib/rmdebug.hh"
+
+RMINITGLOBALS('C')
+int RManDebug2 = 0;
+int RManModule = 0;
+
+int
+main(int argc, char* argv[])
+ {
+ AdminIf* myAdmin;
+ DatabaseIf database;
+ TransactionIf ta;
+ RManDebug = 6;
+
+ myAdmin = AdminIf::instance();
+ database.open("RMAN");
+ ta.begin(&database);
+
+ MDDIterator<DBMDDCollOId>* mdditercoll = &MDDInit::createMDDCollOIdIterator();
+ for (i = 0; mdditercoll->not_done(); mdditercoll->advance(), i++)
+ {
+ cout << "Iter returned for " << i << ". " << mdditercoll->get_element()->getOId() << " " << mdditercoll->get_element()->getName() << " " << mdditercoll->get_element()->getCardinality() << endl;
+ for (DBIterId iter = mdditercoll->get_element()->createIterator(); iter->not_done(); iter->advance())
+ {
+ cout << "\tIter returned for MDDObject " << iter->get_element()->getOId() << endl;
+ cout << "\t\t"; iter->get_element()->printStatus();
+ }
+ }
+ }
diff --git a/relmddif/test/dbmddcollidt.C b/relmddif/test/dbmddcollidt.C
new file mode 100644
index 0000000..1dd4267
--- /dev/null
+++ b/relmddif/test/dbmddcollidt.C
@@ -0,0 +1,111 @@
+/*
+* This file is part of rasdaman community.
+*
+* Rasdaman community is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* Rasdaman community is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+*
+* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+rasdaman GmbH.
+*
+* For more information please see <http://www.rasdaman.org>
+* or contact Peter Baumann via <baumann@rasdaman.com>.
+*/
+#include <stdlib.h>
+#include <iostream.h>
+#include <string.h>
+
+#include "adminif.hh"
+#include "databaseif.hh"
+#include "oidif.hh"
+#include "transactionif.hh"
+
+#include "alltypes.hh"
+#include "typefactory.hh"
+
+#include "dbmddobj.hh"
+
+#include "raslib/rmdebug.hh"
+
+RMINITGLOBALS('C')
+
+int
+main(int argc, char* argv[])
+ {
+ if (argc >= 2)
+ {
+ AdminIf* myAdmin;
+ DatabaseIf database;
+ TransactionIf ta;
+ DBMDDObj* obj = 0;
+ DBMDDColl* dbColl = 0;
+ OId* id = 0;
+ DBIterId* iter = 0;
+
+ myAdmin = AdminIf::instance();
+ database.open("RMAN");
+ ta.begin(&database);
+
+
+ switch (atoi(argv[1]))
+ {
+ default:
+ cout << "DEFAULT" << argv[0] << argv[1] << argv[2] << endl;
+ break;
+ case 1:
+ cout << "Case 1" << endl;
+ dbColl = new DBMDDCollId(argv[2]);
+ obj = new DBMDDObj();
+ dbColl->insert_element(obj);
+
+ obj = new DBMDDObj();
+ dbColl->insert_element(obj);
+
+ obj = new DBMDDObj();
+ dbColl->insert_element(obj);
+
+ for (iter = &dbColl->create_iterator(); iter->not_done(); iter->advance())
+ cout << "Iter returned: " << iter->get_element()->getOId() << endl;
+ cout << "Name of Collection: " << dbColl->getName() << endl;
+ cout << "Size of Collection: " << dbColl->cardinality() << endl;
+ cout << "OId of Collection: " << dbColl->getOId() << endl;
+ cout << "Writing DBMDDCollId" << endl;
+ dbColl->writeToDb();
+ ta.commit();
+ break;
+ case 2:
+ cout << "Case 2" << endl;
+ id = new OId(atol(argv[2]), OId::MDDCOLLOID);
+ cout << "Reading DBMDDCollId " << *id << endl;
+ dbColl = new DBMDDCollId(*id);
+ for (iter = &dbColl->create_iterator(); iter->not_done(); iter->advance())
+ cout << "Iter returned: " << iter->get_element()->getOId() << endl;
+ cout << "Name of Collection: " << dbColl->getName() << endl;
+ cout << "Size of Collection: " << dbColl->cardinality() << endl;
+ cout << "OId of Collection: " << dbColl->getOId() << endl;
+ ta.commit();
+ break;
+ case 3:
+ cout << "Case 3" << endl;
+ id = new OId(atol(argv[2]), OId::MDDCOLLOID);
+ cout << "Deleteing DBMDDCollId " << *id << endl;
+ dbColl = new DBMDDCollId(*id);
+ dbColl->deleteFromDb();
+ ta.commit();
+ break;
+ }
+ database.close();
+ }
+ else {
+ cout << "Usage: 1 write, 2 read, 3 delete" << endl << "\t1: collname" << endl << "\t2: collid" << endl << "\t3: collid" << endl;
+ }
+ }
diff --git a/relmddif/test/dbmddcolloidentryt.C b/relmddif/test/dbmddcolloidentryt.C
new file mode 100644
index 0000000..3e36de6
--- /dev/null
+++ b/relmddif/test/dbmddcolloidentryt.C
@@ -0,0 +1,101 @@
+/*
+* This file is part of rasdaman community.
+*
+* Rasdaman community is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* Rasdaman community is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+*
+* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+rasdaman GmbH.
+*
+* For more information please see <http://www.rasdaman.org>
+* or contact Peter Baumann via <baumann@rasdaman.com>.
+*/
+#include "relcatalogif/alltypes.hh"
+#include "relcatalogif/typefactory.hh"
+#include "raslib/rmdebug.hh"
+#include "raslib/minterval.hh"
+
+#include <string.h>
+#include <stdlib.h>
+#include <iostream.h>
+
+#include "relblobif/blobtile.hh"
+
+#include "reladminif/adminif.hh"
+#include "reladminif/transactionif.hh"
+#include "reladminif/databaseif.hh"
+#include "reladminif/oidif.hh"
+
+#include "relmddif/dbmddcolloidentry.hh"
+#include "relmddif/dbmddcollentry.hh"
+#include "relmddif/dbmddcolloid.hh"
+#include "relmddif/dbmddcoll.hh"
+#include "relmddif/dbmddobj.hh"
+
+RMINITGLOBALS('C')
+
+int
+main(int argc, char* argv[])
+ {
+ if (argc == 0)
+ {
+ OId* t = new OId();
+ BLOBTile b(*t);
+ r_Minterval c();
+ TypeFactory::instance();
+ }
+ AdminIf* myAdmin;
+ DatabaseIf database;
+ TransactionIf ta;
+
+ myAdmin = AdminIf::instance();
+ database.open("RMAN");
+ ta.begin(&database);
+
+ if (argc >= 2)
+ {
+ DBMDDCollOIdEntry* mycoll1 = 0;
+ OId* id = 0;
+ switch(atoi(argv[1]))
+ {
+ case 1:
+ cout << "Creating Entry: " << argv[2] << endl;
+ DBMDDCollEntry::newDBMDDCollEntry(argv[2], TypeFactory::mapSetType("MySet2"));
+ cout << "aborting" << endl;
+ ta.abort();
+ break;
+ case 2:
+ cout << "Creating Entry: " << argv[2] << endl;
+ DBMDDCollEntry::newDBMDDCollEntry(argv[2], TypeFactory::mapSetType("MySet2"));
+ cout << "commiting" << endl;
+ ta.commit();
+ break;
+ case 3:
+ cout << "Reading Entry with OId: " << argv[2] << endl;
+ id = new OId(atol(argv[2]), OId::MDDCOLLOID);
+ mycoll1 = MDDInit::mapMDDCollOIdEntry(*id);
+
+ cout << "Collection Name\t:" << mycoll1->getCollName() << endl;
+ cout << "Collection OId\t:" << mycoll1->getOId() << endl;
+ cout << "Collection SetType\t:" << mycoll1->getCollType()->getTypeName() << endl;
+ cout << "aborting" << endl;
+ ta.abort();
+ break;
+ default:
+ cout << "DONT KNOW WHAT TO DO!" << endl;
+ }
+ }
+ else {
+ cout << "Usage: 1 write abort, 2 write commit, 3 read" << endl << "\t1: name" << endl << "\t2: name" << endl << "\t3: id" << endl;
+ }
+ }
diff --git a/relmddif/test/dbobjtest.C b/relmddif/test/dbobjtest.C
new file mode 100644
index 0000000..441580a
--- /dev/null
+++ b/relmddif/test/dbobjtest.C
@@ -0,0 +1,150 @@
+/*
+* This file is part of rasdaman community.
+*
+* Rasdaman community is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* Rasdaman community is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+*
+* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+rasdaman GmbH.
+*
+* For more information please see <http://www.rasdaman.org>
+* or contact Peter Baumann via <baumann@rasdaman.com>.
+*/
+#include <stdlib.h>
+#include <iostream.h>
+#include <string.h>
+
+#include "adminif.hh"
+#include "databaseif.hh"
+#include "oidif.hh"
+#include "transactionif.hh"
+
+#include "alltypes.hh"
+#include "typefactory.hh"
+
+#include "dbmddcoll.hh"
+#include "dbmddcolloidentry.hh"
+#include "dbmddobj.hh"
+
+#include "raslib/rmdebug.hh"
+
+RMINITGLOBALS('C')
+int RManDebug2 = 8;
+int RManModule = 4;
+
+int
+main(int argc, char* argv[])
+ {
+ if (argc >= 2)
+ {
+ AdminIf* myAdmin;
+ DatabaseIf database;
+ TransactionIf ta;
+ RManDebug = 6;
+
+ myAdmin = AdminIf::instance();
+ database.open("RMAN");
+ ta.begin(&database);
+
+ DBIterId* iter = 0;
+ DBMDDColl* coll = 0;
+ DBMDDCollOIdEntry* entry = 0;
+ DBMDDObj* obj = 0;
+ MDDIterator<DBMDDObj>* mdditerobj = 0;
+ OId* id1 = 0;
+ OId* id2 = 0;
+ OId* id3 = 0;
+ int i = 0;
+ MDDBaseType* type = 0;
+ DBMinterval* dom = 0;
+
+ switch (atoi(argv[1]))
+ {
+ case 1:
+ cout << "Create Object with mdddtype " << atol(argv[2]) << " domainid " << atol(argv[3]) << " objIx " << atol(argv[4]) << endl;
+ id1 = new OId(atol(argv[2]), OId::MDDTYPEOID);
+ id2 = new OId(atol(argv[3]), OId::DBMINTERVALOID);
+ id3 = new OId();
+ cout << *id1 << " " << *id2 << endl;
+ type = (const MDDBaseType*)TypeFactory::mapMDDType(*id1);
+ cout << "MDDType\t: " << type->getName() << endl;
+ dom = TypeFactory::mapDBMinterval(*id2);
+ cout << "Domain\t: " << *dom << endl;
+ OId::allocateOId(*id3, OId::MDDOID);
+ cout << "MDDOId " << *id3 << endl;
+ obj = DBMDDObj::getNonInitializedMDD((char*)0, *id3);
+ cout << "Got Noninitialized at" << obj << endl;
+ obj->initialize((const MDDBaseType*)type, *dom, atol(argv[4]));
+ break;
+ case 2:
+ cout << "Creating Object Iterator" << endl;
+ mdditerobj = &MDDInit::createMDDObjectIterator();
+ for (i = 0; mdditerobj->not_done(); mdditerobj->advance(), i++)
+ {
+ cout << "Iter returned for " << i << ". " << mdditerobj->get_element()->getOId() << " with domain " << mdditerobj->get_element()->getDefinitionDomain() << endl;
+ }
+ break;
+ case 3:
+ id1 = new OId(atol(argv[2]), OId::MDDOID);
+ cout << "Delete Object with id: " << *id1 << endl;
+ MDDInit::deleteMDDObject(*id1);
+ cout << "Deleted" << endl;
+ mdditerobj = &MDDInit::createMDDObjectIterator();
+ for (i = 0; mdditerobj->not_done(); mdditerobj->advance(), i++)
+ {
+ cout << "Iter returned for " << i << ". " << mdditerobj->get_element()->getOId() << " with domain " << mdditerobj->get_element()->getDefinitionDomain() << endl;
+ }
+ cout << "DONE " << endl;
+ break;
+ case 4:
+ id1 = new OId(atol(argv[2]), OId::MDDOID);
+ id2 = new OId(atol(argv[3]), OId::MDDCOLLOID);
+ cout << "Insert Object with id: " << *id1 << " into collection with id: " << *id2 << endl;
+ coll = MDDInit::mapMDDCollection(*id2);
+ coll->insert(MDDInit::mapMDDObject(*id1));
+ for (iter = &coll->createIterator(); iter->not_done(); iter->advance(), i++)
+ cout << "Iter returned for " << i << ". " << iter->get_element()->getOId() << endl;
+ break;
+ case 5:
+ id1 = new OId(atol(argv[2]), OId::MDDOID);
+ id2 = new OId(atol(argv[3]), OId::MDDCOLLOID);
+ cout << "Remove Object with id " << *id1 << " from collection with id: " << *id2 << endl;
+ coll = MDDInit::mapMDDCollection(*id2);
+ coll->remove(MDDInit::mapMDDObject(*id1));
+ for (iter = &coll->createIterator(); iter->not_done(); iter->advance(), i++)
+ cout << "Iter returned for " << i << ". " << iter->get_element()->getOId() << endl;
+ }
+
+ if (argv[5])
+ {
+ if ((strcmp(argv[5],"commit") == 0))
+ {
+ cout << "commiting" << endl;
+ ta.commit();
+ }
+ }
+ cout << "aborting" << endl;
+ ta.abort();
+ database.close();
+ }
+ else {
+ cout << "USAGE:" << endl;
+ cout << "\t1: create object" << endl << "\t\tmddtypeid domainid objix" << endl;
+ cout << "\t2: object iterator" << endl << "\t\t" << endl;
+ cout << "\t3: delete object" << endl << "\t\tobjectid" << endl;
+ cout << "\t4: insert object in collection" << endl << "\t\tobjectid collectionid" << endl;
+ cout << "\t5: remove object from collection" << endl << "\t\tobjectid collectionid" << endl;
+ cout << "5th argument must be abort/commit" << endl;
+ }
+ }
+
diff --git a/relmddif/test/intervaltest.C b/relmddif/test/intervaltest.C
new file mode 100644
index 0000000..333b681
--- /dev/null
+++ b/relmddif/test/intervaltest.C
@@ -0,0 +1,120 @@
+/*
+* This file is part of rasdaman community.
+*
+* Rasdaman community is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* Rasdaman community is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+*
+* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+rasdaman GmbH.
+*
+* For more information please see <http://www.rasdaman.org>
+* or contact Peter Baumann via <baumann@rasdaman.com>.
+*/
+#include <stdlib.h>
+#include <iostream.h>
+#include <string.h>
+
+#include "adminif.hh"
+#include "databaseif.hh"
+#include "oidif.hh"
+#include "transactionif.hh"
+
+#include "alltypes.hh"
+#include "typefactory.hh"
+
+#include "dbmddcoll.hh"
+#include "dbmddcolloidentry.hh"
+#include "dbmddobj.hh"
+
+#include "dbminterval.hh"
+#include "raslib/rmdebug.hh"
+int RManDebug2 = 8;
+int RManModule = 3;
+RMINITGLOBALS('C')
+
+int
+main(int argc, char* argv[])
+ {
+ if (argc >= 2)
+ {
+
+ AdminIf* myAdmin;
+ DatabaseIf database;
+ TransactionIf ta;
+
+ myAdmin = AdminIf::instance();
+ database.open("RMAN");
+ ta.begin(&database);
+
+ cout << endl << endl << endl;
+
+ DBMinterval* in = 0;
+ OId* oi = 0;
+ switch (atoi(argv[1]))
+ {
+ case 1://insert
+ in = new DBMinterval(argv[2]);
+ cout << "built interval with:" << argv[2] << endl;
+ in->setPersistent(1);
+ cout << "OId of interval:" << in->getOId() << endl;
+ cout << "Minterval:" << in->get_string_representation() << endl;
+ delete in;
+ cout << "Domain deleted" << endl;
+ break;
+ case 2://update
+ oi = new OId(atol(argv[2]),OId::DBMINTERVALOID);
+ cout << "OId of interval:" << *oi << endl;
+ in = new DBMinterval(*oi);
+ cout << "Minterval:" << in->get_string_representation() << endl;
+ (*in)[in->dimension() - 2].set_low(1L);
+ (*in)[in->dimension() - 2].set_high(3L);
+ cout << "Minterval:" << in->get_string_representation() << endl;
+ in->setModified();
+ delete in;
+ cout << "Minterval deleted" << endl;
+ break;
+ case 3://delete
+ oi = new OId(atol(argv[2]),OId::DBMINTERVALOID);
+ cout << "OId of interval:" << *oi << endl;
+ in = new DBMinterval(*oi);
+ cout << "Minterval:" << in->get_string_representation() << endl;
+ in->setPersistent(0);
+ delete in;
+ cout << "Minterval deleted" << endl;
+ break;
+ case 4://read
+ oi = new OId(atol(argv[2]),OId::DBMINTERVALOID);
+ cout << "OId of interval:" << *oi << endl;
+ in = new DBMinterval(*oi);
+ cout << "Minterval:" << in->get_string_representation() << endl;
+ delete in;
+ cout << "Minterval deleted" << endl;
+ break;
+ default:
+ cout << "Donīt know what to do!" << endl;
+ break;
+ }
+ cout << endl << endl << endl;
+
+ if (argv[3])
+ {
+ if (strcmp(argv[3], "commit") == 0)
+ ta.commit();
+ }
+ ta.abort();
+ database.close();
+ }
+ else {
+ cout << "Usage:\n\t1 insert domain\n\t2 update oid\n\t3 delete oid\n\t4 read oid\n\t\tcommit/abort" << endl;
+ }
+ }
diff --git a/relmddif/test/mdditest.C b/relmddif/test/mdditest.C
new file mode 100644
index 0000000..c72252b
--- /dev/null
+++ b/relmddif/test/mdditest.C
@@ -0,0 +1,312 @@
+/*
+* This file is part of rasdaman community.
+*
+* Rasdaman community is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* Rasdaman community is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+*
+* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+rasdaman GmbH.
+*
+* For more information please see <http://www.rasdaman.org>
+* or contact Peter Baumann via <baumann@rasdaman.com>.
+*/
+#include <stdlib.h>
+#include <iostream.h>
+#include <string.h>
+
+#include "adminif.hh"
+#include "databaseif.hh"
+#include "oidif.hh"
+#include "transactionif.hh"
+
+#include "alltypes.hh"
+#include "typefactory.hh"
+
+#include "dbmddcoll.hh"
+#include "dbmddcolloidentry.hh"
+#include "dbmddobj.hh"
+
+#include "dbdirix.hh"
+
+#include "raslib/rmdebug.hh"
+
+RMINITGLOBALS('C')
+int RManDebug2 = 8;
+int RManModule = 5;
+
+int
+main(int argc, char* argv[])
+ {
+ if (argc >= 2)
+ {
+ AdminIf* myAdmin;
+ DatabaseIf database;
+ TransactionIf ta;
+ RManDebug = 6;
+
+ myAdmin = AdminIf::instance();
+ database.open("RASBASE");
+ ta.begin(&database);
+
+ DBMDDColl* coll = 0;
+ MDDSet* set = 0;
+ DBMDDCollOIdEntry* entry = 0;
+ DBMDDObjId obj = 0;
+ DBIterId iter = 0;
+ MDDIterator<DBMDDCollOIdEntry>* mdditer = 0;
+ MDDIterator<DBMDDObj>* mdditerobj = 0;
+ MDDIterator<MDDSet>* mdditercoll = 0;
+ DBMDDObjIxId ix1 = 0;
+ DBMDDObjIxId ix2 = 0;
+ DBMDDObjIxId ix3 = 0;
+ DBMDDObjIxId ix4 = 0;
+ DBDirIx* dirix = 0;
+ OId* id2 = 0;
+ OId* id = 0;
+ int i = 0;
+ OId o;
+ StructType st((char*)"StructType6", 2);
+ st.addElement("_ase6", "Bool");
+ st.addElement("_ase7", "Octet");
+ st.addElement("_ase8", "Float");
+ SetType settype((char*)"MySet3", &MDDDomainType("MyMDDDomainType", &st, r_Minterval("[1:200,*:300,20:*,*:*,20:133]")));;
+ SetType* s = 0;
+ cout << endl << endl << endl;
+
+ switch (atoi(argv[1]))
+ {
+ case 1:
+ cout << "Creating Root:" << argv[2] << endl;
+ coll = DBMDDColl::createRoot(argv[2], &database);
+ cout << "Creating Entry:" << argv[3] << endl;
+ s = TypeFactory::mapSetType("MySet3");
+ if (!s)
+ {
+
+ s = TypeFactory::addSetType(&settype);
+ }
+ DBMDDCollOIdEntry::newDBMDDCollEntry(argv[3], TypeFactory::mapSetType("MySet3"));
+ cout << "Getting Entry " << argv[3] << endl;
+ entry = MDDInit::mapMDDCollOIdEntry(argv[3]);
+ cout << "EntryName: " << entry->getCollName() << endl;
+ cout << "Inserting Objects" << endl;
+ id = new OId();
+ cout << endl;
+
+ OId::allocateOId(*id, OId::MDDOID);
+ dirix = new DBDirIx(1, DBMDDObjIx::DIRIX);
+ cout << "DBDIRIX AT " << dirix << endl;
+ ix1 = dirix;
+ cout << "DBREF IS_NULL " << ix1.is_null() << endl;
+ cout << "ALLOCATED OID " << *id << endl;
+ obj = DBMDDObj::getNonInitializedMDD(0, *id);
+ cout << "INITIALIZING" << endl;
+ obj->initialize((const MDDBaseType*)TypeFactory::mapMDDType("MyMDDDomainType"), *((MDDDomainType*)TypeFactory::mapMDDType("MyMDDDomainType"))->getDomain(), ix1);
+ cout << "INSERTING" << endl;
+ coll->insert(obj);
+ cout << endl << endl;
+
+ OId::allocateOId(*id, OId::MDDOID);
+ ix2 = new DBDirIx(1, DBMDDObjIx::DIRIX);
+ cout << "ALLOCATED OID " << *id << endl;
+ obj = DBMDDObj::getNonInitializedMDD(0, *id);
+ cout << "INITIALIZING" << endl;
+ obj->initialize((const MDDBaseType*)TypeFactory::mapMDDType("MyMDDDomainType"), *((MDDDomainType*)TypeFactory::mapMDDType("MyMDDDomainType"))->getDomain(), ix2);
+ cout << "INSERTING" << endl;
+ coll->insert(obj);
+ cout << endl << endl;
+
+ OId::allocateOId(*id, OId::MDDOID);
+ ix3 = new DBDirIx(1, DBMDDObjIx::DIRIX);
+ cout << "ALLOCATED OID " << *id << endl;
+ obj = DBMDDObj::getNonInitializedMDD(0, *id);
+ cout << "INITIALIZING" << endl;
+ obj->initialize((const MDDBaseType*)TypeFactory::mapMDDType("MyMDDDomainType"), *((MDDDomainType*)TypeFactory::mapMDDType("MyMDDDomainType"))->getDomain(), ix3);
+ cout << "INSERTING" << endl;
+ coll->insert(obj);
+ cout << endl << endl;
+
+ for (iter = coll->createNewIterator(); iter->not_done(); iter->advance())
+ {
+ cout << "Iter returned for oid " << iter->get_element()->getOId() << " domain at " << &(iter->get_element()->getDefinitionDomain());
+ iter->get_element()->printStatus();
+ }
+ cout << "Size of Collection: " << coll->getCardinality() << endl;
+ coll->getOId(&o);
+ cout << "OId of Collection: " << o << endl;
+ break;
+ case 2:
+ cout << "Getting Root:" << argv[2] << endl;
+ coll = DBMDDColl::getRoot(argv[2]);
+ i = 0;
+ for (iter = coll->createNewIterator(); iter->not_done(); iter->advance(), i++)
+ cout << "Iter returned for " << i << ". " << iter->get_element()->getOId() << endl;
+ cout << "Size of Collection: " << coll->getCardinality() << endl;
+ coll->getOId(&o);
+ cout << "OId of Collection: " << o << endl;
+ break;
+ case 3:
+ cout << "Creating Object Iterator" << endl;
+ mdditerobj = &MDDInit::createMDDObjectIterator();
+ for (i = 0; mdditerobj->not_done(); mdditerobj->advance(), i++)
+ {
+ cout << "Iter returned for " << i << ". " << mdditerobj->get_element()->getOId() << endl;
+ }
+ break;
+ case 4:
+ cout << "Creating Entry Iterator" << endl;
+ mdditer = &MDDInit::createMDDCollOIdEntryIterator();
+ for (i = 0; mdditer->not_done(); mdditer->advance(), i++)
+ {
+ cout << "Iter returned for " << i << ". " << mdditer->get_element()->getOId() << " " << mdditer->get_element()->getCollName() << " " << mdditer->get_element()->getCollType()->getTypeName() << endl;
+ }
+ break;
+ case 5:
+ cout << "Creating Coll Iterator" << endl;
+ mdditercoll = &MDDInit::createMDDSetIterator();
+ for (i = 0; mdditercoll->not_done(); mdditercoll->advance(), i++)
+ {
+ mdditercoll->get_element()->getOId(&o);
+ cout << "Iter returned for " << i << ". " << o << " " << mdditercoll->get_element()->getName() << " " << mdditercoll->get_element()->getCardinality() << endl;
+ }
+ break;
+ case 6:
+ id = new OId(atol(argv[2]), OId::MDDCOLLOID);
+ cout << "Delete Coll with id: " << *id << endl;
+ MDDInit::deleteMDDSet(*id);
+ cout << "Deleted" << endl;
+ mdditercoll = &MDDInit::createMDDSetIterator();
+ for (i = 0; mdditercoll->not_done(); mdditercoll->advance(), i++)
+ {
+ cout << "Iter returned for " << i << ". " << mdditercoll->get_element()->getOId() << " " << mdditercoll->get_element()->getName() << " " << mdditercoll->get_element()->getCardinality() << endl;
+ }
+ break;
+ case 7:
+ id = new OId(atol(argv[2]), OId::MDDCOLLOID);
+ cout << "Delete Coll Entry with id: " << *id << endl;
+ MDDInit::deleteMDDCollOIdEntry(*id);
+ cout << "Deleted" << endl;
+ mdditer = &MDDInit::createMDDCollOIdEntryIterator();
+ for (i = 0; mdditer->not_done(); mdditer->advance(), i++)
+ {
+ cout << "Iter returned for " << i << ":" << endl;
+ cout << "\t" << mdditer->get_element()->getOId() << endl;
+ cout << "\t" << mdditer->get_element()->getCollName() << endl;
+ cout << "\t" << mdditer->get_element()->getCollType()->getTypeName() << endl;
+ }
+ cout << "Done!" << endl;
+ break;
+ case 8:
+ id = new OId(atol(argv[2]), OId::MDDOID);
+ cout << "Delete Object with id: " << *id << endl;
+ MDDInit::deleteMDDObject(*id);
+ cout << "Deleted" << endl;
+ mdditerobj = &MDDInit::createMDDObjectIterator();
+ for (i = 0; mdditerobj->not_done(); mdditerobj->advance(), i++)
+ {
+ cout << "Iter returned for " << i << ". " << mdditerobj->get_element()->getOId() << endl;
+ }
+ cout << "DONE! " << endl;
+ break;
+ case 9:
+ id = new OId(atol(argv[2]), OId::MDDOID);
+ id2 = new OId(atol(argv[3]), OId::MDDCOLLOID);
+ cout << "Insert Object with id: " << *id << " into collection with id: " << *id2 << endl;
+ set = MDDInit::mapMDDSet(*id2);
+ set->insert(MDDInit::mapMDDObject(*id));
+ for (iter = set->createNewIterator(); iter->not_done(); iter->advance(), i++)
+ cout << "Iter returned for " << i << ". " << iter->get_element()->getOId() << endl;
+ break;
+ case 10:
+ cout << "Creating Root:" << argv[2] << endl;
+ coll = DBMDDColl::createRoot(argv[2], &database);
+ break;
+ case 11:
+ cout << "Creating Entry:" << argv[2] << endl;
+ DBMDDCollOIdEntry::newDBMDDCollEntry(argv[2], TypeFactory::mapSetType("MySet3"));
+ cout << "Getting Entry " << argv[2] << endl;
+ entry = MDDInit::mapMDDCollOIdEntry(argv[2]);
+ cout << "EntryName: " << entry->getCollName() << endl;
+ break;
+ case 12:
+ id = new OId(atol(argv[2]), OId::MDDOID);
+ id2 = new OId(atol(argv[3]), OId::MDDCOLLOID);
+ cout << "Remove Object with id " << *id << " from collection with id: " << *id2 << endl;
+ set = MDDInit::mapMDDSet(*id2);
+ set->remove(MDDInit::mapMDDObject(*id));
+ for (iter = set->createNewIterator(); iter->not_done(); iter->advance(), i++)
+ cout << "Iter returned for " << i << ". " << iter->get_element()->getOId() << endl;
+ break;
+ case 13:
+ cout << "Create new MDDObject" << endl;
+ id = new OId();
+ ix1 = new DBDirIx(1, DBDirIx::DIRIX);
+ cout << endl;
+
+ OId::allocateOId(*id, OId::MDDOID);
+ cout << "ALLOCATED OID " << *id << endl;
+ obj = DBMDDObj::getNonInitializedMDD(0, *id);
+ cout << "INITIALIZING" << endl;
+ obj->initialize((const MDDBaseType*)TypeFactory::mapMDDType("MyMDDDomainType"), *((MDDDomainType*)TypeFactory::mapMDDType("MyMDDDomainType"))->getDomain(), ix1);
+ cout << endl << endl;
+ break;
+ }
+ if (argv[4])
+ if ((strcmp(argv[4],"dbiter") == 0))
+ {
+ cout << "DIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII" << endl;
+ MDDIterator<MDDSet>* mdditercoll = &MDDInit::createMDDSetIterator();
+ for (i = 0; mdditercoll->not_done(); mdditercoll->advance(), i++)
+ {
+ mdditercoll->get_element()->getOId(&o);
+ cout << "Iter returned for " << i << ". " << o << " " << " " << mdditercoll->get_element()->getCardinality() << endl;
+ for (DBIter* iter = mdditercoll->get_element()->createNewIterator(); iter->not_done(); iter->advance())
+ {
+ cout << "\tIter returned for MDDObject " << iter->get_element()->getOId() << endl;
+ cout << "\t\t"; iter->get_element()->printStatus();
+ }
+ }
+ }
+ cout << endl << endl << endl;
+
+ if (argv[4])
+ {
+ if ((strcmp(argv[4],"commit") == 0))
+ {
+ cout << "commiting" << endl;
+ ta.commit();
+ }
+ }
+ else {
+ cout << "aborting" << endl;
+ ta.abort();
+ }
+ database.close();
+ }
+ else {
+ cout << "USAGE:" << endl;
+ cout << "\t1: create Coll and Entry" << endl << "\t\t collectionname entryname" << endl;
+ cout << "\t2: getRoot" << endl << "\t\trootname" << endl;
+ cout << "\t3: mddobject iterator" << endl << "\t\t" << endl;
+ cout << "\t4: entry iterator" << endl << "\t\t" << endl;
+ cout << "\t5: collection iterator" << endl << "\t\t" << endl;
+ cout << "\t6: delete collection" << endl << "\t\tcollectionoid" << endl;
+ cout << "\t7: delete entry" << endl << "\t\tentryoid" << endl;
+ cout << "\t8: delete mddobject" << endl << "\t\tmddobjectoid" << endl;
+ cout << "\t9: insert mddobject into collection" << endl << "\t\tmddobjectoid collectionoid" << endl;
+ cout << "\t10: create collection" << endl << "\t\tcollectionname" << endl;
+ cout << "\t11: create entry" << endl << "\t\tentryname" << endl;
+ cout << "\t12: remove mddobject from collection" << endl << "\t\tmddobjectoid collectionoid" << endl;
+ cout << "\t13: create mddobject" << endl << "\t\t" << endl;
+ }
+ }