Commit 80b16c56 by etcart

DBscan updated

parent 08c0a7e5
File added
......@@ -12,7 +12,9 @@
#define UNCHECKED 0
#define NOISE -1
#include "RIVtoolsCPUlinux.h"
#include "RIVtools.h"
struct DBnode{
sparseRIV RIV;
int* indexes;
......@@ -27,7 +29,7 @@ void directoryToL2s(char *rootString, sparseRIV** fileRIVs, int *fileCount);
int main(int argc, char *argv[]){
clock_t begintotal = clock();
int fileCount = 0;
RIVInit();
lexOpen("/run/media/etcart/UUI/lexicon");
sparseRIV *fileRIVs = (sparseRIV*) malloc(1*sizeof(sparseRIV));
char rootString[2000];
if(argc <2){
......@@ -148,21 +150,16 @@ void directoryToL2s(char *rootString, sparseRIV** fileRIVs, int *fileCount){
}
strcpy(pathString, rootString);
strcat(pathString, files->d_name);
FILE *input = fopen(pathString, "r");
if(!input){
printf("file %s doesn't seem to exist, breaking out of loop", pathString);
return;
}else{
denseRIV temp = lexPull(files->d_name);
if(*temp.frequency >2000){
(*fileRIVs) = (sparseRIV*)realloc((*fileRIVs), ((*fileCount)+1)*sizeof(sparseRIV));
(*fileRIVs)[(*fileCount)] = fileToL2(input);
strcpy((*fileRIVs)[(*fileCount)].name, pathString);
(*fileRIVs)[(*fileCount)] = normalize(temp, 500);
fclose(input);
strcpy((*fileRIVs)[(*fileCount)].name, files->d_name);
(*fileCount)++;
}
free(temp.values);
}
}
......
File added
......@@ -166,7 +166,7 @@ int* addI2D(int* destination, int* locations, size_t seedCount);
*/
denseRIV denseAllocate();
/* 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 */
int* addS2D(int* destination, sparseRIV input){// #TODO fix destination parameter vs calloc of destination
......@@ -313,12 +313,9 @@ void lexOpen(char* lexName){
strcpy(RIVKey.lexName, lexName);
/* open a slot at least large enough for worst case handling of
* sparse to dense conversion. may be enlarged by filetoL2 functions */
struct sigaction action;
action.sa_sigaction = signalSecure;
action.sa_flags = SA_SIGINFO;
//for(int i=1; i<27; i++){
sigaction(11,&action,NULL);
//}
signal(11, signalSecure);
/* open a slot for a cache of dense RIVs, optimized for frequent accesses */
......@@ -440,14 +437,15 @@ denseRIV fLexPull(FILE* lexWord){
}
void signalSecure(int signum, siginfo_t *si, void* arg){
void signalSecure(int signum){
if(cacheDump()){
puts("cache dump failed, some lexicon data lost");
}else{
puts("cache dumped successfully");
}
signal(signum, SIG_DFL);
kill(getpid(), signum);
exit(1);
}
int cacheDump(){
......
No preview for this file type
No preview for this file type
......@@ -146,7 +146,7 @@ void fileGrind(FILE* textFile){
}
void readdirContingency(int sigNumber){
("readdir segfaulted, trying to recover");
puts("readdir segfaulted, trying to recover");
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