Update of /cvsroot/monetdb/sql/src/storage/bpm
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv1648
Modified Files:
bpm_storage.mx
Log Message:
First step to have partition distribution.
The distribution is done at the partition fragment level. Each fragment
resulted from
a bat partition can be located at a different location than the actual bat
location.
For the moment the location information is (by default):
host (localhost)
port (50000)
dbname (demo)
user (monetdb)
passwd (monetdb)
In the bpm_part structure a pointer to this structure was added. By default it
points for the
default location.
Functions:
Function to set location:
If the location does not exit it creates a new one.
Function to remove location:
It only sets the location pointer equal NULL (maybe default would be
better)
However, the location is not removed from the location catalog because
several
fragements might share the same location
Storage management:
I only save the location id. When the fragment is loaded I use this id
to get its location information (if location catalog is not loaded yet it will
be).
The addition and remotion of the fragment location is also implemented
Note: It was compiled with strict compilation and no errors showed up. For the
moment
I only started the mserver with option "--set sql_debug=16" to activate the
partition
model and no errors showed up.
Index: bpm_storage.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/storage/bpm/bpm_storage.mx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- bpm_storage.mx 16 Jan 2008 08:51:15 -0000 1.7
+++ bpm_storage.mx 19 Jan 2008 17:23:54 -0000 1.8
@@ -22,6 +22,7 @@
#include "sql_storage.h"
#include "bpm_logger.h"
+#include "bpm_distribution.h"
#define BPM_SPLIT 1024
#define BPM_DEFAULT 8
@@ -37,6 +38,7 @@
sht hbits, tbits; /* linear hashing bits */
char *name, *uname;
size_t cnt;
+ bpmHost host;
} *Part, PartRec;
typedef struct sql_bpm {
@@ -56,6 +58,9 @@
extern int bpm_add_partition(sql_bpm *p);
+extern int bpm_set_part_location(Part p, char *host, int port, char *dbname,
char* username, char* passwd);
+extern int bpm_del_part_location(Part p);
+
#endif /*BPMSTORAGE_H */
@c
@@ -75,7 +80,9 @@
static BAT *part_thgh = NULL;
static BAT *part_hbits = NULL;
static BAT *part_tbits = NULL;
+static BAT *part_host = NULL;
+static BAT * bpm_part_name(void);
int part = 1; /* part id is saved by the logger */
static int
@@ -122,11 +129,55 @@
}
p -> parts[nr].tlow = p -> parts[nr].thgh = NULL;
p -> parts[nr].hbits = p -> parts[nr].tbits = 0;
+ p -> parts[nr].host = bpm_set_default_host();
p -> nr++;
return nr;
}
int
+bpm_set_part_location(Part p, char *host, int port, char *dbname, char* user,
char* passwd)
+{
+ BATiter part_namei;
+ ptr id;
+ BAT *part_name = bpm_part_name();
+ bpmHost bpmH = bpm_host_create(host, port, dbname, user, passwd);
+
+ if (bpmH) {
+ p->host = bpmH;
+ return 1;
+ }
+
+ part_namei = bat_iterator(part_name);
+ id = BUNhead(part_namei,BUNfnd(part_name, p->name));
+ BUNins(part_host, (ptr)&id, &bpmH->id, TRUE);
+
+ /* error */
+ assert(0);
+ return 0;
+}
+
+int
+bpm_remove_part_location(Part p)
+{
+ BATiter part_namei;
+ ptr id;
+ BAT *part_name = bpm_part_name();
+ int host_id = 0;
+
+ if (p->host) {
+ p->host = NULL;
+ return 1;
+ }
+ part_namei = bat_iterator(part_name);
+ id = BUNhead(part_namei,BUNfnd(part_name, p->name));
+ BUNins(part_host, (ptr)&id, &host_id, TRUE);
+
+ /* error */
+ assert(0);
+ return 0;
+}
+
+int
bpm_add_partition(sql_bpm *p)
{
/* do not add a partition if the current part is empty */
@@ -201,6 +252,7 @@
part_thgh = get_bat("part_thgh");
part_hbits = get_bat("part_hbits");
part_tbits = get_bat("part_tbits");
+ part_host = get_bat("part_host");
}
if (!part_name) {
/* partition bats */
@@ -217,6 +269,7 @@
part_thgh = bat_new(TYPE_oid, TYPE_oid, 0);
part_hbits = bat_new(TYPE_oid, TYPE_sht, 0);
part_tbits = bat_new(TYPE_oid, TYPE_sht, 0);
+ part_host = bat_new(TYPE_oid, TYPE_int, 0);
#define log_P(l, b, n) logger_add_bat(l, b, n); log_bat_persists(l, b, n)
log_P(bpm_logger, part_name, "part_name");
@@ -229,11 +282,12 @@
log_P(bpm_logger, part_thgh, "part_thgh");
log_P(bpm_logger, part_hbits, "part_hbits");
log_P(bpm_logger, part_tbits, "part_tbits");
+ log_P(bpm_logger, part_host, "part_host");
}
}
static BAT *
-bpm_part_name() {
+bpm_part_name(void) {
if (!part_name)
bpm_init();
return part_name;
@@ -599,6 +653,8 @@
ptr id = BUNhead(partsi,p);
BATiter part_nri = bat_iterator(part_nr);
sht nr = *(sht*)BUNtail(part_nri, BUNfnd(part_nr, id));
+ BATiter part_hosti = bat_iterator(part_host);
+ int host = *(int*)BUNtail(part_hosti, BUNfnd(part_host, id));
char *name = sql_message("%s_%d", pp->name, nr);
char *uname = sql_message("U_%s_%d", pp->name, nr);
int bid = logger_find_bat(bpm_logger, name);
@@ -609,7 +665,9 @@
pp->parts[pp->nr-1].name = name;
pp->parts[pp->nr-1].uname = uname;
bat_destroy(b);
+ pp->parts[pp->nr-1].host = bpm_host_get(host);
assert(pp->parts[pp->nr-1].hlow != (oid)-1);
+
}
*cnt = o;
pp->ins = pp->nr;
@@ -949,6 +1007,8 @@
_DELETE(p->parts[i].tlow);
if (p->parts[i].thgh)
_DELETE(p->parts[i].thgh);
+ if (p->parts[i].host)
+ p->parts[i].host = NULL;
}
if (p->name)
_DELETE(p->name);
@@ -1224,6 +1284,7 @@
BUNappend(part_nr, &i, TRUE);
BUNappend(part_hlow, &p->hlow, TRUE);
BUNappend(part_hhgh, &p->hhgh, TRUE);
+ BUNappend(part_host, &p->host, TRUE);
p->name = sql_message("%s_%d", op->name, i);
p->uname = sql_message("U_%s_%d", op->name,i);
@@ -1268,6 +1329,7 @@
BUNappend(part_nr, &i, TRUE);
BUNappend(part_hlow, &p->hlow, TRUE);
BUNappend(part_hhgh, &p->hhgh, TRUE);
+ BUNappend(part_host, &p->host, TRUE);
p->name = sql_message("%s_%d", op->name, i);
p->uname = sql_message("U_%s_%d", op->name,i);
@@ -1304,6 +1366,7 @@
log_bat(bpm_logger, part_nr, "part_nr");
log_bat(bpm_logger, part_hlow, "part_hlow");
log_bat(bpm_logger, part_hhgh, "part_hhgh");
+ log_bat(bpm_logger, part_host, "part_host");
}
return ok;
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins