├── .dockerignore ├── .gitignore ├── .travis.yml ├── Dockerfile ├── Makefile.am ├── README.md ├── autogen.sh ├── configure.ac ├── gnulib.sh ├── hdt-it ├── .cproject ├── .gitignore ├── .project ├── Camera.cpp ├── Camera.h ├── Color.cpp ├── Color.h ├── Info.plist ├── LICENSE ├── README.md ├── StopWatch.cpp ├── StopWatch.hpp ├── abouthdt.cpp ├── abouthdt.hpp ├── abouthdt.ui ├── colors.hpp ├── constants.h ├── createdmg.sh ├── dictionarysuggestions.cpp ├── dictionarysuggestions.hpp ├── doc │ ├── hdtit.png │ ├── manual.html │ └── matrix.png ├── editreset.png ├── hdt-it.pro ├── hdt-it_es.qm ├── hdt-it_es.ts ├── hdtcachedinfo.cpp ├── hdtcachedinfo.hpp ├── hdtcontroller.cpp ├── hdtcontroller.hpp ├── hdtico.icns ├── hdtico.rc ├── hdtit.cpp ├── hdtit.hpp ├── hdtit.ui ├── hdtoperation.cpp ├── hdtoperation.hpp ├── hdtresources.qrc ├── hdtspecform.cpp ├── hdtspecform.hpp ├── hdtspecform.ui ├── hdtsummarygenerator.cpp ├── hdtsummarygenerator.hpp ├── hdtwinico.ico ├── hdtwinico2.ico ├── headermodel.cpp ├── headermodel.hpp ├── loading.gif ├── logo-hdt.png ├── logo-hdt2.png ├── main.cpp ├── matrixviewwidget.cpp ├── matrixviewwidget.hpp ├── myapplication.cpp ├── myapplication.hpp ├── predicatestatus.cpp ├── predicatestatus.hpp ├── qclearlineedit.cpp ├── qclearlineedit.hpp ├── regexmodel.cpp ├── regexmodel.hpp ├── resultcounter.cpp ├── resultcounter.hpp ├── searchresultsmodel.cpp ├── searchresultsmodel.hpp ├── sparqlform.cpp ├── sparqlform.hpp ├── sparqlform.ui ├── sparqlmodel.cpp ├── sparqlmodel.hpp ├── stringutils.cpp ├── stringutils.hpp ├── triplecomponentmodel.cpp └── triplecomponentmodel.hpp ├── lib ├── .gitignore └── Makefile.in ├── libcds ├── COPYRIGHT ├── Changelog ├── Doxyfile ├── Makefile.am ├── README ├── cds.pc.in ├── docs │ └── delete_me ├── include │ ├── Array.h │ ├── BitSequence.h │ ├── BitSequenceBuilder.h │ ├── BitSequenceBuilderDArray.h │ ├── BitSequenceBuilderRG.h │ ├── BitSequenceBuilderRRR.h │ ├── BitSequenceBuilderSDArray.h │ ├── BitSequenceDArray.h │ ├── BitSequenceRG.h │ ├── BitSequenceRRR.h │ ├── BitSequenceSDArray.h │ ├── BitString.h │ ├── BitmapsSequence.h │ ├── Coder.h │ ├── HuffmanCoder.h │ ├── LCP.h │ ├── LCP_DAC.h │ ├── LCP_DAC_VAR.h │ ├── LCP_FMN.h │ ├── LCP_PT.h │ ├── LCP_PhiSpare.h │ ├── LCP_Sad.h │ ├── LCP_naive.h │ ├── Mapper.h │ ├── MapperCont.h │ ├── MapperNone.h │ ├── MapperRev.h │ ├── NPR.h │ ├── NPR_CN.h │ ├── NPR_FMN.h │ ├── NSV.h │ ├── PSV.h │ ├── Permutation.h │ ├── PermutationBuilder.h │ ├── PermutationBuilderMRRR.h │ ├── PermutationBuilderWT.h │ ├── PermutationMRRR.h │ ├── PermutationWT.h │ ├── RMQ_succinct.h │ ├── RMQ_succinct_lcp.h │ ├── Sequence.h │ ├── SequenceAlphPart.h │ ├── SequenceBuilder.h │ ├── SequenceBuilderAlphPart.h │ ├── SequenceBuilderGMR.h │ ├── SequenceBuilderGMRChunk.h │ ├── SequenceBuilderStr.h │ ├── SequenceBuilderWaveletMatrix.h │ ├── SequenceBuilderWaveletTree.h │ ├── SequenceBuilderWaveletTreeNoptrs.h │ ├── SequenceBuilderWaveletTreeNoptrsS.h │ ├── SequenceGMR.h │ ├── SequenceGMRChunk.h │ ├── SuffixTree.h │ ├── SuffixTreeY.h │ ├── TableOffsetRRR.h │ ├── TextIndex.h │ ├── TextIndexCSA.h │ ├── WaveletMatrix.h │ ├── WaveletTree.h │ ├── WaveletTreeNoptrs.h │ ├── WaveletTreeNoptrsS.h │ ├── comparray4.h │ ├── cppUtils.h │ ├── factorization.h │ ├── factorization_var.h │ ├── huff.h │ ├── interface.h │ ├── libcdsBasics.h │ ├── libcdsSDArray.h │ ├── libcdsTrees.h │ ├── mmap.h │ ├── perm.h │ ├── sdarraySadakane.h │ ├── timing.h │ ├── wt_coder.h │ ├── wt_coder_binary.h │ ├── wt_coder_huff.h │ ├── wt_node.h │ ├── wt_node_internal.h │ └── wt_node_leaf.h ├── src │ ├── static │ │ ├── bitsequence │ │ │ ├── BitSequence.cpp │ │ │ ├── BitSequenceBuilderDArray.cpp │ │ │ ├── BitSequenceBuilderRG.cpp │ │ │ ├── BitSequenceBuilderRRR.cpp │ │ │ ├── BitSequenceBuilderSDArray.cpp │ │ │ ├── BitSequenceDArray.cpp │ │ │ ├── BitSequenceRG.cpp │ │ │ ├── BitSequenceRRR.cpp │ │ │ ├── BitSequenceSDArray.cpp │ │ │ ├── TableOffsetRRR.cpp │ │ │ └── sdarraySadakane.cpp │ │ ├── coders │ │ │ ├── HuffmanCoder.cpp │ │ │ └── huff.cpp │ │ ├── mapper │ │ │ ├── Makefile │ │ │ ├── Mapper.cpp │ │ │ ├── MapperCont.cpp │ │ │ ├── MapperNone.cpp │ │ │ └── MapperRev.cpp │ │ ├── permutation │ │ │ ├── Permutation.cpp │ │ │ ├── PermutationBuilderMRRR.cpp │ │ │ ├── PermutationBuilderWT.cpp │ │ │ ├── PermutationMRRR.cpp │ │ │ ├── PermutationWT.cpp │ │ │ └── perm.cpp │ │ ├── sequence │ │ │ ├── BitmapsSequence.cpp │ │ │ ├── Sequence.cpp │ │ │ ├── SequenceAlphPart.cpp │ │ │ ├── SequenceBuilderAlphPart.cpp │ │ │ ├── SequenceBuilderGMR.cpp │ │ │ ├── SequenceBuilderGMRChunk.cpp │ │ │ ├── SequenceBuilderStr.cpp │ │ │ ├── SequenceBuilderWaveletMatrix.cpp │ │ │ ├── SequenceBuilderWaveletTree.cpp │ │ │ ├── SequenceBuilderWaveletTreeNoptrs.cpp │ │ │ ├── SequenceBuilderWaveletTreeNoptrsS.cpp │ │ │ ├── SequenceGMR.cpp │ │ │ ├── SequenceGMRChunk.cpp │ │ │ ├── WaveletMatrix.cpp │ │ │ ├── WaveletTree.cpp │ │ │ ├── WaveletTreeNoptrs.cpp │ │ │ ├── WaveletTreeNoptrsS.cpp │ │ │ ├── wt_coder.cpp │ │ │ ├── wt_coder_binary.cpp │ │ │ ├── wt_coder_huff.cpp │ │ │ ├── wt_node.cpp │ │ │ ├── wt_node_internal.cpp │ │ │ └── wt_node_leaf.cpp │ │ ├── suffixtree │ │ │ ├── LCP.cpp │ │ │ ├── LCP_DAC.cpp │ │ │ ├── LCP_DAC_VAR.cpp │ │ │ ├── LCP_FMN.cpp │ │ │ ├── LCP_PT.cpp │ │ │ ├── LCP_PhiSpare.cpp │ │ │ ├── LCP_Sad.cpp │ │ │ ├── LCP_naive.cpp │ │ │ ├── NPR.cpp │ │ │ ├── NPR_CN.cpp │ │ │ ├── NPR_FMN.cpp │ │ │ ├── NSV.cpp │ │ │ ├── PSV.cpp │ │ │ ├── RMQ_succinct.cpp │ │ │ ├── RMQ_succinct_lcp.cpp │ │ │ ├── SuffixTree.cpp │ │ │ ├── SuffixTreeY.cpp │ │ │ ├── factorization.cpp │ │ │ └── factorization_var.cpp │ │ └── textindex │ │ │ ├── TextIndex.cpp │ │ │ ├── TextIndexCSA.cpp │ │ │ ├── comparray4.cpp │ │ │ ├── mmap.cpp │ │ │ ├── qsufsort.cpp │ │ │ └── suftest3.test.cpp │ └── utils │ │ ├── Array.cpp │ │ ├── BitString.cpp │ │ ├── cppUtils.cpp │ │ └── timing.cpp ├── tests │ ├── Makefile.am │ ├── testArray.cpp │ ├── testBitSequence.cpp │ ├── testHuffman.cpp │ ├── testLCP.cpp │ ├── testNPR.cpp │ ├── testQuantile.cpp │ ├── testSequence.cpp │ ├── testSuffixTree.cpp │ ├── testTextIndex.cpp │ ├── timeSequence.cpp │ ├── toArray.cpp │ └── toArray2.cpp └── tutorial │ ├── src │ ├── ArrayExample.cpp │ ├── ArrayExample2.cpp │ ├── BitSequenceRGExample.cpp │ ├── BitSequenceRRRExample.cpp │ ├── BitSequenceSDArrayExample.cpp │ ├── Makefile │ ├── SequenceAlphPartExample.cpp │ ├── SequenceGMRExample.cpp │ └── SequenceWaveletTreeExample.cpp │ ├── ssa │ ├── Makefile │ ├── build_index.cpp │ ├── dump_bwt.cpp │ ├── ssa.cpp │ ├── ssa.h │ └── test_count.cpp │ └── tutorial.pdf ├── libhdt ├── .cproject ├── .gitignore ├── .project ├── COPYRIGHT ├── Doxyfile ├── Makefile.am ├── README.md ├── data │ ├── literals.hdt │ └── test.nt ├── examples │ ├── .gitignore │ ├── generate.cpp │ ├── search.cpp │ └── statistics.cpp ├── hdt.pc.in ├── include │ ├── ControlInformation.hpp │ ├── Dictionary.hpp │ ├── HDT.hpp │ ├── HDTEnums.hpp │ ├── HDTListener.hpp │ ├── HDTManager.hpp │ ├── HDTSpecification.hpp │ ├── HDTVersion.hpp │ ├── HDTVocabulary.hpp │ ├── Header.hpp │ ├── Iterator.hpp │ ├── RDF.hpp │ ├── RDFParser.hpp │ ├── RDFSerializer.hpp │ ├── SingleTriple.hpp │ └── Triples.hpp ├── presets │ ├── bitmaphuff.hdtcfg │ ├── bitmaplog.hdtcfg │ ├── bitmapwavelet.hdtcfg │ ├── compacthuff.hdtcfg │ ├── compactlog.hdtcfg │ ├── dictionaryfour.hdtcfg │ ├── dictionaryliteral.hdtcfg │ ├── fmindex.hdtcfg │ ├── ops.hdtcfg │ ├── plain.hdtcfg │ ├── plainlog.hdtcfg │ ├── tripleslist.hdtcfg │ └── wrong_dictionaryfour.hdtcfg ├── src │ ├── bitsequence │ │ ├── BitSeq.h │ │ ├── BitSequence375.cpp │ │ └── BitSequence375.h │ ├── dictionary │ │ ├── FourSectionDictionary.cpp │ │ ├── FourSectionDictionary.hpp │ │ ├── KyotoDictionary.cpp │ │ ├── KyotoDictionary.hpp │ │ ├── LiteralDictionary.cpp │ │ ├── LiteralDictionary.hpp │ │ ├── PlainDictionary.cpp │ │ └── PlainDictionary.hpp │ ├── hdt │ │ ├── BasicHDT.cpp │ │ ├── BasicHDT.hpp │ │ ├── BasicModifiableHDT.cpp │ │ ├── BasicModifiableHDT.hpp │ │ ├── ControlInformation.cpp │ │ ├── HDTFactory.cpp │ │ ├── HDTFactory.hpp │ │ ├── HDTManager.cpp │ │ ├── HDTSpecification.cpp │ │ ├── TripleIDStringIterator.cpp │ │ └── TripleIDStringIterator.hpp │ ├── header │ │ ├── PlainHeader.cpp │ │ └── PlainHeader.hpp │ ├── huffman │ │ ├── Huffman.cpp │ │ ├── Huffman.h │ │ ├── huff.cpp │ │ └── huff.h │ ├── libdcs │ │ ├── CSD.cpp │ │ ├── CSD.h │ │ ├── CSD_Cache.cpp │ │ ├── CSD_Cache.h │ │ ├── CSD_Cache2.cpp │ │ ├── CSD_Cache2.h │ │ ├── CSD_FMIndex.cpp │ │ ├── CSD_FMIndex.h │ │ ├── CSD_HTFC.cpp │ │ ├── CSD_HTFC.h │ │ ├── CSD_PFC.cpp │ │ ├── CSD_PFC.h │ │ ├── VByte.cpp │ │ ├── VByte.h │ │ ├── fmindex │ │ │ ├── SSA.cpp │ │ │ ├── SSA.h │ │ │ ├── SuffixArray.cpp │ │ │ └── SuffixArray.h │ │ └── hutucker │ │ │ ├── binarynode.h │ │ │ └── hutucker.h │ ├── rdf │ │ ├── RDFParser.cpp │ │ ├── RDFParserNtriples.cpp │ │ ├── RDFParserNtriples.hpp │ │ ├── RDFParserSerd.cpp │ │ ├── RDFParserSerd.hpp │ │ ├── RDFSerializer.cpp │ │ ├── RDFSerializerNTriples.cpp │ │ ├── RDFSerializerNTriples.hpp │ │ ├── RDFSerializerSerd.cpp │ │ └── RDFSerializerSerd.hpp │ ├── sequence │ │ ├── AdjacencyList.cpp │ │ ├── AdjacencyList.hpp │ │ ├── ArraySequence.cpp │ │ ├── ArraySequence.hpp │ │ ├── HuffmanSequence.cpp │ │ ├── HuffmanSequence.hpp │ │ ├── IntSequence.cpp │ │ ├── IntSequence.hpp │ │ ├── LogSequence.cpp │ │ ├── LogSequence.hpp │ │ ├── LogSequence2.cpp │ │ ├── LogSequence2.hpp │ │ ├── WaveletSequence.cpp │ │ └── WaveletSequence.hpp │ ├── sparql │ │ ├── BaseJoinBinding.hpp │ │ ├── CachedBinding.hpp │ │ ├── IndexJoinBinding.cpp │ │ ├── IndexJoinBinding.hpp │ │ ├── JoinAlgorithms.cpp │ │ ├── JoinAlgorithms.hpp │ │ ├── MergeJoinBinding.cpp │ │ ├── MergeJoinBinding.hpp │ │ ├── QueryProcessor.cpp │ │ ├── QueryProcessor.hpp │ │ ├── SortBinding.cpp │ │ ├── SortBinding.hpp │ │ ├── TriplePatternBinding.cpp │ │ ├── TriplePatternBinding.hpp │ │ ├── VarBindingInterface.hpp │ │ ├── VarFilterBinding.hpp │ │ └── joins.hpp │ ├── triples │ │ ├── BitmapTriples.cpp │ │ ├── BitmapTriples.hpp │ │ ├── BitmapTriplesIterators.cpp │ │ ├── PlainTriples.cpp │ │ ├── PlainTriples.hpp │ │ ├── TripleIterators.cpp │ │ ├── TripleIterators.hpp │ │ ├── TripleListDisk.cpp │ │ ├── TripleListDisk.hpp │ │ ├── TripleOrderConvert.cpp │ │ ├── TripleOrderConvert.hpp │ │ ├── TriplesComparator.cpp │ │ ├── TriplesComparator.hpp │ │ ├── TriplesKyoto.cpp │ │ ├── TriplesKyoto.hpp │ │ ├── TriplesList.cpp │ │ ├── TriplesList.hpp │ │ ├── predicateindex.cpp │ │ └── predicateindex.hpp │ └── util │ │ ├── Histogram.h │ │ ├── StopWatch.cpp │ │ ├── StopWatch.hpp │ │ ├── bitutil.cpp │ │ ├── bitutil.h │ │ ├── crc16.cpp │ │ ├── crc16.h │ │ ├── crc32.cpp │ │ ├── crc32.h │ │ ├── crc8.cpp │ │ ├── crc8.h │ │ ├── fdstream.hpp │ │ ├── fileUtil.cpp │ │ ├── fileUtil.hpp │ │ ├── filemap.cpp │ │ ├── filemap.h │ │ ├── getopt.c │ │ ├── lru_cache.h │ │ ├── lrucache.hpp │ │ ├── mygetopt.h │ │ ├── propertyutil.cpp │ │ ├── propertyutil.h │ │ └── unicode.hpp ├── tests │ ├── .gitignore │ ├── Makefile.am │ ├── README.md │ ├── bit375.cpp │ ├── bitutiltest.cpp │ ├── c11.cpp │ ├── cmp.cpp │ ├── confm.cpp │ ├── conops.cpp │ ├── conpfc.cpp │ ├── convert.cpp │ ├── conwav.cpp │ ├── csd.cpp │ ├── dic.cpp │ ├── dictionaries.cpp │ ├── dumpDictionary.cpp │ ├── filterSearch.cpp │ ├── genCache.cpp │ ├── genIndex.cpp │ ├── getSuggestions.cpp │ ├── getobj.cpp │ ├── hdt2rdfNotMapping.cpp │ ├── hdtExtract.cpp │ ├── iter.cpp │ ├── joinsearch.cpp │ ├── jointest.cpp │ ├── kyoto.cpp │ ├── listener.cpp │ ├── logarr.cpp │ ├── mergeHDT.cpp │ ├── mincor.cpp │ ├── naiveComplete.cpp │ ├── opendic.cpp │ ├── parse.cpp │ ├── patsearch.cpp │ ├── popcnt.cpp │ ├── properties.cpp │ ├── randomSolution.cpp │ ├── serd.cpp │ ├── streamtest.cpp │ ├── testmax.cpp │ ├── userHeaderStats.cpp │ └── wav.cpp ├── third │ ├── fdstream.hpp │ ├── gzstream.cpp │ └── gzstream.h └── tools │ ├── .gitignore │ ├── Makefile.am │ ├── hdt2rdf.cpp │ ├── hdtInfo.cpp │ ├── hdtSearch.cpp │ ├── modifyHeader.cpp │ ├── rdf2hdt.cpp │ ├── replaceHeader.cpp │ └── searchHeader.cpp ├── m4 ├── .gitignore ├── 00gnulib.m4 ├── ax_cxx_compile_stdcxx.m4 ├── ax_cxx_compile_stdcxx_11.m4 ├── ax_require_defined.m4 ├── gnulib-cache.m4 ├── gnulib-common.m4 ├── gnulib-comp.m4 ├── gnulib-tool.m4 ├── onceonly.m4 └── warnings.m4 └── rdf2hdt ├── .gitignore ├── rdf2hdt.cpp └── rdf2hdt.pro /.dockerignore: -------------------------------------------------------------------------------- 1 | .dockerignore 2 | .git 3 | .gitignore 4 | .travis.yml 5 | Dockerfile 6 | README.md 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Others 2 | *~ 3 | .ycm_extra_conf.py 4 | # vim 5 | *.swp 6 | 7 | # C++ builds 8 | *.o 9 | *.so 10 | *.a 11 | *.out 12 | *.lo 13 | *.la 14 | .dirstamp 15 | 16 | # Wasm files 17 | *.wasm 18 | 19 | # Executables 20 | hdt2rdf 21 | hdtInfo 22 | hdtSearch 23 | rdf2hdt 24 | replaceHeader 25 | libhdt/examples/* 26 | libhdt/.libs 27 | libcds/.libs 28 | 29 | # Autotools 30 | m4/ 31 | *.pc 32 | build/ 33 | autom4te.cache/ 34 | config.log 35 | config.status 36 | configure 37 | Makefile 38 | Makefile.in 39 | libtool 40 | aclocal.m4 41 | 42 | .DS_Store 43 | *.pro.user 44 | *.o 45 | unix 46 | macx 47 | win32 48 | delete_me 49 | Makefile 50 | README 51 | autom4te.cache/ 52 | config.h 53 | *~ 54 | config.log 55 | config.status 56 | stamp-h1 57 | .deps/ 58 | 59 | *.hdt 60 | *.hdt.index* 61 | *.nq 62 | *.nt 63 | *.rdf 64 | *.trig 65 | *.ttl 66 | *.a 67 | **/examples/* 68 | **/tests/* 69 | libcds-v1.0.12/includes 70 | !**/examples/*.cpp 71 | !**/tests/*.cpp 72 | *.o 73 | *.lo 74 | .deps 75 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM gcc:bullseye as build 2 | 3 | # Install build dependencies 4 | RUN apt update; \ 5 | apt install -y --no-install-recommends \ 6 | autoconf \ 7 | build-essential \ 8 | liblzma-dev \ 9 | liblzo2-dev \ 10 | libraptor2-dev \ 11 | libserd-dev \ 12 | libtool \ 13 | zlib1g-dev \ 14 | ; \ 15 | rm -rf /var/lib/apt/lists/*; 16 | 17 | WORKDIR /usr/local/src/hdt-cpp 18 | COPY . . 19 | 20 | # Install HDT tools 21 | RUN ./autogen.sh && ./configure 22 | RUN make -j4 23 | RUN make install 24 | 25 | FROM debian:bullseye-slim 26 | 27 | # Install runtime dependencies 28 | RUN apt update; \ 29 | apt install -y --no-install-recommends \ 30 | libserd-0-0 \ 31 | ; \ 32 | rm -rf /var/lib/apt/lists/*; 33 | 34 | # Copy in libraries and binaries from build stage. 35 | COPY --from=build \ 36 | /usr/local/lib/libcds* \ 37 | /usr/local/lib/libhdt* \ 38 | /usr/local/lib/ 39 | COPY --from=build \ 40 | /usr/local/lib64/libstdc++.* \ 41 | /usr/local/lib64/ 42 | COPY --from=build \ 43 | /usr/local/bin/hdt2rdf \ 44 | /usr/local/bin/hdtInfo \ 45 | /usr/local/bin/hdtSearch \ 46 | /usr/local/bin/modifyHeader \ 47 | /usr/local/bin/rdf2hdt \ 48 | /usr/local/bin/replaceHeader \ 49 | /usr/local/bin/searchHeader \ 50 | /usr/local/bin/ 51 | 52 | # Add /usr/local/lib to LD_LIBRARY_PATH. 53 | ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:$LD_LIBRARY_PATH 54 | 55 | CMD ["/bin/echo", "Available commands: rdf2hdt hdt2rdf hdtInfo hdtSearch modifyHeader replaceHeader searchHeader"] 56 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = subdir-objects 2 | SUBDIRS = libcds libhdt 3 | ACLOCAL_AMFLAGS = -I m4 4 | EXTRA_DIST = m4/gnulib-cache.m4 5 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #Before running this file, make sure that gnulib.sh was executed 4 | # or that m4 directory contains gnulib-*.m4 files 5 | 6 | aclocal -I m4 --install 7 | autoreconf --install --force 8 | -------------------------------------------------------------------------------- /gnulib.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | gnulib-tool --import warnings 3 | -------------------------------------------------------------------------------- /hdt-it/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | Makefile.Debug 3 | Makefile.Release 4 | unix/ 5 | win32/ 6 | macx/ 7 | hdt-it.pro.user* 8 | object_script.* 9 | -------------------------------------------------------------------------------- /hdt-it/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | hdt-it 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.core.ccnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /hdt-it/Color.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Color.h 3 | * 4 | * Created on: 04/03/2011 5 | * Author: mck 6 | */ 7 | 8 | #ifndef COLOR_H_ 9 | #define COLOR_H_ 10 | 11 | #include 12 | 13 | class Color { 14 | public: 15 | double r,g,b,a; 16 | 17 | public: 18 | Color(); 19 | Color(double r, double g, double b); 20 | Color(double r, double g, double b, double a); 21 | virtual ~Color(); 22 | 23 | void use(); 24 | void invert(); 25 | 26 | void setRGB(double r, double g, double b); 27 | void setRGBA(double r, double g, double b, double a); 28 | void setHSV(double h, double s, double v); 29 | QColor asQColor(); 30 | }; 31 | 32 | class ColorRamp { 33 | public: 34 | virtual void apply(Color *co, double v, double vmin, double vmax)=0; 35 | }; 36 | 37 | 38 | class ColorRamp1 : public ColorRamp { 39 | public: 40 | void apply(Color *co, double v, double vmin, double vmax); 41 | }; 42 | 43 | 44 | class ColorRamp2 : public ColorRamp { 45 | public: 46 | void apply(Color *co, double v, double vmin, double vmax); 47 | }; 48 | 49 | #endif /* COLOR_H_ */ 50 | -------------------------------------------------------------------------------- /hdt-it/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleIconFile 6 | hdtico.icns 7 | CFBundlePackageType 8 | APPL 9 | CFBundleGetInfoString 10 | Created by Qt/QMake 11 | CFBundleSignature 12 | ???? 13 | CFBundleExecutable 14 | HDT-it 15 | CFBundleIdentifier 16 | org.rdfhdt.HDT-it 17 | CFBundleDocumentTypes 18 | 19 | 20 | CFBundleTypeExtensions 21 | 22 | hdt 23 | 24 | CFBundleTypeIconFile 25 | hdtico.icns 26 | CFBundleTypeMIMETypes 27 | 28 | binary/rdf-hdt 29 | 30 | CFBundleTypeName 31 | HDT RDF File 32 | CFBundleTypeRole 33 | Editor 34 | LSIsAppleDefaultForType 35 | 36 | 37 | 38 | CFBundleTypeExtensions 39 | 40 | hdt.gz 41 | 42 | CFBundleTypeIconFile 43 | hdtico.icns 44 | CFBundleTypeMIMETypes 45 | 46 | binary/rdf-hdt 47 | 48 | CFBundleTypeName 49 | HDT RDF File 50 | CFBundleTypeRole 51 | Editor 52 | LSIsAppleDefaultForType 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /hdt-it/StopWatch.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * StopWatch.hpp 3 | * 4 | * Created on: 03/03/2011 5 | * Author: mck 6 | */ 7 | 8 | #ifndef STOPWATCH_HPP_ 9 | #define STOPWATCH_HPP_ 10 | 11 | #ifdef WIN32 12 | #include 13 | #else 14 | # include 15 | # include 16 | #endif 17 | 18 | #include 19 | #include 20 | 21 | class StopWatch { 22 | private: 23 | 24 | #ifdef WIN32 25 | LARGE_INTEGER frequency; 26 | LARGE_INTEGER startCount; 27 | LARGE_INTEGER endCount; 28 | #else 29 | struct timeval user1, user2; 30 | struct timeval system1, system2; 31 | struct timeval real1, real2; 32 | #endif 33 | 34 | public: 35 | StopWatch(); 36 | 37 | void reset(); 38 | void stop(); 39 | 40 | unsigned long long getUser(); 41 | unsigned long long getSystem(); 42 | unsigned long long getReal(); 43 | 44 | std::string getUserStr(); 45 | std::string getSystemStr(); 46 | std::string getRealStr(); 47 | 48 | unsigned long long stopUser(); 49 | unsigned long long stopSystem(); 50 | unsigned long long stopReal(); 51 | 52 | std::string stopUserStr(); 53 | std::string stopSystemStr(); 54 | std::string stopRealStr(); 55 | 56 | static std::string toHuman(unsigned long long time); 57 | 58 | friend std::ostream &operator<<(std::ostream &stream, StopWatch &sw); 59 | }; 60 | 61 | #endif /* STOPWATCH_HPP_ */ 62 | -------------------------------------------------------------------------------- /hdt-it/abouthdt.cpp: -------------------------------------------------------------------------------- 1 | #include "abouthdt.hpp" 2 | #include "ui_abouthdt.h" 3 | 4 | Abouthdt::Abouthdt(QWidget *parent) : 5 | QDialog(parent), 6 | ui(new Ui::Abouthdt) 7 | { 8 | ui->setupUi(this); 9 | } 10 | 11 | Abouthdt::~Abouthdt() 12 | { 13 | delete ui; 14 | } 15 | -------------------------------------------------------------------------------- /hdt-it/abouthdt.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ABOUTHDT_HPP 2 | #define ABOUTHDT_HPP 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class Abouthdt; 8 | } 9 | 10 | class Abouthdt : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit Abouthdt(QWidget *parent = 0); 16 | ~Abouthdt(); 17 | 18 | private: 19 | Ui::Abouthdt *ui; 20 | }; 21 | 22 | #endif // ABOUTHDT_HPP 23 | -------------------------------------------------------------------------------- /hdt-it/colors.hpp: -------------------------------------------------------------------------------- 1 | #ifndef COLORS_HPP 2 | #define COLORS_HPP 3 | 4 | #define SCREEN 5 | 6 | #ifndef SCREEN 7 | #define TEXT_COLOR 0.0, 0.0, 0.0, 1.0 8 | #define CROSS_COLOR 1.0, 0.0, 0.0, 1.0 9 | #define TEXT_BACKGROUND_COLOR 1.0, 1.0, 1.0, 0.9 10 | #define BACKGROUND_COLOR 1, 1, 1, 1 11 | #define SHARED_AREA_COLOR 0.9, 0.9, 0.9, 1.0 12 | #define SHARED_AREA_BORDER_COLOR 0.1, 0.1, 0.1, 1.0 13 | #define AXIS_COLOR 0.1, 0.1, 0.1, 1.0 14 | #define GRID_COLOR 0.3, 0.3, 0.3, 1.0 15 | #define RDF_POINT_SIZE 1.5 16 | #else 17 | #define TEXT_COLOR 1.0, 1.0, 1.0, 1.0 18 | #define CROSS_COLOR 1.0, 1.0, 1.0, 1.0 19 | #define TEXT_BACKGROUND_COLOR 0.0, 0.0, 0.0, 0.7 20 | #define BACKGROUND_COLOR 0, 0, 0, 1 21 | #define SHARED_AREA_COLOR 0.2, 0.2, 0.2, 1.0 22 | #define SHARED_AREA_BORDER_COLOR 0.3, 0.3, 0.3, 1.0 23 | #define AXIS_COLOR 0.8, 0.8, 0.8, 1.0 24 | #define GRID_COLOR 0.2, 0.2, 0.2, 1.0 25 | #define RDF_POINT_SIZE 1 26 | #endif 27 | 28 | 29 | #endif // COLORS_HPP 30 | -------------------------------------------------------------------------------- /hdt-it/constants.h: -------------------------------------------------------------------------------- 1 | /* 2 | * constants.h 3 | * 4 | * Created on: 04/03/2011 5 | * Author: mck 6 | */ 7 | 8 | #ifndef CONSTANTS_H_ 9 | #define CONSTANTS_H_ 10 | 11 | #define TIMER_DELAY 50 12 | #define RENDER_NUM_POINTS 100000 13 | 14 | #define SCREEN 15 | 16 | #ifndef SCREEN 17 | #define TEXT_COLOR 0.0, 0.0, 0.0, 1.0 18 | #define CROSS_COLOR 1.0, 0.0, 0.0, 1.0 19 | #define TEXT_BACKGROUND_COLOR 1.0, 1.0, 1.0, 0.9 20 | #define BACKGROUND_COLOR 1, 1, 1, 1 21 | #define SHARED_AREA_COLOR 0.9, 0.9, 0.9, 1.0 22 | #define SHARED_AREA_BORDER_COLOR 0.1, 0.1, 0.1, 1.0 23 | #define AXIS_COLOR 0.1, 0.1, 0.1, 1.0 24 | #define GRID_COLOR 0.3, 0.3, 0.3, 1.0 25 | #define RDF_POINT_SIZE 1.5 26 | #else 27 | #define TEXT_COLOR 1.0, 1.0, 1.0, 1.0 28 | #define CROSS_COLOR 0.0, 0.0, 0.0, 1.0 29 | #define TEXT_BACKGROUND_COLOR 0.0, 0.0, 0.0, 0.7 30 | #define BACKGROUND_COLOR 0, 0, 0, 1 31 | #define SHARED_AREA_COLOR 0.1, 0.1, 0.1, 1.0 32 | #define SHARED_AREA_BORDER_COLOR 0.2, 0.2, 0.2, 1.0 33 | #define AXIS_COLOR 0.8, 0.8, 0.8, 1.0 34 | #define GRID_COLOR 0.2, 0.2, 0.2, 1.0 35 | #define RDF_POINT_SIZE 1 36 | #endif 37 | 38 | 39 | #endif /* CONSTANTS_H_ */ 40 | -------------------------------------------------------------------------------- /hdt-it/dictionarysuggestions.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DICTIONARYSUGGESTIONS_HPP 2 | #define DICTIONARYSUGGESTIONS_HPP 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | QT_BEGIN_NAMESPACE 10 | class QLineEdit; 11 | class QTimer; 12 | class QTreeWidget; 13 | QT_END_NAMESPACE 14 | 15 | class DictionarySuggestions : public QObject 16 | { 17 | Q_OBJECT 18 | public: 19 | explicit DictionarySuggestions(QLineEdit *parent = 0); 20 | ~DictionarySuggestions(); 21 | bool eventFilter(QObject *obj, QEvent *ev); 22 | void showCompletion(const vector &choices); 23 | void setController(HDTController *controller); 24 | void setRole(hdt::TripleComponentRole role); 25 | 26 | public slots: 27 | void doneCompletion(); 28 | void preventSuggest(); 29 | void autoSuggest(); 30 | 31 | private: 32 | QLineEdit *editor; 33 | QTreeWidget *popup; 34 | QTimer *timer; 35 | HDTController *controller; 36 | hdt::TripleComponentRole role; 37 | }; 38 | 39 | #endif // DICTIONARYSUGGESTIONS_HPP 40 | -------------------------------------------------------------------------------- /hdt-it/doc/hdtit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdfhdt/hdt-cpp/88110cc24d4d7d07080b40325d1905fae999ef95/hdt-it/doc/hdtit.png -------------------------------------------------------------------------------- /hdt-it/doc/matrix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdfhdt/hdt-cpp/88110cc24d4d7d07080b40325d1905fae999ef95/hdt-it/doc/matrix.png -------------------------------------------------------------------------------- /hdt-it/editreset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdfhdt/hdt-cpp/88110cc24d4d7d07080b40325d1905fae999ef95/hdt-it/editreset.png -------------------------------------------------------------------------------- /hdt-it/hdt-it_es.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdfhdt/hdt-cpp/88110cc24d4d7d07080b40325d1905fae999ef95/hdt-it/hdt-it_es.qm -------------------------------------------------------------------------------- /hdt-it/hdtcachedinfo.hpp: -------------------------------------------------------------------------------- 1 | #ifndef HDTCACHEDINFO_HPP 2 | #define HDTCACHEDINFO_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include "StopWatch.hpp" 8 | 9 | #include "Color.h" 10 | 11 | 12 | class HDTCachedInfo 13 | { 14 | private: 15 | 16 | hdt::HDT *hdt; 17 | vector triples; 18 | 19 | vector predicateColors; 20 | size_t maxPredicateCount; 21 | vector predicateCount; 22 | 23 | public: 24 | HDTCachedInfo(hdt::HDT *hdt); 25 | 26 | Color *getPredicateColor(size_t npred); 27 | size_t getPredicateUsages(size_t predicate); 28 | size_t getMaxPredicateCount(); 29 | vector &getTriples(); 30 | 31 | void generateGeneralInfo(hdt::ProgressListener *listener=NULL); 32 | void generateMatrix(hdt::ProgressListener *listener=NULL); 33 | 34 | void save(QString &fileName, hdt::ProgressListener *listener=NULL); 35 | void load(QString &fileName, hdt::ProgressListener *listener=NULL); 36 | }; 37 | 38 | #endif // HDTCACHEDINFO_HPP 39 | -------------------------------------------------------------------------------- /hdt-it/hdtico.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdfhdt/hdt-cpp/88110cc24d4d7d07080b40325d1905fae999ef95/hdt-it/hdtico.icns -------------------------------------------------------------------------------- /hdt-it/hdtico.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON DISCARDABLE "hdtwinico2.ico" 2 | -------------------------------------------------------------------------------- /hdt-it/hdtresources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | editreset.png 4 | logo-hdt.png 5 | loading.gif 6 | 7 | 8 | -------------------------------------------------------------------------------- /hdt-it/hdtspecform.hpp: -------------------------------------------------------------------------------- 1 | #ifndef HDTSPECFORM_HPP 2 | #define HDTSPECFORM_HPP 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace Ui { 11 | class HDTSpecForm; 12 | } 13 | 14 | class HDTSpecForm : public QDialog 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit HDTSpecForm(QWidget *parent = 0); 20 | ~HDTSpecForm(); 21 | 22 | public: 23 | QString getFileName(); 24 | QString getBaseUri(); 25 | void fillHDTSpecification(hdt::HDTSpecification &spec); 26 | hdt::RDFNotation getNotation(); 27 | 28 | private: 29 | Ui::HDTSpecForm *ui; 30 | std::string getStreamType(int index); 31 | 32 | private slots: 33 | void on_triplesTypeCombo_currentIndexChanged(int index); 34 | void on_inputFileButton_clicked(); 35 | void accept(); 36 | }; 37 | 38 | #endif // HDTSPECFORM_HPP 39 | -------------------------------------------------------------------------------- /hdt-it/hdtsummarygenerator.hpp: -------------------------------------------------------------------------------- 1 | #ifndef HDTSUMMARYGENERATOR_HPP 2 | #define HDTSUMMARYGENERATOR_HPP 3 | 4 | #include 5 | #include 6 | #include "hdtcontroller.hpp" 7 | 8 | class HDTSummaryGenerator : public QObject 9 | { 10 | Q_OBJECT 11 | public: 12 | static QString getSummary(HDTController *hdtController); 13 | }; 14 | 15 | #endif // HDTSUMMARYGENERATOR_HPP 16 | -------------------------------------------------------------------------------- /hdt-it/hdtwinico.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdfhdt/hdt-cpp/88110cc24d4d7d07080b40325d1905fae999ef95/hdt-it/hdtwinico.ico -------------------------------------------------------------------------------- /hdt-it/hdtwinico2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdfhdt/hdt-cpp/88110cc24d4d7d07080b40325d1905fae999ef95/hdt-it/hdtwinico2.ico -------------------------------------------------------------------------------- /hdt-it/headermodel.hpp: -------------------------------------------------------------------------------- 1 | #ifndef HEADERMODEL_HPP 2 | #define HEADERMODEL_HPP 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include "hdtcontroller.hpp" 9 | 10 | class HDTController; 11 | 12 | class HeaderModel : public QAbstractTableModel { 13 | Q_OBJECT 14 | private: 15 | HDTController *hdtController; 16 | hdt::IteratorTripleString *triples; 17 | hdt::TripleString *currentTriple; 18 | unsigned int currentIndex; 19 | 20 | void findTriple(unsigned int index); 21 | 22 | public: 23 | HeaderModel(HDTController *view); 24 | ~HeaderModel(); 25 | 26 | int rowCount(const QModelIndex &parent = QModelIndex()) const ; 27 | int columnCount(const QModelIndex &parent = QModelIndex()) const; 28 | Qt::ItemFlags flags(const QModelIndex &index) const; 29 | QVariant headerData(int section, Qt::Orientation orientation, int role) const; 30 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 31 | bool setData(const QModelIndex & index, const QVariant & value, int role); 32 | 33 | void updateDatasetChanged(); 34 | signals: 35 | }; 36 | 37 | 38 | #endif // HEADERMODEL_HPP 39 | -------------------------------------------------------------------------------- /hdt-it/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdfhdt/hdt-cpp/88110cc24d4d7d07080b40325d1905fae999ef95/hdt-it/loading.gif -------------------------------------------------------------------------------- /hdt-it/logo-hdt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdfhdt/hdt-cpp/88110cc24d4d7d07080b40325d1905fae999ef95/hdt-it/logo-hdt.png -------------------------------------------------------------------------------- /hdt-it/logo-hdt2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdfhdt/hdt-cpp/88110cc24d4d7d07080b40325d1905fae999ef95/hdt-it/logo-hdt2.png -------------------------------------------------------------------------------- /hdt-it/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include "myapplication.hpp" 6 | #include "hdtit.hpp" 7 | 8 | #include 9 | 10 | int main(int argc, char *argv[]) 11 | { 12 | MyApplication a(argc, argv); 13 | 14 | QTranslator qtTranslator; 15 | qtTranslator.load("qt_" + QLocale::system().name(), 16 | QLibraryInfo::location(QLibraryInfo::TranslationsPath)); 17 | a.installTranslator(&qtTranslator); 18 | 19 | QTranslator myappTranslator; 20 | #ifdef __APPLE__ 21 | myappTranslator.load("../Resources/hdt-it_"+QLocale::system().name()); 22 | #else 23 | myappTranslator.load("hdt-it_"+QLocale::system().name()); 24 | #endif 25 | a.installTranslator(&myappTranslator); 26 | 27 | HDTit w; 28 | 29 | a.setHDTit(&w); 30 | 31 | w.show(); 32 | 33 | if(argc>1) { 34 | QString str(argv[1]); 35 | w.openHDTFile(str); 36 | } 37 | 38 | return a.exec(); 39 | } 40 | -------------------------------------------------------------------------------- /hdt-it/matrixviewwidget.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MATRIXVIEWWIDGET_HPP 2 | #define MATRIXVIEWWIDGET_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #ifdef __APPLE__ 9 | #include 10 | #else 11 | #include 12 | #endif 13 | 14 | #include 15 | #include 16 | 17 | #include "colors.hpp" 18 | #include "Camera.h" 19 | #include "StopWatch.hpp" 20 | 21 | #include "hdtcontroller.hpp" 22 | #include "searchresultsmodel.hpp" 23 | #include "triplecomponentmodel.hpp" 24 | 25 | class SearchResultsModel; 26 | class TripleComponentModel; 27 | class HDTController; 28 | 29 | #ifdef __APPLE__ 30 | //#define GESTURES 31 | #endif 32 | 33 | class MatrixViewWidget : public QGLWidget 34 | { 35 | Q_OBJECT 36 | 37 | private: 38 | QTimer timer; 39 | Camera camera; 40 | int lastX, lastY, lastClickX, lastClickY, buttonClick; 41 | HDTController *hdtController; 42 | 43 | void unProject(int x, int y, double *outx, double *outy, double *outz); 44 | 45 | void paintShared(); 46 | void paintScales(); 47 | void paintPoints(); 48 | void paintSelected(); 49 | 50 | public: 51 | explicit MatrixViewWidget(QWidget *parent = 0); 52 | ~MatrixViewWidget(); 53 | 54 | void setManager(HDTController *hdtManager); 55 | 56 | QSize minimumSizeHint() const; 57 | QSize sizeHint() const; 58 | 59 | Camera &getCamera(); 60 | protected: 61 | void initializeGL(); 62 | void paintGL(); 63 | void resizeGL(int width, int height); 64 | void mousePressEvent(QMouseEvent *event); 65 | void mouseReleaseEvent(QMouseEvent *event); 66 | void mouseMoveEvent(QMouseEvent *event); 67 | void wheelEvent( QWheelEvent* e ); 68 | #ifdef GESTURES 69 | bool event(QEvent *); 70 | #endif 71 | 72 | public slots: 73 | void reloadHDTInfo(); 74 | 75 | signals: 76 | void rotationChanged(); 77 | void cameraChanged(); 78 | }; 79 | 80 | 81 | #endif // MATRIXVIEWWIDGET_HPP 82 | -------------------------------------------------------------------------------- /hdt-it/myapplication.cpp: -------------------------------------------------------------------------------- 1 | #include "myapplication.hpp" 2 | 3 | MyApplication::MyApplication(int &argc, char **argv) : QApplication(argc, argv), hdtIt(NULL) 4 | { 5 | } 6 | 7 | bool MyApplication::event(QEvent *event) 8 | { 9 | switch (event->type()) { 10 | case QEvent::FileOpen: 11 | loadFile(static_cast(event)->file()); 12 | return true; 13 | default: 14 | return QApplication::event(event); 15 | } 16 | } 17 | 18 | void MyApplication::loadFile(QString fileName) 19 | { 20 | if(hdtIt) { 21 | hdtIt->openHDTFile(fileName); 22 | } 23 | } 24 | 25 | void MyApplication::setHDTit(HDTit *hdtIt) 26 | { 27 | this->hdtIt=hdtIt; 28 | } 29 | 30 | bool MyApplication::notify(QObject *o, QEvent *e) 31 | { 32 | try { 33 | return QApplication::notify(o, e); 34 | } catch (char *err) { 35 | std::cerr << "Exception caugth in notify (char *): " << err << endl; 36 | } catch (const char *err) { 37 | std::cerr << "Exception caugth in notify (const char *): " << err << endl; 38 | } catch (const std::exception& ex) { 39 | std::cerr << "Exception caugth in notify (std::exception &): " << ex.what() << endl; 40 | } catch (const std::string& ex) { 41 | std::cerr << "Exception caugth in notify (std::string &): " << ex << endl; 42 | } catch (...) { 43 | std::cerr << "Unknown Exception caugth in notify: " << endl; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /hdt-it/myapplication.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MYAPPLICATION_HPP 2 | #define MYAPPLICATION_HPP 3 | 4 | #include 5 | #include "hdtit.hpp" 6 | 7 | class MyApplication : public QApplication 8 | { 9 | Q_OBJECT 10 | private: 11 | HDTit *hdtIt; 12 | void loadFile(QString fileName); 13 | public: 14 | explicit MyApplication(int &argc, char **argv); 15 | bool event(QEvent *); 16 | void setHDTit(HDTit *hdtIt); 17 | bool notify(QObject *, QEvent *); 18 | signals: 19 | 20 | public slots: 21 | 22 | }; 23 | 24 | #endif // MYAPPLICATION_HPP 25 | -------------------------------------------------------------------------------- /hdt-it/predicatestatus.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PREDICATESTATUS_HPP 2 | #define PREDICATESTATUS_HPP 3 | 4 | #include 5 | #include "hdtcontroller.hpp" 6 | 7 | class PredicateStatus : public QObject 8 | { 9 | Q_OBJECT 10 | private: 11 | vector activePredicate; 12 | size_t minPredicateCount; 13 | size_t maxPredicateCount; 14 | HDTController *controller; 15 | 16 | void setMinimumPredicateCountInternal(int count); 17 | public: 18 | explicit PredicateStatus(HDTController *controller); 19 | 20 | size_t getMinimumPredicateCount(); 21 | size_t getMaximumPredicateCount(); 22 | 23 | bool isPredicateActive(size_t i); 24 | void setPredicateActive(size_t i, bool b); 25 | 26 | signals: 27 | void predicatesChanged(size_t min, size_t max); 28 | void minimumPredicateCountChanged(size_t newval); 29 | void predicateSelected(size_t npred); 30 | 31 | public slots: 32 | void refreshAll(); 33 | void selectPredicate(size_t pred); 34 | void selectAllPredicates(); 35 | void selectNonePredicates(); 36 | void setMinimumPredicateCount(int count); 37 | }; 38 | 39 | #endif // PREDICATESTATUS_HPP 40 | -------------------------------------------------------------------------------- /hdt-it/qclearlineedit.cpp: -------------------------------------------------------------------------------- 1 | #include "qclearlineedit.hpp" 2 | #include 3 | #include 4 | 5 | QClearLineEdit::QClearLineEdit(QWidget *parent) 6 | : QLineEdit(parent) 7 | { 8 | clearButton = new QToolButton(this); 9 | QPixmap pixmap(":/images/editreset.png"); 10 | clearButton->setIcon(QIcon(pixmap)); 11 | clearButton->setIconSize(pixmap.size()); 12 | clearButton->setCursor(Qt::ArrowCursor); 13 | clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }"); 14 | clearButton->hide(); 15 | connect(clearButton, SIGNAL(clicked()), this, SLOT(clear())); 16 | connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateCloseButton(const QString&))); 17 | int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); 18 | setStyleSheet(QString("QLineEdit { padding-right: %1px; } ").arg(clearButton->sizeHint().width() + frameWidth + 1)); 19 | QSize msz = minimumSizeHint(); 20 | setMinimumSize(qMax(msz.width(), clearButton->sizeHint().height() + frameWidth * 2 + 2), 21 | qMax(msz.height(), clearButton->sizeHint().height() + frameWidth * 2 + 2)); 22 | 23 | suggestions = new DictionarySuggestions(this); 24 | } 25 | 26 | QClearLineEdit::~QClearLineEdit() 27 | { 28 | delete suggestions; 29 | delete clearButton; 30 | } 31 | 32 | void QClearLineEdit::resizeEvent(QResizeEvent *) 33 | { 34 | QSize sz = clearButton->sizeHint(); 35 | int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); 36 | clearButton->move(rect().right() - frameWidth - sz.width(), 37 | (rect().bottom() + 1 - sz.height())/2); 38 | } 39 | 40 | void QClearLineEdit::updateCloseButton(const QString& text) 41 | { 42 | clearButton->setVisible(!text.isEmpty()); 43 | } 44 | 45 | DictionarySuggestions * QClearLineEdit::getSuggestions() 46 | { 47 | return suggestions; 48 | } 49 | -------------------------------------------------------------------------------- /hdt-it/qclearlineedit.hpp: -------------------------------------------------------------------------------- 1 | #ifndef QCLEARLINEEDIT_HPP 2 | #define QCLEARLINEEDIT_HPP 3 | 4 | #include 5 | 6 | #include "dictionarysuggestions.hpp" 7 | 8 | class QToolButton; 9 | 10 | class QClearLineEdit: public QLineEdit 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | QClearLineEdit(QWidget *parent = 0); 16 | ~QClearLineEdit(); 17 | DictionarySuggestions *getSuggestions(); 18 | 19 | protected: 20 | void resizeEvent(QResizeEvent *); 21 | 22 | private slots: 23 | void updateCloseButton(const QString &text); 24 | 25 | private: 26 | QToolButton *clearButton; 27 | DictionarySuggestions *suggestions; 28 | }; 29 | 30 | #endif // QCLEARLINEEDIT_HPP 31 | -------------------------------------------------------------------------------- /hdt-it/regexmodel.hpp: -------------------------------------------------------------------------------- 1 | #ifndef REGEXMODEL_HPP 2 | #define REGEXMODEL_HPP 3 | 4 | #include 5 | 6 | #include "hdtcontroller.hpp" 7 | 8 | class HDTController; 9 | 10 | class RegexModel : public QAbstractTableModel 11 | { 12 | Q_OBJECT 13 | 14 | private: 15 | HDTController *hdtController; 16 | uint32_t numResults; 17 | uint32_t *results; 18 | 19 | public: 20 | explicit RegexModel(HDTController *manager); 21 | ~RegexModel(); 22 | 23 | void setQuery(QString query); 24 | 25 | int rowCount(const QModelIndex &parent = QModelIndex()) const ; 26 | int columnCount(const QModelIndex &parent = QModelIndex()) const; 27 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 28 | QVariant headerData(int section, Qt::Orientation orientation, int role) const; 29 | 30 | void updateDatasetChanged(); 31 | signals: 32 | 33 | public slots: 34 | 35 | }; 36 | 37 | #endif // REGEXMODEL_HPP 38 | -------------------------------------------------------------------------------- /hdt-it/resultcounter.cpp: -------------------------------------------------------------------------------- 1 | #include "resultcounter.hpp" 2 | #include 3 | 4 | 5 | ResultCounter::ResultCounter(QObject *parent, HDTController *controller) : 6 | QObject(parent), 7 | hdtController(controller), 8 | iterator(NULL) 9 | { 10 | } 11 | 12 | void ResultCounter::startCounting() 13 | { 14 | if(!hdtController->hasHDT()){ 15 | return; 16 | } 17 | iterator = hdtController->getHDT()->getTriples()->search(hdtController->getSearchPatternID()); 18 | shouldCancel = false; 19 | QtConcurrent::run(this, &ResultCounter::run); 20 | } 21 | 22 | void ResultCounter::cancel() 23 | { 24 | shouldCancel = true; 25 | } 26 | 27 | void ResultCounter::run() 28 | { 29 | if(iterator==NULL) { 30 | return; 31 | } 32 | StopWatch cl; 33 | unsigned int numResults = 0; 34 | while(!shouldCancel && iterator->hasNext()) { 35 | iterator->next(); 36 | numResults++; 37 | 38 | cl.stop(); 39 | if(cl.getReal()>10000) { 40 | cl.reset(); 41 | emit numResultsChanged(numResults); 42 | } 43 | } 44 | delete iterator; 45 | iterator = NULL; 46 | emit finished(); 47 | } 48 | -------------------------------------------------------------------------------- /hdt-it/resultcounter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef RESULTCOUNTER_HPP 2 | #define RESULTCOUNTER_HPP 3 | 4 | #include 5 | 6 | #include 7 | 8 | class ResultCounter : public QObject 9 | { 10 | Q_OBJECT 11 | private: 12 | HDTController *hdtController; 13 | hdt::IteratorTripleID *iterator; 14 | bool shouldCancel; 15 | public: 16 | explicit ResultCounter(QObject *parent, HDTController *hdtController); 17 | 18 | void run(); 19 | signals: 20 | void numResultsChanged(int numResults); 21 | void messageChanged(QString message); 22 | void finished(); 23 | private slots: 24 | void startCounting(); 25 | void cancel(); 26 | public slots: 27 | 28 | }; 29 | 30 | #endif // RESULTCOUNTER_HPP 31 | -------------------------------------------------------------------------------- /hdt-it/searchresultsmodel.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SEARCHRESULTSMODEL_HPP 2 | #define SEARCHRESULTSMODEL_HPP 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include "hdtcontroller.hpp" 9 | 10 | class HDTController; 11 | 12 | class SearchResultsModel : public QAbstractTableModel { 13 | Q_OBJECT 14 | private: 15 | HDTController *hdtController; 16 | hdt::IteratorTripleID *triples; 17 | hdt::TripleID *currentTriple; 18 | unsigned int currentIndex; 19 | unsigned int numResults; 20 | bool goingUp; 21 | 22 | void findTriple(unsigned int index); 23 | 24 | public: 25 | SearchResultsModel(HDTController *view); 26 | ~SearchResultsModel(); 27 | 28 | int rowCount(const QModelIndex &parent = QModelIndex()) const ; 29 | int columnCount(const QModelIndex &parent = QModelIndex()) const; 30 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 31 | QVariant headerData(int section, Qt::Orientation orientation, int role) const; 32 | 33 | void updateResultListChanged(); 34 | void updateNumResultsChanged(); 35 | signals: 36 | }; 37 | 38 | 39 | #endif // SEARCHRESULTSMODEL_HPP 40 | -------------------------------------------------------------------------------- /hdt-it/sparqlform.cpp: -------------------------------------------------------------------------------- 1 | #include "sparqlform.hpp" 2 | #include "ui_sparqlform.h" 3 | 4 | #include "sparqlmodel.hpp" 5 | #include "hdtit.hpp" 6 | 7 | SparqlForm::SparqlForm(QWidget *parent) : 8 | QMainWindow(parent), 9 | ui(new Ui::SparqlForm) 10 | { 11 | ui->setupUi(this); 12 | 13 | HDTit *hdtit = reinterpret_cast(parent); 14 | sparqlModel = new SparqlModel(hdtit->getManager()); 15 | ui->sparqlResultTable->setModel(sparqlModel); 16 | } 17 | 18 | SparqlForm::~SparqlForm() 19 | { 20 | delete ui; 21 | } 22 | 23 | void SparqlForm::on_pushButton_clicked() 24 | { 25 | sparqlModel->setQuery(ui->sparqlTextEdit->toPlainText()); 26 | ui->sparqlResultTable->scrollToTop(); 27 | } 28 | -------------------------------------------------------------------------------- /hdt-it/sparqlform.hpp: -------------------------------------------------------------------------------- 1 | #ifndef JOINFORM_HPP 2 | #define JOINFORM_HPP 3 | 4 | #include 5 | 6 | #include "sparqlmodel.hpp" 7 | 8 | namespace Ui { 9 | class SparqlForm; 10 | } 11 | 12 | class SparqlForm : public QMainWindow 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit SparqlForm(QWidget *parent = 0); 18 | ~SparqlForm(); 19 | 20 | private slots: 21 | void on_pushButton_clicked(); 22 | 23 | private: 24 | Ui::SparqlForm *ui; 25 | SparqlModel *sparqlModel; 26 | }; 27 | 28 | #endif // JOINFORM_HPP 29 | -------------------------------------------------------------------------------- /hdt-it/sparqlmodel.hpp: -------------------------------------------------------------------------------- 1 | #ifndef JOINMODEL_HPP 2 | #define JOINMODEL_HPP 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include "hdtcontroller.hpp" 9 | 10 | class SparqlModel : public QAbstractTableModel { 11 | Q_OBJECT 12 | private: 13 | HDTController *hdtController; 14 | 15 | hdt::VarBindingString *binding; 16 | unsigned int currentIndex; 17 | unsigned int numresults; 18 | void find(unsigned int index); 19 | public: 20 | SparqlModel(HDTController *controller); 21 | virtual ~SparqlModel(); 22 | 23 | void setQuery(QString query); 24 | 25 | int rowCount(const QModelIndex &parent = QModelIndex()) const ; 26 | int columnCount(const QModelIndex &parent = QModelIndex()) const; 27 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 28 | QVariant headerData(int section, Qt::Orientation orientation, int role) const; 29 | signals: 30 | }; 31 | 32 | #endif // JOINMODEL_HPP 33 | -------------------------------------------------------------------------------- /hdt-it/stringutils.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include "stringutils.hpp" 5 | 6 | QString stringutils::sizeHuman(unsigned long long size) 7 | { 8 | static const char *sizes[] = { "EB", "PB", "TB", "GB", "MB", "KB", "B" }; 9 | static const quint64 exbibytes = 1024ULL * 1024ULL * 1024ULL * 1024ULL * 1024ULL * 1024ULL; 10 | 11 | quint64 multiplier = exbibytes; 12 | 13 | if(size==0) { 14 | return QString("0"); 15 | } 16 | 17 | for (unsigned int i = 0; i < 7; i++, multiplier /= 1024) 18 | { 19 | if (size < multiplier) { 20 | continue; 21 | } 22 | 23 | return QString("%1 %2") 24 | .arg(QString::number((double)size / multiplier, 'f', 1)) 25 | .arg(sizes[i]); 26 | } 27 | return QString("0"); 28 | } 29 | 30 | QString stringutils::toQString(const char *str) 31 | { 32 | 33 | QString out = QString::fromUtf8(str); 34 | 35 | return out; 36 | } 37 | 38 | QString stringutils::escapeHTML(QString in) 39 | { 40 | return in.replace("<", "<").replace(">", ">"); 41 | } 42 | 43 | void stringutils::cut(QString &in, int size) 44 | { 45 | if(in.length()>size) { 46 | in = in.left(size)+"..."; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /hdt-it/stringutils.hpp: -------------------------------------------------------------------------------- 1 | #ifndef STRINGUTILS_HPP 2 | #define STRINGUTILS_HPP 3 | 4 | #include 5 | #include 6 | 7 | class stringutils 8 | { 9 | public: 10 | static QString sizeHuman(unsigned long long size); 11 | static QString toQString(const char *str); 12 | static QString escapeHTML(QString in); 13 | static void cut(QString &in, int size); 14 | }; 15 | 16 | 17 | 18 | #endif // STRINGUTILS_HPP 19 | -------------------------------------------------------------------------------- /hdt-it/triplecomponentmodel.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TRIPLECOMPONENTMODEL_HPP 2 | #define TRIPLECOMPONENTMODEL_HPP 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include "hdtcontroller.hpp" 9 | 10 | class HDTController; 11 | 12 | class TripleComponentModel : public QAbstractTableModel { 13 | Q_OBJECT 14 | private: 15 | HDTController *hdtController; 16 | hdt::TripleComponentRole tripleComponentRole; 17 | public: 18 | TripleComponentModel(HDTController *view, hdt::TripleComponentRole compRole); 19 | 20 | int rowCount(const QModelIndex &parent = QModelIndex()) const ; 21 | int columnCount(const QModelIndex &parent = QModelIndex()) const; 22 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 23 | bool setData(const QModelIndex & index, const QVariant & value, int role); 24 | QVariant headerData(int section, Qt::Orientation orientation, int role) const; 25 | Qt::ItemFlags flags(const QModelIndex &index) const; 26 | 27 | public slots: 28 | void itemsChanged(unsigned int ini, unsigned int fin); 29 | void notifyLayoutChanged(); 30 | signals: 31 | }; 32 | 33 | #endif // TRIPLECOMPONENTMODEL_HPP 34 | -------------------------------------------------------------------------------- /lib/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile.am 2 | /dummy.c 3 | -------------------------------------------------------------------------------- /libcds/Changelog: -------------------------------------------------------------------------------- 1 | 2 | Version 0.9: 3 | 4 | - static_bitsequence: 5 | - added sdarray 6 | - static_sequence: 7 | - added sequence representation based in sdarray (no efficient access) 8 | 9 | Version 0.8: 10 | 11 | - trying: 12 | - git 13 | - missing: 14 | - improve design and class names 15 | - add namespaces 16 | - reference counters for coders and util clases 17 | - static_bitsequence: 18 | - Added base class with virtual functions 19 | - Added testing naive rank/select 20 | - Added rank/select with one-level sampling 21 | - Added compressed representation 22 | - static_sequence 23 | - Added wavelet tree without pointers 24 | - Added wavelet tree with pointers 25 | - Added coder for giving huffman/normal shape to the wavelet tree 26 | - Added Golynski et al.'s data structure for large alphabets 27 | - static_permutation 28 | - Added Diego Arroyuelo's implementation of Munro et al.'s permutations 29 | - Added base classes 30 | - TODO: check interface and add functionality 31 | - coders 32 | - temporal coders for the wavelet tree 33 | - TODO: add coders and a general interface for them 34 | - utils 35 | - Added the alphabet mapper interface 36 | - Added a dummy alphabet mapper 37 | 38 | 39 | -------------------------------------------------------------------------------- /libcds/README: -------------------------------------------------------------------------------- 1 | libcds implements low-level succinct data structures such as bitmaps, 2 | sequences, permutations, etc. The main goal is to provide a set of 3 | structures that form the building block of most compressed/succinct 4 | solutions. In the near future we are planning to add compression 5 | algorithms and support for succinct trees. 6 | 7 | You can find more information at http://libcds.recoded.cl/ 8 | 9 | Right now we are just fixing bugs and testing some new things in here, 10 | but most of the effort is being put into libcds2, this rewrite aims at 11 | solving many problems with 64bits systems. This is necessary in order 12 | to index bigger inputs. -------------------------------------------------------------------------------- /libcds/cds.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libcds 7 | Description: CDS library 8 | Version: 1.0.12 9 | URL: @PACKAGE_URL@ 10 | Libs: -L${libdir} -lcds 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /libcds/docs/delete_me: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdfhdt/hdt-cpp/88110cc24d4d7d07080b40325d1905fae999ef95/libcds/docs/delete_me -------------------------------------------------------------------------------- /libcds/include/BitSequenceBuilderDArray.h: -------------------------------------------------------------------------------- 1 | /* BitSequenceBuilderDArray.h 2 | * Copyright (C) 2008, Francisco Claude, all rights reserved. 3 | * 4 | * Rodrigo Canovas 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #ifndef BITSEQUENCEBUILDERDARRAY_H 23 | #define BITSEQUENCEBUILDERDARRAY_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace cds_static 30 | { 31 | /** Base class for BitSequence builders, it defines the build function 32 | * that takes only a bitmap. The parameters for construction are can 33 | * be set in any way by the builder, but none are received when 34 | * the actual building takes place. 35 | * 36 | * @author Rodrigo Canovas 37 | */ 38 | class BitSequenceBuilderDArray : public BitSequenceBuilder 39 | { 40 | public: 41 | BitSequenceBuilderDArray(); 42 | virtual ~BitSequenceBuilderDArray(); 43 | virtual BitSequence * build(uint * bitseq, size_t len) const; 44 | virtual BitSequence * build(const BitString & bs) const; 45 | }; 46 | }; 47 | #endif 48 | -------------------------------------------------------------------------------- /libcds/include/BitSequenceBuilderRG.h: -------------------------------------------------------------------------------- 1 | /* BitSequenceBuilderRG.h 2 | * Copyright (C) 2008, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #ifndef BITSEQUENCEBUILDERRG_H 23 | #define BITSEQUENCEBUILDERRG_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace cds_static 30 | { 31 | /** BitSequence builder for BitSequenceRG 32 | * 33 | * @author Francisco Claude 34 | */ 35 | class BitSequenceBuilderRG : public BitSequenceBuilder 36 | { 37 | public: 38 | BitSequenceBuilderRG(uint factor); 39 | virtual ~BitSequenceBuilderRG() {} 40 | virtual BitSequence * build(uint * bitseq, size_t len) const; 41 | virtual BitSequence * build(const BitString & bs) const; 42 | protected: 43 | uint factor; 44 | }; 45 | }; 46 | #endif 47 | -------------------------------------------------------------------------------- /libcds/include/BitSequenceBuilderRRR.h: -------------------------------------------------------------------------------- 1 | /* BitSequenceBuilderRRR.h 2 | * Copyright (C) 2008, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #ifndef BITSEQUENCEBUILDERRRR_H 23 | #define BITSEQUENCEBUILDERRRR_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | using namespace cds_utils; 30 | 31 | namespace cds_static 32 | { 33 | /** BitSequence builder for RRR BitSequences. 34 | * 35 | * @author Francisco Claude 36 | */ 37 | class BitSequenceBuilderRRR : public BitSequenceBuilder 38 | { 39 | public: 40 | BitSequenceBuilderRRR(uint sample_rate); 41 | virtual ~BitSequenceBuilderRRR() {} 42 | virtual BitSequence * build(uint * bitseq, size_t len) const; 43 | virtual BitSequence * build(const BitString & bs) const; 44 | protected: 45 | uint sample_rate; 46 | }; 47 | }; 48 | #endif 49 | -------------------------------------------------------------------------------- /libcds/include/BitSequenceBuilderSDArray.h: -------------------------------------------------------------------------------- 1 | /* BitSequenceBuilderSDArray.h 2 | * Copyright (C) 2008, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #ifndef BITSEQUENCEBUILDERSDARRAY_H 23 | #define BITSEQUENCEBUILDERSDARRAY_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace cds_static 30 | { 31 | /** Base class for BitSequence builders, it defines the build function 32 | * that takes only a bitmap. The parameters for construction are can 33 | * be set in any way by the builder, but none are received when 34 | * the actual building takes place. 35 | * 36 | * @author Francisco Claude 37 | */ 38 | class BitSequenceBuilderSDArray : public BitSequenceBuilder 39 | { 40 | public: 41 | BitSequenceBuilderSDArray(); 42 | virtual ~BitSequenceBuilderSDArray(); 43 | virtual BitSequence * build(uint * bitseq, size_t len) const; 44 | virtual BitSequence * build(const BitString & bs) const; 45 | }; 46 | }; 47 | #endif 48 | -------------------------------------------------------------------------------- /libcds/include/Coder.h: -------------------------------------------------------------------------------- 1 | /* Coder.h 2 | * Copyright (C) 2010, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #ifndef CODER_H 23 | #define CODER_H 24 | 25 | #include 26 | #include 27 | namespace cds_static 28 | { 29 | 30 | class Coder 31 | { 32 | public: 33 | virtual size_t encode(uint symb, uint * stream, size_t pos) const = 0; 34 | virtual size_t decode(uint * symb, uint *stream, size_t pos) const = 0; 35 | virtual size_t maxLength() const = 0; 36 | virtual size_t getSize() const = 0; 37 | virtual void save(ostream & fp) const = 0; 38 | static Coder * load(istream & fp); 39 | }; 40 | 41 | }; 42 | 43 | #include 44 | #endif 45 | -------------------------------------------------------------------------------- /libcds/include/LCP_DAC.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. 2 | * 3 | *This library is free software; you can redistribute it and/or 4 | * modify it under the terms of the GNU Lesser General Public 5 | * License as published by the Free Software Foundation; either 6 | * version 2.1 of the License, or (at your option) any later version. 7 | * 8 | * This library is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * Lesser General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Lesser General Public 14 | * License along with this library; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 | * 17 | */ 18 | 19 | #ifndef LCP_DAC_H 20 | #define LCP_DAC_H 21 | 22 | #include 23 | #include 24 | 25 | namespace cds_static 26 | { 27 | 28 | class LCP_DAC: public LCP 29 | { 30 | 31 | private: 32 | size_t *next_p; //usefull for get_seq_LCP 33 | factorization *rep; 34 | LCP_DAC(); 35 | 36 | public: 37 | size_t n; 38 | 39 | /* LCP encoding using Susana's static factorization, 40 | * @param csa The compressed suffix array of the text 41 | * @param text The text 42 | * @param n The length of the text 43 | * */ 44 | LCP_DAC(TextIndex *csa, char *text, size_t n); 45 | virtual size_t get_LCP(size_t i, TextIndex *csa) const; 46 | virtual size_t get_seq_LCP(size_t i, TextIndex *csa, size_t **next_pos, size_t *n_next, bool dir) const; 47 | virtual size_t getSize() const; 48 | virtual void save(ostream & fp) const; 49 | static LCP_DAC * load(istream & fp); 50 | virtual ~LCP_DAC(); 51 | }; 52 | }; 53 | #endif 54 | -------------------------------------------------------------------------------- /libcds/include/LCP_PhiSpare.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. 2 | * 3 | *This library is free software; you can redistribute it and/or 4 | * modify it under the terms of the GNU Lesser General Public 5 | * License as published by the Free Software Foundation; either 6 | * version 2.1 of the License, or (at your option) any later version. 7 | * 8 | * This library is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * Lesser General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Lesser General Public 14 | * License along with this library; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 | * 17 | */ 18 | 19 | #ifndef LCP_PHISPARE_H 20 | #define LCP_PHISPARE_H 21 | 22 | #include 23 | 24 | namespace cds_static 25 | { 26 | 27 | class LCP_PhiSpare: public LCP 28 | { 29 | private: 30 | int q; 31 | size_t n; //length of LCP 32 | int *plcp; //psi lcp 33 | 34 | LCP_PhiSpare(); 35 | 36 | public: 37 | /*Karkkainen, Manzini, and Puglisi encoding of the LCP, 38 | * @param csa The compressed suffix array of the text 39 | * @param text The text 40 | * @param n The length of the text 41 | * @param _q The sample period to use (if q = -1 its mean that we will not use any sample) 42 | * */ 43 | LCP_PhiSpare(TextIndex *csa, char *text, size_t _n, int _q = 32); 44 | virtual size_t get_LCP(size_t i, TextIndex *csa) const; 45 | virtual size_t get_seq_LCP(size_t i, TextIndex *csa, size_t **next_pos, size_t *n_next, bool dir) const; 46 | virtual size_t getSize() const; 47 | virtual void save(ostream & fp) const; 48 | static LCP_PhiSpare * load(istream & fp); 49 | virtual ~LCP_PhiSpare(); 50 | }; 51 | }; 52 | #endif 53 | -------------------------------------------------------------------------------- /libcds/include/LCP_naive.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. 2 | * 3 | *This library is free software; you can redistribute it and/or 4 | * modify it under the terms of the GNU Lesser General Public 5 | * License as published by the Free Software Foundation; either 6 | * version 2.1 of the License, or (at your option) any later version. 7 | * 8 | * This library is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * Lesser General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Lesser General Public 14 | * License along with this library; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 | * 17 | */ 18 | 19 | #ifndef LCP_NAIVE_H 20 | #define LCP_NAIVE_H 21 | 22 | #include 23 | 24 | namespace cds_static 25 | { 26 | 27 | class LCP_naive: public LCP 28 | { 29 | private: 30 | LCP_naive(); 31 | uint *lcp_array; 32 | size_t b; 33 | size_t length; 34 | 35 | public: 36 | 37 | LCP_naive(TextIndex *csa, char *text, size_t n); 38 | 39 | /**Return LCP[i]*/ 40 | virtual size_t get_LCP(size_t i, TextIndex *csa) const; 41 | 42 | /**Return LCP[i], being faster if sequential acceses to the LCP had been done*/ 43 | virtual size_t get_seq_LCP(size_t i, TextIndex *csa, size_t **next_pos, size_t *n_next, bool dir) const; 44 | 45 | /** Returns the size of the structure in bytes */ 46 | virtual size_t getSize() const; 47 | 48 | /** Stores the structure given a file pointer, return 0 in case of success */ 49 | virtual void save(ostream & fp) const; 50 | 51 | /** Reads a LCP determining the type */ 52 | static LCP_naive * load(istream & fp); 53 | 54 | virtual ~LCP_naive(); 55 | }; 56 | }; 57 | #endif 58 | -------------------------------------------------------------------------------- /libcds/include/MapperCont.h: -------------------------------------------------------------------------------- 1 | /* mapper_cont.h 2 | * Copyright (C) 2008, Francisco Claude, all rights reserved. 3 | * 4 | * mapper_cont definition 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #ifndef _MAPPERCONT_H 23 | #define _MAPPERCONT_H 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | using namespace std; 34 | using namespace cds_utils; 35 | 36 | namespace cds_static 37 | { 38 | 39 | /** Mapper that makes the values in the set contiguous 40 | * 41 | * @author Francisco Claude 42 | */ 43 | class MapperCont : public Mapper 44 | { 45 | public: 46 | MapperCont(const Array & seq, const BitSequenceBuilder & bsb); 47 | MapperCont(const uint * A, const size_t len, const BitSequenceBuilder & bsb); 48 | 49 | virtual ~MapperCont(); 50 | 51 | virtual uint map(uint s) const; 52 | virtual uint unmap(uint s) const; 53 | virtual size_t getSize() const; 54 | 55 | virtual void save(ostream & out) const; 56 | static MapperCont * load(istream & input); 57 | 58 | protected: 59 | MapperCont(); 60 | BitSequence * m; 61 | }; 62 | 63 | }; 64 | #endif /* _MAPPERCONT_H */ 65 | -------------------------------------------------------------------------------- /libcds/include/MapperNone.h: -------------------------------------------------------------------------------- 1 | /* MapperNone.h 2 | * Copyright (C) 2008, Francisco Claude, all rights reserved. 3 | * 4 | * MapperNone definition 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #ifndef _MAPPERNONE_H 23 | #define _MAPPERNONE_H 24 | 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | using namespace std; 31 | 32 | namespace cds_static 33 | { 34 | 35 | /** Mapper that doesn't change the value (identity) 36 | * 37 | * @author Francisco Claude 38 | */ 39 | class MapperNone : public Mapper 40 | { 41 | public: 42 | MapperNone(); 43 | virtual ~MapperNone() {} 44 | virtual uint map(uint s) const; 45 | virtual uint unmap(uint s) const; 46 | virtual size_t getSize() const; 47 | virtual void save(ostream & out) const; 48 | static MapperNone * load(istream & input); 49 | }; 50 | }; 51 | #endif /* __MAPPER_NONE_H */ 52 | -------------------------------------------------------------------------------- /libcds/include/MapperRev.h: -------------------------------------------------------------------------------- 1 | /* MapperRev.h 2 | * Copyright (C) 2012, Francisco Claude, all rights reserved. 3 | * 4 | * MapperRev definition 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #ifndef _MAPPERREV_H 23 | #define _MAPPERREV_H 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | using namespace std; 34 | using namespace cds_utils; 35 | 36 | namespace cds_static 37 | { 38 | 39 | /** Mapper that reverses the bits (considering how many bits are required 40 | * to represent the maximum value in the sequence) 41 | * 42 | * @author Francisco Claude 43 | */ 44 | class MapperRev : public Mapper 45 | { 46 | public: 47 | MapperRev(const Array &a); 48 | MapperRev(const uint *A, const size_t len); 49 | virtual ~MapperRev() {} 50 | virtual uint map(const uint s) const; 51 | virtual uint unmap(const uint s) const; 52 | virtual size_t getSize() const; 53 | virtual void save(ostream & out) const; 54 | static MapperRev * load(istream & input); 55 | 56 | protected: 57 | MapperRev(); 58 | uint bits; 59 | }; 60 | }; 61 | #endif /* __MAPPER_REV_H */ 62 | -------------------------------------------------------------------------------- /libcds/include/PermutationBuilder.h: -------------------------------------------------------------------------------- 1 | /* PermutationBuilder.h 2 | * Copyright (C) 2010, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #ifndef PERMUTATIONBUILDER_H 22 | #define PERMUTATIONBUILDER_H 23 | 24 | #include 25 | #include 26 | 27 | namespace cds_static 28 | { 29 | 30 | class PermutationBuilder 31 | { 32 | public: 33 | PermutationBuilder() { userCount=0; } 34 | virtual ~PermutationBuilder() {} 35 | virtual Permutation * build(uint * perm, uint n) const = 0; 36 | virtual void use() { userCount++; } 37 | virtual void unuse() { userCount--; assert(userCount>=0); if(userCount==0) delete this; } 38 | 39 | protected: 40 | int userCount; 41 | }; 42 | }; 43 | 44 | #include 45 | #include 46 | #endif 47 | -------------------------------------------------------------------------------- /libcds/include/PermutationBuilderMRRR.h: -------------------------------------------------------------------------------- 1 | /* PermutationBuilderMRRR.h 2 | * Copyright (C) 2010, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #ifndef PERMUTATIONBUILDERMRRR_H 22 | #define PERMUTATIONBUILDERMRRR_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | namespace cds_static 29 | { 30 | 31 | class PermutationBuilderMRRR : public PermutationBuilder 32 | { 33 | public: 34 | PermutationBuilderMRRR(uint sample, BitSequenceBuilder * bmb); 35 | virtual ~PermutationBuilderMRRR(); 36 | virtual Permutation * build(uint * perm, uint len) const; 37 | protected: 38 | uint sample; 39 | BitSequenceBuilder * bmb; 40 | }; 41 | }; 42 | #endif 43 | -------------------------------------------------------------------------------- /libcds/include/PermutationBuilderWT.h: -------------------------------------------------------------------------------- 1 | /* PermutationBuilderWT.h 2 | * Copyright (C) 2011, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #ifndef PERMUTATIONBUILDERWT_H 22 | #define PERMUTATIONBUILDERWT_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | namespace cds_static 29 | { 30 | 31 | class PermutationBuilderWT : public PermutationBuilder 32 | { 33 | public: 34 | PermutationBuilderWT() {} 35 | virtual ~PermutationBuilderWT() {} 36 | virtual Permutation * build(uint * perm, uint len) const; 37 | }; 38 | }; 39 | #endif 40 | -------------------------------------------------------------------------------- /libcds/include/PermutationWT.h: -------------------------------------------------------------------------------- 1 | /* Permutation.h 2 | * Copyright (C) 2010, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #ifndef __PERMUTATIONWT_H 22 | #define __PERMUTATIONWT_H 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | using namespace cds_utils; 31 | 32 | namespace cds_static 33 | { 34 | class WaveletTree; 35 | 36 | class PermutationWT:public Permutation 37 | { 38 | public: 39 | PermutationWT(uint * perm, size_t len); 40 | virtual ~PermutationWT(); 41 | 42 | /** Compute the value at position i 43 | */ 44 | virtual uint pi(uint i) const; 45 | 46 | /** Compute the position where i appears */ 47 | virtual uint revpi(uint i) const; 48 | 49 | /** Size in bytes 50 | */ 51 | virtual size_t getSize() const; 52 | 53 | /** Saves permutation to stream */ 54 | virtual void save(ostream & fp) const; 55 | 56 | /** Loads the permutation */ 57 | static PermutationWT * load(istream & fp); 58 | 59 | protected: 60 | PermutationWT() {} 61 | BitSequence * marks; 62 | Sequence * wt; 63 | uint runs; 64 | }; 65 | }; 66 | #endif 67 | -------------------------------------------------------------------------------- /libcds/include/SequenceBuilder.h: -------------------------------------------------------------------------------- 1 | /* SequenceBuilder.h 2 | * Copyright (C) 2010, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #include 22 | 23 | #include 24 | 25 | #ifndef SEQUENCEBUILDER_H 26 | #define SEQUENCEBUILDER_H 27 | 28 | namespace cds_static 29 | { 30 | 31 | class SequenceBuilder 32 | { 33 | public: 34 | SequenceBuilder() { userCount=0; } 35 | virtual ~SequenceBuilder() {} 36 | virtual Sequence * build(uint * seq, size_t len)=0; 37 | virtual Sequence * build(const Array & seq)=0; 38 | virtual void use() { userCount++; } 39 | virtual void unuse() { userCount--; assert(userCount>=0); if(userCount==0) delete this; } 40 | 41 | protected: 42 | int userCount; 43 | }; 44 | }; 45 | 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #endif 54 | -------------------------------------------------------------------------------- /libcds/include/SequenceBuilderAlphPart.h: -------------------------------------------------------------------------------- 1 | /* SequenceBuilderAlphPart.h 2 | * Copyright (C) 2010, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #ifndef SequenceBuilderAlphPart_H 27 | #define SequenceBuilderAlphPart_H 28 | 29 | namespace cds_static 30 | { 31 | class SequenceBuilderAlphPart : public SequenceBuilder 32 | { 33 | public: 34 | SequenceBuilderAlphPart(SequenceBuilder * groupIndexBuilder, SequenceBuilder * indexBuilder, uint cut); 35 | virtual ~SequenceBuilderAlphPart(); 36 | virtual Sequence * build(uint * seq, size_t len); 37 | virtual Sequence * build(const Array & seq); 38 | 39 | protected: 40 | SequenceBuilder * groupIndexBuilder; 41 | SequenceBuilder * indexBuilder; 42 | uint cut; 43 | }; 44 | }; 45 | #endif 46 | -------------------------------------------------------------------------------- /libcds/include/SequenceBuilderGMR.h: -------------------------------------------------------------------------------- 1 | /* SequenceBuilderGMR.h 2 | * Copyright (C) 2010, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #ifndef SequenceBuilderGMR_H 27 | #define SequenceBuilderGMR_H 28 | 29 | namespace cds_static 30 | { 31 | class SequenceBuilderGMR : public SequenceBuilder 32 | { 33 | public: 34 | SequenceBuilderGMR(BitSequenceBuilder * bsb, SequenceBuilder * sqb, uint chunk_len=0); 35 | virtual ~SequenceBuilderGMR(); 36 | virtual Sequence * build(uint * seq, size_t len); 37 | virtual Sequence * build(const Array & seq); 38 | 39 | protected: 40 | BitSequenceBuilder * bsb; 41 | SequenceBuilder * sqb; 42 | uint chunk_len; 43 | }; 44 | }; 45 | #endif 46 | -------------------------------------------------------------------------------- /libcds/include/SequenceBuilderGMRChunk.h: -------------------------------------------------------------------------------- 1 | /* SequenceBuilderGMRChunk.h 2 | * Copyright (C) 2010, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #ifndef SequenceBuilderGMRChunk_H 28 | #define SequenceBuilderGMRChunk_H 29 | 30 | namespace cds_static 31 | { 32 | class SequenceBuilderGMRChunk : public SequenceBuilder 33 | { 34 | public: 35 | SequenceBuilderGMRChunk(BitSequenceBuilder * bsb, PermutationBuilder * pmb); 36 | virtual ~SequenceBuilderGMRChunk(); 37 | virtual Sequence * build(uint * seq, size_t len); 38 | virtual Sequence * build(const Array & seq); 39 | 40 | protected: 41 | BitSequenceBuilder * bsb; 42 | PermutationBuilder * pmb; 43 | }; 44 | }; 45 | #endif 46 | -------------------------------------------------------------------------------- /libcds/include/SequenceBuilderStr.h: -------------------------------------------------------------------------------- 1 | /* SequenceBuilderStr.h 2 | * Copyright (C) 2010, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #ifndef SequenceBuilderStr_H 28 | #define SequenceBuilderStr_H 29 | 30 | namespace cds_static 31 | { 32 | class SequenceBuilderStr : public SequenceBuilder 33 | { 34 | public: 35 | SequenceBuilderStr(const string & options); 36 | virtual ~SequenceBuilderStr(); 37 | virtual Sequence * build(uint * seq, size_t len); 38 | virtual Sequence * build(const Array & seq); 39 | 40 | protected: 41 | virtual SequenceBuilder * getBuilder(const Array & seq); 42 | 43 | string str; 44 | }; 45 | }; 46 | #endif 47 | -------------------------------------------------------------------------------- /libcds/include/SequenceBuilderWaveletMatrix.h: -------------------------------------------------------------------------------- 1 | /* SequenceBuilderWaveletTreeNoptrs.h 2 | * Copyright (C) 2010, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #ifndef SEQUENCEBUILDERWAVELETMATRIX_H 28 | #define SEQUENCEBUILDERWAVELETMATRIX_H 29 | 30 | namespace cds_static 31 | { 32 | class SequenceBuilderWaveletMatrix : public SequenceBuilder 33 | { 34 | public: 35 | SequenceBuilderWaveletMatrix(BitSequenceBuilder * bsb, Mapper * am); 36 | virtual ~SequenceBuilderWaveletMatrix(); 37 | virtual Sequence * build(uint * seq, size_t len); 38 | virtual Sequence * build(const Array & seq); 39 | 40 | protected: 41 | BitSequenceBuilder * bsb; 42 | Mapper * am; 43 | }; 44 | }; 45 | #endif 46 | -------------------------------------------------------------------------------- /libcds/include/SequenceBuilderWaveletTree.h: -------------------------------------------------------------------------------- 1 | /* SequenceBuilderWaveletTree.h 2 | * Copyright (C) 2010, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #ifndef SEQUENCEBUILDERWAVELETTREE_H 28 | #define SEQUENCEBUILDERWAVELETTREE_H 29 | 30 | namespace cds_static 31 | { 32 | class SequenceBuilderWaveletTree : public SequenceBuilder 33 | { 34 | public: 35 | SequenceBuilderWaveletTree(BitSequenceBuilder * bsb, Mapper * am, wt_coder * wc=NULL); 36 | virtual ~SequenceBuilderWaveletTree(); 37 | virtual Sequence * build(uint * seq, size_t len); 38 | virtual Sequence * build(const Array & seq); 39 | 40 | protected: 41 | BitSequenceBuilder * bsb; 42 | Mapper * am; 43 | wt_coder * wc; 44 | }; 45 | }; 46 | #endif 47 | -------------------------------------------------------------------------------- /libcds/include/SequenceBuilderWaveletTreeNoptrs.h: -------------------------------------------------------------------------------- 1 | /* SequenceBuilderWaveletTreeNoptrs.h 2 | * Copyright (C) 2010, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #ifndef SEQUENCEBUILDERWAVELETTREENOPTRS_H 28 | #define SEQUENCEBUILDERWAVELETTREENOPTRS_H 29 | 30 | namespace cds_static 31 | { 32 | class SequenceBuilderWaveletTreeNoptrs : public SequenceBuilder 33 | { 34 | public: 35 | SequenceBuilderWaveletTreeNoptrs(BitSequenceBuilder * bsb, Mapper * am); 36 | virtual ~SequenceBuilderWaveletTreeNoptrs(); 37 | virtual Sequence * build(uint * seq, size_t len); 38 | virtual Sequence * build(const Array & seq); 39 | 40 | protected: 41 | BitSequenceBuilder * bsb; 42 | Mapper * am; 43 | }; 44 | }; 45 | #endif 46 | -------------------------------------------------------------------------------- /libcds/include/SequenceBuilderWaveletTreeNoptrsS.h: -------------------------------------------------------------------------------- 1 | /* SequenceBuilderWaveletTreeNoptrsS.h 2 | * Copyright (C) 2012, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #ifndef SEQUENCEBUILDERWAVELETTREENOPTRSS_H 28 | #define SEQUENCEBUILDERWAVELETTREENOPTRSS_H 29 | 30 | namespace cds_static { 31 | class SequenceBuilderWaveletTreeNoptrsS : public SequenceBuilder { 32 | public: 33 | SequenceBuilderWaveletTreeNoptrsS(BitSequenceBuilder * bsb, Mapper * am); 34 | virtual ~SequenceBuilderWaveletTreeNoptrsS(); 35 | virtual Sequence * build(uint * seq, size_t len); 36 | virtual Sequence * build(const Array & seq); 37 | 38 | protected: 39 | BitSequenceBuilder * bsb; 40 | Mapper * am; 41 | }; 42 | }; 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /libcds/include/mmap.h: -------------------------------------------------------------------------------- 1 | 2 | /* mman.h 3 | Copyright (C) 2005, K. Sadakane, all rights reserved. 4 | 5 | This file contains an implementation of memory manager 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | 21 | */ 22 | 23 | #ifndef _MYMMAP_H_ 24 | #define _MYMMAP_H_ 25 | 26 | #ifdef WIN32 27 | #include 28 | #else 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #endif 37 | 38 | #ifdef WIN32 39 | #define PAGE_READONLY 0x02 40 | #define SECTION_MAP_READ 0x0004 41 | #define FILE_MAP_READ SECTION_MAP_READ 42 | #endif 43 | 44 | namespace cds_static 45 | { 46 | 47 | typedef struct 48 | { 49 | void *addr; 50 | int len; 51 | #ifdef WIN32 52 | HANDLE h1,h2; 53 | #else 54 | int fd; 55 | #endif 56 | } MMAP; 57 | 58 | MMAP *mymmap (char *fname); 59 | int mymunmap (MMAP *m); 60 | 61 | }; 62 | #endif 63 | -------------------------------------------------------------------------------- /libcds/include/timing.h: -------------------------------------------------------------------------------- 1 | /* timing.h 2 | * Copyright (C) 2010, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | using namespace std; 35 | 36 | namespace cds_utils 37 | { 38 | /** Resets the system timer (yes, we only have one) 39 | */ 40 | void start_timing(); 41 | 42 | /** Obtains the number of milliseconds since the last timer start 43 | */ 44 | double get_timing(); 45 | 46 | }; 47 | -------------------------------------------------------------------------------- /libcds/src/static/bitsequence/BitSequenceBuilderDArray.cpp: -------------------------------------------------------------------------------- 1 | /* BitSequenceBuilderDArray.cpp 2 | * Copyright (C) 2010, Rodrigo Canovas, all rights reserved. 3 | * 4 | * Rodrigo Canovas 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #include "BitSequenceBuilderDArray.h" 23 | 24 | namespace cds_static 25 | { 26 | 27 | BitSequenceBuilderDArray::BitSequenceBuilderDArray() { 28 | } 29 | 30 | BitSequenceBuilderDArray::~BitSequenceBuilderDArray() { 31 | } 32 | 33 | BitSequence * BitSequenceBuilderDArray::build(uint * bitseq, size_t len) const 34 | { 35 | return new BitSequenceDArray(bitseq,len); 36 | } 37 | 38 | BitSequence * BitSequenceBuilderDArray::build(const BitString & bs) const 39 | { 40 | return new BitSequenceDArray(bs); 41 | } 42 | 43 | }; 44 | -------------------------------------------------------------------------------- /libcds/src/static/bitsequence/BitSequenceBuilderRG.cpp: -------------------------------------------------------------------------------- 1 | /* BitSequenceBuilderRG.cpp 2 | * Copyright (C) 2009, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #include 23 | 24 | namespace cds_static 25 | { 26 | 27 | BitSequenceBuilderRG::BitSequenceBuilderRG(uint factor) { 28 | this->factor = factor; 29 | } 30 | 31 | BitSequence * BitSequenceBuilderRG::build(uint * bitseq, size_t len) const 32 | { 33 | return new BitSequenceRG(bitseq,len,factor); 34 | } 35 | 36 | BitSequence * BitSequenceBuilderRG::build(const BitString & bs) const 37 | { 38 | return new BitSequenceRG(bs,factor); 39 | } 40 | 41 | }; 42 | -------------------------------------------------------------------------------- /libcds/src/static/bitsequence/BitSequenceBuilderRRR.cpp: -------------------------------------------------------------------------------- 1 | /* BitSequenceBuilderRRR.cpp 2 | * Copyright (C) 2009, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #include 23 | 24 | namespace cds_static 25 | { 26 | 27 | BitSequenceBuilderRRR::BitSequenceBuilderRRR(uint sample_rate) { 28 | this->sample_rate = sample_rate; 29 | } 30 | 31 | BitSequence * BitSequenceBuilderRRR::build(uint * bitseq, size_t len) const 32 | { 33 | return new BitSequenceRRR(bitseq,len,sample_rate); 34 | } 35 | 36 | BitSequence * BitSequenceBuilderRRR::build(const BitString & bs) const 37 | { 38 | return new BitSequenceRRR(bs,sample_rate); 39 | } 40 | 41 | }; 42 | -------------------------------------------------------------------------------- /libcds/src/static/bitsequence/BitSequenceBuilderSDArray.cpp: -------------------------------------------------------------------------------- 1 | /* BitSequenceBuilderSDArray.cpp 2 | * Copyright (C) 2009, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #include 23 | 24 | namespace cds_static 25 | { 26 | 27 | BitSequenceBuilderSDArray::BitSequenceBuilderSDArray() { 28 | } 29 | 30 | BitSequenceBuilderSDArray::~BitSequenceBuilderSDArray() { 31 | } 32 | 33 | BitSequence * BitSequenceBuilderSDArray::build(uint * bitseq, size_t len) const 34 | { 35 | return new BitSequenceSDArray(bitseq,len); 36 | } 37 | 38 | BitSequence * BitSequenceBuilderSDArray::build(const BitString & bs) const 39 | { 40 | return new BitSequenceSDArray(bs); 41 | } 42 | 43 | }; 44 | -------------------------------------------------------------------------------- /libcds/src/static/mapper/Makefile: -------------------------------------------------------------------------------- 1 | 2 | all: 3 | @cp -f *.h ../../../includes/ 4 | -------------------------------------------------------------------------------- /libcds/src/static/mapper/Mapper.cpp: -------------------------------------------------------------------------------- 1 | /* mapper.cpp 2 | * Copyright (C) 2008, Francisco Claude, all rights reserved. 3 | * 4 | * static_bitsequence definition 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #include 23 | 24 | namespace cds_static 25 | { 26 | Mapper::Mapper() { 27 | userCount=0; 28 | } 29 | 30 | void Mapper::use() { 31 | userCount++; 32 | } 33 | 34 | void Mapper::unuse() { 35 | userCount--; 36 | assert(userCount>=0); 37 | if(userCount==0) 38 | delete this; 39 | } 40 | 41 | Mapper * Mapper::load(istream & input) { 42 | uint rd; 43 | input.read((char*)&rd,sizeof(uint)); 44 | size_t pos = input.tellg(); 45 | input.seekg(pos-sizeof(uint)); 46 | switch(rd) { 47 | case MAPPER_NONE_HDR: return MapperNone::load(input); 48 | case MAPPER_CONT_HDR: return MapperCont::load(input); 49 | case MAPPER_REV_HDR: return MapperRev::load(input); 50 | } 51 | return NULL; 52 | } 53 | }; 54 | -------------------------------------------------------------------------------- /libcds/src/static/mapper/MapperNone.cpp: -------------------------------------------------------------------------------- 1 | /* MapperNone.cpp 2 | * Copyright (C) 2008, Francisco Claude, all rights reserved. 3 | * 4 | * mapper definition 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #include 23 | 24 | namespace cds_static 25 | { 26 | MapperNone::MapperNone() { } 27 | 28 | uint MapperNone::map(const uint s) const {return s;} 29 | 30 | uint MapperNone::unmap(const uint s) const {return s;} 31 | 32 | size_t MapperNone::getSize() const { return sizeof(MapperNone); } 33 | 34 | void MapperNone::save(ostream & out) const 35 | { 36 | uint wr = MAPPER_NONE_HDR; 37 | out.write((char*)&wr,sizeof(uint)); 38 | } 39 | 40 | MapperNone * MapperNone::load(istream & input) { 41 | uint rd; 42 | input.read((char*)&rd,sizeof(uint)); 43 | if(rd!=MAPPER_NONE_HDR) return NULL; 44 | return new MapperNone(); 45 | } 46 | }; 47 | -------------------------------------------------------------------------------- /libcds/src/static/permutation/PermutationBuilderMRRR.cpp: -------------------------------------------------------------------------------- 1 | /* PermutationBuilderMRRR.cpp 2 | * Copyright (C) 2010, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | namespace cds_static 25 | { 26 | PermutationBuilderMRRR::PermutationBuilderMRRR(uint sample, BitSequenceBuilder * bmb) { 27 | this->sample = sample; 28 | this->bmb = bmb; 29 | bmb->use(); 30 | } 31 | 32 | PermutationBuilderMRRR::~PermutationBuilderMRRR() { 33 | bmb->unuse(); 34 | } 35 | 36 | Permutation * PermutationBuilderMRRR::build(uint * perm, uint len) const 37 | { 38 | return new PermutationMRRR(perm,len,sample,bmb); 39 | } 40 | 41 | }; 42 | -------------------------------------------------------------------------------- /libcds/src/static/permutation/PermutationBuilderWT.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * PermutationBuilderWT.cpp 3 | * Copyright (C) 2011 Francisco Claude F. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | 21 | namespace cds_static 22 | { 23 | Permutation * PermutationBuilderWT::build(uint * perm, uint len) const 24 | { 25 | return new PermutationWT(perm,len); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /libcds/src/static/sequence/SequenceBuilderAlphPart.cpp: -------------------------------------------------------------------------------- 1 | /* SequenceBuilderAlphPart.cpp 2 | * Copyright (C) 2010, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #include 22 | 23 | namespace cds_static 24 | { 25 | 26 | SequenceBuilderAlphPart::SequenceBuilderAlphPart(SequenceBuilder * groupIndexBuilder, SequenceBuilder * indexBuilder, uint cut) { 27 | this->groupIndexBuilder = groupIndexBuilder; 28 | this->indexBuilder = indexBuilder; 29 | this->cut = cut; 30 | groupIndexBuilder->use(); 31 | indexBuilder->use(); 32 | } 33 | 34 | SequenceBuilderAlphPart::~SequenceBuilderAlphPart() { 35 | groupIndexBuilder->unuse(); 36 | indexBuilder->unuse(); 37 | } 38 | 39 | Sequence * SequenceBuilderAlphPart::build(uint * sequence, size_t len) { 40 | return new SequenceAlphPart(sequence,len,cut,groupIndexBuilder,indexBuilder); 41 | } 42 | 43 | Sequence * SequenceBuilderAlphPart::build(const Array & seq) { 44 | return new SequenceAlphPart(seq,cut,groupIndexBuilder,indexBuilder); 45 | } 46 | }; 47 | -------------------------------------------------------------------------------- /libcds/src/static/sequence/SequenceBuilderGMR.cpp: -------------------------------------------------------------------------------- 1 | /* SequenceBuilderGMR.cpp 2 | * Copyright (C) 2010, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #include 22 | 23 | namespace cds_static 24 | { 25 | 26 | SequenceBuilderGMR::SequenceBuilderGMR(BitSequenceBuilder * bsb, SequenceBuilder * sqb, uint chunk_len) { 27 | this->bsb = bsb; 28 | this->sqb = sqb; 29 | this->chunk_len = chunk_len; 30 | bsb->use(); 31 | sqb->use(); 32 | } 33 | 34 | SequenceBuilderGMR::~SequenceBuilderGMR() { 35 | bsb->unuse(); 36 | sqb->unuse(); 37 | } 38 | 39 | Sequence * SequenceBuilderGMR::build(uint * sequence, size_t len) { 40 | uint cl = chunk_len; 41 | if(chunk_len==0) { 42 | uint s=0; 43 | for(size_t i=0;i 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #include 22 | 23 | namespace cds_static 24 | { 25 | 26 | SequenceBuilderGMRChunk::SequenceBuilderGMRChunk(BitSequenceBuilder * bsb, PermutationBuilder * pmb) { 27 | this->bsb = bsb; 28 | this->pmb = pmb; 29 | bsb->use(); 30 | pmb->use(); 31 | } 32 | 33 | SequenceBuilderGMRChunk::~SequenceBuilderGMRChunk() { 34 | bsb->unuse(); 35 | pmb->unuse(); 36 | } 37 | 38 | Sequence * SequenceBuilderGMRChunk::build(uint * sequence, size_t len) { 39 | return new SequenceGMRChunk(sequence, len, bsb, pmb); 40 | } 41 | 42 | Sequence * SequenceBuilderGMRChunk::build(const Array & seq) { 43 | return new SequenceGMRChunk(seq, bsb, pmb); 44 | } 45 | 46 | }; 47 | -------------------------------------------------------------------------------- /libcds/src/static/sequence/SequenceBuilderWaveletMatrix.cpp: -------------------------------------------------------------------------------- 1 | /* SequenceBuilderWaveletMatrix.cpp 2 | * Copyright (C) 2010, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #include 22 | 23 | namespace cds_static 24 | { 25 | 26 | SequenceBuilderWaveletMatrix::SequenceBuilderWaveletMatrix(BitSequenceBuilder * bsb, Mapper * am) { 27 | this->bsb = bsb; 28 | this->am = am; 29 | bsb->use(); 30 | am->use(); 31 | } 32 | 33 | SequenceBuilderWaveletMatrix::~SequenceBuilderWaveletMatrix() { 34 | bsb->unuse(); 35 | am->unuse(); 36 | } 37 | 38 | Sequence * SequenceBuilderWaveletMatrix::build(uint * sequence, size_t len) { 39 | return new WaveletMatrix(sequence, len, bsb, am); 40 | } 41 | 42 | Sequence * SequenceBuilderWaveletMatrix::build(const Array & seq) { 43 | return new WaveletMatrix(seq, bsb, am); 44 | } 45 | }; 46 | -------------------------------------------------------------------------------- /libcds/src/static/sequence/SequenceBuilderWaveletTreeNoptrs.cpp: -------------------------------------------------------------------------------- 1 | /* SequenceBuilderWaveletTreeNoptrs.cpp 2 | * Copyright (C) 2010, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #include 22 | 23 | namespace cds_static 24 | { 25 | 26 | SequenceBuilderWaveletTreeNoptrs::SequenceBuilderWaveletTreeNoptrs(BitSequenceBuilder * bsb, Mapper * am) { 27 | this->bsb = bsb; 28 | this->am = am; 29 | bsb->use(); 30 | am->use(); 31 | } 32 | 33 | SequenceBuilderWaveletTreeNoptrs::~SequenceBuilderWaveletTreeNoptrs() { 34 | bsb->unuse(); 35 | am->unuse(); 36 | } 37 | 38 | Sequence * SequenceBuilderWaveletTreeNoptrs::build(uint * sequence, size_t len) { 39 | return new WaveletTreeNoptrs(sequence, len, bsb, am); 40 | } 41 | 42 | Sequence * SequenceBuilderWaveletTreeNoptrs::build(const Array & seq) { 43 | return new WaveletTreeNoptrs(seq, bsb, am); 44 | } 45 | }; 46 | -------------------------------------------------------------------------------- /libcds/src/static/sequence/SequenceBuilderWaveletTreeNoptrsS.cpp: -------------------------------------------------------------------------------- 1 | /* SequenceBuilderWaveletTreeNoptrsS.cpp 2 | * Copyright (C) 2012, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #include 22 | 23 | namespace cds_static { 24 | 25 | SequenceBuilderWaveletTreeNoptrsS::SequenceBuilderWaveletTreeNoptrsS(BitSequenceBuilder * bsb, Mapper * am) { 26 | this->bsb = bsb; 27 | this->am = am; 28 | bsb->use(); 29 | am->use(); 30 | } 31 | 32 | SequenceBuilderWaveletTreeNoptrsS::~SequenceBuilderWaveletTreeNoptrsS() { 33 | bsb->unuse(); 34 | am->unuse(); 35 | } 36 | 37 | Sequence * SequenceBuilderWaveletTreeNoptrsS::build(uint * sequence, size_t len) { 38 | return new WaveletTreeNoptrsS(sequence, len, bsb, am); 39 | } 40 | 41 | Sequence * SequenceBuilderWaveletTreeNoptrsS::build(const Array & seq) { 42 | return new WaveletTreeNoptrsS(seq, bsb, am); 43 | } 44 | }; 45 | 46 | 47 | -------------------------------------------------------------------------------- /libcds/src/static/sequence/wt_coder.cpp: -------------------------------------------------------------------------------- 1 | /* wt_coder.cpp 2 | * Copyright (C) 2008, Francisco Claude, all rights reserved. 3 | * 4 | * wt_coder definition 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #include 23 | 24 | namespace cds_static 25 | { 26 | 27 | wt_coder::wt_coder() { 28 | user_count=0; 29 | } 30 | 31 | void wt_coder::use() { 32 | user_count++; 33 | } 34 | 35 | void wt_coder::unuse() { 36 | user_count--; 37 | if(user_count==0) delete this; 38 | } 39 | 40 | wt_coder * wt_coder::load(istream & fp) { 41 | uint rd = loadValue(fp); 42 | size_t pos = fp.tellg(); 43 | fp.seekg(pos-sizeof(uint)); 44 | switch(rd) { 45 | case WT_CODER_HUFF_HDR: return wt_coder_huff::load(fp); 46 | case WT_CODER_BINARY_HDR: return wt_coder_binary::load(fp); 47 | } 48 | return NULL; 49 | } 50 | }; 51 | -------------------------------------------------------------------------------- /libcds/src/static/sequence/wt_node.cpp: -------------------------------------------------------------------------------- 1 | /* wt_node.cpp 2 | * Copyright (C) 2008, Francisco Claude, all rights reserved. 3 | * 4 | * wt_node 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | * 20 | */ 21 | 22 | #include 23 | 24 | namespace cds_static 25 | { 26 | 27 | wt_node * wt_node::load(istream & fp) { 28 | uint rd = loadValue(fp); 29 | if(rd==WT_NODE_NULL_HDR) return NULL; 30 | size_t pos = fp.tellg(); 31 | fp.seekg(pos-sizeof(uint)); 32 | switch(rd) { 33 | case WT_NODE_INTERNAL_HDR: return wt_node_internal::load(fp); 34 | case WT_NODE_LEAF_HDR: return wt_node_leaf::load(fp); 35 | } 36 | return NULL; 37 | } 38 | }; 39 | -------------------------------------------------------------------------------- /libcds/src/static/suffixtree/NPR.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. 2 | * 3 | *This library is free software; you can redistribute it and/or 4 | * modify it under the terms of the GNU Lesser General Public 5 | * License as published by the Free Software Foundation; either 6 | * version 2.1 of the License, or (at your option) any later version. 7 | * 8 | * This library is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * Lesser General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Lesser General Public 14 | * License along with this library; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 | * 17 | */ 18 | 19 | #include 20 | 21 | namespace cds_static 22 | { 23 | NPR * NPR::load(istream & fp) { 24 | size_t r = loadValue(fp); 25 | size_t pos = fp.tellg(); 26 | fp.seekg(pos-sizeof(size_t)); 27 | cout << "Loading NPR "<< r << endl; 28 | switch(r) { 29 | case FMN_NPR: return NPR_FMN::load(fp); 30 | case CN_NPR: return NPR_CN::load(fp); 31 | } 32 | return NULL; 33 | } 34 | 35 | }; 36 | -------------------------------------------------------------------------------- /libcds/src/static/suffixtree/SuffixTree.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. 2 | * 3 | *This library is free software; you can redistribute it and/or 4 | * modify it under the terms of the GNU Lesser General Public 5 | * License as published by the Free Software Foundation; either 6 | * version 2.1 of the License, or (at your option) any later version. 7 | * 8 | * This library is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * Lesser General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Lesser General Public 14 | * License along with this library; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 | * 17 | */ 18 | 19 | #include 20 | 21 | namespace cds_static 22 | { 23 | 24 | SuffixTree * SuffixTree::load(istream & fp) { 25 | size_t r = loadValue(fp); 26 | size_t pos = fp.tellg(); 27 | fp.seekg(pos-sizeof(size_t)); 28 | cout << "Loading "<< r << endl; 29 | switch(r) { 30 | case CSTY: return SuffixTreeY::load(fp); 31 | } 32 | return NULL; 33 | } 34 | 35 | }; 36 | -------------------------------------------------------------------------------- /libcds/src/static/textindex/TextIndex.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. 2 | * 3 | *This library is free software; you can redistribute it and/or 4 | * modify it under the terms of the GNU Lesser General Public 5 | * License as published by the Free Software Foundation; either 6 | * version 2.1 of the License, or (at your option) any later version. 7 | * 8 | * This library is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * Lesser General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Lesser General Public 14 | * License along with this library; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 | * 17 | */ 18 | 19 | /* General interface for using the compressed index libraries */ 20 | 21 | #include 22 | 23 | namespace cds_static 24 | { 25 | 26 | /** Reads a text index determining the type */ 27 | TextIndex * TextIndex::load(istream & fp) { 28 | uint r = loadValue(fp); 29 | size_t pos = fp.tellg(); 30 | fp.seekg(pos-sizeof(uint)); 31 | switch(r) { 32 | case CSA_HDR: return TextIndexCSA::load(fp); 33 | } 34 | return NULL; 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /libcds/src/utils/cppUtils.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | namespace cds_utils 6 | { 7 | 8 | uint transform(const string & s) { 9 | stringstream ss; 10 | ss << s; 11 | uint ret; 12 | ss >> ret; 13 | return ret; 14 | } 15 | 16 | void tokenize(string str, vector &tokens, char delim) { 17 | string::size_type last_pos = 0; 18 | string::size_type pos = str.find_first_of(delim); 19 | while(pos!=string::npos) { 20 | tokens.push_back(str.substr(last_pos,pos-last_pos)); 21 | last_pos = pos+1; 22 | if(last_pos >= str.length()) break; 23 | pos = str.find_first_of(delim,pos+1); 24 | } 25 | if(last_pos 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | using namespace std; 34 | 35 | namespace cds_utils 36 | { 37 | #ifndef WIN32 38 | clock_t init; 39 | void start_timing() { 40 | init = clock(); 41 | } 42 | 43 | double get_timing() { 44 | clock_t fin = clock(); 45 | return (1000.*(fin-init)/CLOCKS_PER_SEC); 46 | } 47 | #else 48 | void start_timing() { 49 | } 50 | 51 | double get_timing() { 52 | return 0.0; 53 | } 54 | #endif 55 | } 56 | -------------------------------------------------------------------------------- /libcds/tests/Makefile.am: -------------------------------------------------------------------------------- 1 | check_PROGRAMS = \ 2 | testArray \ 3 | testBitSequence \ 4 | testHuffman \ 5 | testLCP \ 6 | testNPR \ 7 | testSequence \ 8 | testSuffixTree \ 9 | testTextIndex \ 10 | timeSequence \ 11 | toArray2 \ 12 | toArray 13 | #testQuantile 14 | 15 | AM_DEFAULT_SOURCE_EXT = .cpp 16 | AM_CPPFLAGS = -I@top_srcdir@/libcds/include $(WARN_CFLAGS) 17 | LDADD = ../libcds.la 18 | 19 | TESTS = $(check_PROGRAMS) 20 | -------------------------------------------------------------------------------- /libcds/tests/testHuffman.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | using namespace cds_utils; 9 | using namespace cds_static; 10 | 11 | 12 | int main(int argc, char ** argv) { 13 | 14 | if(argc!=4) { 15 | cout << "Checks the array class generating elements between 0 and using as seed for the numbers generation" << endl << endl; 16 | cout << "usage: " << argv[0] << " " << endl; 17 | return 0; 18 | } 19 | 20 | srand(transform(string(argv[1]))); 21 | uint len = transform(string(argv[2])); 22 | uint maxv = transform(string(argv[3])); 23 | 24 | //cout << "maxv = " << maxv << endl; 25 | //cout << "len = " << len << endl; 26 | 27 | Array a(len,maxv); 28 | for(uint i=0;imaxLength() << endl; 35 | 36 | for(size_t i=0;iencode(a[i],stream,ptr); 41 | for(size_t k=0;k 3 | 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | using namespace cds_utils; 9 | using namespace cds_static; 10 | 11 | TextIndex * saveLoad(TextIndex * bs) { 12 | ofstream ofs("textindex.tmp"); 13 | bs->save(ofs); 14 | ofs.close(); 15 | ifstream ifs("textindex.tmp"); 16 | TextIndex * ret = TextIndex::load(ifs); 17 | ifs.close(); 18 | return ret; 19 | } 20 | 21 | bool testTextIndex(TextIndex *s1, TextIndex *s2){ 22 | for(size_t i=0; iindex_length(); i++){ 23 | if(s1->getSA(i)!=s2->getSA(i)) 24 | return false; 25 | if(s1->getISA(i)!=s2->getISA(i)) 26 | return false; 27 | if(s1->getPsi(i)!=s2->getPsi(i)) 28 | return false; 29 | } 30 | return true; 31 | } 32 | 33 | int main(int argc, char ** argv) { 34 | 35 | if(argc!=2) { 36 | cout << "Checks if the TextIndex of the file is save/load correctly" << endl << endl; 37 | cout << "usage: " << argv[0] << " " << endl; 38 | return 0; 39 | } 40 | char *text=NULL; 41 | size_t length; 42 | TextIndex *ticsa, *load_ticsa; 43 | 44 | if(loadText(argv[1], &text, &length)) 45 | return 1; 46 | cout << "length: " << length << endl; 47 | 48 | ticsa = new TextIndexCSA((uchar *)text, (ulong)length, NULL); 49 | 50 | load_ticsa = saveLoad(ticsa); 51 | 52 | if(!testTextIndex(ticsa, load_ticsa)) { 53 | cerr << "ERROR TESTING TextIndexCSA" << endl; 54 | return -1; 55 | } 56 | 57 | cout << "CSA OK\n" << endl; 58 | delete (TextIndexCSA *)ticsa; 59 | delete (TextIndexCSA *)load_ticsa; 60 | if(text!=NULL) 61 | delete text; 62 | } 63 | 64 | -------------------------------------------------------------------------------- /libcds/tests/toArray.cpp: -------------------------------------------------------------------------------- 1 | /* toArray.cpp 2 | * Copyright (C) 2010, Francisco Claude, all rights reserved. 3 | * 4 | * Francisco Claude 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | using namespace std; 34 | 35 | #include 36 | #include 37 | 38 | using namespace cds_utils; 39 | 40 | int main(int argc, char ** argv) { 41 | if(argc!=3) { 42 | cout << "usage: " << argv[0] << " " << endl; 43 | return 0; 44 | } 45 | 46 | size_t len = 0; 47 | uchar * content = loadValue(argv[1],len); 48 | uint * content2 = new uint[len]; 49 | for(size_t i=0;i 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | * 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | using namespace std; 34 | 35 | #include 36 | #include 37 | 38 | using namespace cds_utils; 39 | 40 | int main(int argc, char ** argv) { 41 | if(argc!=3) { 42 | cout << "usage: " << argv[0] << " " << endl; 43 | return 0; 44 | } 45 | 46 | size_t len = 0; 47 | int * content = loadValue(argv[1],len); 48 | uint * content2 = new uint[len]; 49 | size_t pos = 0; 50 | for(size_t i=3;i0) content2[pos++]=content[i]; 52 | 53 | Array a(content2,pos); 54 | ofstream out(argv[2]); 55 | a.save(out); 56 | out.close(); 57 | 58 | delete [] content; 59 | delete [] content2; 60 | return 0; 61 | } 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /libcds/tutorial/src/ArrayExample.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * ArrayExample.cpp 3 | * Copyright (C) 2011 Francisco Claude F. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | using namespace std; 26 | using namespace cds_utils; 27 | 28 | int main(int argc, char **argv) { 29 | size_t N=0; 30 | cout << "Enter array length: "; 31 | cin >> N; 32 | uint * A = new uint[N]; 33 | for(size_t i=0;i> A[i]; 36 | } 37 | 38 | Array * a = new Array(A,N); 39 | delete [] A; 40 | 41 | cout << "Size: " << a->getSize() << " bytes" << endl; 42 | for(uint i=0;i> N; 33 | cout << "Enter the maximum value to be stored: "; 34 | cin >> M; 35 | Array *a = new Array(N,M); 36 | for(size_t i=0;i> tmp; 40 | a->setField(i,tmp); 41 | } 42 | 43 | cout << "Size: " << a->getSize() << " bytes" << endl; 44 | for(uint i=0;i> N; 33 | uint * bs = new uint[uint_len(N,1)]; 34 | for(uint i=0;i> b; 38 | if(b==0) bitclean(bs,i); 39 | else bitset(bs,i); 40 | } 41 | BitSequenceRG * bsrg = new BitSequenceRG(bs,N,20); 42 | cout << "rank(" << N/2 << ")=" << bsrg->rank1(N/2) << endl; 43 | cout << "select(1) = " << bsrg->select1(1) << endl; 44 | cout << "size = " << bsrg->getSize() << endl; 45 | delete bsrg; 46 | delete [] bs; 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /libcds/tutorial/src/BitSequenceRRRExample.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * BitSequenceRRRExample.cpp 3 | * Copyright (C) 2011 Francisco Claude F. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | using namespace std; 26 | using namespace cds_utils; 27 | using namespace cds_static; 28 | 29 | int main(int argc, char **argv) { 30 | size_t N; 31 | cout << "Length of the bitmap: "; 32 | cin >> N; 33 | uint * bs = new uint[uint_len(N,1)]; 34 | for(uint i=0;i> b; 38 | if(b==0) bitclean(bs,i); 39 | else bitset(bs,i); 40 | } 41 | BitSequenceRRR * bsrrr = new BitSequenceRRR(bs,N,16); 42 | cout << "rank(" << N/2 << ")=" << bsrrr->rank1(N/2) << endl; 43 | cout << "select(1) = " << bsrrr->select1(1) << endl; 44 | cout << "size = " << bsrrr->getSize() << endl; 45 | delete bsrrr; 46 | delete [] bs; 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /libcds/tutorial/src/BitSequenceSDArrayExample.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * BitSequenceSDArrayExample.cpp 3 | * Copyright (C) 2011 Francisco Claude F. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | using namespace std; 27 | using namespace cds_utils; 28 | using namespace cds_static; 29 | 30 | int main(int argc, char **argv) { 31 | size_t N; 32 | cout << "Length of the bitmap: "; 33 | cin >> N; 34 | uint * bs = new uint[uint_len(N,1)]; 35 | for(uint i=0;i> b; 39 | if(b==0) bitclean(bs,i); 40 | else bitset(bs,i); 41 | } 42 | BitSequenceSDArray * bss = new BitSequenceSDArray(bs,N); 43 | cout << "rank(" << N/2 << ")=" << bss->rank1(N/2) << endl; 44 | cout << "select(1) = " << bss->select1(1) << endl; 45 | cout << "size = " << bss->getSize() << endl; 46 | delete bss; 47 | delete [] bs; 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /libcds/tutorial/src/SequenceAlphPartExample.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * SequenceAlphPartExample.cpp 3 | * Copyright (C) 2011 Francisco Claude F. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | using namespace std; 26 | using namespace cds_static; 27 | 28 | int main(int argc, char **argv) { 29 | 30 | size_t N; 31 | uint s; 32 | cout << "Length: "; 33 | cin >> N; 34 | uint * seq = new uint[N]; 35 | for(size_t i=0;i> seq[i]; 39 | } 40 | 41 | SequenceBuilder * sb1 = new SequenceBuilderWaveletTree( 42 | new BitSequenceBuilderRG(20), 43 | new MapperNone()); 44 | SequenceBuilder * sb2 = new SequenceBuilderGMRChunk( 45 | new BitSequenceBuilderRG(20), 46 | new PermutationBuilderMRRR( 47 | 20, new BitSequenceBuilderRG(20))); 48 | SequenceBuilder * sb3 = new SequenceBuilderGMR( 49 | new BitSequenceBuilderRG(20), 50 | sb2); 51 | 52 | SequenceAlphPart * ap = new SequenceAlphPart(seq, N, 0u, 53 | sb1, sb3); 54 | cout << "size = " << ap->getSize() << " bytes" << endl; 55 | 56 | delete ap; 57 | delete []seq; 58 | return 0; 59 | } 60 | 61 | -------------------------------------------------------------------------------- /libcds/tutorial/src/SequenceGMRExample.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * SequenceGMRExample.cpp 3 | * Copyright (C) 2011 Francisco Claude F. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | using namespace std; 26 | using namespace cds_static; 27 | 28 | int main(int argc, char **argv) { 29 | 30 | size_t N; 31 | uint s; 32 | cout << "Length: "; 33 | cin >> N; 34 | uint * seq = new uint[N]; 35 | for(size_t i=0;i> seq[i]; 39 | } 40 | SequenceGMR * gmr = new SequenceGMR(seq, N, 5u, 41 | new BitSequenceBuilderRG(20), 42 | new SequenceBuilderGMRChunk( 43 | new BitSequenceBuilderRG(20), 44 | new PermutationBuilderMRRR( 45 | 20, 46 | new BitSequenceBuilderRG(20)))); 47 | cout << "size = " << gmr->getSize() << " bytes" << endl; 48 | 49 | delete gmr; 50 | delete []seq; 51 | return 0; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /libcds/tutorial/src/SequenceWaveletTreeExample.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * SequenceWaveletTreeExample.cpp 3 | * Copyright (C) 2011 Francisco Claude F. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | using namespace std; 26 | using namespace cds_static; 27 | 28 | int main(int argc, char **argv) { 29 | 30 | size_t N; 31 | uint s; 32 | cout << "Length: "; 33 | cin >> N; 34 | uint * seq = new uint[N]; 35 | for(size_t i=0;i> seq[i]; 39 | } 40 | WaveletTree * wt1 = new WaveletTree(seq, N, 41 | new wt_coder_huff(seq, N, 42 | new MapperNone()), 43 | new BitSequenceBuilderRG(20), 44 | new MapperNone()); 45 | cout << "size = " << wt1->getSize() << " bytes" << endl; 46 | 47 | delete wt1; 48 | delete []seq; 49 | return 0; 50 | } 51 | 52 | -------------------------------------------------------------------------------- /libcds/tutorial/ssa/Makefile: -------------------------------------------------------------------------------- 1 | CPP=g++ 2 | 3 | 4 | #CPPFLAGS=-g3 -Wall -DVERBOSE 5 | #CPPFLAGS=-O9 -Wall -DNDEBUG 6 | CPPFLAGS=-O9 -Wall -DVERBOSE 7 | 8 | INCLUDES=-I../../includes/ -I. 9 | LIB=../../lib/libcds.a 10 | OBJECTS=ssa.o 11 | BINS=test_count build_index dump_bwt 12 | 13 | %.o: %.cpp 14 | @echo " [C++] Compiling $<" 15 | @$(CPP) $(CPPFLAGS) $(INCLUDES) -c $< -o $@ 16 | 17 | all: clean stats $(OBJECTS) $(BINS) 18 | 19 | stats: 20 | @echo 21 | @echo " COMPILING SSA" 22 | @echo " ###################" 23 | @echo " * Compiler flags: $(CPPFLAGS)" 24 | @echo " * Include dirs: $(INCLUDES)" 25 | @echo 26 | @echo 27 | 28 | clean: 29 | @echo " [CLN] Removing object files" 30 | @rm -f $(OBJECTS) $(BINS) 31 | 32 | test_count: 33 | @echo " [BLD] Building test_count" 34 | @$(CPP) $(CPPFLAGS) $(INCLUDES) -o test_count test_count.cpp $(OBJECTS) $(LIB) 35 | 36 | dump_bwt: 37 | @echo " [BLD] Building dump_bwt" 38 | @$(CPP) $(CPPFLAGS) $(INCLUDES) -o dump_bwt dump_bwt.cpp $(OBJECTS) $(LIB) 39 | 40 | build_index: 41 | @echo " [BLD] Building build_index" 42 | @$(CPP) $(CPPFLAGS) $(INCLUDES) -o build_index build_index.cpp $(OBJECTS) $(LIB) 43 | 44 | -------------------------------------------------------------------------------- /libcds/tutorial/ssa/build_index.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * build_index.cpp 3 | * Copyright (C) 2011 Francisco Claude F. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | 20 | #include "ssa.h" 21 | #include 22 | #include 23 | #include 24 | 25 | using namespace std; 26 | 27 | int main(int argc, char ** argv) { 28 | if(argc!=3) { 29 | cout << "usage: " << argv[0] << " " << endl; 30 | return 0; 31 | } 32 | 33 | fstream input(argv[1],ios::in | ios::binary); 34 | if(!input.is_open()) { 35 | cerr << "Error opening file: " << argv[1] << endl; 36 | return -1; 37 | } 38 | 39 | input.seekg(0,ios::end); 40 | uint n=input.tellg(); 41 | uchar * text = new uchar[n+1]; 42 | 43 | input.seekg(0,ios::beg); 44 | input.read((char*)text,sizeof(uchar)*n); 45 | input.close(); 46 | //for(uint i=0;iset_samplepos(32); 51 | _ssa->set_samplesuff(32); 52 | _ssa->build_index(); 53 | _ssa->print_stats(); 54 | 55 | cerr << "Index size: " << _ssa->size() << endl; 56 | 57 | ofstream fp(argv[2]); 58 | _ssa->save(fp); 59 | fp.close(); 60 | 61 | //delete sbb; 62 | delete _ssa; 63 | delete [] text; 64 | 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /libcds/tutorial/ssa/dump_bwt.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * dump_bwt.cpp 3 | * Copyright (C) 2011 Francisco Claude F. 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | 20 | #include "ssa.h" 21 | #include 22 | #include 23 | #include 24 | 25 | using namespace std; 26 | 27 | int main(int argc, char ** argv) { 28 | if(argc!=2) { 29 | cout << "usage: " << argv[0] << " " << endl; 30 | return 0; 31 | } 32 | 33 | ifstream ssainput(argv[1]); 34 | ssa * _ssa = new ssa(ssainput); 35 | ssainput.close(); 36 | _ssa->print_bwt(); 37 | delete _ssa; 38 | 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /libcds/tutorial/tutorial.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdfhdt/hdt-cpp/88110cc24d4d7d07080b40325d1905fae999ef95/libcds/tutorial/tutorial.pdf -------------------------------------------------------------------------------- /libhdt/.gitignore: -------------------------------------------------------------------------------- 1 | libhdt.a 2 | -------------------------------------------------------------------------------- /libhdt/data/literals.hdt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rdfhdt/hdt-cpp/88110cc24d4d7d07080b40325d1905fae999ef95/libhdt/data/literals.hdt -------------------------------------------------------------------------------- /libhdt/data/test.nt: -------------------------------------------------------------------------------- 1 | "literal1" . 2 | "literalA" . 3 | "literalA" . 4 | "literalB" . 5 | "literalC" . 6 | . 7 | . 8 | . 9 | "literal1" . 10 | . 11 | . 12 | . 13 | -------------------------------------------------------------------------------- /libhdt/examples/.gitignore: -------------------------------------------------------------------------------- 1 | generate 2 | search 3 | libhdt.a 4 | -------------------------------------------------------------------------------- /libhdt/examples/generate.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace hdt; 4 | 5 | int main(int argc, char *argv[]) { 6 | 7 | HDTSpecification spec; 8 | 9 | // Read RDF into an HDT file. 10 | HDT *hdt = HDTManager::generateHDT("data/test.nt", "http://example.org/test", NTRIPLES, spec); 11 | 12 | // Add additional domain-specific properties to the header 13 | Header *header = hdt->getHeader(); 14 | header->insert("myResource1", "property", "value"); 15 | 16 | // Save HDT to a file 17 | hdt->saveToHDT("data/test.hdt"); 18 | 19 | delete hdt; 20 | } 21 | -------------------------------------------------------------------------------- /libhdt/examples/search.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | using namespace hdt; 6 | 7 | int main(int argc, char *argv[]) { 8 | 9 | // Load HDT file 10 | HDT *hdt = HDTManager::mapHDT("data/test.hdt"); 11 | 12 | // Enumerate all triples matching a pattern ("" means any) 13 | IteratorTripleString *it = hdt->search("http://example.org/uri3","",""); 14 | while(it->hasNext()){ 15 | TripleString *triple = it->next(); 16 | cout << "Result: " << triple->getSubject() << ", " << triple->getPredicate() << ", " << triple->getObject() << endl; 17 | } 18 | delete it; // Remember to delete iterator to avoid memory leaks! 19 | 20 | // Enumerate all different predicates 21 | cout << "Dataset contains " << hdt->getDictionary()->getNpredicates() << " predicates."; 22 | IteratorUCharString *itPred = hdt->getDictionary()->getPredicates(); 23 | while(itPred->hasNext()) { 24 | unsigned char *str = itPred->next(); // Warning this pointer is only valid until next call to next(); 25 | cout << str << endl; 26 | itPred->freeStr(str); 27 | } 28 | delete itPred; // Remember to delete iterator to avoid memory leaks! 29 | 30 | delete hdt; // Remember to delete instance when no longer needed! 31 | } 32 | -------------------------------------------------------------------------------- /libhdt/hdt.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: @PACKAGE_NAME@ 7 | Description: HDT C++ library 8 | Version: @PACKAGE_VERSION@ 9 | URL: @PACKAGE_URL@ 10 | Libs: -L${libdir} -lhdt 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /libhdt/presets/bitmaphuff.hdtcfg: -------------------------------------------------------------------------------- 1 | header.type = 2 | triples.type = 3 | dictionary.type = 4 | stream.x = 5 | stream.y = 6 | stream.z = 7 | triplesOrder = SPO 8 | -------------------------------------------------------------------------------- /libhdt/presets/bitmaplog.hdtcfg: -------------------------------------------------------------------------------- 1 | header.type = 2 | triples.type = 3 | dictionary.type = 4 | stream.x = 5 | stream.y = 6 | stream.z = 7 | triplesOrder = SPO 8 | -------------------------------------------------------------------------------- /libhdt/presets/bitmapwavelet.hdtcfg: -------------------------------------------------------------------------------- 1 | header.type = 2 | triples.type = 3 | dictionary.type = 4 | stream.y = 5 | stream.z = 6 | triplesOrder = SPO 7 | -------------------------------------------------------------------------------- /libhdt/presets/compacthuff.hdtcfg: -------------------------------------------------------------------------------- 1 | header.type = 2 | triples.type = 3 | dictionary.type = 4 | stream.x = 5 | stream.y = 6 | stream.z = 7 | triplesOrder = SPO 8 | -------------------------------------------------------------------------------- /libhdt/presets/compactlog.hdtcfg: -------------------------------------------------------------------------------- 1 | header.type = 2 | triples.type = 3 | dictionary.type = 4 | stream.x = 5 | stream.y = 6 | stream.z = 7 | triplesOrder = SPO 8 | -------------------------------------------------------------------------------- /libhdt/presets/dictionaryfour.hdtcfg: -------------------------------------------------------------------------------- 1 | dictionary.type 2 | triples.type 3 | triplesOrder SPO 4 | dict.block.size 32 5 | -------------------------------------------------------------------------------- /libhdt/presets/dictionaryliteral.hdtcfg: -------------------------------------------------------------------------------- 1 | dictionary.type 2 | triples.type 3 | triplesOrder SPO 4 | -------------------------------------------------------------------------------- /libhdt/presets/fmindex.hdtcfg: -------------------------------------------------------------------------------- 1 | header.type = 2 | triples.type = 3 | dictionary.type = 4 | stream.x = 5 | stream.y = 6 | stream.z = 7 | triplesOrder = SPO 8 | -------------------------------------------------------------------------------- /libhdt/presets/ops.hdtcfg: -------------------------------------------------------------------------------- 1 | dictionary.type 2 | triples.type 3 | triplesOrder OPS 4 | -------------------------------------------------------------------------------- /libhdt/presets/plain.hdtcfg: -------------------------------------------------------------------------------- 1 | header.type = 2 | triples.type = 3 | dictionary.type = 4 | stream.x = 5 | stream.y = 6 | stream.z = 7 | triplesOrder = SPO 8 | -------------------------------------------------------------------------------- /libhdt/presets/plainlog.hdtcfg: -------------------------------------------------------------------------------- 1 | header.type = 2 | triples.type = 3 | dictionary.type = 4 | stream.x = 5 | stream.y = 6 | stream.z = 7 | triplesOrder = SPO 8 | -------------------------------------------------------------------------------- /libhdt/presets/tripleslist.hdtcfg: -------------------------------------------------------------------------------- 1 | header.type = 2 | triples.type = 3 | dictionary.type = 4 | triplesOrder = SPO 5 | -------------------------------------------------------------------------------- /libhdt/presets/wrong_dictionaryfour.hdtcfg: -------------------------------------------------------------------------------- 1 | dictionary.type 2 | triples.type 3 | triplesOrder SPO 4 | dict.block.size 0 5 | -------------------------------------------------------------------------------- /libhdt/src/hdt/TripleIDStringIterator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * TripleIDStringIterator.cpp 3 | * 4 | * Created on: 11/08/2012 5 | * Author: mck 6 | */ 7 | 8 | 9 | #include "TripleIDStringIterator.hpp" 10 | 11 | namespace hdt { 12 | 13 | TripleIDStringIterator::TripleIDStringIterator(Dictionary *dict, IteratorTripleID *iterator) : dict(dict), iterator(iterator){ 14 | 15 | } 16 | 17 | TripleIDStringIterator::~TripleIDStringIterator() { 18 | delete iterator; 19 | } 20 | 21 | bool TripleIDStringIterator::hasNext() { 22 | return iterator->hasNext(); 23 | } 24 | 25 | TripleString *TripleIDStringIterator::next() { 26 | TripleID *tid = iterator->next(); 27 | dict->tripleIDtoTripleString(*tid, result); 28 | return &result; 29 | } 30 | 31 | bool TripleIDStringIterator::hasPrevious() { 32 | return iterator->hasPrevious(); 33 | } 34 | 35 | TripleString *TripleIDStringIterator::previous() { 36 | TripleID *tid = iterator->previous(); 37 | dict->tripleIDtoTripleString(*tid, result); 38 | return &result; 39 | } 40 | 41 | void TripleIDStringIterator::goToStart() { 42 | iterator->goToStart(); 43 | } 44 | bool TripleIDStringIterator::canGoTo() { 45 | return iterator->canGoTo(); 46 | } 47 | size_t TripleIDStringIterator::estimatedNumResults() { 48 | return iterator->estimatedNumResults(); 49 | } 50 | ResultEstimationType TripleIDStringIterator::numResultEstimation() { 51 | return iterator->numResultEstimation(); 52 | } 53 | void TripleIDStringIterator::skip(size_t pos) { 54 | iterator->skip(pos); 55 | } 56 | 57 | } 58 | 59 | -------------------------------------------------------------------------------- /libhdt/src/hdt/TripleIDStringIterator.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * TripleIDStringIterator.hpp 3 | * 4 | * Created on: 11/08/2012 5 | * Author: mck 6 | */ 7 | 8 | #ifndef TRIPLEIDSTRINGITERATOR_HPP_ 9 | #define TRIPLEIDSTRINGITERATOR_HPP_ 10 | 11 | #include 12 | #include 13 | 14 | namespace hdt { 15 | 16 | class TripleIDStringIterator : public IteratorTripleString { 17 | 18 | private: 19 | Dictionary *dict; 20 | IteratorTripleID *iterator; 21 | TripleString result; 22 | public: 23 | TripleIDStringIterator(Dictionary *dict, IteratorTripleID *iterator); 24 | virtual ~TripleIDStringIterator(); 25 | bool hasNext(); 26 | TripleString *next(); 27 | bool hasPrevious(); 28 | TripleString *previous(); 29 | bool canGoTo(); 30 | void goToStart(); 31 | size_t estimatedNumResults(); 32 | ResultEstimationType numResultEstimation(); 33 | void skip(size_t pos); 34 | }; 35 | 36 | } /* namespace hdt */ 37 | #endif /* TRIPLEIDSTRINGITERATOR_HPP_ */ 38 | -------------------------------------------------------------------------------- /libhdt/src/rdf/RDFParser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * RDFParser.cpp 3 | * 4 | * Created on: 11/07/2011 5 | * Author: mck 6 | */ 7 | 8 | #include "RDFParser.hpp" 9 | #ifdef HAVE_SERD 10 | #include "RDFParserSerd.hpp" 11 | #endif 12 | 13 | namespace hdt { 14 | 15 | RDFParserCallback *RDFParserCallback::getParserCallback(RDFNotation notation) { 16 | #ifdef HAVE_SERD 17 | if(notation==NQUAD || // Deprecated: use `NQUADS' instead. 18 | notation==NQUADS || 19 | notation==NTRIPLES || 20 | notation==TRIG || 21 | notation==TURTLE) { 22 | return new RDFParserSerd(); 23 | } 24 | #else 25 | throw ParseException("No Parser available for input RDF Format"); 26 | #endif 27 | return nullptr; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /libhdt/src/rdf/RDFParserNtriples.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * RDFParserN3.h 3 | * 4 | * Created on: 05/03/2011 5 | * Author: mck 6 | */ 7 | 8 | #ifndef RDFPARSERN3_H_ 9 | #define RDFPARSERN3_H_ 10 | 11 | #include 12 | #include 13 | 14 | #include "RDFParser.hpp" 15 | 16 | namespace hdt { 17 | 18 | class RDFParserNtriples : public RDFParserPull { 19 | 20 | private: 21 | uint64_t size; 22 | std::string line; 23 | TripleString ts; 24 | std::istream *input; 25 | 26 | public: 27 | RDFParserNtriples(std::istream &in, RDFNotation notation); 28 | RDFParserNtriples(const char *fileName, RDFNotation notation); 29 | virtual ~RDFParserNtriples(); 30 | 31 | bool hasNext(); 32 | TripleString *next(); 33 | void reset(); 34 | uint64_t getPos(); 35 | uint64_t getSize(); 36 | }; 37 | 38 | } 39 | 40 | #endif /* RDFPARSERN3_H_ */ 41 | -------------------------------------------------------------------------------- /libhdt/src/rdf/RDFParserSerd.hpp: -------------------------------------------------------------------------------- 1 | #ifndef RDFPARSERSERD_HPP 2 | #define RDFPARSERSERD_HPP 3 | 4 | #ifdef HAVE_SERD 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include 11 | 12 | #include "RDFParser.hpp" 13 | 14 | namespace hdt { 15 | 16 | class RDFParserSerd : public RDFParserCallback { 17 | 18 | private: 19 | SerdEnv *env; 20 | RDFCallback *callback; 21 | string error; 22 | uint64_t numByte; 23 | 24 | string getString(const SerdNode *term); 25 | string getStringObject(const SerdNode *term, const SerdNode *dataType, const SerdNode *lang); 26 | SerdSyntax getParserType(RDFNotation notation); 27 | 28 | public: 29 | RDFParserSerd(); 30 | virtual ~RDFParserSerd(); 31 | 32 | void doParse(const char *fileName, const char *baseUri, RDFNotation notation, bool ignoreErrors, RDFCallback *callback); 33 | 34 | friend SerdStatus hdtserd_on_statement(void *handle, 35 | SerdStatementFlags flags, 36 | const SerdNode *graph, 37 | const SerdNode *subject, 38 | const SerdNode *predicate, 39 | const SerdNode *object, 40 | const SerdNode *datatype, 41 | const SerdNode *lang); 42 | 43 | friend SerdStatus hdtserd_on_prefix(void *handle, 44 | const SerdNode *name, 45 | const SerdNode *uri); 46 | 47 | friend SerdStatus hdtserd_on_base(void *handle, const SerdNode *uri); 48 | friend SerdStatus hdtserd_on_error(void *handle, const SerdError *e); 49 | }; 50 | 51 | } 52 | 53 | #endif 54 | 55 | #endif // RDFPARSERSERD_HPP 56 | -------------------------------------------------------------------------------- /libhdt/src/rdf/RDFSerializer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * RDFSerializer.cpp 3 | * 4 | * Created on: 11/07/2011 5 | * Author: mck 6 | */ 7 | #include 8 | #include "RDFSerializer.hpp" 9 | #ifdef HAVE_SERD 10 | #include "RDFSerializerSerd.hpp" 11 | #endif 12 | #include "RDFSerializerNTriples.hpp" 13 | 14 | namespace hdt { 15 | 16 | RDFSerializer *RDFSerializer::getSerializer(std::ostream &out, RDFNotation notation) { 17 | 18 | #ifdef HAVE_SERD 19 | return new RDFSerializerSerd(out, notation); 20 | #else 21 | if(notation==NTRIPLES) { 22 | return new RDFSerializerNTriples(out,notation); 23 | } else { 24 | throw std::runtime_error("RDFSerialization not available"); 25 | } 26 | #endif 27 | } 28 | 29 | RDFSerializer *RDFSerializer::getSerializer(const char *fileName, RDFNotation notation) { 30 | 31 | #ifdef HAVE_SERD 32 | return new RDFSerializerSerd(fileName, notation); 33 | #else 34 | if(notation==NTRIPLES) { 35 | return new RDFSerializerNTriples(fileName,notation); 36 | } else { 37 | throw std::runtime_error("RDFSerialization not available"); 38 | } 39 | #endif 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /libhdt/src/rdf/RDFSerializerNTriples.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * RDFSerializerNTriples.cpp 3 | * 4 | * Created on: 05/03/2011 5 | * Author: mck 6 | */ 7 | #include 8 | #include "RDFSerializerNTriples.hpp" 9 | 10 | using namespace std; 11 | 12 | namespace hdt { 13 | 14 | RDFSerializerNTriples::RDFSerializerNTriples(std::ostream &s, RDFNotation notation) 15 | : RDFSerializer(notation), 16 | output(&s) 17 | { 18 | 19 | } 20 | 21 | RDFSerializerNTriples::RDFSerializerNTriples(const char *fileName, RDFNotation notation) 22 | : RDFSerializer(notation), 23 | output(new std::ofstream(fileName, ios::binary | ios::out)) 24 | { 25 | 26 | } 27 | 28 | RDFSerializerNTriples::~RDFSerializerNTriples() { 29 | 30 | } 31 | 32 | void serializeTerm(std::string str, ostream &output) { 33 | if(str=="") { 34 | throw std::runtime_error("Empty Value on triple!"); 35 | } 36 | 37 | // FIXME: Escape non-ascii. 38 | 39 | if(str.at(0)=='"') { 40 | output << str; 41 | } else if(str.at(0)=='_') { 42 | output << str; 43 | } else { 44 | output << "<" << str << ">"; 45 | } 46 | } 47 | 48 | void RDFSerializerNTriples::serialize(IteratorTripleString *it, ProgressListener *listener, size_t totalTriples) 49 | { 50 | size_t numTriple=0; 51 | while(it->hasNext()) { 52 | TripleString *ts = it->next(); 53 | 54 | if(!ts->isEmpty()) { 55 | serializeTerm(ts->getSubject(), *output); 56 | *output << ' '; 57 | serializeTerm(ts->getPredicate(), *output); 58 | *output << ' '; 59 | serializeTerm(ts->getObject(), *output); 60 | *output << " ." << endl; 61 | } 62 | numTriple++; 63 | 64 | NOTIFYCOND(listener, "Exporting HDT to RDF", numTriple, totalTriples); 65 | } 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /libhdt/src/rdf/RDFSerializerNTriples.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * RDFSerializerNTriples.h 3 | * 4 | */ 5 | 6 | #ifndef RDFSERIALIZERNTRIPLES_H_ 7 | #define RDFSERIALIZERNTRIPLES_H_ 8 | 9 | #include 10 | #include "RDFSerializer.hpp" 11 | 12 | namespace hdt { 13 | 14 | class RDFSerializerNTriples: public RDFSerializer { 15 | std::ostream *output; 16 | public: 17 | RDFSerializerNTriples(std::ostream &s, RDFNotation notation); 18 | RDFSerializerNTriples(const char *fileName, RDFNotation notation); 19 | virtual ~RDFSerializerNTriples(); 20 | void serialize(IteratorTripleString *it, ProgressListener *listener=NULL, size_t totalTriples=0); 21 | }; 22 | 23 | } 24 | 25 | #endif /* RDFSERIALIZERNTRIPLES_H_ */ 26 | -------------------------------------------------------------------------------- /libhdt/src/rdf/RDFSerializerSerd.hpp: -------------------------------------------------------------------------------- 1 | #ifndef RDFSERIALIZERSERD_H_ 2 | #define RDFSERIALIZERSERD_H_ 3 | 4 | #ifdef HAVE_SERD 5 | 6 | #include 7 | 8 | #include "RDFSerializer.hpp" 9 | 10 | namespace hdt { 11 | 12 | class RDFSerializerSerd : public RDFSerializer { 13 | private: 14 | FILE *file; 15 | SerdEnv *env; 16 | SerdWriter *writer; 17 | 18 | public: 19 | RDFSerializerSerd(const char *fileName, RDFNotation notation); 20 | RDFSerializerSerd(std::ostream &s, RDFNotation notation); 21 | 22 | virtual ~RDFSerializerSerd(); 23 | 24 | void serialize(IteratorTripleString *it, 25 | ProgressListener *listener=NULL, 26 | size_t totalTriples=0); 27 | }; 28 | 29 | } 30 | 31 | #endif 32 | 33 | #endif /* RDFSERIALIZERSERD_H_ */ 34 | -------------------------------------------------------------------------------- /libhdt/src/sparql/IndexJoinBinding.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * IndexJoinBinding.hpp 3 | * 4 | * Created on: 24/09/2011 5 | * Author: mck 6 | */ 7 | 8 | #ifndef INDEXJOINBINDING_HPP_ 9 | #define INDEXJOINBINDING_HPP_ 10 | 11 | #include "BaseJoinBinding.hpp" 12 | 13 | namespace hdt { 14 | 15 | class IndexJoinBinding : public BaseJoinBinding { 16 | size_t leftVarValue; 17 | vector< vector > leftOperands, rightOperands; 18 | //size_t leftCount, rightCount; 19 | //bool remainingRight; 20 | public: 21 | IndexJoinBinding(char *var, VarBindingInterface *left, VarBindingInterface *right); 22 | virtual ~IndexJoinBinding(); 23 | size_t isOrdered(size_t numvar); 24 | 25 | size_t estimatedNumResults(); 26 | ResultEstimationType estimationAccuracy(); 27 | 28 | bool findNext(const char *varName, size_t value=0); 29 | 30 | bool findNext(); 31 | 32 | //virtual void findNext(size_t numvar, size_t value=0); 33 | void goToStart(); 34 | 35 | void searchVar(size_t numvar, size_t value); 36 | }; 37 | 38 | } 39 | 40 | #endif /* INDEXJOINBINDING_HPP_ */ 41 | -------------------------------------------------------------------------------- /libhdt/src/sparql/JoinAlgorithms.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * JoinAlgorithms.hpp 3 | * 4 | * Created on: 13/09/2011 5 | * Author: mck 6 | */ 7 | 8 | #ifndef JOINALGORITHMS_HPP_ 9 | #define JOINALGORITHMS_HPP_ 10 | 11 | #include 12 | 13 | namespace hdt { 14 | 15 | #define SUBJA_SUBJB 0 16 | #define SUBJA_PREDB 1 17 | #define SUBJA_OBJB 2 18 | #define PREDA_SUBJB 3 19 | #define PREDA_PREDB 4 20 | #define PREDA_OBJB 5 21 | #define OBJA_SUBJB 6 22 | #define OBJA_PREDB 7 23 | #define OBJA_OBJB 8 24 | #define SUBJA_PREDA 9 25 | #define SUBJA_OBJA 10 26 | #define PREDA_OBJA 11 27 | #define SUBJB_PREDB 12 28 | #define SUBJB_OBJB 13 29 | #define PREDB_OBJB 14 30 | 31 | 32 | unsigned short getComparisons(TripleString &a, TripleString &b); 33 | bool checkComparisons(TripleID &a, TripleID &b, unsigned short cond); 34 | void dumpComparisons(unsigned short cond); 35 | 36 | TripleID getSecondPattern(TripleID &pattern, TripleID &tid, unsigned short cond); 37 | TripleID getFirstPattern(TripleID &pattern, TripleID &tid, unsigned short cond); 38 | 39 | 40 | } 41 | 42 | 43 | #endif /* JOINALGORITHMS_HPP_ */ 44 | -------------------------------------------------------------------------------- /libhdt/src/sparql/MergeJoinBinding.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MergeJoinBinding.hpp 3 | * 4 | * Created on: 24/09/2011 5 | * Author: mck 6 | */ 7 | 8 | #ifndef MERGEJOINBINDING_HPP_ 9 | #define MERGEJOINBINDING_HPP_ 10 | 11 | #include "BaseJoinBinding.hpp" 12 | 13 | namespace hdt { 14 | 15 | class MergeJoinBinding : public BaseJoinBinding { 16 | size_t s, r; 17 | vector< vector > leftOperands, rightOperands; 18 | size_t leftCount, rightCount; 19 | bool hasMoreOperands; 20 | public: 21 | MergeJoinBinding(char *var, VarBindingInterface *left, VarBindingInterface *right); 22 | virtual ~MergeJoinBinding(); 23 | 24 | size_t isOrdered(size_t numvar); 25 | 26 | size_t estimatedNumResults(); 27 | ResultEstimationType estimationAccuracy(); 28 | bool findNext(const char *varName, size_t value=0); 29 | 30 | bool findNext(); 31 | //virtual void findNext(size_t numvar, size_t value=0); 32 | void goToStart(); 33 | 34 | size_t getVarValue(size_t numvar); 35 | void searchVar(size_t numvar, size_t value); 36 | }; 37 | 38 | } 39 | 40 | #endif /* MERGEJOINBINDING_HPP_ */ 41 | -------------------------------------------------------------------------------- /libhdt/src/sparql/SortBinding.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SORTBINDING_HPP 2 | #define SORTBINDING_HPP 3 | 4 | #include "VarBindingInterface.hpp" 5 | 6 | namespace hdt { 7 | 8 | class SortBinding : public VarBindingInterface 9 | { 10 | private: 11 | vector varnames; 12 | size_t *table; 13 | //char *joinVar; 14 | //size_t joinVarPos; 15 | size_t numRows; 16 | size_t numCols; 17 | //size_t currentRow; 18 | public: 19 | // Sort all of the child by var 20 | SortBinding(char *var, VarBindingInterface *child); 21 | virtual ~SortBinding(); 22 | 23 | size_t isOrdered(size_t numvar); 24 | 25 | size_t estimatedNumResults(); 26 | ResultEstimationType estimationAccuracy(); 27 | bool findNext(const char *varName, size_t value=0); 28 | 29 | bool findNext(); 30 | //virtual void findNext(size_t numvar, size_t value=0); 31 | void goToStart(); 32 | 33 | size_t getVarValue(size_t numvar); 34 | void searchVar(size_t numvar, size_t value); 35 | }; 36 | 37 | } 38 | 39 | #endif // SORTBINDING_HPP 40 | -------------------------------------------------------------------------------- /libhdt/src/sparql/TriplePatternBinding.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * TriplePatternBinding.hpp 3 | * 4 | * Created on: 24/09/2011 5 | * Author: mck 6 | */ 7 | 8 | #ifndef TRIPLEPATTERNBINDING_HPP_ 9 | #define TRIPLEPATTERNBINDING_HPP_ 10 | 11 | #include "VarBindingInterface.hpp" 12 | 13 | #include 14 | #include "../triples/TripleOrderConvert.hpp" 15 | 16 | namespace hdt { 17 | 18 | /** Provides a Binding by using a Triple Pattern underneath */ 19 | class TriplePatternBinding : public VarBindingInterface { 20 | private: 21 | TripleID pattern; 22 | IteratorTripleID *iterator; 23 | Triples *triples; 24 | TripleID *currentTriple; 25 | vector vars; // Each position means: 1 Subject, 2 Predicate, 3 Object. 26 | vectorvarnames; 27 | //hash_map varsByName; 28 | 29 | public: 30 | TriplePatternBinding(Triples *triples, TripleID &pattern, vector &vars, vector &varnames); 31 | 32 | virtual ~TriplePatternBinding(); 33 | 34 | size_t isOrdered(size_t numvar); 35 | 36 | size_t estimatedNumResults(); 37 | ResultEstimationType estimationAccuracy(); 38 | bool findNext(); 39 | 40 | #if 0 41 | // Use TriplePattern to jump to next occurence. 42 | bool findNext(const char *varName, size_t value=0); 43 | #endif 44 | 45 | void goToStart(); 46 | size_t getNumVars(); 47 | size_t getVarValue(size_t numvar); 48 | size_t getVarValue(const char *varname); 49 | const char *getVarName(size_t numvar); 50 | void searchVar(size_t numvar, size_t value); 51 | 52 | }; 53 | 54 | } 55 | 56 | #endif /* TRIPLEPATTERNBINDING_HPP_ */ 57 | -------------------------------------------------------------------------------- /libhdt/src/sparql/VarBindingInterface.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * VarBindingBase.h 3 | * 4 | * Created on: 24/09/2011 5 | * Author: mck 6 | */ 7 | #include 8 | #ifndef VARBINDINGBASE_H_ 9 | #define VARBINDINGBASE_H_ 10 | 11 | #include 12 | 13 | namespace hdt { 14 | 15 | 16 | /** Users of the library should use VarBindingID, 17 | VarBindingInterface for internal use only */ 18 | class VarBindingInterface : public VarBindingID { 19 | public: 20 | virtual ~VarBindingInterface() { } 21 | 22 | virtual size_t isOrdered(size_t numvar)=0; 23 | 24 | virtual size_t estimatedNumResults()=0; 25 | virtual ResultEstimationType estimationAccuracy()=0; 26 | 27 | virtual bool findNext()=0; 28 | virtual bool findNext(const char *varName, size_t value=0) { 29 | while(findNext()) { 30 | if(getVarValue(varName)==value) { 31 | return true; 32 | } 33 | } 34 | return false; 35 | } 36 | virtual bool findNext(size_t varIndex, size_t value=0) { 37 | while(findNext()) { 38 | if(getVarValue(varIndex)==value) { 39 | return true; 40 | } 41 | } 42 | return false; 43 | } 44 | virtual size_t getNumVars()=0; 45 | virtual size_t getVarValue(const char *varName)=0; 46 | virtual size_t getVarValue(size_t numvar)=0; 47 | virtual size_t getVarIndex(const char *varName) { 48 | for(int i=0;i 36 | 37 | namespace hdt { 38 | 39 | class TriplesComparator { 40 | 41 | private: 42 | TripleComponentOrder order; 43 | 44 | public: 45 | TriplesComparator(); 46 | TriplesComparator(TripleComponentOrder order); 47 | virtual ~TriplesComparator(); 48 | bool operator()(const TripleID &a, const TripleID &b); 49 | void setOrder(TripleComponentOrder order); 50 | 51 | }; //TriplesComparator{} 52 | 53 | } // namespace hdt 54 | 55 | #endif /* TRIPLESCOMPARATOR_HPP_ */ 56 | -------------------------------------------------------------------------------- /libhdt/src/util/bitutil.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * bitutil.cpp 3 | * 4 | * Created on: 14/08/2012 5 | * Author: mck 6 | */ 7 | 8 | #include "bitutil.h" 9 | 10 | namespace hdt { 11 | 12 | /** popcount array for uchars */ 13 | extern const unsigned char popcount_tab[256] = { 14 | 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 15 | 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 16 | 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 17 | 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 18 | 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 19 | 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 20 | 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 21 | 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, 22 | }; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /libhdt/src/util/filemap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * File: filemap.h 3 | * Last modified: $Date: 2012-09-19 12:02:39 +0100 (mié, 19 sep 2012) $ 4 | * Revision: $Revision: 278 $ 5 | * Last modified by: $Author: mario.arias $ 6 | * 7 | * Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto 8 | * All rights reserved. 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Lesser General Public 12 | * License as published by the Free Software Foundation; either 13 | * version 2.1 of the License, or (at your option) any later version. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | * Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | * 24 | * 25 | * Contacting the authors: 26 | * Mario Arias: mario.arias@gmail.com 27 | * Javier D. Fernandez: jfergar@infor.uva.es 28 | * Miguel A. Martinez-Prieto: migumar2@infor.uva.es 29 | * 30 | */ 31 | 32 | #ifndef FILE_MAP_H_ 33 | #define FILE_MAP_H_ 34 | 35 | #include 36 | 37 | #ifdef WIN32 38 | #include 39 | #include 40 | #endif 41 | 42 | namespace hdt { 43 | 44 | class FileMap { 45 | private: 46 | 47 | #ifdef WIN32 48 | HANDLE fd,h; 49 | #else 50 | int fd; 51 | #endif 52 | size_t mappedSize; 53 | unsigned char *ptr; 54 | 55 | public: 56 | FileMap(const char *fileName); 57 | virtual ~FileMap(); 58 | 59 | unsigned char *getPtr() { 60 | return ptr; 61 | } 62 | 63 | size_t getMappedSize() { 64 | return mappedSize; 65 | } 66 | 67 | }; 68 | 69 | } 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /libhdt/src/util/mygetopt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Public Domain getopt header 3 | * 4 | */ 5 | 6 | #ifndef MY_GETOPT_H 7 | #define MY_GETOPT_H 8 | 9 | #ifdef WIN32 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | int getopt(int argc, char * const argv[], const char *optstring); 16 | extern char *optarg; 17 | extern int optind, opterr, optopt; 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /libhdt/src/util/propertyutil.h: -------------------------------------------------------------------------------- 1 | // Java-Style Properties in C++ 2 | // 3 | // (c) Paul D. Senzee 4 | // Senzee 5 5 | // http://senzee.blogspot.com 6 | 7 | #ifndef _PROPERTYUTIL_H 8 | #define _PROPERTYUTIL_H 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | class PropertyUtil 15 | { 16 | 17 | public: 18 | 19 | typedef std::map PropertyMapT; 20 | typedef PropertyMapT::value_type value_type; 21 | typedef PropertyMapT::iterator iterator; 22 | 23 | static void read(const char *filename, PropertyMapT &map); 24 | static void read(std::istream &is, PropertyMapT &map); 25 | static void write(const char *filename, PropertyMapT &map, const char *header = NULL); 26 | static void write(std::ostream &os, PropertyMapT &map, const char *header = NULL); 27 | static void print(std::ostream &os, PropertyMapT &map); 28 | 29 | private: 30 | 31 | static inline char m_hex(int nibble) 32 | { 33 | static const char *digits = "0123456789ABCDEF"; 34 | return digits[nibble & 0xf]; 35 | } 36 | }; 37 | 38 | #endif // _PROPERTYUTIL_H 39 | -------------------------------------------------------------------------------- /libhdt/tests/.gitignore: -------------------------------------------------------------------------------- 1 | bit375 2 | bitutiltest 3 | cmp 4 | confm 5 | conops 6 | conpfc 7 | convert 8 | conwav 9 | csd 10 | dic 11 | filterSearch 12 | genIndex 13 | getobj 14 | hdt2rdfNotMapping 15 | hdtExtract 16 | iter 17 | joinsearch 18 | jointest 19 | -------------------------------------------------------------------------------- /libhdt/tests/Makefile.am: -------------------------------------------------------------------------------- 1 | check_PROGRAMS = \ 2 | bit375 \ 3 | bitutiltest \ 4 | c11 \ 5 | dictionaries \ 6 | listener \ 7 | logarr \ 8 | properties \ 9 | serd \ 10 | streamtest \ 11 | testmax \ 12 | dumpDictionary 13 | #cmp \ 14 | #confm \ 15 | #conops \ 16 | #conpfc \ 17 | #convert \ 18 | #conwav \ 19 | #csd \ 20 | #dic \ 21 | #filterSearch \ 22 | #genCache \ 23 | #genIndex \ 24 | #getobj \ 25 | #hdt2rdfNotMapping \ 26 | #hdtExtract \ 27 | #iter \ 28 | #joinsearch \ 29 | #jointest \ 30 | #kyoto \ 31 | #mergeHDT \ 32 | #mincor \ 33 | #naiveComplete \ 34 | #opendic \ 35 | #parse \ 36 | #patsearch \ 37 | #popcnt \ 38 | #randomSolution \ 39 | #wav 40 | 41 | AM_DEFAULT_SOURCE_EXT = .cpp 42 | 43 | AM_CPPFLAGS = -I@top_srcdir@/libhdt/include $(WARN_CFLAGS) $(EXTRAFLAGS) 44 | AM_LDFLAGS = $(SERD_LIBS) $(ZLIB_LIBS) $(KYOTO_LIBS) 45 | LDADD = ../libhdt.la 46 | 47 | if WANTS_LIBCDS 48 | AM_CPPFLAGS += -DHAVE_CDS -I$(top_builddir)/libcds/include 49 | LDADD += $(top_builddir)/libcds/libcds.la 50 | endif 51 | 52 | TESTS = $(check_PROGRAMS) 53 | -------------------------------------------------------------------------------- /libhdt/tests/README.md: -------------------------------------------------------------------------------- 1 | 2 | # HDT TESTS 3 | 4 | ## Overview 5 | 6 | This folder contains different snippets of code to showcase and test the HDT suite. Some pieces of code could be outdated. 7 | 8 | ## Compilation 9 | 10 | Compile the examples with: 11 | 12 | ``` 13 | $ make check 14 | ``` 15 | 16 | This command will compile all the (uncommented) programs listed in Makefile.am. If you need to include another one, uncomment or include the name of the program in Makefile.am, and generate again the Makefile with ./autogen.sh and ./configure in the main root path. 17 | 18 | ## License 19 | 20 | Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto 21 | All rights reserved. 22 | 23 | This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. 24 | 25 | This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 27 | 28 | You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 29 | 30 | Visit our Web Page: http://www.rdfhdt.org 31 | 32 | ## Contacting the authors: 33 | 34 | - Mario Arias: mario.arias@deri.org 35 | 36 | - Javier D. Fernandez: jfergar@infor.uva.es 37 | 38 | - Miguel A. Martinez-Prieto: migumar2@infor.uva.es 39 | -------------------------------------------------------------------------------- /libhdt/tests/bit375.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * bit375.cpp 3 | * 4 | * Created on: 15/08/2012 5 | * Author: mck 6 | */ 7 | 8 | #include 9 | 10 | #include "../src/bitsequence/BitSequence375.h" 11 | 12 | using namespace std; 13 | using namespace hdt; 14 | 15 | int main(int argc, char **argv) { 16 | BitSequence375 bit(1000); 17 | 18 | for(size_t i=0;i<1000;i++) { 19 | bool val = (i%3)==0; 20 | bit.set(i,val); 21 | if(bit.access(i)!=val) { 22 | cout << "Wrong insert << " << i << " / "<< val << endl; 23 | } 24 | } 25 | 26 | #if 0 27 | ofstream out("test.bin"); 28 | bit.save(out); 29 | out.close(); 30 | 31 | 32 | ifstream in("test.bin"); 33 | BitSequence375 *bit2 = BitSequence375::load(in); 34 | in.close(); 35 | #endif 36 | 37 | size_t count=0; 38 | for(size_t i=0;i<1005;i++) { 39 | if(bit.access(i)) { 40 | count++; 41 | } 42 | size_t rank = bit.rank1(i); 43 | 44 | cout << "i= "< 2 | 3 | int 4 | main(int argc, char **argv) 5 | { 6 | std::tuple t = std::make_tuple(1,1); 7 | std::tuple u; 8 | t.swap(u); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /libhdt/tests/convert.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Tutorial01.cpp 3 | * 4 | * Created on: 02/03/2011 5 | * Author: mck 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include "../src/triples/TriplesList.hpp" 20 | #include "../src/triples/BitmapTriples.hpp" 21 | 22 | #include "../src/util/StopWatch.hpp" 23 | 24 | using namespace hdt; 25 | using namespace std; 26 | 27 | int main(int argc, char **argv) { 28 | int c; 29 | string query, inputFile, outputFile; 30 | bool measure = false; 31 | 32 | while( (c = getopt(argc,argv,"hq:o:m"))!=-1) { 33 | switch(c) { 34 | case 'h': 35 | break; 36 | case 'q': 37 | query = optarg; 38 | break; 39 | case 'o': 40 | outputFile = optarg; 41 | break; 42 | case 'm': 43 | measure = true; 44 | break; 45 | default: 46 | cout << "ERROR: Unknown option" << endl; 47 | return 1; 48 | } 49 | } 50 | 51 | if(argc-optind<2) { 52 | cout << "ERROR: You must supply an input and HDT File" << endl << endl; 53 | return 1; 54 | } 55 | 56 | inputFile = argv[optind]; 57 | outputFile = argv[optind+1]; 58 | 59 | StopWatch st; 60 | 61 | try { 62 | // LOAD 63 | HDT *hdt = HDTManager::mapHDT(inputFile.c_str()); 64 | 65 | // Save 66 | hdt->saveToHDT(outputFile.c_str()); 67 | 68 | delete hdt; 69 | } catch (std::exception& e) { 70 | cout << "ERROR: " << e.what() << endl; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /libhdt/tests/conwav.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Tutorial01.cpp 3 | * 4 | * Created on: 02/03/2011 5 | * Author: mck 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "../src/util/StopWatch.hpp" 17 | 18 | using namespace hdt; 19 | using namespace std; 20 | 21 | int interruptSignal = 0; 22 | 23 | void signalHandler(int sig) 24 | { 25 | interruptSignal = 1; 26 | } 27 | 28 | void help() { 29 | cout << "$ hdtSearch [options] " << endl; 30 | cout << "\t-h\t\t\tThis help" << endl; 31 | cout << "\t-q\t\t\tLaunch query and exit." << endl; 32 | cout << "\t-o\t\tSave query output to file." << endl; 33 | cout << "\t-m\t\t\tDo not show results, just measure query time." << endl; 34 | 35 | //cout << "\t-v\tVerbose output" << endl; 36 | } 37 | 38 | 39 | int main(int argc, char **argv) { 40 | int c; 41 | string query, inputFile, outputFile; 42 | bool measure = false; 43 | 44 | while( (c = getopt(argc,argv,"hq:o:m"))!=-1) { 45 | switch(c) { 46 | case 'h': 47 | help(); 48 | break; 49 | case 'q': 50 | query = optarg; 51 | break; 52 | case 'o': 53 | outputFile = optarg; 54 | break; 55 | case 'm': 56 | measure = true; 57 | break; 58 | default: 59 | cout << "ERROR: Unknown option" << endl; 60 | help(); 61 | return 1; 62 | } 63 | } 64 | 65 | if(argc-optind<2) { 66 | cout << "ERROR: You must supply an HDT File" << endl << endl; 67 | help(); 68 | return 1; 69 | } 70 | 71 | inputFile = argv[optind]; 72 | outputFile = argv[optind+1]; 73 | 74 | try { 75 | HDT *hdt = HDTManager::mapHDT(inputFile.c_str()); 76 | hdt->saveToHDT(outputFile.c_str()); 77 | 78 | cout << "IN: " << inputFile << " Out: " << outputFile << endl; 79 | 80 | delete hdt; 81 | } catch (std::exception& e) { 82 | cout << "ERROR: " << e.what() << endl; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /libhdt/tests/csd.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Tutorial01.cpp 3 | * 4 | * Created on: 02/03/2011 5 | * Author: mck 6 | */ 7 | 8 | #include 9 | 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include "../src/hdt/HDTFactory.hpp" 21 | #include "../src/libdcs/CSD_PFC.h" 22 | 23 | #include "../src/util/StopWatch.hpp" 24 | 25 | using namespace hdt; 26 | using namespace csd; 27 | using namespace std; 28 | 29 | int main(int argc, char **argv) { 30 | int c; 31 | string query, inputFile, outputFile; 32 | bool measure = false; 33 | 34 | while( (c = getopt(argc,argv,"hq:o:m"))!=-1) { 35 | switch(c) { 36 | case 'h': 37 | break; 38 | case 'q': 39 | query = optarg; 40 | break; 41 | case 'o': 42 | outputFile = optarg; 43 | break; 44 | case 'm': 45 | measure = true; 46 | break; 47 | default: 48 | cout << "ERROR: Unknown option" << endl; 49 | return 1; 50 | } 51 | } 52 | 53 | if(argc-optind<1) { 54 | cout << "ERROR: You must supply an input and HDT File" << endl << endl; 55 | return 1; 56 | } 57 | 58 | inputFile = argv[optind]; 59 | 60 | try { 61 | 62 | StdoutProgressListener progress; 63 | // CONVERT 64 | FileIteratorUCharString iterator(inputFile); 65 | 66 | CSD_PFC *csd = new CSD_PFC(&iterator, 32, &progress); 67 | 68 | ofstream out(outputFile.c_str(), ios::binary); 69 | csd->save(out); 70 | out.close(); 71 | 72 | delete csd; 73 | 74 | } catch (std::exception& e) { 75 | cout << "ERROR: " << e.what() << endl; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /libhdt/tests/dic.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | using namespace hdt; 6 | 7 | int main(int argc, char **argv) { 8 | 9 | try { 10 | HDT *hdt = HDTManager::mapHDT(argv[1]); 11 | IteratorUCharString *it =hdt->getDictionary()->getObjects(); 12 | 13 | ofstream lit("lit.txt"); 14 | ofstream blk("blank.txt"); 15 | ofstream uri("uri.txt"); 16 | while(it->hasNext()) { 17 | unsigned char *str = it->next(); 18 | if(*str=='"') { 19 | // Literal 20 | lit << (char*)str << endl; 21 | } else if(*str=='_'){ 22 | // Blanco 23 | blk << (char*)str << endl; 24 | } else { 25 | // URI 26 | uri << (char*)str << endl; 27 | } 28 | } 29 | lit.close(); 30 | blk.close(); 31 | uri.close(); 32 | 33 | delete it; 34 | delete hdt; 35 | } catch(std::exception& e) { 36 | cerr << e.what() << endl; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /libhdt/tests/dictionaries.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace hdt; 5 | 6 | int 7 | main(int argc, char **argv) 8 | { 9 | char error = 0; 10 | try 11 | { 12 | HDT *hdt = HDTManager::mapHDT("../data/literals.hdt"); 13 | Dictionary *dict = hdt ->getDictionary(); 14 | TripleID tid; 15 | IteratorTripleID *iter = hdt ->getTriples() ->search( tid ); 16 | while ( iter -> hasNext() ) 17 | { 18 | TripleID* id = iter ->next(); 19 | unsigned int global_object_id = id ->getObject(); 20 | if (global_object_id < dict ->getMaxSubjectID()) 21 | { 22 | cerr << "Object id is less than max subject id" << endl; 23 | error = 1; 24 | break; 25 | } 26 | unsigned int local_object_id = dict ->getMapping() == MAPPING2 ? 27 | global_object_id - dict ->getNshared() : 28 | global_object_id - dict ->getNshared() - dict ->getNsubjects() + 2; 29 | if ( local_object_id > dict ->getNobjectsLiterals() ) 30 | { 31 | cerr << "Local Literal id is greater than number of total literals " << endl; 32 | error = 2; 33 | break; 34 | } 35 | } 36 | delete iter; 37 | delete hdt; 38 | } 39 | catch (std::exception& e) 40 | { 41 | cerr << e.what() << endl; 42 | error = 1; 43 | } 44 | if ( error > 0 ) 45 | return 1; 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /libhdt/tests/genIndex.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Tutorial01.cpp 3 | * 4 | * Created on: 02/03/2011 5 | * Author: mck 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "../src/util/StopWatch.hpp" 17 | 18 | using namespace hdt; 19 | using namespace std; 20 | 21 | 22 | void help() { 23 | cout << "$ hdtSearch [options] " << endl; 24 | cout << "\t-h\t\t\tThis help" << endl; 25 | 26 | //cout << "\t-v\tVerbose output" << endl; 27 | } 28 | 29 | int main(int argc, char **argv) { 30 | int c; 31 | string inputFile; 32 | 33 | while( (c = getopt(argc,argv,"h"))!=-1) { 34 | switch(c) { 35 | case 'h': 36 | help(); 37 | break; 38 | default: 39 | cout << "ERROR: Unknown option" << endl; 40 | help(); 41 | return 1; 42 | } 43 | } 44 | 45 | if(argc-optind<1) { 46 | cout << "ERROR: You must supply an HDT File" << endl << endl; 47 | help(); 48 | return 1; 49 | } 50 | 51 | inputFile = argv[optind]; 52 | 53 | 54 | try { 55 | StdoutProgressListener progress; 56 | HDT *hdt = HDTManager::mapIndexedHDT(inputFile.c_str(), &progress); 57 | 58 | delete hdt; 59 | } catch (std::exception& e) { 60 | cerr << "ERROR: " << e.what() << endl; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /libhdt/tests/getobj.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "../src/util/StopWatch.hpp" 11 | 12 | using namespace hdt; 13 | using namespace std; 14 | 15 | int interruptSignal = 0; 16 | 17 | void signalHandler(int sig) 18 | { 19 | interruptSignal = 1; 20 | } 21 | 22 | void help() { 23 | cout << "$ hdtSearch [options] " << endl; 24 | cout << "\t-h\t\t\tThis help" << endl; 25 | cout << "\t-q\t\t\tLaunch query and exit." << endl; 26 | cout << "\t-o\t\tSave query output to file." << endl; 27 | cout << "\t-m\t\t\tDo not show results, just measure query time." << endl; 28 | 29 | //cout << "\t-v\tVerbose output" << endl; 30 | } 31 | 32 | 33 | int main(int argc, char **argv) { 34 | int c; 35 | string query, inputFile, outputFile; 36 | bool measure = false; 37 | 38 | while( (c = getopt(argc,argv,"hq:o:m"))!=-1) { 39 | switch(c) { 40 | case 'h': 41 | help(); 42 | break; 43 | case 'q': 44 | query = optarg; 45 | break; 46 | case 'o': 47 | outputFile = optarg; 48 | break; 49 | case 'm': 50 | measure = true; 51 | break; 52 | default: 53 | cout << "ERROR: Unknown option" << endl; 54 | help(); 55 | return 1; 56 | } 57 | } 58 | 59 | if(argc-optind<1) { 60 | cout << "ERROR: You must supply an HDT File" << endl << endl; 61 | help(); 62 | return 1; 63 | } 64 | 65 | inputFile = argv[optind]; 66 | 67 | try { 68 | HDT *hdt = HDTManager::mapHDT(inputFile.c_str()); 69 | 70 | cout << hdt->getDictionary()->idToString(65449489, OBJECT) << endl; 71 | 72 | //hdt->generateIndex(); 73 | 74 | //hdt->saveToHDT(inputFile.c_str()); 75 | 76 | delete hdt; 77 | } catch (std::exception& e) { 78 | cerr << "ERROR: " << e.what() << endl; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /libhdt/tests/kyoto.cpp: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_KYOTO 2 | #include 3 | #endif 4 | 5 | using namespace std; 6 | 7 | #ifdef HAVE_KYOTO 8 | using namespace kyotocabinet; 9 | #endif 10 | 11 | // main routine 12 | int main(int argc, char** argv) { 13 | #ifdef HAVE_KYOTO 14 | // create the database object 15 | TreeDB db; 16 | 17 | // open the database 18 | if (!db.open("casket.kch", PolyDB::OWRITER | PolyDB::OCREATE)) { 19 | cerr << "open error: " << db.error().name() << endl; 20 | } 21 | 22 | // store records 23 | if (!db.set("foo", "hop") || 24 | !db.set("bar", "step") || 25 | !db.set("baz", "jump")) { 26 | cerr << "set error: " << db.error().name() << endl; 27 | } 28 | 29 | // retrieve a record 30 | string value; 31 | if (db.get("foo", &value)) { 32 | cout << value << endl; 33 | } else { 34 | cerr << "get error: " << db.error().name() << endl; 35 | } 36 | 37 | // traverse records 38 | DB::Cursor* cur = db.cursor(); 39 | cur->jump(); 40 | string ckey, cvalue; 41 | while (cur->get(&ckey, &cvalue, true)) { 42 | cout << ckey << ":" << cvalue << endl; 43 | } 44 | delete cur; 45 | 46 | // close the database 47 | if (!db.close()) { 48 | cerr << "close error: " << db.error().name() << endl; 49 | } 50 | #endif 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /libhdt/tests/listener.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Tutorial01.cpp 3 | * 4 | * Created on: 02/03/2011 5 | * Author: mck 6 | */ 7 | 8 | #include 9 | 10 | using namespace std; 11 | 12 | class ProgressListener { 13 | public: 14 | virtual void notifyProgress(float level, const char *section)=0; 15 | }; 16 | 17 | class IntermediateListener : public ProgressListener { 18 | ProgressListener *child; 19 | float min, max; 20 | public: 21 | IntermediateListener(ProgressListener *child) 22 | : child(child), min(0), max(100) { 23 | } 24 | 25 | virtual void notifyProgress(float level, const char *section) { 26 | float newLevel = min + level*(max-min)/100; 27 | child->notifyProgress(newLevel, section); 28 | } 29 | 30 | void setRange(float min, float max) { 31 | this->min=min; 32 | this->max=max; 33 | } 34 | }; 35 | 36 | class ConvertProgress : public ProgressListener { 37 | 38 | public: 39 | void notifyProgress(float level, const char *section) { 40 | cout << "Progress: " << level << " " << section << endl; 41 | } 42 | 43 | }; 44 | 45 | int main(int argc, char **argv) { 46 | ConvertProgress progress; 47 | 48 | IntermediateListener iListener(&progress); 49 | 50 | iListener.setRange(0,30); 51 | for(int i=0;i<100;i+=2){ 52 | iListener.notifyProgress(i, "Process 1"); 53 | } 54 | 55 | iListener.setRange(30,60); 56 | for(int i=0;i<100;i+=2){ 57 | iListener.notifyProgress(i, "Process 2"); 58 | } 59 | 60 | iListener.setRange(60,100); 61 | for(int i=0;i<100;i+=2){ 62 | iListener.notifyProgress(i, "Process 3"); 63 | } 64 | 65 | } 66 | 67 | -------------------------------------------------------------------------------- /libhdt/tests/logarr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * streamtest.cpp 3 | * 4 | * Created on: 28/08/2011 5 | * Author: mck 6 | */ 7 | 8 | #include 9 | 10 | #include "../src/sequence/LogSequence2.hpp" 11 | #include "../src/util/StopWatch.hpp" 12 | 13 | using namespace hdt; 14 | using namespace std; 15 | 16 | int main(int argc, char **argv) { 17 | StopWatch st; 18 | 19 | int num = 100; 20 | 21 | LogSequence2 arr(bits(num), num); 22 | cout << "Bits: " << bits(num) << " Val: "< 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "../src/dictionary/FourSectionDictionary.hpp" 19 | 20 | #include "../src/util/StopWatch.hpp" 21 | 22 | using namespace hdt; 23 | using namespace std; 24 | 25 | int main(int argc, char **argv) { 26 | int c; 27 | string query, inputFile, outputFile; 28 | bool measure = false; 29 | 30 | while( (c = getopt(argc,argv,"hq:o:m"))!=-1) { 31 | switch(c) { 32 | case 'h': 33 | break; 34 | case 'q': 35 | query = optarg; 36 | break; 37 | case 'o': 38 | outputFile = optarg; 39 | break; 40 | case 'm': 41 | measure = true; 42 | break; 43 | default: 44 | cout << "ERROR: Unknown option" << endl; 45 | return 1; 46 | } 47 | } 48 | 49 | if(argc-optind<1) { 50 | cout << "ERROR: You must supply an input and HDT File" << endl << endl; 51 | return 1; 52 | } 53 | 54 | inputFile = argv[optind]; 55 | 56 | try { 57 | 58 | // CONVERT 59 | StdoutProgressListener progress; 60 | ControlInformation ci; 61 | FourSectionDictionary dict; 62 | 63 | ifstream in(inputFile.c_str(), ios::binary); 64 | 65 | ci.load(in); 66 | dict.load(in, ci, &progress); 67 | } catch (std::exception& e) { 68 | cerr << "ERROR: " << e.what() << endl; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /libhdt/tests/parse.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Tutorial01.cpp 3 | * 4 | * Created on: 02/03/2011 5 | * Author: mck 6 | */ 7 | 8 | #include 9 | #include 10 | #include "../src/util/StopWatch.hpp" 11 | 12 | 13 | using namespace std; 14 | using namespace hdt; 15 | 16 | class Processor : public RDFCallback { 17 | 18 | size_t count; 19 | StopWatch st; 20 | public: 21 | Processor() :count(0) { 22 | st.reset(); 23 | } 24 | 25 | void processTriple(const TripleString &triple, unsigned long long pos) { 26 | count++; 27 | if(count%1000000 == 0) { 28 | cout << (count/1000000) << " M triples parsed in " << st << endl; 29 | st.reset(); 30 | } 31 | } 32 | }; 33 | 34 | 35 | int main(int argc, char **argv) { 36 | Processor proc; 37 | StopWatch st; 38 | 39 | RDFParserCallback *parser = RDFParserCallback::getParserCallback(NTRIPLES); 40 | 41 | parser->doParse(argv[1], "http://dataset.com/dataset", NTRIPLES, true, &proc); 42 | 43 | cout << argv[1] << " parsed in " << st << endl; 44 | 45 | delete parser; 46 | } 47 | -------------------------------------------------------------------------------- /libhdt/tests/serd.cpp: -------------------------------------------------------------------------------- 1 | 2 | #ifdef HAVE_CONFIG_H 3 | #include 4 | #endif 5 | 6 | #include "RDFParser.hpp" 7 | 8 | using namespace std; 9 | using namespace hdt; 10 | 11 | int main(int argc, char **argv) 12 | { 13 | #ifdef HAVE_SERD 14 | // If libhdt was not built with serd support, this will fail 15 | cout << "calling serd " << endl; 16 | RDFParserCallback::getParserCallback(TURTLE); 17 | #endif 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /libhdt/tests/streamtest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * streamtest.cpp 3 | * 4 | * Created on: 28/08/2011 5 | * Author: mck 6 | */ 7 | 8 | #include 9 | 10 | #if 0 11 | #include "../src/sequence/LogSequence.hpp" 12 | #else 13 | #include "../src/sequence/LogSequence2.hpp" 14 | #endif 15 | 16 | #include "../src/util/StopWatch.hpp" 17 | 18 | using namespace hdt; 19 | using namespace std; 20 | 21 | int main(int argc, char **argv) { 22 | StopWatch st; 23 | 24 | #if 0 25 | LogStream logStream; 26 | #else 27 | LogSequence2 logStream(bits(1000)); 28 | #endif 29 | 30 | #if 0 31 | std::vector v; 32 | for(unsigned int i=0; i<10; i++) { 33 | v.push_back(i); 34 | } 35 | 36 | VectorIterator it(v); 37 | st.reset(); 38 | logStream.add(it); 39 | 40 | cout << "Added in " << st << endl; 41 | 42 | ofstream out("tmp.bin", ios::binary); 43 | 44 | /*size_t tmpvar = (size_t) 0x1122334455667788ul; 45 | unsigned int ptr[] = { 0x55667788, 0x11223344}; 46 | out.write((char*)&tmpvar, sizeof(size_t)); 47 | out.write((char*)&tmpvar, sizeof(size_t)); 48 | out.write((char*)ptr, sizeof(size_t)); 49 | out.write((char*)ptr, sizeof(size_t));*/ 50 | logStream.save(out); 51 | out.close(); 52 | 53 | #else 54 | #if 0 55 | ifstream in("tmp.bin", ios::binary); 56 | logStream.load(in); 57 | in.close(); 58 | #else 59 | for(unsigned int i=0; i<100; i++) { 60 | logStream.push_back(i); 61 | } 62 | logStream.reduceBits(); 63 | #endif 64 | 65 | #endif 66 | 67 | st.reset(); 68 | for(unsigned int i=0; i 3 | 4 | using namespace std; 5 | 6 | inline size_t maxVal1(unsigned int numbits) { 7 | return ~((size_t)-1< "<< hex << maxVal1(i) << " = " << maxVal2(i) << dec << endl; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /libhdt/tests/wav.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Tutorial01.cpp 3 | * 4 | * Created on: 02/03/2011 5 | * Author: mck 6 | */ 7 | #if HAVE_CDS 8 | 9 | #include 10 | #include 11 | 12 | using namespace std; 13 | 14 | int main(int argc, char **argv) { 15 | //unsigned int arr[] = { 1,2,4,5,1,2,3,1,4,3,2,1 }; 16 | unsigned int arr[] = { 3,4,1,2,1 }; 17 | unsigned int numel = sizeof(arr)/sizeof(unsigned int); 18 | 19 | vector vector; 20 | 21 | for(unsigned int i=0;irank(i, sequence->getLength()); 33 | cout << "Rank item: " << i << " => " << rank << endl; 34 | for(unsigned int j=1;j<=rank;j++){ 35 | cout << "\t" << sequence->select(i, j)<save(out); 42 | out.close(); 43 | 44 | delete sequence; 45 | 46 | cout << "------" << endl; 47 | 48 | ifstream in("tmp"); 49 | cds_static::Sequence *seq2 = cds_static::Sequence::load(in); 50 | 51 | for(unsigned int i=1;i<=5;i++){ 52 | unsigned int rank = sequence->rank(i, sequence->getLength()); 53 | cout << "Rank item: " << i << " => " << rank << endl; 54 | for(unsigned int j=1;j<=rank;j++){ 55 | cout << "\t" << sequence->select(i, j)< 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include "../src/dictionary/LiteralDictionary.hpp" 21 | #include "../src/dictionary/FourSectionDictionary.hpp" 22 | 23 | #include "../src/util/StopWatch.hpp" 24 | #include "../src/util/fileUtil.hpp" 25 | 26 | 27 | using namespace hdt; 28 | using namespace std; 29 | 30 | 31 | int main(int argc, char **argv) { 32 | char *inputFile, *headerFile, *outputFile; 33 | 34 | if(argc!=4) { 35 | cout << "ERROR: Specify the arguments:" << endl << "replaceHeader " << endl << endl; 36 | return 1; 37 | } 38 | 39 | inputFile = argv[1]; 40 | outputFile = argv[2]; 41 | headerFile = argv[3 ]; 42 | 43 | try { 44 | // LOAD 45 | HDT *hdt = HDTManager::mapHDT(inputFile); 46 | 47 | // Replace header 48 | Header *head= hdt->getHeader(); 49 | head->clear(); 50 | 51 | ifstream in(headerFile, ios::binary); 52 | ControlInformation ci; 53 | ci.setFormat(HDTVocabulary::HEADER_NTRIPLES); 54 | ci.setUint("length", fileUtil::getSize(in)); 55 | 56 | head->load(in, ci); 57 | in.close(); 58 | 59 | // SAVE 60 | hdt->saveToHDT(outputFile); 61 | 62 | delete hdt; 63 | } catch (std::exception& e) { 64 | cerr << "ERROR: " << e.what() << endl; 65 | return 1; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /libhdt/tools/searchHeader.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "../include/Header.hpp" 7 | #include "../include/Iterator.hpp" 8 | #include "../include/SingleTriple.hpp" 9 | #include "../src/hdt/BasicHDT.hpp" 10 | 11 | using namespace hdt; 12 | using namespace std; 13 | 14 | void help() { 15 | cout << "$ searchHeader \"s p o\"" << endl; 16 | cout << "\t-h\t\t\tThis help" << endl; 17 | } 18 | 19 | int main(int argc, char **argv) { 20 | int c; 21 | char *inputFile = NULL, *query = NULL; 22 | 23 | while ((c = getopt(argc, argv, "h")) != -1) { 24 | switch (c) { 25 | case 'h': 26 | help(); 27 | break; 28 | } 29 | } 30 | 31 | if (argc - optind < 2) { 32 | cout << "ERROR: You must supply an input HDT and a query" << endl 33 | << endl; 34 | help(); 35 | return 1; 36 | } 37 | inputFile = argv[optind]; 38 | query = argv[optind + 1]; 39 | 40 | try { 41 | // LOAD 42 | //HDT *hdt = HDTManager::mapHDT(inputFile); 43 | BasicHDT *hdt = new BasicHDT(); 44 | ProgressListener *listener=NULL; 45 | hdt->loadHeader(inputFile,listener); 46 | 47 | Header *head = hdt->getHeader(); 48 | 49 | TripleString ti; 50 | ti.read(query); 51 | string subject = ti.getSubject(); 52 | string predicate = ti.getPredicate(); 53 | string object = ti.getObject(); 54 | 55 | if (!subject.compare(0, 1, "?")) { 56 | 57 | subject = ""; 58 | } 59 | if (!predicate.compare(0, 1, "?")) { 60 | predicate = ""; 61 | } 62 | if (!object.compare(0, 1, "?")) { 63 | object = ""; 64 | } 65 | IteratorTripleString *it = head->search((char*) subject.c_str(), 66 | (char*) predicate.c_str(), 67 | (char*) object.c_str()); 68 | while (it->hasNext()) { 69 | TripleString* ts = it->next(); 70 | cout << *ts< 25 | # Copyright (c) 2012 Zack Weinberg 26 | # Copyright (c) 2013 Roy Stogner 27 | # Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov 28 | # Copyright (c) 2015 Paul Norman 29 | # Copyright (c) 2015 Moritz Klammler 30 | # 31 | # Copying and distribution of this file, with or without modification, are 32 | # permitted in any medium without royalty provided the copyright notice 33 | # and this notice are preserved. This file is offered as-is, without any 34 | # warranty. 35 | 36 | #serial 18 37 | 38 | AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX]) 39 | AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [AX_CXX_COMPILE_STDCXX([11], [$1], [$2])]) 40 | -------------------------------------------------------------------------------- /m4/ax_require_defined.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # https://www.gnu.org/software/autoconf-archive/ax_require_defined.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_REQUIRE_DEFINED(MACRO) 8 | # 9 | # DESCRIPTION 10 | # 11 | # AX_REQUIRE_DEFINED is a simple helper for making sure other macros have 12 | # been defined and thus are available for use. This avoids random issues 13 | # where a macro isn't expanded. Instead the configure script emits a 14 | # non-fatal: 15 | # 16 | # ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found 17 | # 18 | # It's like AC_REQUIRE except it doesn't expand the required macro. 19 | # 20 | # Here's an example: 21 | # 22 | # AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG]) 23 | # 24 | # LICENSE 25 | # 26 | # Copyright (c) 2014 Mike Frysinger 27 | # 28 | # Copying and distribution of this file, with or without modification, are 29 | # permitted in any medium without royalty provided the copyright notice 30 | # and this notice are preserved. This file is offered as-is, without any 31 | # warranty. 32 | 33 | #serial 2 34 | 35 | AC_DEFUN([AX_REQUIRE_DEFINED], [dnl 36 | m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])]) 37 | ])dnl AX_REQUIRE_DEFINED 38 | -------------------------------------------------------------------------------- /m4/gnulib-tool.m4: -------------------------------------------------------------------------------- 1 | # gnulib-tool.m4 serial 2 2 | dnl Copyright (C) 2004-2005, 2009-2014 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl The following macros need not be invoked explicitly. 8 | dnl Invoking them does nothing except to declare default arguments 9 | dnl for "gnulib-tool --import". 10 | 11 | dnl Usage: gl_LOCAL_DIR([DIR]) 12 | AC_DEFUN([gl_LOCAL_DIR], []) 13 | 14 | dnl Usage: gl_MODULES([module1 module2 ...]) 15 | AC_DEFUN([gl_MODULES], []) 16 | 17 | dnl Usage: gl_AVOID([module1 module2 ...]) 18 | AC_DEFUN([gl_AVOID], []) 19 | 20 | dnl Usage: gl_SOURCE_BASE([DIR]) 21 | AC_DEFUN([gl_SOURCE_BASE], []) 22 | 23 | dnl Usage: gl_M4_BASE([DIR]) 24 | AC_DEFUN([gl_M4_BASE], []) 25 | 26 | dnl Usage: gl_PO_BASE([DIR]) 27 | AC_DEFUN([gl_PO_BASE], []) 28 | 29 | dnl Usage: gl_DOC_BASE([DIR]) 30 | AC_DEFUN([gl_DOC_BASE], []) 31 | 32 | dnl Usage: gl_TESTS_BASE([DIR]) 33 | AC_DEFUN([gl_TESTS_BASE], []) 34 | 35 | dnl Usage: gl_WITH_TESTS 36 | AC_DEFUN([gl_WITH_TESTS], []) 37 | 38 | dnl Usage: gl_LIB([LIBNAME]) 39 | AC_DEFUN([gl_LIB], []) 40 | 41 | dnl Usage: gl_LGPL or gl_LGPL([VERSION]) 42 | AC_DEFUN([gl_LGPL], []) 43 | 44 | dnl Usage: gl_MAKEFILE_NAME([FILENAME]) 45 | AC_DEFUN([gl_MAKEFILE_NAME], []) 46 | 47 | dnl Usage: gl_LIBTOOL 48 | AC_DEFUN([gl_LIBTOOL], []) 49 | 50 | dnl Usage: gl_MACRO_PREFIX([PREFIX]) 51 | AC_DEFUN([gl_MACRO_PREFIX], []) 52 | 53 | dnl Usage: gl_PO_DOMAIN([DOMAIN]) 54 | AC_DEFUN([gl_PO_DOMAIN], []) 55 | 56 | dnl Usage: gl_VC_FILES([BOOLEAN]) 57 | AC_DEFUN([gl_VC_FILES], []) 58 | -------------------------------------------------------------------------------- /rdf2hdt/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /rdf2hdt/rdf2hdt.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | CONFIG += console c++11 3 | 4 | SOURCES += \ 5 | rdf2hdt.cpp 6 | 7 | LIBCDS = ../libcds-v1.0.12 8 | 9 | # Using Hard-coded Makefile 10 | INCLUDEPATH += $${LIBCDS}/includes ../hdt-lib/include/ . 11 | #LIBS += $${LIBCDS}/lib/libcds.a ../hdt-lib/libhdt.a 12 | 13 | win32:LIBS += ../hdt-lib/qmake/win32/hdt.lib $${LIBCDS}/qmake/win32/cds.lib "F:\git\zlib\bin\zlib.lib" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10586.0\um\x64\opengl32.lib" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10586.0\um\x64\glu32.lib" "F:\git\serd\bin\serd.lib" 14 | 15 | PRE_TARGETDEPS += $$LIBS 16 | --------------------------------------------------------------------------------