Changeset: ccb2a686e81c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ccb2a686e81c
Removed Files:
        monetdb5/modules/mal/urlbox.c
        monetdb5/modules/mal/urlbox.h
        monetdb5/modules/mal/urlbox.mal
Branch: default
Log Message:

Move old url index to the attic


diffs (truncated from 689 to 300 lines):

diff --git a/monetdb5/modules/mal/urlbox.c b/monetdb5/modules/mal/urlbox.c
deleted file mode 100644
--- a/monetdb5/modules/mal/urlbox.c
+++ /dev/null
@@ -1,530 +0,0 @@
-/*
- * The contents of this file are subject to the MonetDB Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.monetdb.org/Legal/MonetDBLicense
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the MonetDB Database System.
- *
- * The Initial Developer of the Original Code is CWI.
- * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
- * Copyright August 2008-2014 MonetDB B.V.
- * All Rights Reserved.
- */
-
-/*
- * author Martin Kersten
- *  URL box
- * This module implements the flattened tree model for URLs.
- * It is targeted at the GGLETICK student project
- */
-/*
- *  Module initializaton
- * The content of this box my only be changed by the Administrator.
- */
-#include "monetdb_config.h"
-#include "urlbox.h"
-#include "mal_linker.h"
-#include "mal_authorize.h"
-
-/*
- * Access to a box calls for resolving the first parameter
- * to a named box.
- */
-#define authorize(X) { str tmp = NULL; rethrow("urlBox."X, tmp, 
AUTHrequireAdmin(&cntxt)); }
-#define OpenBox(X) authorize(X); box= findBox("urlbox"); if( box ==0) 
throw(MAL, "urlbox."X, BOX_CLOSED);
-
-#define MAXURLDEPTH 50
-static int urlDepth = 0;
-static BAT *urlBAT[MAXURLDEPTH];
-
-str
-URLBOXprelude(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
-{
-       Box box;
-       int depth;
-
-       (void) cntxt;
-       (void) mb;
-       (void) stk;
-       (void) pci;             /* fool compiler */
-       authorize("prelude");
-       box = openBox("urlbox");
-       if (box == 0)
-               throw(MAL, "urlbox.prelude", BOX_CLOSED);
-       /* if the box was already filled we can skip initialization */
-       for(depth=0; depth<MAXURLDEPTH; depth++) {
-               urlBAT[depth]=0;
-       }
-       urlDepth= 0;
-       return MAL_SUCCEED;
-}
-
-/*
- * Operator implementation
- */
-str
-URLBOXopen(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
-{
-       (void) cntxt;
-       (void) mb;
-       (void) stk;
-       (void) pci;             /* fool compiler */
-       authorize("open");
-       if (openBox("urlbox") != 0)
-               return MAL_SUCCEED;
-       throw(MAL, "urlbox.open", BOX_CLOSED);
-}
-
-str
-URLBOXclose(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
-{
-       (void) cntxt;
-       (void) mb;
-       (void) stk;
-       (void) pci;             /* fool compiler */
-       authorize("close");
-       closeBox("urlbox", TRUE);
-       return MAL_SUCCEED;
-}
-
-str
-URLBOXdestroy(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
-{
-       Box box;
-
-       (void) cntxt;
-       (void) mb;
-       (void) stk;
-       (void) pci;             /* fool compiler */
-       OpenBox("destroy");
-       destroyBox("urlbox");
-       return MAL_SUCCEED;
-}
-
-/*
- * The real work starts here. We have to insert an URL.
- */
-static int
-URLBOXchop(str url, str *parts){
-       char *s, *t;
-       int depth=0;
-
-       s= url;
-       while( *s && *s != '\n'){
-               t= s+1;
-               while(*t && *t !='\n' && *t!= '/') t++;
-               if( *t ){
-                       *t= 0;
-               } else break;
-               parts[depth++]= s;
-               for( t++; *t && (*t == '\n' || *t== '/'); t++) ;
-               s= t;
-       }
-       return depth;
-}
-static str
-URLBOXinsert(char *tuple)
-{
-       str parts[MAXURLDEPTH];
-       int i=0,depth;
-       BAT *b;
-       BUN p;
-       BUN idx= 0;
-       int prv=0;
-       char buf[128];
-
-       depth= URLBOXchop(tuple, parts);
-       if( depth == 0) return MAL_SUCCEED;
-       if( depth > urlDepth || urlBAT[0]== NULL){
-               for(i=0; i<=depth; i++){
-                       /* make new bat */
-                       snprintf(buf, 128, "urlbox_%d", i);
-                       b = BATdescriptor(BBPindex(buf));
-                       if (b){
-                               urlBAT[i] = b;
-                               continue;
-                       }
-
-                       b = BATnew(TYPE_void, TYPE_str, 1024);
-                       if (b == NULL)
-                               throw(MAL, "urlbox.deposit", MAL_MALLOC_FAIL);
-                       BATseqbase(b,0);
-
-                       BATkey(b,TRUE);
-                       BBPrename(b->batCacheid, buf);
-                       BATmode(b, PERSISTENT);
-                       BATcommit(b);
-                       urlBAT[i] = b;
-               }
-               urlDepth= depth;
-       }
-       /*
-        * Find the common prefix first
-        */
-       p= BUNfnd(BATmirror(urlBAT[0]),parts[0]);
-       if (p != BUN_NONE) 
-               for( i=1; i<depth; i++){
-                       /* printf("search [%d]:%s\n",i,parts[i]);*/
-                       p = BUNfnd(BATmirror(urlBAT[i]),parts[i]);
-                       if (p == BUN_NONE) 
-                               break;
-                       prv = *(int*)Hloc(urlBAT[i], p);
-               }
-       else i = 0;
-       /*
-        * Insert the remainder as a new url string
-        */
-       for( ; i<depth; i++){
-               /* printf("update [%d]:%s\n",i,parts[i]);*/
-               idx = BATcount(urlBAT[i]);
-               BUNins(urlBAT[i], (ptr) &prv, parts[i], FALSE);
-               assert(idx <= GDK_int_max);
-               prv = (int) idx;
-       }
-       return MAL_SUCCEED;
-}
-#define SIZE 1*1024*1024
-
-str
-URLBOXdepositFile(int *r, str *fnme){
-
-       stream *fs;
-       bstream *bs;
-       char *s,*t;
-       int len=0;
-       char buf[PATHLENGTH];
-
-       (void) r; 
-       if( **fnme == '/')
-               snprintf(buf,PATHLENGTH,"%s", *fnme);
-       else 
-               snprintf(buf,PATHLENGTH,"%s/%s", monet_cwd, *fnme);
-       /* later, handle directory separator */
-       fs= open_rastream(buf);
-       if( fs == NULL )
-               throw(MAL, "urlbox.deposit", RUNTIME_FILE_NOT_FOUND "%s",buf);
-       if( mnstr_errnr(fs) ) {
-               close_stream(fs);
-               throw(MAL, "urlbox.deposit", RUNTIME_FILE_NOT_FOUND "%s",buf);
-       }
-       bs= bstream_create(fs,SIZE);
-       if( bs == NULL) 
-               throw(MAL, "urlbox.deposit", MAL_MALLOC_FAIL);
-       while( bstream_read(bs,bs->size-(bs->len-bs->pos)) != 0 &&
-               !mnstr_errnr(bs->s) ){
-               s= bs->buf;
-               for( t=s; *t ; ){
-                       while(t < bs->buf+bs->len && *t && *t != '\n') t++;
-                       if(t== bs->buf+bs->len || *t != '\n'){
-                               /* read next block if possible after shift  */
-                               assert(t-s <= INT_MAX);
-                               len = (int) (t-s);
-                               memcpy(bs->buf, s, len);
-                               bs->len = len;
-                               bs->pos = 0;
-                               break;
-                       }
-                       /* found a string to be processed */
-                       *t = 0;
-                       URLBOXinsert(s);
-                       *t= '\n';
-                       s= t+1;
-                       t= s;
-               }
-       }
-
-       bstream_destroy(bs);
-       mnstr_close(fs);
-       mnstr_destroy(fs);
-       return MAL_SUCCEED;
-}
-str
-URLBOXdeposit(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
-{
-       str url;
-       Box box;
-       char tuple[2048];
-
-       (void) cntxt;
-       (void) mb;
-       OpenBox("deposit");
-       url = *(str*) getArgReference(stk, pci, 1);
-       if( strlen(url) <2048)
-               strcpy(tuple,url);
-       else throw(MAL, "urlbox.deposit", ILLEGAL_ARGUMENT " URL too long");
-       return URLBOXinsert(url);
-}
-
-str
-URLBOXtake(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
-{
-       str url, parts[MAXURLDEPTH];
-       Box box;
-
-       (void) cntxt;
-       OpenBox("take");
-       url = *(str*) getArgReference(stk, pci, 1);
-       url = GDKstrdup(url);
-       URLBOXchop(url, parts);
-       GDKfree(url);
-       (void) mb;
-       return MAL_SUCCEED;
-}
-
-str
-URLBOXrelease(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
-{
-       str name;
-       Box box;
-
-       (void) cntxt;
-       (void) mb;              /* fool compiler */
-
-       OpenBox("release");
-       name = *(str*) getArgReference(stk, pci, 1);
-       if (releaseBox(box, name))
-               throw(MAL, "urlbox.release", OPERATION_FAILED);
-       return MAL_SUCCEED;
-}
-str
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to