Commit 80b16c56 by etcart

DBscan updated

parent 08c0a7e5
File added
...@@ -12,7 +12,9 @@ ...@@ -12,7 +12,9 @@
#define UNCHECKED 0 #define UNCHECKED 0
#define NOISE -1 #define NOISE -1
#include "RIVtoolsCPUlinux.h"
#include "RIVtools.h"
struct DBnode{ struct DBnode{
sparseRIV RIV; sparseRIV RIV;
int* indexes; int* indexes;
...@@ -27,7 +29,7 @@ void directoryToL2s(char *rootString, sparseRIV** fileRIVs, int *fileCount); ...@@ -27,7 +29,7 @@ void directoryToL2s(char *rootString, sparseRIV** fileRIVs, int *fileCount);
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
clock_t begintotal = clock(); clock_t begintotal = clock();
int fileCount = 0; int fileCount = 0;
RIVInit(); lexOpen("/run/media/etcart/UUI/lexicon");
sparseRIV *fileRIVs = (sparseRIV*) malloc(1*sizeof(sparseRIV)); sparseRIV *fileRIVs = (sparseRIV*) malloc(1*sizeof(sparseRIV));
char rootString[2000]; char rootString[2000];
if(argc <2){ if(argc <2){
...@@ -100,7 +102,7 @@ int main(int argc, char *argv[]){ ...@@ -100,7 +102,7 @@ int main(int argc, char *argv[]){
clock_t endtotal = clock(); clock_t endtotal = clock();
double time_spent = (double)(endtotal - begintotal) / CLOCKS_PER_SEC; double time_spent = (double)(endtotal - begintotal) / CLOCKS_PER_SEC;
printf("total time:%lf\n\n", time_spent); printf("total time:%lf\n\n", time_spent);
return 0; return 0;
} }
...@@ -148,21 +150,16 @@ void directoryToL2s(char *rootString, sparseRIV** fileRIVs, int *fileCount){ ...@@ -148,21 +150,16 @@ void directoryToL2s(char *rootString, sparseRIV** fileRIVs, int *fileCount){
} }
strcpy(pathString, rootString); denseRIV temp = lexPull(files->d_name);
strcat(pathString, files->d_name); if(*temp.frequency >2000){
FILE *input = fopen(pathString, "r");
if(!input){
printf("file %s doesn't seem to exist, breaking out of loop", pathString);
return;
}else{
(*fileRIVs) = (sparseRIV*)realloc((*fileRIVs), ((*fileCount)+1)*sizeof(sparseRIV)); (*fileRIVs) = (sparseRIV*)realloc((*fileRIVs), ((*fileCount)+1)*sizeof(sparseRIV));
(*fileRIVs)[(*fileCount)] = normalize(temp, 500);
(*fileRIVs)[(*fileCount)] = fileToL2(input); strcpy((*fileRIVs)[(*fileCount)].name, files->d_name);
strcpy((*fileRIVs)[(*fileCount)].name, pathString);
fclose(input);
(*fileCount)++; (*fileCount)++;
} }
free(temp.values);
} }
} }
......
File added
...@@ -166,7 +166,7 @@ int* addI2D(int* destination, int* locations, size_t seedCount); ...@@ -166,7 +166,7 @@ int* addI2D(int* destination, int* locations, size_t seedCount);
*/ */
denseRIV denseAllocate(); denseRIV denseAllocate();
/* redefines signal behavior to protect cached data against seg-faults etc*/ /* redefines signal behavior to protect cached data against seg-faults etc*/
void signalSecure(int signum, siginfo_t *si, void* arg); void signalSecure(int signum);
/* begin definitions */ /* begin definitions */
int* addS2D(int* destination, sparseRIV input){// #TODO fix destination parameter vs calloc of destination int* addS2D(int* destination, sparseRIV input){// #TODO fix destination parameter vs calloc of destination
...@@ -313,12 +313,9 @@ void lexOpen(char* lexName){ ...@@ -313,12 +313,9 @@ void lexOpen(char* lexName){
strcpy(RIVKey.lexName, lexName); strcpy(RIVKey.lexName, lexName);
/* open a slot at least large enough for worst case handling of /* open a slot at least large enough for worst case handling of
* sparse to dense conversion. may be enlarged by filetoL2 functions */ * sparse to dense conversion. may be enlarged by filetoL2 functions */
struct sigaction action;
action.sa_sigaction = signalSecure; signal(11, signalSecure);
action.sa_flags = SA_SIGINFO;
//for(int i=1; i<27; i++){
sigaction(11,&action,NULL);
//}
/* open a slot for a cache of dense RIVs, optimized for frequent accesses */ /* open a slot for a cache of dense RIVs, optimized for frequent accesses */
...@@ -440,14 +437,15 @@ denseRIV fLexPull(FILE* lexWord){ ...@@ -440,14 +437,15 @@ denseRIV fLexPull(FILE* lexWord){
} }
void signalSecure(int signum, siginfo_t *si, void* arg){ void signalSecure(int signum){
if(cacheDump()){ if(cacheDump()){
puts("cache dump failed, some lexicon data lost"); puts("cache dump failed, some lexicon data lost");
}else{ }else{
puts("cache dumped successfully"); puts("cache dumped successfully");
} }
signal(signum, SIG_DFL); signal(signum, SIG_DFL);
kill(getpid(), signum); exit(1);
} }
int cacheDump(){ int cacheDump(){
......
No preview for this file type
No preview for this file type
...@@ -146,7 +146,7 @@ void fileGrind(FILE* textFile){ ...@@ -146,7 +146,7 @@ void fileGrind(FILE* textFile){
} }
void readdirContingency(int sigNumber){ void readdirContingency(int sigNumber){
("readdir segfaulted, trying to recover"); puts("readdir segfaulted, trying to recover");
longjmp(readdirRecov, 1); longjmp(readdirRecov, 1);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment