summaryrefslogtreecommitdiffstats
path: root/relmddif/test
diff options
context:
space:
mode:
Diffstat (limited to 'relmddif/test')
-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
7 files changed, 938 insertions, 0 deletions
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;
+ }
+ }