AllocatedBlocks HeapProfiler::blocks;
// Override initialising hook from the C library.
-void (*__malloc_initialize_hook) (void) = HeapProfiler::InitHooks;
+void (* volatile __malloc_initialize_hook) (void) = HeapProfiler::InitHooks;
// Variables to save original hooks.
void *(*HeapProfiler::old_malloc_hook)(size_t, const void *);
{
if (i == ROOT) return NULLT; // parent of root
if (T->boost[T->letters[i-rank(T->pdata->bdata,i)]] == i) return ROOT;
- return enclose (T->pdata,i);
+ return _enclose (T->pdata,i);
}
// subtree size
// open position of closest parentheses pair that contains the pair
// that opens at i, ~0 if no parent
-uint enclose (parentheses P, uint i)
+uint _enclose (parentheses P, uint i)
{ if (i == 0) return ~0; // no parent!
return findparent (P,i);
uint excess (parentheses P, uint i);
// open position of closest parentheses pair that contains the pair
// that opens at i, ~0 if no parent
-uint enclose (parentheses P, uint i);
+uint _enclose (parentheses P, uint i);
uint sizeofParentheses(parentheses P);
#endif
+HIDE=@
CC = g++
LIBCDSPATH = ../libcds
-CPPFLAGS = -Wall -ansi -g -I$(LIBCDSPATH)/includes/ -O3 -DNDEBUG
+CPPFLAGS = -Wall -ansi -g -I$(LIBCDSPATH)/includes/ -O3 -DNDEBUG -Wno-deprecated-declarations
#CPPFLAGS = -Wall -ansi -g -I$(LIBCDSPATH)/includes/
LIBCDSA = $(LIBCDSPATH)/lib/libcds.a
LIBRLCSA = incbwt/rlcsa.a
LIBLZTRIE = lzindex/lztrie.a
LIBSWCSA = swcsa/swcsa.a
+LIBS= ${LIBRLCSA} ${LIBCDSA} ${LIBLZTRIE} ${LIBSWCSA}
dcover_obs = dcover/difference_cover.o
TextCollection_obs = TextCollection.o TextCollectionBuilder.o FMIndexBuilder.o RLCSABuilder.o FMIndex.o Tools.o \
- TextStorage.o Query.o EditDistance.o ResultSet.o ${LIBRLCSA} ${LIBCDSA} ${LIBLZTRIE} ${LIBSWCSA}
+ TextStorage.o Query.o EditDistance.o ResultSet.o
TCDebug_obs = bittree.o rbtree.o dynFMI.o
+TEXTCOLLECTION_A=libTextCollection.a
+
all: testTextCollection
-testTextCollection: testTextCollection.o $(TextCollection_obs) $(TCDebug_obs) HeapProfiler.o
- $(CC) -o testTextCollection testTextCollection.o $(TextCollection_obs) $(TCDebug_obs) HeapProfiler.o
+testTextCollection: testTextCollection.o $(TextCollection_obs) $(LIBS) $(TCDebug_obs) HeapProfiler.o
+ $(CC) -o testTextCollection testTextCollection.o $(TextCollection_obs) $(LIBS) $(TCDebug_obs) HeapProfiler.o
-timeTextCollection: timeTextCollection.o $(TextCollection_obs) $(TCDebug_obs)
+timeTextCollection: timeTextCollection.o $(TextCollection_obs) $(LIBS) $(TCDebug_obs)
$(CC) -o timeTextCollection timeTextCollection.o $(TextCollection_obs) $(TCDebug_obs)
test2dRange: test2dRange.o ${LIBCDSA}
swcsa/swcsa.a:
@make -C swcsa
+%o: %c
+ @echo [C] $@
+ $(HIDE) (gcc -c $(CPPFLAGS) $< -o $@
+
+%o: %cpp
+ @echo [C++] $@
+ $(HIDE) $(CC) -c $(CPPFLAGS) $< -o $@
+
+
+$(TEXTCOLLECTION_A): $(TextCollection_obs) $(LIBS)
+ @echo [Link] $@
+ $(HIDE) rm -rf .objs
+ $(HIDE) mkdir .objs
+ $(HIDE) (cd .objs; ar x ../${LIBRLCSA};ar x ../${LIBLZTRIE}; ar x ../${LIBSWCSA})
+ $(HIDE) ar rcs $@ $(TextCollection_obs) .objs/*.o
+# $(HIDE) rm -rf .objs
+
+
clean:
@make clean -C incbwt
@make clean -C lzindex
mv bitmap.o bitmapswcsa.o
mv parameters.o parametswcsa.o
ar rc $(LIBINTINDEX) parametswcsa.o buildFacade.o hashswcsa.o valstring.o MemoryManager.o basicsswcsa.o \
- bitmapswcsa.o huffDecswcsa.o huffswcsa.o fileInfo.o
+ bitmapswcsa.o huffDecswcsa.o huffswcsa.o fileInfo.o
mv $(LIBINTINDEX) $(LIBINDEX)
################# SELF INDEX ON INTEGERS ##############################
####################### UTILS MODULES #################################
-parameters.o:
- $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/parameters.c
+parameters.o:
+ $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/parameters.c
-fileInfo.o:
+fileInfo.o:
$(CC) $(CFLAGS) -c $(SRCDIRUTILS)/fileInfo.c
hash.o: MemoryManager.o
MemoryManager.o:
$(CC) $(CFLAGS) -c $(SRCDIRUTILS)/MemoryManager.c
-valstring.o:
- $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/valstring.c
+valstring.o:
+ $(CC) $(CFLAGS) -c $(SRCDIRUTILS)/valstring.c
-huff.o:
+huff.o:
$(CC) $(CFLAGS) -c $(SRCDIRUTILS)/huff.c
-huffDec.o:
+huffDec.o:
$(CC) $(CFLAGS) -c $(SRCDIRUTILS)/huffDec.c
-basics.o:
+basics.o:
$(CC) $(CFLAGS) -c $(SRCDIRUTILS)/basics.c
-bitmap.o:
+bitmap.o:
$(CC) $(CFLAGS) -c $(SRCDIRUTILS)/bitmap.c
############################ CLEANING #################################
-cleanO:
+cleanO:
rm -f *.o
-
+
clean:
cd $(SRCDIRCSA) && $(MAKE) clean -w
rm -rf *~ *% *.o core *.bak $(LIBINTINDEX) $(LIBINDEX)
tmpOffsets[zeroNode]=tmpOffset; //setting pointer to the "virtual" word {zeroNode+1}^{th}
//kbit encoding of the offsets
- uint elemSize = bits(tmpOffset);
+ uint elemSize = _bits(tmpOffset);
wcsa->wordsData.elemSize = elemSize;
wcsa->wordsData.words = (uint *) malloc (((((zeroNode +1)*elemSize)+W-1) /W) * sizeof(uint)); //with 1 extra slot !.
wcsa->wordsData.words[((((zeroNode +1)*elemSize)+W-1) /W) -1 ] =0000;
ifndef CFLAGS ##possibly already defined by the "main Makefile".
##CFLAGS = -O9 -m32
- CFLAGS = -O9 -m32
+ CFLAGS = -O9 -m32
##CFLAGS = -g -m32 -O0
endif
intIndex: icsa.o parameters.o basics.o huff.o bitmap.o psiHuffmanRLE.o psiDeltaCode.o psiGonzalo.o
- ar rc $(LIBINTINDEX) icsa.o psiHuffmanRLE.o psiDeltaCode.o psiGonzalo.o
+ ar rc $(LIBINTINDEX) icsa.o psiHuffmanRLE.o psiDeltaCode.o psiGonzalo.o
#not including "parameters.o basics.o bitmap.o huff.o" as they are included by wcsa
#they are already included into the library by the presentation layer.
-icsa.o: parameters.o basics.o bitmap.o huff.o psiHuffmanRLE.o psiDeltaCode.o psiGonzalo.o
- $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/icsa.c
+icsa.o: parameters.o basics.o bitmap.o huff.o psiHuffmanRLE.o psiDeltaCode.o psiGonzalo.o
+ $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/icsa.c
psiHuffmanRLE.o: huff.o
- $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/psiHuffmanRLE.c
+ $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/psiHuffmanRLE.c
psiDeltaCode.o:
- $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/psiDeltaCode.c
+ $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/psiDeltaCode.c
psiGonzalo.o: huff.o
- $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/psiGonzalo.c
+ $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRCSA)/psiGonzalo.c
-parameters.o:
- $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRUTILS)/parameters.c
-
-
-huff.o:
+parameters.o:
+ $(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRUTILS)/parameters.c
+
+
+huff.o:
$(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRUTILS)/huff.c
-basics.o:
+basics.o:
$(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRUTILS)/basics.c
-bitmap.o:
+bitmap.o:
$(CC) $(CFLAGS) -c $(SRCDIR)/$(SRCDIRUTILS)/bitmap.c
-cleanO:
+cleanO:
rm -f *.o
-
+
clean:
- rm -rf *~ *% *.o core *.bak icsa.a
+ rm -rf *~ *% *.o core *.bak icsa.a
tar:
tar czvf icsa.tar.gz Makefile
-#include <stdio.h>\r#include <fcntl.h>\r#include <sys/stat.h>\r#include <time.h>\r#include <sys/time.h>\r\r#include "defValues.h"\r#include "../utils/bitmap.h"\r#include "../utils/huff.h"\r#include "../utils/parameters.h"\r\r#ifdef PSI_HUFFMANRLE\r #include "psiHuffmanRLE.h"\r#endif\r\r#ifdef PSI_GONZALO\r #include "psiGonzalo.h"\r#endif\r\r#ifdef PSI_DELTACODES\r #include "psiDeltaCode.h"\r#endif\r\r\rtypedef struct {\r uint suffixArraySize;\r uint T_Psi;\r uint *D;\r bitmap bD;\r uint T_A;\r uint T_AInv;\r uint *samplesA;\r uint samplesASize;\r uint *BA;\r bitmap bBA; \r uint *samplesAInv;\r uint samplesAInvSize;\r uint displayCSAState;\r int displayCSAPrevPosition;\r #ifdef PSI_HUFFMANRLE \r HuffmanCompressedPsi hcPsi;\r #endif \r #ifdef PSI_GONZALO\r GonzaloCompressedPsi gcPsi;\r #endif\r #ifdef PSI_DELTACODES\r DeltaCompressedPsi dcPsi;\r #endif\r \r //only needed during "parse_parameters".\r uint tempNSHUFF;\r uint psiSearchFactorJump; //factor of the T_Psi value.\r} ticsa; \r\r \r// FUNCTION PROTOTYPES: BUILDING THE INDEX\r\r//Creates the ICSA \r\r int buildIntIndex (uint *intVector, uint n, char *build_options, void **index ); //ticsa *createIntegerCSA (uint **aintVector, uint SAsize, char *build_options);\r\r//Returns number of elements in the indexed sequence of integers\r int sourceLenIntIndex(void *index, uint *numInts);\r\r//Save the index to disk\r int saveIntIndex(void *index, char *pathname); //void storeStructsCSA(ticsa *myicsa, char *basename);\r\r// Loads the index from disk.\r int loadIntIndex(char *pathname, void **index); //ticsa *loadCSA(char *basename);\r\r// Frees memory \r int freeIntIndex(void *index); //uint destroyStructsCSA(ticsa *myicsa);\r\r//Returns the size (in bytes) of the index over the sequence of integers.\r int sizeIntIndex(void *index, uint *numBytes); //uint CSA_size(ticsa *myicsa); \r\r // Shows detailed summary info of the self-index (memory usage of each structure)\rint printInfoIntIndex(void *index, const char tab[]);\r\r//Number of occurrences of the pattern, and the interval [left,right] in the suffix array.\r int countIntIndex(void *index, uint *pattern, uint length, ulong *numocc, ulong *left, ulong *right);\r //uint countCSA(ticsa *myicsa, uint *pattern, uint patternSize, uint *left, uint *right); // Exponential search\r //uint countCSABin(ticsa *myicsa, uint *pattern, uint patternSize, uint *left, uint *right); // Binary search\r\r// Returns an array with integers corresponding offsets to the occurrences of the pattern, \r// as well as the number of occurrences\r int locateIntIndex(void *index, uint *pattern, uint length, ulong **occ, ulong *numocc);\r //uint *locateCSA(ticsa *myicsa, uint *pattern, uint patternSize, uint *occ);\r\r//Returns the value of the source (array of integers) at a given offset.\r// (that is, the element "position" from the original array of uints)\r int displayIntIndex(void *index, ulong position, uint *value);\r //uint displayCSA(ticsa *myicsa, uint position); \r\r\r/* Private function prototypes ********************************************/\ruint parametersCSA(ticsa *myicsa, char *build_options);\r\ruint displayCSAFirst(ticsa *myicsa, uint position);\ruint displayCSANext(ticsa *myicsa);\rint SadCSACompare(ticsa *myicsa, uint *pattern, uint patternSize, uint p);\ruint A(ticsa *myicsa, uint position);\ruint inverseA(ticsa *myicsa, uint offset);\r\rvoid showStructsCSA(ticsa *myicsa); // For Debugging\r\r
\ No newline at end of file
+//#include <stdio.h>\r#include <fcntl.h>\r#include <sys/stat.h>\r#include <time.h>\r#include <sys/time.h>\r\r#include "defValues.h"\r#include "../utils/bitmap.h"\r#include "../utils/huff.h"\r#include "../utils/parameters.h"\r\r#ifdef PSI_HUFFMANRLE\r #include "psiHuffmanRLE.h"\r#endif\r\r#ifdef PSI_GONZALO\r #include "psiGonzalo.h"\r#endif\r\r#ifdef PSI_DELTACODES\r #include "psiDeltaCode.h"\r#endif\r\r\rtypedef struct {\r uint suffixArraySize;\r uint T_Psi;\r uint *D;\r bitmap bD;\r uint T_A;\r uint T_AInv;\r uint *samplesA;\r uint samplesASize;\r uint *BA;\r bitmap bBA; \r uint *samplesAInv;\r uint samplesAInvSize;\r uint displayCSAState;\r int displayCSAPrevPosition;\r #ifdef PSI_HUFFMANRLE \r HuffmanCompressedPsi hcPsi;\r #endif \r #ifdef PSI_GONZALO\r GonzaloCompressedPsi gcPsi;\r #endif\r #ifdef PSI_DELTACODES\r DeltaCompressedPsi dcPsi;\r #endif\r \r //only needed during "parse_parameters".\r uint tempNSHUFF;\r uint psiSearchFactorJump; //factor of the T_Psi value.\r} ticsa; \r\r \r// FUNCTION PROTOTYPES: BUILDING THE INDEX\r\r//Creates the ICSA \r\r int buildIntIndex (uint *intVector, uint n, char *build_options, void **index ); //ticsa *createIntegerCSA (uint **aintVector, uint SAsize, char *build_options);\r\r//Returns number of elements in the indexed sequence of integers\r int sourceLenIntIndex(void *index, uint *numInts);\r\r//Save the index to disk\r int saveIntIndex(void *index, char *pathname); //void storeStructsCSA(ticsa *myicsa, char *basename);\r\r// Loads the index from disk.\r int loadIntIndex(char *pathname, void **index); //ticsa *loadCSA(char *basename);\r\r// Frees memory \r int freeIntIndex(void *index); //uint destroyStructsCSA(ticsa *myicsa);\r\r//Returns the size (in bytes) of the index over the sequence of integers.\r int sizeIntIndex(void *index, uint *numBytes); //uint CSA_size(ticsa *myicsa); \r\r // Shows detailed summary info of the self-index (memory usage of each structure)\rint printInfoIntIndex(void *index, const char tab[]);\r\r//Number of occurrences of the pattern, and the interval [left,right] in the suffix array.\r int countIntIndex(void *index, uint *pattern, uint length, ulong *numocc, ulong *left, ulong *right);\r //uint countCSA(ticsa *myicsa, uint *pattern, uint patternSize, uint *left, uint *right); // Exponential search\r //uint countCSABin(ticsa *myicsa, uint *pattern, uint patternSize, uint *left, uint *right); // Binary search\r\r// Returns an array with integers corresponding offsets to the occurrences of the pattern, \r// as well as the number of occurrences\r int locateIntIndex(void *index, uint *pattern, uint length, ulong **occ, ulong *numocc);\r //uint *locateCSA(ticsa *myicsa, uint *pattern, uint patternSize, uint *occ);\r\r//Returns the value of the source (array of integers) at a given offset.\r// (that is, the element "position" from the original array of uints)\r int displayIntIndex(void *index, ulong position, uint *value);\r //uint displayCSA(ticsa *myicsa, uint position); \r\r\r/* Private function prototypes ********************************************/\ruint parametersCSA(ticsa *myicsa, char *build_options);\r\ruint displayCSAFirst(ticsa *myicsa, uint position);\ruint displayCSANext(ticsa *myicsa);\rint SadCSACompare(ticsa *myicsa, uint *pattern, uint patternSize, uint p);\ruint A(ticsa *myicsa, uint position);\ruint inverseA(ticsa *myicsa, uint offset);\r\rvoid showStructsCSA(ticsa *myicsa); // For Debugging\r\r
\ No newline at end of file
Hacc = createHuff (acc,HUFF-1, UNSORTED);
Hlen = createHuff (lacc,samplen-2, UNSORTED);
totexc = acc[0];
- pslen = bits(psiSize+1);
- _bplen = bits(Hacc.total+Hlen.total+(1+links/samplen+totexc)*pslen);
+ pslen = _bits(psiSize+1);
+ _bplen = _bits(Hacc.total+Hlen.total+(1+links/samplen+totexc)*pslen);
_bposS = (uint *)malloc ((((1+links/samplen)*_bplen+W-1)/W)*sizeof(uint));
_cPsi = (uint *)malloc (((Hacc.total+Hlen.total+(1+links/samplen+totexc)*pslen+W-1)/W)*sizeof(uint));
else
if(diffs[index]<0) { // Valor negativo
absolute_value = -diffs[index];
- binaryLenght = bits(absolute_value);
+ binaryLenght = _bits(absolute_value);
huffmanDst[binaryLenght+negStart-1]++;
} else { // Valor grande >= 128
absolute_value = diffs[index];
- binaryLenght = bits(absolute_value);
+ binaryLenght = _bits(absolute_value);
huffmanDst[binaryLenght+bigStart-1]++;
}
}
// Calculamos o numero de mostras e o espacio ocupado por cada mostra e por cada punteiro
numberOfSamples = (psiSize+T-1)/T;
- sampleSize = bits(psiSize);
- pointerSize = bits(streamSize);
+ sampleSize = _bits(psiSize);
+ pointerSize = _bits(streamSize);
// Reservamos espacio para a secuencia e para as mostras e punteiros
samples = (unsigned int *)malloc(sizeof(uint)*((numberOfSamples*sampleSize+31)/32));
else
if(diffs[index]<0) { // Valor negativo
absolute_value = -diffs[index];
- binaryLenght = bits(absolute_value);
+ binaryLenght = _bits(absolute_value);
ptr = encodeHuff(diffsHT,binaryLenght+negStart-1,stream,ptr);
bitwrite(stream,ptr,binaryLenght,absolute_value);
ptr += binaryLenght;
} else { // Valor grande >= 128
absolute_value = diffs[index];
- binaryLenght = bits(absolute_value);
+ binaryLenght = _bits(absolute_value);
ptr = encodeHuff(diffsHT,binaryLenght+bigStart-1,stream,ptr);
bitwrite(stream,ptr,binaryLenght,absolute_value);
ptr += binaryLenght;
+#ifdef __cplusplus
+extern "C" {
+#endif
// Basics
#include <stdlib.h>
// Memory management
-
- void *Malloc (int n)
-
+
+static void *Malloc (size_t n)
+
{ void *p;
if (n == 0) return NULL;
p = (void*) malloc (n);
}
return p;
}
-
- void Free (void *p)
-
- { if (p) free (p);
+
+static void Free (void *p)
+
+ { if (p) free (p);
}
-
- void *Realloc (void *p, int n)
-
+
+static void *Realloc (void *p, size_t n)
+
{ if (p == NULL) return Malloc (n);
if (n == 0) { Free(p); return NULL; }
p = (void*) realloc (p,n);
// bits needed to represent a number between 0 and n
-uint bits (uint n)
+uint _bits (uint n)
{ uint b = 0;
while (n)
// writes e[p..p+len-1] = s, len <= W
-void bitwrite (register uint *e, register uint p,
+void bitwrite (register uint *e, register uint p,
register uint len, register uint s)
{ e += p/W; p %= W;
}
// writes e[p..p+len-1] = 0
-void bitzero2 (register uint *e, register uint p,
+void bitzero2 (register uint *e, register uint p,
register uint len)
{ e += p/W; p %= W;
if (len > 0)
*e &= ~(((1<<len)-1)<<p);
}
+#ifdef __cplusplus
+}
+#endif
#ifndef BASICSINCLUDED
#define BASICSINCLUDED
+#ifdef __cplusplus
+extern "C" {
+#endif
+
// Includes
#include <sys/types.h>
// Memory management
-#define malloc(n) Malloc(n)
-#define free(p) Free(p)
-#define realloc(p,n) Realloc(p,n)
+ //#define malloc(n) Malloc(n)
+ //#define free(p) Free(p)
+ //#define realloc(p,n) Realloc(p,n)
-void *Malloc (int n);
-void Free (void *p);
-void *Realloc (void *p, int n);
+static void *Malloc (size_t n);
+static void Free (void *p);
+static void *Realloc (void *p, size_t n);
// Data types
#define W (32)
// bits needed to represent a number between 0 and n
-uint bits (uint n);
+uint _bits (uint n);
// returns e[p..p+len-1], assuming len <= W
uint bitread (uint *e, uint p, uint len);
// writes e[p..p+len-1] = s, assuming len <= W
} \
} \
}
+#ifdef __cplusplus
+ }
+#endif
#endif