diff --git a/.gitignore b/.gitignore index e5a731db..6d927335 100644 --- a/.gitignore +++ b/.gitignore @@ -24,7 +24,6 @@ rdf2hdt replaceHeader libhdt/examples/* libhdt/.libs -libcds/.libs # Autotools m4/ @@ -66,7 +65,6 @@ stamp-h1 *.a **/examples/* **/tests/* -libcds-v1.0.12/includes !**/examples/*.cpp !**/tests/*.cpp *.o diff --git a/.travis.yml b/.travis.yml index f92c6126..5f63c62a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,7 +47,6 @@ script: - ./configure --prefix=$LOCAL CXX=$HDT_CPP - make -j2 # Make and run selected tests. Most tests in HDT are failing - - make check -j2 -C libcds || ( cat libcds/tests/test-suite.log && exit -1) - make check -j2 -C libhdt || ( cat libhdt/tests/test-suite.log && exit -1) # Install - make install @@ -61,10 +60,7 @@ script: - test -f $LOCAL/bin/replaceHeader - test -f $LOCAL/bin/searchHeader - test -f $LOCAL/lib/libhdt.la - - test -f $LOCAL/lib/libcds.la - "if [ \"$TRAVIS_OS_NAME\" = \"linux\" ]; then test -L $LOCAL/lib/libhdt.so; fi" - - "if [ \"$TRAVIS_OS_NAME\" = \"linux\" ]; then test -L $LOCAL/lib/libcds.so; fi" - "if [ \"$TRAVIS_OS_NAME\" = \"osx\" ]; then test -L $LOCAL/lib/libhdt.dylib; fi" - - "if [ \"$TRAVIS_OS_NAME\" = \"osx\" ]; then test -L $LOCAL/lib/libcds.dylib; fi" - test -f $LOCAL/lib/pkgconfig/hdt.pc - test -f $LOCAL/lib/pkgconfig/cds.pc diff --git a/Dockerfile b/Dockerfile index 1078c138..51c1d282 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,7 +33,6 @@ RUN apt update; \ # Copy in libraries and binaries from build stage. COPY --from=build \ - /usr/local/lib/libcds* \ /usr/local/lib/libhdt* \ /usr/local/lib/ COPY --from=build \ diff --git a/Makefile.am b/Makefile.am index 11d2e1f1..c6d6a18c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ AUTOMAKE_OPTIONS = subdir-objects -SUBDIRS = libcds libhdt +SUBDIRS = libhdt ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = m4/gnulib-cache.m4 diff --git a/configure.ac b/configure.ac index 0b71ab1e..13d8f8b3 100644 --- a/configure.ac +++ b/configure.ac @@ -28,17 +28,9 @@ AC_MSG_CHECKING(whether to enable optimizations) AC_ARG_ENABLE([optimization], AS_HELP_STRING([--enable-optimization],[Build library with optimization parameters [default=yes]]), [AC_MSG_RESULT(${enableval})], - [CXXFLAGS="${CXXFLAGS} -g -O2 -std=c++11"] + [CXXFLAGS="${CXXFLAGS} -g -O2 -std=c++14"] [AC_MSG_RESULT(yes)]) -AC_MSG_CHECKING(whether to build libcds) -AC_ARG_ENABLE([libcds], - AS_HELP_STRING([--enable-libcds],[Build libcds [default=yes]]), - [AC_MSG_RESULT(${enableval})], - [enable_cds=yes] - [AC_MSG_RESULT(yes)]) -AM_CONDITIONAL([WANTS_LIBCDS], [test x$enable_cds != xno]) - # Dependencies AC_ARG_WITH([zlib], AS_HELP_STRING([--with-zlib], [Use z library [default=yes] ]), @@ -94,8 +86,5 @@ AC_CONFIG_FILES([ libhdt/Makefile libhdt/tools/Makefile libhdt/tests/Makefile - libcds/cds.pc - libcds/Makefile - libcds/tests/Makefile ]) AC_OUTPUT diff --git a/hdt-it/.cproject b/hdt-it/.cproject deleted file mode 100644 index a58e5c8c..00000000 --- a/hdt-it/.cproject +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/hdt-it/.gitignore b/hdt-it/.gitignore deleted file mode 100644 index 3f4ae9cf..00000000 --- a/hdt-it/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -Makefile -Makefile.Debug -Makefile.Release -unix/ -win32/ -macx/ -hdt-it.pro.user* -object_script.* diff --git a/hdt-it/.project b/hdt-it/.project deleted file mode 100644 index 46c9a264..00000000 --- a/hdt-it/.project +++ /dev/null @@ -1,27 +0,0 @@ - - - hdt-it - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - diff --git a/hdt-it/Camera.cpp b/hdt-it/Camera.cpp deleted file mode 100644 index 61c3b23c..00000000 --- a/hdt-it/Camera.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Camera.cpp - * - * Created on: 04/03/2011 - * Author: mck - */ - -#include - -#include "Camera.h" - -Camera::Camera() : - rotationAnimation(this, "camRotation") -{ - widgetWidth = 800; - widgetHeight = 600; - toDefaultValues(); - - connect(this, SIGNAL(rotationChanged()), this, SIGNAL(cameraChanged())); - connect(this, SIGNAL(zoomChanged()), this, SIGNAL(cameraChanged())); - connect(this, SIGNAL(offsetChanged()), this, SIGNAL(cameraChanged())); -} - -Camera::~Camera() -{ -} - -qreal Camera::getZoom() -{ - return zoom; -} - -void Camera::setZoom(double newz) -{ - zoom = newz; - zoom = zoom < 0.5 ? 0.5 : zoom; - emit zoomChanged(); -} - -void Camera::increaseZoom(int dif) -{ - zoom += 0.001*dif*zoom; - zoom = zoom < 0.5 ? 0.5 : zoom; - emit zoomChanged(); -} - -void Camera::decreaseZoom(int dif){ - zoom -= 0.001*dif*zoom; - zoom = zoom < 0.5 ? 0.5 : zoom; - emit zoomChanged(); -} - -void Camera::multiplyZoom(int mult) -{ - zoom *= mult; - zoom = zoom < 0.5 ? 0.5 : zoom; - emit zoomChanged(); -} - - -void Camera::setOffset(double x,double y){ - offx = x; - offy = y; - if(offx<-1.0) offx=-1.0; - if(offx>0.0) offx=0.0; - if(offy<-1.0) offy=-1.0; - if(offy>0.0) offy=0.0; - emit offsetChanged(); -} - -void Camera::setOffset(QPointF &rect){ - this->setOffset(rect.x(), rect.y()); -} - -QPointF Camera::getOffset() { - return QPointF(offx, offy); -} - -void Camera::moveOffset(double x,double y){ - setOffset(offx + x / (zoom*widgetWidth), offy - y / (zoom*widgetHeight)); -} - -void Camera::setRotation(double x,double y){ - rotx = x; - roty = y; - emit rotationChanged(); -} - -void Camera::setRotation(QPointF &rect){ - this->setRotation(rect.x(), rect.y()); -} - -void Camera::animateRotation(double x, double y) { - rotationAnimation.stop(); - rotationAnimation.setDuration(500); - rotationAnimation.setEasingCurve(QEasingCurve::InOutQuad); - rotationAnimation.setStartValue(QPointF(rotx, roty)); - rotationAnimation.setEndValue(QPointF(x,y)); - rotationAnimation.start(); -} - -QPointF Camera::getRotation() { - return QPointF(rotx, roty); -} - -void Camera::rotateCamera(double x,double y){ - rotationAnimation.stop(); - rotx += 0.5 * x; - roty += 0.5 * y; - emit rotationChanged(); -} - -void Camera::toDefaultValues(){ - rotx = roty = 0; - zoom = 1; - offx = -0.5; - offy = -0.5; - emit rotationChanged(); - emit zoomChanged(); - emit offsetChanged(); -} - -void Camera::setScreenSize(int w, int h){ - widgetWidth = w; - widgetHeight = h; - - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - - GLdouble aspect, left, right, bottom, top; - - aspect = (GLdouble) widgetWidth / (GLdouble) widgetHeight; - - if ( aspect < 1.0 ) { - left = -0.75; - right = 0.75; - bottom = -1.0 * ( 1.0 / aspect ); - top = 1.0 * ( 1.0 / aspect ); - } else { - left = -0.75 * aspect; - right = 0.75 * aspect; - bottom = -1.0; - top = 1.0; - } - - glMatrixMode( GL_PROJECTION ); - glLoadIdentity(); - glOrtho( left*widgetWidth, right*widgetWidth, bottom*widgetHeight, top*widgetHeight, -10, 10 ); - glMatrixMode( GL_MODELVIEW ); -} - -void Camera::applyTransform(){ - glScaled(1.1*zoom, 1.1*zoom, 1.0); - - glScalef(widgetWidth, widgetHeight, 1.0); - - glTranslatef(offx, offy, 1); - - glTranslatef(0.5, 0.5, 0.5); - glRotatef(roty, 1, 0, 0); - glRotatef(rotx, 0, 1, 0); - glTranslatef(-0.5, -0.5, -0.5); -} - -void Camera::setFrontView() -{ - animateRotation(0, 0); -} - -void Camera::setLeftView() -{ - animateRotation(90,0); -} - -void Camera::setTopView() -{ - animateRotation(0,90); -} - -void Camera::set3DView() -{ - animateRotation(-45,45); -} - -bool Camera::isFrontView() -{ - return rotx==0 && roty==0; -} - -bool Camera::isLeftView() -{ - return rotx==90 && roty==0; -} - -bool Camera::isTopView() -{ - return rotx==0 && roty==90; -} - -bool Camera::is3DView() -{ - return rotx==-45 && roty==45; -} - -void Camera::toDefaultValuesAnimated() -{ - QPropertyAnimation *rotAnim = new QPropertyAnimation(this, "camRotation"); - rotAnim->setEasingCurve(QEasingCurve::InOutQuad); - rotAnim->setDuration(400); - rotAnim->setStartValue(QPointF(rotx, roty)); - rotAnim->setEndValue(QPointF(0,0)); - - QPropertyAnimation *zoomAnim = new QPropertyAnimation(this, "camZoom"); - zoomAnim->setEasingCurve(QEasingCurve::InOutQuad); - zoomAnim->setDuration(400); - zoomAnim->setStartValue(zoom); - zoomAnim->setEndValue(1); - - QPropertyAnimation *offAnim = new QPropertyAnimation(this, "camOffset"); - offAnim->setEasingCurve(QEasingCurve::InOutQuad); - offAnim->setDuration(400); - offAnim->setStartValue(QPointF(offx, offy)); - offAnim->setEndValue(QPointF(-0.5, -0.5)); - - QSequentialAnimationGroup *animationGroup = new QSequentialAnimationGroup(); - - if(offAnim->startValue()!=offAnim->endValue()) - animationGroup->addAnimation(offAnim); - else - delete offAnim; - - if(zoomAnim->startValue()!=zoomAnim->endValue()) - animationGroup->addAnimation(zoomAnim); - else - delete zoomAnim; - - if(rotAnim->startValue()!=rotAnim->endValue()) - animationGroup->addAnimation(rotAnim); - else - delete rotAnim; - - animationGroup->start(QAbstractAnimation::DeleteWhenStopped); -} - -void Camera::stopAnimations() -{ - rotationAnimation.stop(); -} - - diff --git a/hdt-it/Camera.h b/hdt-it/Camera.h deleted file mode 100644 index aa8bd217..00000000 --- a/hdt-it/Camera.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Camera.h - * - * Created on: 04/03/2011 - * Author: mck - */ - -#ifndef CAMERA_H_ -#define CAMERA_H_ - -#include -#include - -#include - -class Camera : public QObject { - Q_OBJECT - Q_PROPERTY(QPointF camRotation READ getRotation WRITE setRotation NOTIFY rotationChanged) - Q_PROPERTY(QPointF camOffset READ getOffset WRITE setOffset NOTIFY offsetChanged) - Q_PROPERTY(qreal camZoom READ getZoom WRITE setZoom NOTIFY zoomChanged) - -private: - double zoom; - double rotx, roty; - double offx, offy; - int widgetWidth, widgetHeight; - QPropertyAnimation rotationAnimation; - - void stopAnimations(); -public: - explicit Camera(); - ~Camera(); - -public: - qreal getZoom(); - void setZoom(double newz); - void increaseZoom(int dif); - void decreaseZoom(int dif); - void multiplyZoom(int mult); - - void setOffset(double x,double y); - void setOffset(QPointF &rect); - QPointF getOffset(); - - void moveOffset(double x,double y); - - QPointF getRotation(); - void setRotation(QPointF &rect); - void setRotation(double x,double y); - void animateRotation(double x,double y); - void rotateCamera(double x,double y); - - void toDefaultValues(); - void toDefaultValuesAnimated(); - - void setScreenSize(int width, int height); - void applyTransform(); - - bool isFrontView(); - bool isLeftView(); - bool isTopView(); - bool is3DView(); - -public slots: - void setFrontView(); - void setLeftView(); - void setTopView(); - void set3DView(); - -signals: - void rotationChanged(); - void zoomChanged(); - void offsetChanged(); - void cameraChanged(); -}; - -#endif /* CAMERA_H_ */ diff --git a/hdt-it/Color.cpp b/hdt-it/Color.cpp deleted file mode 100644 index 8e477d53..00000000 --- a/hdt-it/Color.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Color.cpp - * - * Created on: 04/03/2011 - * Author: mck - */ - -#include -#include - -#include "Color.h" -#include "constants.h" - - Color::Color() { - setRGBA(1,1,1,1); - } - - Color::~Color() { - } - - -void Color::use() { - -} - -/** Invert Color - * @param c Description of the param. - * @return void - */ -void Color::invert() { - r = 1 - r; - g = 1 - g; - b = 1 - b; -} - -void Color::setRGB(double r, double g, double b) { - this->r = r; - this->g = g; - this->b = b; -} - -void Color::setRGBA(double r, double g, double b, double a) { - this->r = r; - this->g = g; - this->b = b; - this->a = a; -} - -/** HSV to RGB - * @param h Description of the param. - * @param s Description of the param. - * @param v Description of the param. - * @param c Description of the param. - * @return void - */ -void Color::setHSV(double h, double s, double v) { - // H is given on [0, 6]. S and V are given on [0, 1]. - // RGB are each returned on [0, 1]. - float m, n, f; - int i; - - if (h == -1) { - setRGB(v, v, v); - return; - } - - i = floor(h); - f = h - i; - if (!(i & 1)) - f = 1 - f; // if i is even - m = v * (1 - s); - n = v * (1 - s * f); - switch (i) { - case 6: - case 0: - setRGB(v, n, m); - break; - case 1: - setRGB(n, v, m); - break; - case 2: - setRGB(m, v, n); - break; - case 3: - setRGB(m, n, v); - break; - case 4: - setRGB(n, m, v); - break; - case 5: - setRGB(v, m, n); - break; - } -} - -QColor Color::asQColor() -{ - QColor c(255*r, 255*g, 255*b, 255*a); - return c; -} - -/**Get Color 2 - * @param val Description of the param. - * @param vmin Description of the param. - * @param vmax Description of the param. - * @param c Description of the param. - * @return void - */ -void ColorRamp2::apply(Color *c, double val, double vmin, double vmax) { - double total = vmax - vmin; - double prop = (vmin + val / total); - - if(vmax==0.0) { - c->setRGB(1.0, 0.0, 0.0); - return; - } - - //std::cout << "h: " << fmod(prop*100,6) << std::endl; - //std::cout << "\tmin: " << vmin << " val: "<< val << " max: " << vmax << " Prop: " << prop << " dv: " << total << std::endl; -#ifdef SCREEN - c->setHSV(fmod(prop*100,6), 1.0 , 0.5 + 0.5 * prop); - c->invert(); -#else - c->setHSV(fmod(prop*100,6), 1.0, 0.3+0.7*prop); - //c->invert(); -#endif - // printf("(%.1f, %.1f, %.1f) %.1f\n", val, vmin, vmax, prop); -} - -/** Get Color - * @param v Description of the param. - * @param vmin Description of the param. - * @param vmax Description of the param. - * @param c Description of the param. - * @return void - */ -void ColorRamp1::apply(Color *c, double v, double vmin, double vmax) { - if (v < vmin) - v = vmin; - if (v > vmax) - v = vmax; - - double dv = vmax - vmin; - - if (v < (vmin + 0.25 * dv)) { - c->setRGB(0, 4 * (v - vmin) / dv, 1); - } else if (v < (vmin + 0.5 * dv)) { - c->setRGB(0, 1 + 4 * (vmin + 0.25 * dv - v) / dv, 1); - } else if (v < (vmin + 0.75 * dv)) { - c->setRGB(4 * (v - vmin - 0.5 * dv) / dv, 1, 0); - } else { - c->setRGB(1, 1 + 4 * (vmin + 0.75 * dv - v) / dv, 0); - } -} - - - diff --git a/hdt-it/Color.h b/hdt-it/Color.h deleted file mode 100644 index 0ede20a1..00000000 --- a/hdt-it/Color.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Color.h - * - * Created on: 04/03/2011 - * Author: mck - */ - -#ifndef COLOR_H_ -#define COLOR_H_ - -#include - -class Color { -public: - double r,g,b,a; - -public: - Color(); - Color(double r, double g, double b); - Color(double r, double g, double b, double a); - virtual ~Color(); - - void use(); - void invert(); - - void setRGB(double r, double g, double b); - void setRGBA(double r, double g, double b, double a); - void setHSV(double h, double s, double v); - QColor asQColor(); -}; - -class ColorRamp { -public: - virtual void apply(Color *co, double v, double vmin, double vmax)=0; -}; - - -class ColorRamp1 : public ColorRamp { -public: - void apply(Color *co, double v, double vmin, double vmax); -}; - - -class ColorRamp2 : public ColorRamp { -public: - void apply(Color *co, double v, double vmin, double vmax); -}; - -#endif /* COLOR_H_ */ diff --git a/hdt-it/Info.plist b/hdt-it/Info.plist deleted file mode 100644 index 7244838c..00000000 --- a/hdt-it/Info.plist +++ /dev/null @@ -1,58 +0,0 @@ - - - - - CFBundleIconFile - hdtico.icns - CFBundlePackageType - APPL - CFBundleGetInfoString - Created by Qt/QMake - CFBundleSignature - ???? - CFBundleExecutable - HDT-it - CFBundleIdentifier - org.rdfhdt.HDT-it - CFBundleDocumentTypes - - - CFBundleTypeExtensions - - hdt - - CFBundleTypeIconFile - hdtico.icns - CFBundleTypeMIMETypes - - binary/rdf-hdt - - CFBundleTypeName - HDT RDF File - CFBundleTypeRole - Editor - LSIsAppleDefaultForType - - - - CFBundleTypeExtensions - - hdt.gz - - CFBundleTypeIconFile - hdtico.icns - CFBundleTypeMIMETypes - - binary/rdf-hdt - - CFBundleTypeName - HDT RDF File - CFBundleTypeRole - Editor - LSIsAppleDefaultForType - - - - - - diff --git a/hdt-it/LICENSE b/hdt-it/LICENSE deleted file mode 100644 index 56fd5d6a..00000000 --- a/hdt-it/LICENSE +++ /dev/null @@ -1,280 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS diff --git a/hdt-it/README.md b/hdt-it/README.md deleted file mode 100644 index af9450a9..00000000 --- a/hdt-it/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# HDT-it! GUI tool for the HDT triple format - -Overview -================= - -HDT-it is a tool that can generate -and consume RDF files in HDT format. It demonstrates the capabilities -of HDT by allowing to search basic triple patterns against HDT files, and -also visualizes the 3D adjacency matrix of the underlying RDF graph to -provide an overview of the dataset distribution. - -Download executable -================= - -An executable version of the tool is available for multiple platforms in http://www.rdfhdt.org/downloads/ - -Compiling -================= - -Dependencies: - -- HDT-Lib -- QT4 (http://doc.qt.io/qt-4.8/) - -Compilation: - -1.Compile the main hdt-lib library. To compile the library run `make` under the directory `hdt-lib`, this will generate the library and tools. -2. Execute Qmake in libcds-v1.0.12: - - $ cd libcds-v1.0.12/qmake - $ qmake - $ make - -3.Execute Qmake in hdt-lib - - $ cd hdt-lib/qmake - $ qmake - $ make - -4.Execute Qmake in hdt-it - - $ cd hdt-it - $ qmake - $ make - -The application should be available in a new hdt-it subfolder (e.g. hdt-it/unix or hdt-it/win32) - -Licensing -================= -Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto -All rights reserved. - -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. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -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 - -Visit our Web Page: www.rdfhdt.org - -Contacting the authors: - - Mario Arias: mario.arias@deri.org - - Javier D. Fernandez: jfergar@infor.uva.es - - Miguel A. Martinez-Prieto: migumar2@infor.uva.es - diff --git a/hdt-it/StopWatch.cpp b/hdt-it/StopWatch.cpp deleted file mode 100644 index 7a2e8d8a..00000000 --- a/hdt-it/StopWatch.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/* - * StopWatch.cpp - * - * Created on: 03/03/2011 - * Author: mck - */ - -#include -#include - -#include // For memcpy() - -#include "StopWatch.hpp" - -StopWatch::StopWatch() { -#ifdef WIN32 - QueryPerformanceFrequency(&frequency); - startCount.QuadPart = 0; - endCount.QuadPart = 0; -#endif - reset(); -} - -#ifdef WIN32 -void StopWatch::reset() { - QueryPerformanceCounter(&startCount); - endCount = startCount; -} - -void StopWatch::stop() { - QueryPerformanceCounter(&endCount); -} - -unsigned long long StopWatch::getUser() { - unsigned long long start = startCount.QuadPart * (1000000.0 / frequency.QuadPart); - unsigned long long end = endCount.QuadPart * (1000000.0 / frequency.QuadPart); - return end - start; -} - -unsigned long long StopWatch::getSystem() { - return getUser(); -} - -unsigned long long StopWatch::getReal() { - return getUser(); -} - -#else -void StopWatch::reset() { - struct rusage ru; - - getrusage(RUSAGE_SELF, &ru); - gettimeofday(&real1, NULL); - - memcpy(&user1, &ru.ru_utime, sizeof(struct timeval)); - memcpy(&system1, &ru.ru_stime, sizeof(struct timeval)); - - memcpy(&user2, &user1, sizeof(struct timeval)); - memcpy(&system2, &system1, sizeof(struct timeval) ); -} - -void StopWatch::stop() { - struct rusage ru; - getrusage(RUSAGE_SELF, &ru); - gettimeofday(&real2, NULL); - - memcpy(&user2, &ru.ru_utime, sizeof(struct timeval)); - memcpy(&system2, &ru.ru_stime, sizeof(struct timeval)); -} - -unsigned long long difference(time_t s1, time_t s2, suseconds_t us1, suseconds_t us2) { - unsigned long long tmp1, tmp2; - - tmp1 = s1 * 1000000 + us1; - tmp2 = s2 * 1000000 + us2; - - return tmp1-tmp2; -} - -unsigned long long StopWatch::getUser() { - return difference(user2.tv_sec,user1.tv_sec, user2.tv_usec,user1.tv_usec); -} - -unsigned long long StopWatch::getSystem() { - return difference(system2.tv_sec,system1.tv_sec, system2.tv_usec,system1.tv_usec); -} - -unsigned long long StopWatch::getReal() { - return difference(real2.tv_sec,real1.tv_sec, real2.tv_usec,real1.tv_usec); -} -#endif - - - - - -std::string StopWatch::getUserStr() { - return toHuman(getUser()); -} -std::string StopWatch::getSystemStr() { - return toHuman(getSystem()); -} -std::string StopWatch::getRealStr() { - return toHuman(getReal()); -} - - -unsigned long long StopWatch::stopUser() { - stop(); - return getUser(); -} - -unsigned long long StopWatch::stopSystem() { - stop(); - return getSystem(); -} - -unsigned long long StopWatch::stopReal() { - stop(); - return getReal(); -} - - -std::string StopWatch::stopUserStr() { - stop(); - return getUserStr(); -} - -std::string StopWatch::stopSystemStr() { - stop(); - return getSystemStr(); -} - -std::string StopWatch::stopRealStr() { - stop(); - return getRealStr(); -} - -std::ostream &operator<<(std::ostream &stream, StopWatch &sw) { - stream << sw.stopRealStr(); - return stream; -} - -std::string StopWatch::toHuman(unsigned long long time) { - unsigned int tot_secs = time/1000000; - - unsigned int hours = tot_secs/3600; - unsigned int mins = (tot_secs/60) % 60; - unsigned int secs = (tot_secs % 60); - unsigned int ms = (time%1000000)/1000; - unsigned int us = time%1000; - - std::ostringstream out; - if(hours>0) { - out << hours << " hour "; - } - if(mins>0) { - out << mins << " min "; - } - if(secs>0) { - out << secs << " sec "; - } - if(ms>0) { - out << ms << " ms "; - } - if(us>0){ - out << us << " us"; - } - return out.str(); -} diff --git a/hdt-it/StopWatch.hpp b/hdt-it/StopWatch.hpp deleted file mode 100644 index c10b0814..00000000 --- a/hdt-it/StopWatch.hpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * StopWatch.hpp - * - * Created on: 03/03/2011 - * Author: mck - */ - -#ifndef STOPWATCH_HPP_ -#define STOPWATCH_HPP_ - -#ifdef WIN32 -#include -#else -# include -# include -#endif - -#include -#include - -class StopWatch { -private: - -#ifdef WIN32 - LARGE_INTEGER frequency; - LARGE_INTEGER startCount; - LARGE_INTEGER endCount; -#else - struct timeval user1, user2; - struct timeval system1, system2; - struct timeval real1, real2; -#endif - -public: - StopWatch(); - - void reset(); - void stop(); - - unsigned long long getUser(); - unsigned long long getSystem(); - unsigned long long getReal(); - - std::string getUserStr(); - std::string getSystemStr(); - std::string getRealStr(); - - unsigned long long stopUser(); - unsigned long long stopSystem(); - unsigned long long stopReal(); - - std::string stopUserStr(); - std::string stopSystemStr(); - std::string stopRealStr(); - - static std::string toHuman(unsigned long long time); - - friend std::ostream &operator<<(std::ostream &stream, StopWatch &sw); -}; - -#endif /* STOPWATCH_HPP_ */ diff --git a/hdt-it/abouthdt.cpp b/hdt-it/abouthdt.cpp deleted file mode 100644 index cde89f16..00000000 --- a/hdt-it/abouthdt.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "abouthdt.hpp" -#include "ui_abouthdt.h" - -Abouthdt::Abouthdt(QWidget *parent) : - QDialog(parent), - ui(new Ui::Abouthdt) -{ - ui->setupUi(this); -} - -Abouthdt::~Abouthdt() -{ - delete ui; -} diff --git a/hdt-it/abouthdt.hpp b/hdt-it/abouthdt.hpp deleted file mode 100644 index 7a7981c6..00000000 --- a/hdt-it/abouthdt.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef ABOUTHDT_HPP -#define ABOUTHDT_HPP - -#include - -namespace Ui { - class Abouthdt; -} - -class Abouthdt : public QDialog -{ - Q_OBJECT - -public: - explicit Abouthdt(QWidget *parent = 0); - ~Abouthdt(); - -private: - Ui::Abouthdt *ui; -}; - -#endif // ABOUTHDT_HPP diff --git a/hdt-it/abouthdt.ui b/hdt-it/abouthdt.ui deleted file mode 100644 index fb4767dc..00000000 --- a/hdt-it/abouthdt.ui +++ /dev/null @@ -1,173 +0,0 @@ - - - Abouthdt - - - - 0 - 0 - 557 - 377 - - - - - 0 - 0 - - - - - 557 - 377 - - - - - 557 - 377 - - - - About HDT-it! - - - - - 200 - 340 - 341 - 32 - - - - Qt::Horizontal - - - QDialogButtonBox::Close - - - false - - - - - - 10 - 10 - 91 - 81 - - - - - 0 - 0 - - - - - 91 - 81 - - - - - 91 - 81 - - - - border-image: url(:/images/logo-hdt.png); - - - - - - - 110 - 10 - 431 - 321 - - - - - 12 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'.Lucida Grande UI'; font-size:12pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:16pt; font-weight:600;">HDT-it! version 1.1</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande'; font-size:16pt; font-weight:600;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande';">HDT (Header, Dictionary, Triples) is a binary representation for RDF that compresses big datasets in order to store and share big RDF files.</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande';"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande';">HDT-it is a tool that allows generating and consuming HDT files. As an example, the tool allows to search for basic graph patterns, and shows a global 3D Matrix of the RDF distribution.</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande';"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande';">For more information about the tool and our research, please visit:</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande';">HDT Web page: </span><a href="http://www.rdfhdt.org"><span style=" font-family:'Lucida Grande'; font-size:13pt; text-decoration: underline; color:#0000ff;">http://www.rdfhdt.org</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande';">Research group: </span><a href="http://dataweb.infor.uva.es"><span style=" font-family:'Lucida Grande'; font-size:13pt; text-decoration: underline; color:#0000ff;">http://dataweb.infor.uva.es</span></a></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande';"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:14pt; font-weight:600;">HDT was possible thanks to:</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande';"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande';">Mario Arias Gallego &lt;</span><a href="mailto:mario.arias@insight-centre.org"><span style=" text-decoration: underline; color:#0000ff;">mario.arias@insight-centre.org</span></a><span style=" font-family:'Lucida Grande';">&gt;</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande';">Javier D. Fernández García &lt;</span><a href="mailto:jfergar@infor.uva.es"><span style=" text-decoration: underline; color:#0000ff;">jfergar@infor.uva.es</span></a><span style=" font-family:'Lucida Grande';">&gt;</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande';">Miguel A. Martínez-Prieto &lt;</span><a href="mailto:migumar2@infor.uva.es"><span style=" text-decoration: underline; color:#0000ff;">migumar2@infor.uva.es</span></a><span style=" font-family:'Lucida Grande';">&gt;</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande';">Claudio Gutierrez &lt;</span><a href="mailto:cgutierr@dcc.uchile.cl"><span style=" text-decoration: underline; color:#0000ff;">cgutierr@dcc.uchile.cl</span></a><span style=" font-family:'Lucida Grande';">&gt;</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande';"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:14pt; font-weight:600;">And the following organizations:</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande';"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande';">University of Valladolid. </span><a href="http://www.uva.es"><span style=" text-decoration: underline; color:#0000ff;">http://www.uva.es</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande';">University of Chile. </span><a href="http://dcc.uchile.cl"><span style=" text-decoration: underline; color:#0000ff;">http://dcc.uchile.cl</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande';">Insight Centre for Data Analytics </span><a href="http://www.insight-centre.org"><span style=" text-decoration: underline; color:#0000ff;">http://www.insight-centre.org</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande';">(Formerly known as Digital Enterprise Research Insitute. </span><a href="http://www.deri.ie"><span style=" text-decoration: underline; color:#0000ff;">http://www.deri.ie</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande';">National University of Ireland Galway. </span><a href="http://www.nuigalway.ie"><span style=" text-decoration: underline; color:#0000ff;">http://www.nuigalway.ie</span></a></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; text-decoration: underline; color:#0000ff;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:14pt; font-weight:600;">Acknowledgemens:</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; text-decoration: underline; color:#0000ff;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande';">RDF/HDT is a project funded by the Spanish Ministry of Economy and Competitiveness (TIN2009-14009-C02-02); Science Foundation Ireland: Grant No. SFI/08/CE/I1380, Lion-II; Chilean Fondecyt's 1110287 and 1-110066</span></p></body></html> - - - true - - - - - - - buttonBox - accepted() - Abouthdt - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Abouthdt - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/hdt-it/colors.hpp b/hdt-it/colors.hpp deleted file mode 100644 index f1bbc166..00000000 --- a/hdt-it/colors.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef COLORS_HPP -#define COLORS_HPP - -#define SCREEN - -#ifndef SCREEN -#define TEXT_COLOR 0.0, 0.0, 0.0, 1.0 -#define CROSS_COLOR 1.0, 0.0, 0.0, 1.0 -#define TEXT_BACKGROUND_COLOR 1.0, 1.0, 1.0, 0.9 -#define BACKGROUND_COLOR 1, 1, 1, 1 -#define SHARED_AREA_COLOR 0.9, 0.9, 0.9, 1.0 -#define SHARED_AREA_BORDER_COLOR 0.1, 0.1, 0.1, 1.0 -#define AXIS_COLOR 0.1, 0.1, 0.1, 1.0 -#define GRID_COLOR 0.3, 0.3, 0.3, 1.0 -#define RDF_POINT_SIZE 1.5 -#else -#define TEXT_COLOR 1.0, 1.0, 1.0, 1.0 -#define CROSS_COLOR 1.0, 1.0, 1.0, 1.0 -#define TEXT_BACKGROUND_COLOR 0.0, 0.0, 0.0, 0.7 -#define BACKGROUND_COLOR 0, 0, 0, 1 -#define SHARED_AREA_COLOR 0.2, 0.2, 0.2, 1.0 -#define SHARED_AREA_BORDER_COLOR 0.3, 0.3, 0.3, 1.0 -#define AXIS_COLOR 0.8, 0.8, 0.8, 1.0 -#define GRID_COLOR 0.2, 0.2, 0.2, 1.0 -#define RDF_POINT_SIZE 1 -#endif - - -#endif // COLORS_HPP diff --git a/hdt-it/constants.h b/hdt-it/constants.h deleted file mode 100644 index dc955d74..00000000 --- a/hdt-it/constants.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * constants.h - * - * Created on: 04/03/2011 - * Author: mck - */ - -#ifndef CONSTANTS_H_ -#define CONSTANTS_H_ - -#define TIMER_DELAY 50 -#define RENDER_NUM_POINTS 100000 - -#define SCREEN - -#ifndef SCREEN -#define TEXT_COLOR 0.0, 0.0, 0.0, 1.0 -#define CROSS_COLOR 1.0, 0.0, 0.0, 1.0 -#define TEXT_BACKGROUND_COLOR 1.0, 1.0, 1.0, 0.9 -#define BACKGROUND_COLOR 1, 1, 1, 1 -#define SHARED_AREA_COLOR 0.9, 0.9, 0.9, 1.0 -#define SHARED_AREA_BORDER_COLOR 0.1, 0.1, 0.1, 1.0 -#define AXIS_COLOR 0.1, 0.1, 0.1, 1.0 -#define GRID_COLOR 0.3, 0.3, 0.3, 1.0 -#define RDF_POINT_SIZE 1.5 -#else -#define TEXT_COLOR 1.0, 1.0, 1.0, 1.0 -#define CROSS_COLOR 0.0, 0.0, 0.0, 1.0 -#define TEXT_BACKGROUND_COLOR 0.0, 0.0, 0.0, 0.7 -#define BACKGROUND_COLOR 0, 0, 0, 1 -#define SHARED_AREA_COLOR 0.1, 0.1, 0.1, 1.0 -#define SHARED_AREA_BORDER_COLOR 0.2, 0.2, 0.2, 1.0 -#define AXIS_COLOR 0.8, 0.8, 0.8, 1.0 -#define GRID_COLOR 0.2, 0.2, 0.2, 1.0 -#define RDF_POINT_SIZE 1 -#endif - - -#endif /* CONSTANTS_H_ */ diff --git a/hdt-it/createdmg.sh b/hdt-it/createdmg.sh deleted file mode 100755 index 10fcc7c7..00000000 --- a/hdt-it/createdmg.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash - -SRCAPP="macx/HDT-it.app" -FOLDER="macdmg" -VOL="HDT-it" -NAME="HDT-it!" -VERS="1.1" -DMG="$VOL-$VERS.dmg" - -FRAMEWORK_BASE="$SRCAPP/Contents/Frameworks/" -REMOVE="QtSql.framework QtXmlPatterns.framework QtDeclarative.framework QtNetwork.framework QtScript.framework QtSvg.framework QtGui.framework/Versions/4/QtGui.strip" - -DATASETBASE="$HOME/rdf/dataset/" -DATASETS="test.nt" -DATASETHDTBASE="$HOME/hdt/" -DATASETSHDT="3kbo.hdt aaronland.hdt 3dnews.hdt aisricom.hdt" -#DATASETSHDT="aifb.hdt apex.hdt 2blog.hdt 3kbo.hdt aaronland.hdt 3dnews.hdt aisricom.hdt" - -mkdir -p $FOLDER -rm -Rf $FOLDER/* - -# ADD LIBRARIES -echo macdeployqt $SRCAPP -macdeployqt $SRCAPP - -# ADD Translation files -cp -Rf *.qm $SRCAPP/Contents/Resources - -# ADD License and documentation -cp -Rf LICENSE $FOLDER - -mkdir -p $FOLDER/doc -cp -Rf doc/* $FOLDER/doc - -# REMOVE UNNEDED FILES -for i in $REMOVE -do - echo rm -Rf $FRAMEWORK_BASE$i; - rm -Rf $FRAMEWORK_BASE$i; -done - -echo rm -Rf "$SRCAPP/Contents/PlugIns/*" -rm -Rf "$SRCAPP/Contents/PlugIns/*" - -# CREATE TMP FOLDER -echo mkdir -p $FOLDER/datasets -mkdir -p $FOLDER/datasets - -echo "Fill moredatasets.txt" -echo "You can download more datasets from http://www.rdfhdt.org/datasets or import your own ones using the 'Import RDF' option!" > $FOLDER/datasets/moredatasets.txt - -# COPY APP to folder -echo cp -R $SRCAPP $FOLDER -cp -R $SRCAPP $FOLDER - -# COPY DATASETS -for i in $DATASETS -do - echo cp $DATASETBASE$i $FOLDER/datasets - cp $DATASETBASE$i $FOLDER/datasets -done - -for i in $DATASETSHDT -do - echo cp $DATASETHDTBASE$i $FOLDER/datasets - cp $DATASETHDTBASE$i $FOLDER/datasets -done - -# CREATE DMG -rm -Rf "$DMG" -echo hdiutil create -srcfolder "$FOLDER" -volname "$VOL" -format UDZO -imagekey zlib-level=9 "$DMG" -hdiutil create -srcfolder "$FOLDER" -volname "$NAME" -format UDZO -imagekey zlib-level=9 "$DMG" diff --git a/hdt-it/dictionarysuggestions.cpp b/hdt-it/dictionarysuggestions.cpp deleted file mode 100644 index c50c80d3..00000000 --- a/hdt-it/dictionarysuggestions.cpp +++ /dev/null @@ -1,186 +0,0 @@ - -#include -#include -#include - -#include "dictionarysuggestions.hpp" - -#include "stringutils.hpp" - -#include - -#define NUM_SUGGESTIONS 10 - -DictionarySuggestions::DictionarySuggestions(QLineEdit *parent) : - QObject(parent), - editor(parent), - controller(NULL) -{ - popup = new QTreeWidget; - popup->setWindowFlags(Qt::Popup); - popup->setFocusPolicy(Qt::NoFocus); - popup->setFocusProxy(parent); - popup->setMouseTracking(true); - - popup->setColumnCount(1); - popup->setUniformRowHeights(true); - popup->setRootIsDecorated(false); - popup->setEditTriggers(QTreeWidget::NoEditTriggers); - popup->setSelectionBehavior(QTreeWidget::SelectRows); - popup->setFrameStyle(QFrame::Box | QFrame::Plain); - popup->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - popup->header()->hide(); - - popup->installEventFilter(this); - - connect(popup, SIGNAL(itemClicked(QTreeWidgetItem*,int)), - SLOT(doneCompletion())); - - timer = new QTimer(this); - timer->setSingleShot(true); - timer->setInterval(100); - connect(timer, SIGNAL(timeout()), SLOT(autoSuggest())); - connect(editor, SIGNAL(textEdited(QString)), timer, SLOT(start())); -} - -DictionarySuggestions::~DictionarySuggestions(){ - delete popup; -} - -bool DictionarySuggestions::eventFilter(QObject *obj, QEvent *ev) -{ - if (obj != popup) - return false; - - if (ev->type() == QEvent::MouseButtonPress) { - popup->hide(); - editor->setFocus(); - return true; - } - - if (ev->type() == QEvent::KeyPress) { - bool consumed = false; - int key = static_cast(ev)->key(); - switch (key) { - case Qt::Key_Enter: - case Qt::Key_Return: - doneCompletion(); - consumed = true; - - case Qt::Key_Escape: - editor->setFocus(); - popup->hide(); - consumed = true; - - case Qt::Key_Up: - case Qt::Key_Down: - case Qt::Key_Home: - case Qt::Key_End: - case Qt::Key_PageUp: - case Qt::Key_PageDown: - case Qt::Key_Shift: - break; - - default: - editor->setFocus(); - editor->event(ev); - popup->hide(); - break; - } - - return consumed; - } - - return false; -} - -void DictionarySuggestions::showCompletion(const vector &choices) -{ - if (choices.size()==0) - return; - - popup->setUpdatesEnabled(false); - popup->clear(); - int maxWidth=0; - QFontMetrics metrics(popup->font()); - - for (int i = 0; i < choices.size(); ++i) { - QTreeWidgetItem * item; - item = new QTreeWidgetItem(popup); - item->setText(0, stringutils::toQString(choices[i].c_str())); - maxWidth = qMax(maxWidth, metrics.boundingRect(item->text(0)).width()); - } - popup->setCurrentItem(popup->topLevelItem(0)); - popup->resizeColumnToContents(0); - popup->adjustSize(); - popup->setUpdatesEnabled(true); - - int h = popup->sizeHintForRow(0) * qMin(NUM_SUGGESTIONS, (int)choices.size()) + 3; - popup->resize( qMax(popup->width(), qMin(maxWidth+20, 600)), h); - - popup->move(editor->mapToGlobal(QPoint(0, editor->height()))); - popup->setFocus(); - popup->show(); -} - -void DictionarySuggestions::doneCompletion() -{ - timer->stop(); - popup->hide(); - editor->setFocus(); - QTreeWidgetItem *item = popup->currentItem(); - if (item) { - editor->setText(item->text(0)); - QMetaObject::invokeMethod(editor, "returnPressed"); - } -} - -void DictionarySuggestions::autoSuggest() -{ - if(!controller ||!controller->hasHDT() ) { - return; - } - - try { - QString str = editor->text(); - if(str.length()<1) { - return; - } - - // If not URI, Literal, Blank - if( str.at(0)!='"' && str.at(0)!='_' && str.left(4)!="http") { - // Assume literal otherwise - str.prepend("\""); - } - vector choices; - - // FETCH RESULTS FROM DICTIONARY - controller->getHDT()->getDictionary()->getSuggestions(str.toUtf8(), role, choices, NUM_SUGGESTIONS); - - if(choices.size()==1 && choices[0]==string(str.toUtf8())) { - return; - } - - // show - showCompletion(choices); - } catch (const char *ex) { -#ifndef WIN32 - } catch (char *ex) { -#endif - } -} - -void DictionarySuggestions::preventSuggest() -{ - timer->stop(); -} - -void DictionarySuggestions::setRole(hdt::TripleComponentRole role) -{ - this->role = role; -} - -void DictionarySuggestions::setController(HDTController *controller) -{ - this->controller = controller; -} diff --git a/hdt-it/dictionarysuggestions.hpp b/hdt-it/dictionarysuggestions.hpp deleted file mode 100644 index fedf5fbc..00000000 --- a/hdt-it/dictionarysuggestions.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef DICTIONARYSUGGESTIONS_HPP -#define DICTIONARYSUGGESTIONS_HPP - -#include -#include - -#include - -QT_BEGIN_NAMESPACE -class QLineEdit; -class QTimer; -class QTreeWidget; -QT_END_NAMESPACE - -class DictionarySuggestions : public QObject -{ - Q_OBJECT -public: - explicit DictionarySuggestions(QLineEdit *parent = 0); - ~DictionarySuggestions(); - bool eventFilter(QObject *obj, QEvent *ev); - void showCompletion(const vector &choices); - void setController(HDTController *controller); - void setRole(hdt::TripleComponentRole role); - -public slots: - void doneCompletion(); - void preventSuggest(); - void autoSuggest(); - -private: - QLineEdit *editor; - QTreeWidget *popup; - QTimer *timer; - HDTController *controller; - hdt::TripleComponentRole role; -}; - -#endif // DICTIONARYSUGGESTIONS_HPP diff --git a/hdt-it/doc/hdtit.png b/hdt-it/doc/hdtit.png deleted file mode 100644 index cb3e2885..00000000 Binary files a/hdt-it/doc/hdtit.png and /dev/null differ diff --git a/hdt-it/doc/manual.html b/hdt-it/doc/manual.html deleted file mode 100644 index 1d442cf8..00000000 --- a/hdt-it/doc/manual.html +++ /dev/null @@ -1,88 +0,0 @@ - - - -HDT-it! 0.9Beta User Manual - - - -

HDT-it! 0.9Beta User Manual

- -

Purpose

- -

HDT (Header, Dictionary, Triples) is a binary representation for RDF that compresses big datasets to save space while maintaining search and browse operations. This makes it an ideal format for storing and sharing RDF datasets.

-

HDT-it! is a tool that allows generating and consuming HDT files. As an example, the tool allows to search basic graph patterns, and shows a global 3D Matrix of the RDF distribution to understand the organization of the information.

-

This document teaches how to use the tool to create and browse HDT files. There is also a screencast demonstrating visually all the features of HDT-it available at the RDF HDT Web page.

- -

Installation.

-

Windows

-

To install HDT-it! on Microsoft Windows, download the binary package for Windows from the RDF-HDT Download page. Uncompress the zip file using any appropriate software (Such as IZarc) to any folder of your choice. To launch the application, just double click on HDT-it.exe. You might find usefull to have a shortcut on your desktop. To do so, drag the hdt-it.exe file to your desktop using the right button of the mouse, and select "Create shortcut".

- -

Should you want to uninstall HDT-it!, just delete the folder on your hard drive.

- -

MacOSX

-

To install HDT-it! on MacOSX, download the binary package for MacOSX from RDF-HDT Download page. Launch the dmg file and drag the HDT-it! app to your Applications folder. Then you can launch HDT-it! the same way as any MacOSX application. You can create a shortcut to it by droping the app from the Applications folder to your dock.

- -

Note that HDT-it! is a Universal binary, and can run on 32 and 64 bit Intel platforms, but cannot run on PowerPC.

- -

Should you want to uninstall HDT-it!, just drag the App from the Applications folder to the Trash.

- -

Linux

-

To install HDT-it! on Linux, download the binary package for Linux from RDF-HDT Download page. Untar the package on your home (tar jxfv HDT-it-0.9beta-linux.tbz2) and launch it using the HDT-it.sh script (./HDT-it.sh). The package contains all the needed libraries: namely Qt 4.7.

- -

HDT-it Usage

- -

After opening HDT-it, you can see the following view:

- - - -

Managing datasets:

-

The first step when using HDT-it is loading a dataset. It uses the HDT format to keep all the information in a compact but at the same time accessible manner. -

Load HDT

-

If you have any dataset in HDT, you can load it using the "Open HDT" option from the toolbar. The instalation distribution package contains several example datasets that you can play with. You can also download bigger datasets from the Dataweb page. -

Import RDF

-

You also probably want to load your own dataset. HDT-it! is able to load RDF data in several well-known RDF formats (NTriples, N3, Turtle and RDF-XML) and convert it to HDT. To import data, select Import RDF and follow the instructions. You need to specify some information, namely:

-
    -
  • The file source of RDF
  • -
  • The base URI used for loading the RDF.
  • -
  • The specific format of the different sections of HDT. Depending on this options we can obtain a compromise between compression ratio and search capabilities. The default options will provide a fair balance between the two. -
- -

The process of importing the RDF file will take a while. We recommend using "NTriples" as input format since it can be processed statement by statement therefore using fewer RAM memory. For really big datasets, you may need a powerfull computer with a high amount of RAM memory, since the conversion process needs to construct intermediate data structures. In these cases, we recommend using the commandline tools available in HDT-lib on a server machine. Then the resulting HDT file can be loaded using a more modest computer since it is already compressed and ready to be used.

- -

Save HDT

-

This option allows saving the HDT file. It is specially useful when you just imported a RDF file and want to keep an HDT version for faster loading and consumption.

-

Export RDF

-

You can export any HDT search back to RDF to consume it using traditional tools or loading it to any RDF database. Just select export and by default the tool will serialize it to NTriples. If you want to export the whole dataset, just left empty all the fields in the triple search pattern.

- -

Browsing

-

Triple Search Pattern

-

On the top left, you can insert a triple search pattern to filter the results. It allows searching for a specific subject, predicate or object. Any field left blank means "any", so the default empty option will show all triples. In order to simplify the typing task, options are proposed as the user types thanks to the dictionary. -

Dataset Information

-

On the bottom left part of the window, all the information available about the dataset is shown. Namely the size of the original dataset and the compressed HDT version (to highlight the savings of using HDT). It also shows the details about the dictionary (the number of entries in the dictionary and the number of triples). It is also interesting to see the relative size of the dictionary against the triples.

-

List of Components.

-

Also on the bottom left you can select any of the components (Subjects, predicates, or objects). It will show a list of all the different elements available. The user can double click on any item to add it to the search box.

-

Metadata

-

The Metadata tab on the top right allows browsing all the information about the HDT's header in plain RDF format.

-

Search Results

-

The Search Results Tab shows the list of all triples that match the specified query in the triple search pattern block. You can double-click on any element to add it to the search pattern box. Also, you can right-click on it and select "Search as Subject/Predicate/Object".

-

Visualization.

-

The visualization widget allows the developer to have an overall view of the dataset. It allows understanding the structure of the RDF data.

- -

The matrix view is based on an Adjacency Matrix. The dictionary part of the HDT assigns numerical ID to each of the different subject, predicate and object. Then, each RDF triple can be referred as a triple of numerical IDs, such as 234,5,3425. This ID can be interpreted as a point in a 3-Dimensional space, therefore it can be plotted as a point in a 3D graph axis. The matrix view is just a scatter-plot of all the triples of the dataset.

- - - -

To better see the details, you can rotate the view by holding the mouse's left button, or pan using the right one. To increase/decrease the zoom the mouse wheel shall be used. There are three predefined views: Top, Left, and 3D, that can be selected on the top bar. You can also select reset to go back to the initial view.

-

In order to understand the information underlying each area of the visualization, the application reveals information about the nearest triple under the cursor when the user hovers the mouse over each area. Note that this feature is only available for the Front view.

- -

Acknowledgements

-

HDT was possible thanks to: -

- - diff --git a/hdt-it/doc/matrix.png b/hdt-it/doc/matrix.png deleted file mode 100644 index 6f40af1f..00000000 Binary files a/hdt-it/doc/matrix.png and /dev/null differ diff --git a/hdt-it/editreset.png b/hdt-it/editreset.png deleted file mode 100644 index d9bd6661..00000000 Binary files a/hdt-it/editreset.png and /dev/null differ diff --git a/hdt-it/hdt-it.pro b/hdt-it/hdt-it.pro deleted file mode 100644 index 9cd1b43c..00000000 --- a/hdt-it/hdt-it.pro +++ /dev/null @@ -1,135 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2011-06-07T18:38:15 -# -#------------------------------------------------- - -QT += core gui opengl - -QMAKE_CXXFLAGS_RELEASE -= -O2 -QMAKE_CXXFLAGS_RELEASE += -O3 - -#macx:QMAKE_CXXFLAGS += -msse4.2 - -win32-g++:contains(QMAKE_HOST.arch, x86_64):{ - CONFIG += exceptions rtti -} - -CONFIG += debug_and_release -macx:CONFIG += x86_64 - -TARGET = HDT-it -TEMPLATE = app - -win32:OutputDir = 'win32' -unix:OutputDir = 'unix' -macx:OutputDir = 'macx' - -DESTDIR = $${OutputDir} -OBJECTS_DIR = $${OutputDir} -MOC_DIR = $${OutputDir} -RCC_DIR = $${OutputDir} -UI_DIR = $${OutputDir} - -SOURCES += main.cpp\ - hdtit.cpp \ - matrixviewwidget.cpp \ - hdtspecform.cpp \ - Color.cpp \ - Camera.cpp \ - StopWatch.cpp \ - qclearlineedit.cpp \ - searchresultsmodel.cpp \ - triplecomponentmodel.cpp \ - hdtoperation.cpp \ - abouthdt.cpp \ - hdtcachedinfo.cpp \ - stringutils.cpp \ - predicatestatus.cpp \ - hdtsummarygenerator.cpp \ - resultcounter.cpp \ - headermodel.cpp \ - dictionarysuggestions.cpp \ - myapplication.cpp \ - sparqlmodel.cpp \ - sparqlform.cpp \ - regexmodel.cpp \ - hdtcontroller.cpp - -HEADERS += hdtit.hpp \ - matrixviewwidget.hpp \ - hdtspecform.hpp \ - Color.h \ - Camera.h \ - constants.h \ - colors.hpp \ - StopWatch.hpp \ - qclearlineedit.hpp \ - searchresultsmodel.hpp \ - triplecomponentmodel.hpp \ - hdtoperation.hpp \ - abouthdt.hpp \ - hdtcachedinfo.hpp \ - stringutils.hpp \ - predicatestatus.hpp \ - hdtsummarygenerator.hpp \ - resultcounter.hpp \ - headermodel.hpp \ - dictionarysuggestions.hpp \ - myapplication.hpp \ - sparqlmodel.hpp \ - sparqlform.hpp \ - regexmodel.hpp \ - hdtcontroller.hpp - -FORMS += hdtit.ui \ - hdtspecform.ui \ - abouthdt.ui \ - sparqlform.ui - -TRANSLATIONS += hdt-it_es.ts - -LIBCDS = ../libcds-v1.0.12 - -# Using Hard-coded Makefile -INCLUDEPATH += $${LIBCDS}/includes ../hdt-lib/include/ . -#LIBS += $${LIBCDS}/lib/libcds.a ../hdt-lib/libhdt.a - -# Using autotools -#LIBS += $${LIBCDS}/src/.libs/libcds.a ../hdt-lib/.libs/libhdt.a - -# Using Qt Projects -#win32:LIBS += ../hdt-lib/qmake/win32/libhdt.a $${LIBCDS}/qmake/win32/libcds.a - -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:\serd-0.26.0\bin\serd.lib" - -unix:!macx:LIBS += ../hdt-lib/qmake/unix/libhdt.a $${LIBCDS}/qmake/unix/libcds.a -lGLU -macx:LIBS += $${LIBCDS}/qmake/macx/libcds.a ../hdt-lib/qmake/macx/libhdt.a -#PRE_TARGETDEPS += $$LIBS - -# Installed in the system -#LIBS += -lcds -lhdt - - -#External libs - -#Windows -win32-g++:contains(QMAKE_HOST.arch, x86_64):{ - #win32:LIBS += -L"C:/msys/local/lib/" -lxml2 -lws2_32 -} else { - # win32:LIBS += -L"C:/MinGW/msys/1.0/local/lib/" -lxml2 -lws2_32 -} - -win32:LIBS += -L"C:/msys/local/lib/" -L"/usr/local/lib" -L"C:/MinGW/msys/1.0/local/lib/" - -#Unix (Linux & Mac) -unix:LIBS += -L"/usr/local/lib" -lz -lserd-0 - -RESOURCES += \ - hdtresources.qrc - -win32:RC_FILE = hdtico.rc - -QMAKE_INFO_PLIST = Info.plist - -ICON = hdtico.icns diff --git a/hdt-it/hdt-it_es.qm b/hdt-it/hdt-it_es.qm deleted file mode 100644 index 29fb43d8..00000000 Binary files a/hdt-it/hdt-it_es.qm and /dev/null differ diff --git a/hdt-it/hdt-it_es.ts b/hdt-it/hdt-it_es.ts deleted file mode 100644 index 5182168a..00000000 --- a/hdt-it/hdt-it_es.ts +++ /dev/null @@ -1,906 +0,0 @@ - - - - - Abouthdt - - - About HDT-it! - Acerca de HDT-it! - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Lucida Grande'; font-size:12pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:16pt; font-weight:600;">HDT-it! version 0.9beta</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt; font-weight:600;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">HDT (Header, Dictionary, Triples) is a binary representation for RDF that compresses big datasets in order to store and share big RDF files.</p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">HDT-it is a tool that allows generating and consuming HDT files. As an example, the tool allows to search for basic graph patterns, and shows a global 3D Matrix of the RDF distribution.</p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">For more information about the tool and our research, please visit:</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">HDT Web page: <a href="http://www.rdfhdt.org"><span style=" font-size:13pt; text-decoration: underline; color:#0000ff;">http://www.rdfhdt.org</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Research group: <a href="http://dataweb.infor.uva.es"><span style=" font-size:13pt; text-decoration: underline; color:#0000ff;">http://dataweb.infor.uva.es</span></a></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">HDT was possible thanks to:</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Javier D. Fernández García &lt;<a href="mailto:jfergar@infor.uva.es"><span style=" text-decoration: underline; color:#0000ff;">jfergar@infor.uva.es</span></a>&gt;</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Miguel A. Martínez-Prieto &lt;<a href="mailto:migumar2@infor.uva.es"><span style=" text-decoration: underline; color:#0000ff;">migumar2@infor.uva.es</span></a>&gt;</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Mario Arias Gallego &lt;<a href="mario.arias@gmail.com"><span style=" font-size:13pt; text-decoration: underline; color:#0000ff;">mario.arias@gmail.com</span></a>&gt;</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Claudio Gutierrez &lt;<a href="mailto:cgutierr@dcc.uchile.cl"><span style=" font-size:13pt; text-decoration: underline; color:#0000ff;">cgutierr@dcc.uchile.cl</span></a>&gt;</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Alejandro Andres &lt;<a href="mailto:fuzzy.alej@gmail.com"><span style=" font-size:13pt; text-decoration: underline; color:#0000ff;">fuzzy.alej@gmail.com</span></a>&gt;</p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></body></html> - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Lucida Grande'; font-size:12pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:16pt; font-weight:600;">HDT-it! version 0.9beta</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt; font-weight:600;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">HDT (Header, Dictionary, Triples) is a binary representation for RDF that compresses big datasets in order to store and share big RDF files.</p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">HDT-it is a tool that allows generating and consuming HDT files. As an example, the tool allows to search for basic graph patterns, and shows a global 3D Matrix of the RDF distribution.</p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">For more information about the tool and our research, please visit:</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">HDT Web page: <a href="http://www.rdfhdt.org"><span style=" font-size:13pt; text-decoration: underline; color:#0000ff;">http://www.rdfhdt.org</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Research group: <a href="http://dataweb.infor.uva.es"><span style=" font-size:13pt; text-decoration: underline; color:#0000ff;">http://dataweb.infor.uva.es</span></a></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">HDT was possible thanks to:</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Javier D. Fernández García &lt;<a href="mailto:jfergar83@gmail.com"><span style=" font-size:13pt; text-decoration: underline; color:#0000ff;">jfergar83@gmail.com</span></a>&gt;</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Miguel Ángel Martínez-Prieto &lt;<a href="mailto:migumar2@gmail.com"><span style=" font-size:13pt; text-decoration: underline; color:#0000ff;">migumar2@gmail.com</span></a>&gt;</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Mario Arias Gallego &lt;<a href="mario.arias@gmail.com"><span style=" font-size:13pt; text-decoration: underline; color:#0000ff;">mario.arias@gmail.com</span></a>&gt;</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Claudio Gutierrez &lt;<a href="mailto:cgutierr@dcc.uchile.cl"><span style=" font-size:13pt; text-decoration: underline; color:#0000ff;">cgutierr@dcc.uchile.cl</span></a>&gt;</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Alejandro Andres &lt;<a href="mailto:fuzzy.alej@gmail.com"><span style=" font-size:13pt; text-decoration: underline; color:#0000ff;">fuzzy.alej@gmail.com</span></a>&gt;</p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></body></html> - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Lucida Grande'; font-size:12pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:16pt; font-weight:600;">HDT-it! versión 0.9beta</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt; font-weight:600;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">HDT (Header, Dictionary, Triples) es una representación binaria de RDF que comprime grandes volumenes de datos en ficheros reducidos para su almacenamiento o intercambio.</p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">HDT-it es una herramienta que permite generar y consumir ficheros en formato HDT. Como ejemplo, la herramienta permite realizar consultas de patrones básicos de triples, y también muestra una matriz 3D con la distribución de los datos RDF dentro del dataset.</p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Para más información acerca de HDT:</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Página Web de HDT: <a href="http://www.rdfhdt.org"><span style=" font-size:13pt; text-decoration: underline; color:#0000ff;">http://www.rdfhdt.org</span></a></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Grupo de investigación: <a href="http://dataweb.infor.uva.es"><span style=" font-size:13pt; text-decoration: underline; color:#0000ff;">http://dataweb.infor.uva.es</span></a></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">HDT ha sido posible gracias a:</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Javier D. Fernández García &lt;<a href="mailto:jfergar@infor.uva.es"><span style=" font-size:13pt; text-decoration: underline; color:#0000ff;">jfergar@infor.uva.es</span></a>&gt;</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Miguel A. Martínez-Prieto &lt;<a href="mailto:migumar2@infor.uva.es"><span style=" font-size:13pt; text-decoration: underline; color:#0000ff;">migumar2@infor.uva.es</span></a>&gt;</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Mario Arias Gallego &lt;<a href="mario.arias@gmail.com"><span style=" font-size:13pt; text-decoration: underline; color:#0000ff;">mario.arias@gmail.com</span></a>&gt;</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Claudio Gutierrez &lt;<a href="mailto:cgutierr@dcc.uchile.cl"><span style=" font-size:13pt; text-decoration: underline; color:#0000ff;">cgutierr@dcc.uchile.cl</span></a>&gt;</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Alejandro Andres &lt;<a href="mailto:fuzzy.alej@gmail.com"><span style=" font-size:13pt; text-decoration: underline; color:#0000ff;">fuzzy.alej@gmail.com</span></a>&gt;</p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></body></html> - - - - HDTManager - - File Error - Error en el fichero - - - No open file. - Ningún fichero abierto. - - - <h3>Dataset:</h3> - <h3>Conjunto de datos:</h3> - - - <b>Original Size</b>: - <b>Tamaño original</b>: - - - <b>HDT Size</b>: - <b>Tamaño HDT</b>: - - - <b>Compression ratio</b>: - <b>Ratio de compresión</b>: - - - <b>Number of triples</b>: %1<br/> - <b>Número de triples</b>: %1<br/> - - - <h3>Dictionary:</h3> - <h3>Diccionario:</h3> - - - <b>Number of entries</b>: %1<br/> - <b>Número de entradas</b>: %1<br/> - - - <b>Different subjects</b>: %1<br/> - <b>Sujetos diferentes</b>: %1<br/> - - - <b>Different predicates</b>: %1<br/> - <b>Predicados diferentes</b>: %1<br/> - - - <b>Different objects</b>: %1<br/> - <b>Objetos diferentes</b>: %1<br/> - - - <b>Shared area</b>: %1<br/> - <b>Zona compartida</b>: %1<br/> - - - <b>Type</b>: <small> - <b>Tipo</b>: <small> - - - <b>Dictionary Size</b>: - <b>Tamaño diccionario</b>: - - - <h3>Triples:</h3> - <h3>Triples:</h3> - - - <b>Triples Size</b>: - <b>Tamaño Triples</b>: - - - - HDTOperation - - - Loading HDT File - Cargando fichero HDT - - - - Importing RDF File to HDT - Importando fichero RDF a HDT - - - - Saving HDT File - Guardando fichero HDT - - - - Exporting HDT File to RDF - Exportando fichero HDT a RDF - - - - Exporting results to RDF - Exportar resultados a RDF - - - - Cancel - Cancelar - - - - HDTSpecForm - - - Import RDF File to HDT - Importar fichero RDF a HDT - - - - InputRDF file name or URI - RDF Input File - URL o nombre del fichero RDF de entrada - - - - ... - - - - - NTRIPLES - - - - - N3 - - - - - TURTLE - - - - - RDF-XML - - - - - Base URI for the dataset - URI base para el conjunto de datos - - - - Header - Cabecera - - - - - Plain - - - - - - - Type: - - - - - Dictionary - Diccionario - - - - Plain Front Coding - - - - - Triples - Triples - - - - BitmapTriples - - - - - TriplesList - - - - - PlainTriples - - - - - SPO - - - - - SOP - - - - - PSO - - - - - POS - - - - - OSP - - - - - OPS - - - - - Order - Orden - - - - - - LogStream - - - - - - - IntegerStream - - - - - - - HuffmanStream - - - - - StreamX: - - - - - StreamY: - - - - - StreamZ: - - - - - Select Input RDF File - Seleccione fichero RDF de entrada - - - - RDF Files(*) - Ficheros RDF(*) - - - - Select a file name. - Seleccione un nombre de fichero. - - - - Please insert a file name or URI. - Seleccione un nombre de fichero o URI. - - - - HDTSummaryGenerator - - - No open file. - Ningún fichero abierto. - - - - <h3>Dataset:</h3> - <h3>Conjunto de datos:</h3> - - - - <b>File name</b>: <small> - <b>Nombre del fichero</b>: <small> - - - - <b>Dataset base URI</b>: <small> - <b>URI base</b>: <small> - - - - <b>Original Size</b>: - <b>Tamaño original</b>: - - - - <b>HDT Size</b>: - <b>Tamaño HDT</b>: - - - - <b>Compression ratio</b>: - <b>Ratio de compresión</b>: - - - - <b>Issued</b>: %1<br/> - <b>Creado</b>: %1 <br/> - - - - <h3>Header:</h3> - <h3>Cabecera</h3> - - - - - <b>Number of triples</b>: %1<br/> - <b>Número de triples</b>: %1<br/> - - - - <h3>Dictionary:</h3> - <h3>Diccionario:</h3> - - - - <b>Number of entries</b>: %1<br/> - <b>Número de entradas</b>: %1<br/> - - - - <b>Different subjects</b>: %1<br/> - <b>Sujetos diferentes</b>: %1<br/> - - - - <b>Different predicates</b>: %1<br/> - <b>Predicados diferentes</b>: %1<br/> - - - - <b>Different objects</b>: %1<br/> - <b>Objetos diferentes</b>: %1<br/> - - - - <b>Shared area</b>: %1<br/> - <b>Zona compartida</b>: %1<br/> - - - - - <b>Type</b>: <small> - <b>Tipo</b>: <small> - - - - <b>Dictionary Size</b>: - <b>Tamaño diccionario</b>: - - - - - <br/> - - - - - <h3>Triples:</h3> - <h3>Triples:</h3> - - - - <b>Triples Size</b>: - <b>Tamaño Triples</b>: - - - - <b>Triples Order</b>: - <b>Orden de triples</b>: - - - - HDTit - - - HDT-it ! - - - - - Triple Search Pattern - Patrón de Búsqueda de Triples - - - - Insert a Subject Search Pattern - Inserte un patrón de búsqueda de sujeto - - - - Insert a Predicate Search Pattern - Inserte un patrón de búsqueda de predicado - - - - S - - - - - P - - - - - Insert an Object Search Pattern - Inserte un patrón de búsqueda de objeto - - - - O - - - - - No results. - No hay resultados. - - - - Info - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">No dataset.</p></body></html> - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Ningún conjunto de datos abierto.</p></body></html> - - - - Subjects - Sujetos - - - - Predicates - Predicados - - - - Show only triples from most used predicates. - Mostrar solo los triples de los predicados más usados. - - - - Minimum predicate usage count: - Uso mínimo de predicado: - - - - 0 - - - - - All - Todos - - - - None - Ninguno - - - - Objects - Objetos - - - - Metadata - Metadatos - - - - Search Results - Resultados de Búsqueda - - - - Matrix View - Vista de Matriz - - - - File - Archivo - - - - Views - Vistas - - - - Open HDT - Abrir HDT - - - - Ctrl+O - - - - - Import RDF - Importar RDF - - - - Ctrl+I - - - - - Save HDT - Guardar HDT - - - - Ctrl+S - - - - - Export RDF - Exportar RDF - - - - Ctrl+E - - - - - Views: - Vistas: - - - - Front - Frontal - - - - Front View - Vista Frontal - - - - Ctrl+1 - - - - - Left - Izquierda - - - - Left View - Vista izquierda - - - - Ctrl+2 - - - - - Top - Superior - - - - Top View - Vista Superior - - - - Ctrl+3 - - - - - 3D - - - - - 3D View - Vista 3D - - - - Ctrl+4 - - - - - Full Screen - Pantalla completa - - - - Switch Full Screen - Cambiar a pantalla completa - - - - Ctrl+F - - - - - Reset - Inicial - - - - Reset to Initial view - Reiniciar a la vista inicial - - - - Ctrl+R - - - - - Close - - - - - Ctrl+W - - - - - About - Acerca - - - - About HDT-it! - Acerca de HDT-it! - - - - Ctrl+A - - - - - Quit - Salir - - - - Quit HDT-it! - Salir de HDT-it! - - - - Ctrl+Q - - - - - %1 results found in %2. - %1 resultados en %2. - - - - Select HDT File - Seleccione el fichero HDT - - - - - HDT Files(*.hdt *.HDT) - Ficheros HDT (*.hdt *.HDT) - - - - Select Output HDT File - Seleccione fichero HDT de salida - - - - Export Search Results - Exportar resultados de búsqueda - - - - Warning: Only those triples matching the selected search pattern will be exported. - Advertencia: Solo se exportarán los triples relativos a la búsqueda actual. - - - - Select Output RDF File - Seleccione fichero RDF de salida - - - - RDF Files(*.rdf *.RDF *.n3 *.N3) - Ficheros RDF(*.rdf *.RDF *.n3 *.N3) - - - - Copy - Copiar - - - - Search as Subject - Buscar como sujeto - - - - Search as Predicate - Buscar como Predicado - - - - Search as Object - Buscar como objeto - - - HDT Files(*.rdf *.RDF *.n3 *.N3) - Ficheros RDF(*.rdf *.RDF *.n3 *.N3) - - - - HeaderModel - - - Subject - Sujeto - - - - Predicate - Predicado - - - - Object - Objeto - - - - SearchResultsModel - - - Subject - Sujeto - - - - Predicate - Predicado - - - - Object - Objeto - - - - TripleComponentModel - - - Subject - Sujeto - - - - Predicate - Predicado - - - - Object - Objeto - - - diff --git a/hdt-it/hdtcachedinfo.cpp b/hdt-it/hdtcachedinfo.cpp deleted file mode 100644 index 48b49d97..00000000 --- a/hdt-it/hdtcachedinfo.cpp +++ /dev/null @@ -1,155 +0,0 @@ -#include "hdtcachedinfo.hpp" -#include "constants.h" - -#include "../../hdt-lib/src/triples/BitmapTriples.hpp" - -#include - -HDTCachedInfo::HDTCachedInfo(hdt::HDT *hdt) : hdt(hdt) -{ - -} - -void HDTCachedInfo::generateGeneralInfo(hdt::ProgressListener *listener) -{ - // Count predicates - unsigned int nPred = hdt->getDictionary()->getNpredicates(); - - maxPredicateCount = 0; - predicateCount.clear(); - predicateCount.resize(nPred+1); - - NOTIFYCOND(listener, "Loading predicates", 0, 100); - - // TODO: Use predicateCount directly - if(hdt->isIndexed()) { - hdt::Triples *t = hdt->getTriples(); - hdt::TripleID triplePredicate; - for(int p=1;p<=nPred;p++) { -#if 1 - predicateCount[p] = t->getNumAppearances(p); -#else - triplePredicate.setAll(0, p, 0); - hdt::IteratorTripleID *predIt = t->search(triplePredicate); - - predicateCount[p] = predIt->estimatedNumResults(); - - maxPredicateCount = max(maxPredicateCount, predicateCount[p]); - - delete predIt; -#endif - } - } - - // Calculate Predicate Colors - predicateColors.clear(); - predicateColors.resize(nPred); - ColorRamp2 cr; - for(unsigned int i=0;isearch(pat); - for(int i=0;i<50 && it2->hasNext(); i++) { - it2->next(); - } - delete it2; - - // Iterate over elements of the array to make sure their dictionary entries are loaded. -#if 0 - hdt::TripleString out; - for(size_t i=0;igetDictionary()->tripleIDtoTripleString(triples[i], out); - } -#endif -} - -void HDTCachedInfo::generateMatrix(hdt::ProgressListener *listener) -{ - // Generate matrix - hdt::Triples *t = hdt->getTriples(); - size_t increment = t->getNumberOfElements()/RENDER_NUM_POINTS; - increment = increment < 1 ? 1 : increment; - - -// Using InterleavedIterator to jump directly to the triple and get the related information. - hdt::BTInterleavedIterator it(dynamic_cast(t), increment); - - size_t count=0; - while(it.hasNext()) { - hdt::TripleID *tid = it.next(); - triples.push_back(*tid); - //cout << *tid << endl; - - NOTIFYCOND(listener, "Generating Matrix", count, RENDER_NUM_POINTS); - count++; - //if((count%100)==0) - //cout << "Iteration: " << count << endl; - } - -// Using normal iterator that goes through all entries. -// hdt::IteratorTripleID *it = t->searchAll(); -// size_t count=0; -// for(size_t i=0;igetNumberOfElements();i+=increment) { -// it->goTo(i); -// hdt::TripleID *tid = it->next(); -// triples.push_back(*tid); -// NOTIFYCOND(listener, "Generating Matrix", i, t->getNumberOfElements()); -// count++; -// if((count%100)==0) -// cout << "Iteration: " << count << endl; -// } -// delete it; - -} - -Color * HDTCachedInfo::getPredicateColor(size_t npred) -{ - return &predicateColors[npred]; -} - -size_t HDTCachedInfo::getPredicateUsages(size_t predicate) -{ - return predicateCount[predicate]; -} - -size_t HDTCachedInfo::getMaxPredicateCount() -{ - return maxPredicateCount; -} - -vector &HDTCachedInfo::getTriples() -{ - return triples; -} - -void HDTCachedInfo::save(QString &fileName, hdt::ProgressListener *listener) -{ - // Only save info of files bigger than 2M triples. Otherwise is fast to create from scratch. - if(hdt->getTriples()->getNumberOfElements()>2000000) { - std::ofstream out(fileName.toLatin1(), ios::binary); - uint64_t numTriples = triples.size(); - out.write((char *)&numTriples, sizeof(uint64_t)); - out.write((char *)&triples[0], sizeof(hdt::TripleID)*numTriples); - out.close(); - } -} - -void HDTCachedInfo::load(QString &fileName, hdt::ProgressListener *listener) -{ - generateGeneralInfo(listener); - - std::ifstream in(fileName.toLatin1(), ios::binary); - if(in.good()) { - uint64_t numTriples; - in.read((char *)&numTriples, sizeof(uint64_t)); - triples.resize(numTriples); - in.read((char *)&triples[0], sizeof(hdt::TripleID)*numTriples); - in.close(); - } else { - generateMatrix(listener); - save(fileName, listener); - } -} diff --git a/hdt-it/hdtcachedinfo.hpp b/hdt-it/hdtcachedinfo.hpp deleted file mode 100644 index 39242c51..00000000 --- a/hdt-it/hdtcachedinfo.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef HDTCACHEDINFO_HPP -#define HDTCACHEDINFO_HPP - -#include -#include -#include -#include "StopWatch.hpp" - -#include "Color.h" - - -class HDTCachedInfo -{ -private: - - hdt::HDT *hdt; - vector triples; - - vector predicateColors; - size_t maxPredicateCount; - vector predicateCount; - -public: - HDTCachedInfo(hdt::HDT *hdt); - - Color *getPredicateColor(size_t npred); - size_t getPredicateUsages(size_t predicate); - size_t getMaxPredicateCount(); - vector &getTriples(); - - void generateGeneralInfo(hdt::ProgressListener *listener=NULL); - void generateMatrix(hdt::ProgressListener *listener=NULL); - - void save(QString &fileName, hdt::ProgressListener *listener=NULL); - void load(QString &fileName, hdt::ProgressListener *listener=NULL); -}; - -#endif // HDTCACHEDINFO_HPP diff --git a/hdt-it/hdtcontroller.cpp b/hdt-it/hdtcontroller.cpp deleted file mode 100644 index 449e19aa..00000000 --- a/hdt-it/hdtcontroller.cpp +++ /dev/null @@ -1,369 +0,0 @@ -#include -#include - -#include - -#include -#include -#include - -#include - -#include "hdtcontroller.hpp" -#include "hdtoperation.hpp" -#include "hdtcachedinfo.hpp" -#include "stringutils.hpp" -#include "resultcounter.hpp" - -#define SHOW_DIALOGS - -HDTController::HDTController(QObject *parent) : - QObject(parent), - hdt(NULL), - searchPatternID(0,0,0), - selectedTriple(0,0,0), - numResults(0), - iteratorResults(NULL) -{ - subjectModel = new TripleComponentModel(this, hdt::SUBJECT); - predicateModel = new TripleComponentModel(this, hdt::PREDICATE); - objectModel = new TripleComponentModel(this, hdt::OBJECT); - searchResultsModel = new SearchResultsModel(this); - headerModel = new HeaderModel(this); - predicateStatus = new PredicateStatus(this); - regexModel = new RegexModel(this); -} - -HDTController::~HDTController() { - closeHDT(); - delete subjectModel; - delete predicateModel; - delete objectModel; - delete searchResultsModel; - delete headerModel; - delete predicateStatus; - delete regexModel; -} - -void HDTController::updateOnHDTChanged() -{ - this->numResults = hdt->getTriples()->getNumberOfElements(); - - subjectModel->notifyLayoutChanged(); - predicateModel->notifyLayoutChanged(); - predicateStatus->refreshAll(); - objectModel->notifyLayoutChanged(); - searchResultsModel->updateResultListChanged(); - headerModel->updateDatasetChanged(); - regexModel->updateDatasetChanged(); - - emit datasetChanged(); -} - -void HDTController::importRDFFile(QString file, const string &baseUri, hdt::RDFNotation notation, hdt::HDTSpecification &spec) -{ - closeHDT(); - - HDTOperation *hdtop = new HDTOperation(); - hdtop->loadFromRDF(spec, file, notation, baseUri); - int result = hdtop->exec(); - if(result==0) { - this->hdt = hdtop->getHDT(); - this->hdtCachedInfo = hdtop->getHDTInfo(); - this->fileName = file; - - updateOnHDTChanged(); - } - delete hdtop; -} - -void HDTController::openHDTFile(QString file) -{ - closeHDT(); - - HDTOperation *hdtop = new HDTOperation(file); - hdtop->loadFromHDT(file); - int result = hdtop->exec(); - - if(result==0) { - this->hdt = hdtop->getHDT(); - this->hdtCachedInfo = hdtop->getHDTInfo(); - this->fileName = file; - - updateOnHDTChanged(); - } - - delete hdtop; -} - -void HDTController::saveHDTFile(QString file) -{ - if(hdt!=NULL) { -#ifdef SHOW_DIALOGS - HDTOperation *hdtop = new HDTOperation(hdt); - hdtop->saveToHDT(file); - hdtop->exec(); - delete hdtop; -#else - hdt->saveToHDT(file.toAscii()); -#endif - } -} - -void HDTController::exportRDFFile(QString file, hdt::RDFNotation notation) -{ - if(hdt!=NULL) { -#ifdef SHOW_DIALOGS - HDTOperation *hdtop = new HDTOperation(hdt); - hdtop->saveToRDF(file, notation); - hdtop->exec(); - delete hdtop; -#else - hdt::RDFSerializer *serializer = hdt::RDFSerializer::getSerializer(file.toAscii(), notation); - hdt->saveToRDF(*serializer); -#endif - } -} - -void HDTController::exportResultsRDFFile(QString file, hdt::RDFNotation notation) -{ - if(hdt!=NULL) { -#ifdef SHOW_DIALOGS - HDTOperation *hdtop = new HDTOperation(hdt); - hdt::IteratorTripleString *it = hdt->search(searchPatternString); - hdtop->exportResults(file, it, getNumResults(), notation); - hdtop->exec(); - delete hdtop; -#else - hdt::RDFSerializer *serializer = hdt::RDFSerializer::getSerializer(file.toAscii(), notation); - hdt::IteratorTripleString *it = hdt->search(searchPatternString); - serializer->serialize(iterator, getNumResults()); - delete serializer; - delete iterator; - break; -#endif - } -} - - -void HDTController::closeHDT() -{ - if(hdt!=NULL) { - delete hdt; - hdt = NULL; - - numResults=0; - subjectModel->notifyLayoutChanged(); - predicateModel->notifyLayoutChanged(); - predicateStatus->refreshAll(); - objectModel->notifyLayoutChanged(); - searchResultsModel->updateResultListChanged(); - headerModel->updateDatasetChanged(); - regexModel->updateDatasetChanged(); - - emit datasetChanged(); - } -} - - -TripleComponentModel * HDTController::getSubjectModel() -{ - return subjectModel; -} - -TripleComponentModel * HDTController::getPredicateModel() -{ - return predicateModel; -} -TripleComponentModel * HDTController::getObjectModel() -{ - return objectModel; -} - -SearchResultsModel * HDTController::getSearchResultsModel() -{ - return searchResultsModel; -} - -HeaderModel * HDTController::getHeaderModel() -{ - return headerModel; -} - -RegexModel *HDTController::getRegexModel() -{ - return regexModel; -} - -PredicateStatus *HDTController::getPredicateStatus() -{ - return predicateStatus; -} - -HDTCachedInfo *HDTController::getHDTCachedInfo() -{ - return hdtCachedInfo; -} - -hdt::HDT *HDTController::getHDT() -{ - return hdt; -} - -bool HDTController::hasHDT() -{ - return hdt!=NULL; -} - -void HDTController::setSearchPattern(hdt::TripleString &pattern) -{ - if(hdt==NULL) { - return; - } - - if(searchPatternString != pattern) { - try { - this->searchPatternString = pattern; - - hdt->getDictionary()->tripleStringtoTripleID(pattern, searchPatternID); - - // Reset iterator - if(iteratorResults!=NULL) { - delete iteratorResults; - iteratorResults=NULL; - } - numResults=0; - - // Check not found - if( (searchPatternID.getSubject()==0 && !pattern.getSubject().empty()) || - (searchPatternID.getPredicate()==0 && !pattern.getPredicate().empty()) || - (searchPatternID.getObject()==0 && !pattern.getObject().empty()) ) { - - } else { - iteratorResults = hdt->getTriples()->search(searchPatternID); - } - updateNumResults(); - - predicateStatus->selectPredicate(searchPatternID.getPredicate()); - } catch (char *exception){ - numResults = 0; - iteratorResults = NULL; - } catch (const char *exception){ - numResults = 0; - iteratorResults = NULL; - } - searchResultsModel->updateResultListChanged(); - - emit searchPatternChanged(); - } -} - -hdt::TripleID & HDTController::getSearchPatternID() -{ - return searchPatternID; -} - -hdt::TripleString & HDTController::getSearchPatternString() -{ - return searchPatternString; -} - -hdt::TripleID HDTController::getSelectedTriple() -{ - return selectedTriple; -} - -void HDTController::setSelectedTriple(hdt::TripleID &selected) -{ - selectedTriple = selected; -} - -void HDTController::clearSelectedTriple() -{ - selectedTriple.clear(); -} - -quint64 inline DIST(quint64 x1, quint64 x2, quint64 y1, quint64 y2) { - return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2); -} - -void HDTController::selectNearestTriple(int subject, int predicate, int object) -{ - vector &triples = getTriples(); - if(triples.size()==0) { - this->clearSelectedTriple(); - return; - } - - hdt::TripleID *best = &triples[0]; - unsigned int bestpos = 0; - quint64 bestdist = DIST(triples[0].getSubject(), subject, triples[0].getObject(), object); - - for (unsigned int i = 0; i < triples.size(); i ++) { - if (triples[i].match(searchPatternID) && predicateStatus->isPredicateActive(triples[i].getPredicate()-1)) { - quint64 dist = DIST(triples[i].getSubject(), subject, triples[i].getObject(), object); - - if (dist < bestdist) { - best = &triples[i]; - bestdist = dist; - bestpos = i; - //printf("1New %u, %u, %u, Dist: %u Pos: %u\n", best->getSubject(), best->getPredicate(), best->getObject(), bestdist, bestpos); - } - } - } - //printf("Found: %u, %u, %u, Dist: %llu\n", best->getSubject(), best->getPredicate(), best->getObject(), bestdist); - - this->setSelectedTriple( *best ); -} - -vector & HDTController::getTriples() -{ - return hdtCachedInfo->getTriples(); -} - -size_t HDTController::getNumResults() -{ - return numResults; -} - -void HDTController::numResultsValueChanged(int numResults) -{ - this->numResults = numResults; - searchResultsModel->updateNumResultsChanged(); - emit numResultsChanged(numResults); -} - -void HDTController:: numResultCountFinished() -{ - -} - -void HDTController::updateNumResults() -{ - if(iteratorResults==NULL) { - return; - } - - if(iteratorResults->numResultEstimation()==hdt::EXACT) { - // Provided, use. - numResults = iteratorResults->estimatedNumResults(); - } else { - // Not provided, count. - while(iteratorResults->hasNext()) { - iteratorResults->next(); - numResults++; - } - } - - searchResultsModel->updateNumResultsChanged(); - emit numResultsChanged(numResults); -} - -QString HDTController::getFileName() -{ - return fileName; -} - - - - diff --git a/hdt-it/hdtcontroller.hpp b/hdt-it/hdtcontroller.hpp deleted file mode 100644 index af67a966..00000000 --- a/hdt-it/hdtcontroller.hpp +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef HDTMANAGER_HPP -#define HDTMANAGER_HPP - -#include -#include - -#include "hdtcachedinfo.hpp" -#include "triplecomponentmodel.hpp" -#include "searchresultsmodel.hpp" -#include "headermodel.hpp" -#include "predicatestatus.hpp" -#include "regexmodel.hpp" - -class TripleComponentModel; -class SearchResultsModel; -class PredicateStatus; -class HeaderModel; -class RegexModel; - -class HDTController : public QObject -{ - Q_OBJECT - -public: - explicit HDTController(QObject *parent = 0); - ~HDTController(); - -private: - // HDT - hdt::HDT *hdt; - QString fileName; - - // Models / Info - TripleComponentModel *subjectModel; - TripleComponentModel *predicateModel; - TripleComponentModel *objectModel; - SearchResultsModel *searchResultsModel; - HeaderModel *headerModel; - PredicateStatus *predicateStatus; - HDTCachedInfo *hdtCachedInfo; - RegexModel *regexModel; - - // Search pattern / results - hdt::TripleID selectedTriple; - hdt::TripleID searchPatternID; - hdt::TripleString searchPatternString; - hdt::IteratorTripleID *iteratorResults; - size_t numResults; - -public: - hdt::HDT *getHDT(); - bool hasHDT(); - void openHDTFile(QString file); - void saveHDTFile(QString file); - void importRDFFile(QString file, const string &baseUri, hdt::RDFNotation notation, hdt::HDTSpecification &spec); - void exportRDFFile(QString file, hdt::RDFNotation notation); - void exportResultsRDFFile(QString file, hdt::RDFNotation notation); - void closeHDT(); - - TripleComponentModel *getSubjectModel(); - TripleComponentModel *getPredicateModel(); - TripleComponentModel *getObjectModel(); - RegexModel *getRegexModel(); - SearchResultsModel *getSearchResultsModel(); - HeaderModel *getHeaderModel(); - PredicateStatus *getPredicateStatus(); - HDTCachedInfo *getHDTCachedInfo(); - - void selectNearestTriple(int subject, int predicate, int object); - void setSelectedTriple(hdt::TripleID &selected); - hdt::TripleID getSelectedTriple(); - void clearSelectedTriple(); - - hdt::TripleID &getSearchPatternID(); - hdt::TripleString &getSearchPatternString(); - void setSearchPattern(hdt::TripleString &pattern); - - vector &getTriples(); - - size_t getNumResults(); - - QString getFileName(); - -signals: - void datasetChanged(); - void searchPatternChanged(); - void numResultsChanged(int numResults); - -private slots: - void updateOnHDTChanged(); - void updateNumResults(); - void numResultsValueChanged(int numResults); - void numResultCountFinished(); - -public slots: - -}; - - -#endif // HDTMANAGER_HPP - - - diff --git a/hdt-it/hdtico.icns b/hdt-it/hdtico.icns deleted file mode 100644 index e7f7aae7..00000000 Binary files a/hdt-it/hdtico.icns and /dev/null differ diff --git a/hdt-it/hdtico.rc b/hdt-it/hdtico.rc deleted file mode 100644 index e8acf432..00000000 --- a/hdt-it/hdtico.rc +++ /dev/null @@ -1 +0,0 @@ -IDI_ICON1 ICON DISCARDABLE "hdtwinico2.ico" diff --git a/hdt-it/hdtit.cpp b/hdt-it/hdtit.cpp deleted file mode 100644 index 9890ac23..00000000 --- a/hdt-it/hdtit.cpp +++ /dev/null @@ -1,400 +0,0 @@ -#include "hdtit.hpp" -#include "ui_hdtit.h" - -#include "hdtspecform.hpp" -#include "ui_hdtspecform.h" - -#include "sparqlform.hpp" -#include "ui_sparqlform.h" - -#include "abouthdt.hpp" -#include "hdtsummarygenerator.hpp" - -#include - -HDTit::HDTit(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::HDTit), - hdtController(new HDTController()), - lastDir(QDir::currentPath()) -{ - ui->setupUi(this); - //this->setUnifiedTitleAndToolBarOnMac(true); - - ui->matrixView->setManager(hdtController); - ui->subjectView->setModel(hdtController->getSubjectModel()); - ui->predicateView->setModel(hdtController->getPredicateModel()); - ui->objectView->setModel(hdtController->getObjectModel()); - ui->resultsTable->setModel(hdtController->getSearchResultsModel()); - ui->headerView->setModel(hdtController->getHeaderModel()); - ui->regexResultsView->setModel(hdtController->getRegexModel()); - - ui->subjectPatternEdit->getSuggestions()->setController(hdtController); - ui->predicatePatternEdit->getSuggestions()->setController(hdtController); - ui->objectPatternEdit->getSuggestions()->setController(hdtController); - ui->subjectPatternEdit->getSuggestions()->setRole(hdt::SUBJECT); - ui->predicatePatternEdit->getSuggestions()->setRole(hdt::PREDICATE); - ui->objectPatternEdit->getSuggestions()->setRole(hdt::OBJECT); - - // Context menus - connect(ui->resultsTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); - connect(ui->subjectView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); - connect(ui->predicateView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); - connect(ui->objectView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); - - // Camera - connect(ui->matrixView, SIGNAL(rotationChanged()), this, SLOT(updateViewButtons())); - - // Dataset - connect(hdtController, SIGNAL(datasetChanged()), ui->matrixView, SLOT(reloadHDTInfo())); - - // Predicate Status - connect(ui->predicateCountSlider, SIGNAL(valueChanged(int)), hdtController->getPredicateStatus(), SLOT(setMinimumPredicateCount(int))); - connect(hdtController->getPredicateStatus(), SIGNAL(minimumPredicateCountChanged(int)), ui->predicateCountSlider, SLOT(setValue(int))); - connect(hdtController->getPredicateStatus(), SIGNAL(predicatesChanged(unsigned int, unsigned int)), ui->matrixView, SLOT(updateGL())); - connect(ui->selectAllPredicatesButton, SIGNAL(clicked()), hdtController->getPredicateStatus(), SLOT(selectAllPredicates())); - connect(ui->selectNoneButton, SIGNAL(clicked()), hdtController->getPredicateStatus(), SLOT(selectNonePredicates())); - connect(hdtController->getPredicateStatus(), SIGNAL(predicatesChanged(unsigned int,unsigned int)), hdtController->getPredicateModel(), SLOT(itemsChanged(uint,uint))); - connect(hdtController->getPredicateStatus(), SIGNAL(predicateSelected(int)), ui->predicateView, SLOT(selectRow(int))); - - // Search pattern - connect(hdtController, SIGNAL(searchPatternChanged()), this, SLOT(refreshSearchPattern())); - connect(hdtController, SIGNAL(numResultsChanged(int)), this, SLOT(updateNumResults())); -} - -HDTit::~HDTit() -{ - delete ui; - delete hdtController; -} - -void HDTit::updateNumResults() -{ - ui->numResultsLabel->setText( - QString(tr("%1 results found.")) - .arg(QLocale::system().toString((quint64)hdtController->getNumResults())) - ); -} - -void HDTit::searchPatternEdited() -{ - std::string subject = ui->subjectPatternEdit->text().toUtf8().constData(); - std::string predicate = ui->predicatePatternEdit->text().toUtf8().constData(); - std::string object = ui->objectPatternEdit->text().toUtf8().constData(); - - hdt::TripleString ts(subject, predicate, object); - hdtController->setSearchPattern(ts); - - this->updateNumResults(); - - ui->resultsTable->scrollToTop(); - - ui->matrixView->updateGL(); - - ui->subjectView->selectRow(hdtController->getSearchPatternID().getSubject()-1); - ui->predicateView->selectRow(hdtController->getSearchPatternID().getPredicate()-1); - ui->objectView->selectRow(hdtController->getSearchPatternID().getObject()-1); - -} - -void HDTit::refreshSearchPattern() -{ - if(hdtController->hasHDT()) { - hdt::TripleString &ts = hdtController->getSearchPatternString(); - ui->subjectPatternEdit->setText(QString::fromUtf8(ts.getSubject().c_str())); - ui->predicatePatternEdit->setText(QString::fromUtf8(ts.getPredicate().c_str())); - ui->objectPatternEdit->setText(QString::fromUtf8(ts.getObject().c_str())); - } else { - ui->subjectPatternEdit->clear(); - ui->predicatePatternEdit->clear(); - ui->objectPatternEdit->clear(); - } -} - - -void HDTit::openHDTFile(QString &file) -{ - hdtController->openHDTFile(file); - - hdtChanged(file); -} - -void HDTit::importRDFFile(QString &file, const string &baseUri, hdt::RDFNotation notation, hdt::HDTSpecification &spec) -{ - hdtController->importRDFFile(file, baseUri, notation, spec); - - hdtChanged(file); -} - -void HDTit::hdtChanged(QString &file) -{ - ui->subjectPatternEdit->clear(); - ui->predicatePatternEdit->clear(); - ui->objectPatternEdit->clear(); - - ui->predicateCountSlider->setMaximum(hdtController->getPredicateStatus()->getMaximumPredicateCount()+1); - ui->predicateCountSlider->setValue(0); - ui->statusBar->showMessage(file); - ui->statsLabel->setText(HDTSummaryGenerator::getSummary(hdtController)); - updateNumResults(); - - bool hasDataset = hdtController->hasHDT(); - ui->actionSaveHDT->setEnabled(hasDataset); - ui->actionExportRDF->setEnabled(hasDataset); - ui->subjectPatternEdit->setEnabled(hasDataset); - ui->predicatePatternEdit->setEnabled(hasDataset); - ui->objectPatternEdit->setEnabled(hasDataset); - - // Enable/Disable substring search tab. - bool hdtHasSubstring = false; - if(hdtController->hasHDT()) { - hdtHasSubstring = hdtController->getHDT()->getDictionary()->getType()==hdt::HDTVocabulary::DICTIONARY_TYPE_LITERAL; - } - ui->tabRegex->setEnabled(hdtHasSubstring); - if(hdtHasSubstring) { - if(ui->resultTabs->count()<4) { - ui->resultTabs->insertTab(3, ui->tabRegex, "Substring Search"); - } - } else { - ui->resultTabs->removeTab(3); - } - - refreshSearchPattern(); -} - - - -void HDTit::on_actionOpenHDT_triggered() -{ - QString file = QFileDialog::getOpenFileName(this,tr("Select HDT File"), lastDir , tr("HDT Files(*.hdt *.HDT *.hdt.gz *.HDT.gz)"), 0, 0 ); - if(!file.isEmpty()) { - lastDir = file; - openHDTFile(file); - } -} - -void HDTit::on_actionImportRDF_triggered() -{ - HDTSpecForm hdtSpecForm; - int result = hdtSpecForm.exec(); - if(result>0) { - hdt::HDTSpecification spec; - hdtSpecForm.fillHDTSpecification(spec); - - QString file = hdtSpecForm.getFileName(); - string baseUri = string(hdtSpecForm.getBaseUri().toLatin1()); - hdt::RDFNotation notation = hdtSpecForm.getNotation(); - importRDFFile(file, baseUri, notation, spec); - } -} - -void HDTit::on_actionSaveHDT_triggered() -{ - QString file = QFileDialog::getSaveFileName(this,tr("Select Output HDT File"), lastDir, tr("HDT Files(*.hdt *.HDT)"), 0, 0 ); - if(!file.isEmpty()) { - lastDir = file; - hdtController->saveHDTFile(file); - } -} - -void HDTit::on_actionExportRDF_triggered() -{ - if(!hdtController->getSearchPatternID().isEmpty()) { - QMessageBox::warning(0, tr("Export Search Results"), tr("Warning: Only those triples matching the selected search pattern will be exported.")); - } - - QString file = lastDir; - file.replace(".hdt",".nt"); - - // TODO: Rename lastDir - file = QFileDialog::getSaveFileName(this,tr("Select Output RDF File"), file, tr("RDF Files(*.rdf *.RDF *.n3 *.N3 *.nt *.NT *.ttl *.TTL)"), 0, 0 ); - if(!file.isEmpty()) { - // FIXME: Select notation. - lastDir = file; - hdtController->exportResultsRDFFile(file, hdt::NTRIPLES); - } -} - -void HDTit::updateViewButtons() -{ - Camera &cam = ui->matrixView->getCamera(); - ui->actionFrontView->setChecked(cam.isFrontView()); - ui->actionLeftView->setChecked(cam.isLeftView()); - ui->actionTopView->setChecked(cam.isTopView()); - ui->action3Dview->setChecked(cam.is3DView()); -} - -void HDTit::on_actionFrontView_toggled(bool state) -{ - if(state) { - ui->resultTabs->setCurrentIndex(2); - ui->matrixView->getCamera().setFrontView(); - updateViewButtons(); - } -} - -void HDTit::on_actionLeftView_toggled(bool state) -{ - if(state) { - ui->resultTabs->setCurrentIndex(2); - ui->matrixView->getCamera().setLeftView(); - updateViewButtons(); - } -} - -void HDTit::on_actionTopView_toggled(bool state) -{ - if(state) { - ui->resultTabs->setCurrentIndex(2); - ui->matrixView->getCamera().setTopView(); - updateViewButtons(); - } -} - -void HDTit::on_action3Dview_toggled(bool state) -{ - if(state) { - ui->resultTabs->setCurrentIndex(2); - ui->matrixView->getCamera().set3DView(); - updateViewButtons(); - } -} - -void HDTit::on_actionReset_triggered() -{ - ui->matrixView->getCamera().toDefaultValuesAnimated(); -} - -void HDTit::setPatternSubject(QModelIndex index) -{ - ui->subjectPatternEdit->setText(hdtController->getSubjectModel()->data(index).toString()); -} - -void HDTit::setPatternPredicate(QModelIndex index) -{ - ui->predicatePatternEdit->setText(hdtController->getPredicateModel()->data(index).toString()); -} - -void HDTit::setPatternObject(QModelIndex index) -{ - ui->objectPatternEdit->setText(hdtController->getObjectModel()->data(index).toString()); -} - -void HDTit::setPatternGlobal(QModelIndex index) -{ - //cout << "Index: " << index.row() << ", " << index.column() << endl; - - switch(index.column()) { - case 0: - ui->subjectPatternEdit->setText(hdtController->getSearchResultsModel()->data(index).toString()); - break; - case 1: - ui->predicatePatternEdit->setText(hdtController->getSearchResultsModel()->data(index).toString()); - break; - case 2: - ui->objectPatternEdit->setText(hdtController->getSearchResultsModel()->data(index).toString()); - break; - } -} - -void HDTit::setPatternContextSubject() -{ - ui->subjectPatternEdit->setText(lastContextMenuTable->model()->data(lastContextMenuCell).toString()); -} - -void HDTit::setPatternContextPredicate() -{ - ui->predicatePatternEdit->setText(lastContextMenuTable->model()->data(lastContextMenuCell).toString()); -} - -void HDTit::setPatternContextObject() -{ - ui->objectPatternEdit->setText(lastContextMenuTable->model()->data(lastContextMenuCell).toString()); -} - -void HDTit::copyResultTableSelection() -{ - QApplication::clipboard()->setText(hdtController->getSearchResultsModel()->data(lastContextMenuCell).toString()); -} - -void HDTit::on_actionAbout_triggered() -{ - Abouthdt aboutForm; - aboutForm.exec(); -} - -void HDTit::on_actionFull_Screen_triggered() -{ - static bool maximized=false; - if(isFullScreen()) { - if(maximized) { - showMaximized(); - } else { - showNormal(); - } - } else { - maximized = isMaximized(); - showFullScreen(); - } -} - -void HDTit::showContextMenu(QPoint pos) -{ - lastContextMenuTable = qobject_cast(QObject::sender()); - if(lastContextMenuTable==NULL) { - return; - } - lastContextMenuCell = lastContextMenuTable->indexAt(pos); - if(!lastContextMenuCell.isValid()){ - return; - } - - QMenu menu; -#if 0 - menu.addAction(tr("Copy")), this, this, SLOT(copyResultTableSelection()); - menu.addSeparator(); -#endif - menu.addAction(tr("Search as Subject"), this, SLOT(setPatternContextSubject())); - menu.addAction(tr("Search as Predicate"), this, SLOT(setPatternContextPredicate())); - menu.addAction(tr("Search as Object"), this, SLOT(setPatternContextObject())); - menu.exec(lastContextMenuTable->mapToGlobal(pos)); -} - - -void HDTit::on_actionClose_triggered() -{ - hdtController->closeHDT(); - QString str; - hdtChanged(str); -} - -HDTController * HDTit::getManager() -{ - return hdtController; -} - -void HDTit::on_actionSparql_triggered() -{ - SparqlForm *jf = new SparqlForm(this); - - jf->show(); -} - -void HDTit::on_regexSearchButton_clicked() -{ - this->on_regexEdit_editingFinished(); -} - -void HDTit::on_regexEdit_editingFinished() -{ - hdtController->getRegexModel()->setQuery(ui->regexEdit->text()); - ui->regexResultsView->scrollToTop(); -} - -void HDTit::on_regexResultsView_doubleClicked(const QModelIndex &index) -{ - if(index.column()==1) { - ui->objectPatternEdit->setText(hdtController->getRegexModel()->data(index).toString()); - ui->resultTabs->setCurrentIndex(1); - } -} diff --git a/hdt-it/hdtit.hpp b/hdt-it/hdtit.hpp deleted file mode 100644 index 51c124d3..00000000 --- a/hdt-it/hdtit.hpp +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef HDTIT_HPP -#define HDTIT_HPP - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "hdtcontroller.hpp" - -namespace Ui { - class HDTit; -} - -class HDTit : public QMainWindow -{ - Q_OBJECT - -private: - Ui::HDTit *ui; - HDTController *hdtController; - QString lastDir; - QModelIndex lastContextMenuCell; - QTableView *lastContextMenuTable; - - void hdtChanged(QString &file); - -public: - explicit HDTit(QWidget *parent = 0); - ~HDTit(); - - void openHDTFile(QString &file); - void importRDFFile(QString &file, const string &baseUri, hdt::RDFNotation notation, hdt::HDTSpecification &spec); - - HDTController *getManager(); -private slots: - void on_actionOpenHDT_triggered(); - void on_actionImportRDF_triggered(); - void on_actionSaveHDT_triggered(); - void on_actionExportRDF_triggered(); - void on_actionClose_triggered(); - - void on_actionFrontView_toggled(bool arg1); - void on_actionLeftView_toggled(bool arg1); - void on_actionTopView_toggled(bool arg1); - void on_action3Dview_toggled(bool arg1); - void on_actionReset_triggered(); - - void searchPatternEdited(); - void refreshSearchPattern(); - - void setPatternSubject(QModelIndex index); - void setPatternPredicate(QModelIndex index); - void setPatternObject(QModelIndex index); - - void showContextMenu(QPoint pos); - void setPatternContextSubject(); - void setPatternContextPredicate(); - void setPatternContextObject(); - void copyResultTableSelection(); - - void setPatternGlobal(QModelIndex index); - void on_actionAbout_triggered(); - - void updateViewButtons(); - void updateNumResults(); - void on_actionFull_Screen_triggered(); - void on_actionSparql_triggered(); - void on_regexSearchButton_clicked(); - void on_regexEdit_editingFinished(); - void on_regexResultsView_doubleClicked(const QModelIndex &index); -}; - -#endif // HDTIT_HPP diff --git a/hdt-it/hdtit.ui b/hdt-it/hdtit.ui deleted file mode 100644 index 74ac262a..00000000 --- a/hdt-it/hdtit.ui +++ /dev/null @@ -1,875 +0,0 @@ - - - HDTit - - - - 0 - 0 - 845 - 514 - - - - HDT-it ! - - - - :/images/logo-hdt.png:/images/logo-hdt.png - - - - - 0 - 0 - - - - - - - Qt::Horizontal - - - - - - - Triple Search Pattern - - - - - - - - false - - - Insert a Subject Search Pattern - - - - - - - - - - false - - - Insert a Predicate Search Pattern - - - - - - - S - - - - - - - P - - - - - - - false - - - Insert an Object Search Pattern - - - - - - - O - - - - - - - - - - - - No results. - - - - - - - - - - - 300 - 0 - - - - 0 - - - - Info - - - - - - QFrame::Panel - - - QFrame::Sunken - - - 1 - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">No dataset.</p></body></html> - - - - - - - - Subjects - - - - - - Qt::CustomContextMenu - - - true - - - Qt::ElideMiddle - - - QAbstractItemView::ScrollPerPixel - - - 400 - - - 200 - - - true - - - 20 - - - false - - - - - - - - Predicates - - - - - - - - Show only triples from most used predicates. - - - Filter least used predicates: - - - - - - - 0 - - - - - - - - - 0 - - - true - - - Qt::Horizontal - - - false - - - false - - - QSlider::NoTicks - - - - - - - - - All - - - - - - - None - - - - - - - - - Qt::CustomContextMenu - - - true - - - Qt::ElideMiddle - - - QAbstractItemView::ScrollPerPixel - - - 400 - - - 200 - - - true - - - 20 - - - false - - - - - - - - Objects - - - - - - Qt::CustomContextMenu - - - true - - - Qt::ElideMiddle - - - QAbstractItemView::ScrollPerPixel - - - 400 - - - 200 - - - true - - - 20 - - - - - - - - - - - - 2 - - - - Metadata - - - - - - true - - - Qt::ElideMiddle - - - QAbstractItemView::ScrollPerPixel - - - 300 - - - 200 - - - 20 - - - - - - - - Search Results - - - - - - Qt::CustomContextMenu - - - true - - - Qt::ElideMiddle - - - QAbstractItemView::ScrollPerPixel - - - 300 - - - 50 - - - true - - - 20 - - - - - - - - Matrix View - - - - - false - - - Substring Search - - - - - - Search Literal: - - - - - - - - - - - - Search - - - - - - - - - Qt::CustomContextMenu - - - true - - - Qt::ElideMiddle - - - QAbstractItemView::ScrollPerPixel - - - 100 - - - 100 - - - true - - - 20 - - - false - - - - - - - - - - - - - - 0 - 0 - 845 - 22 - - - - - File - - - - - - - - - - - - - Views - - - - - - - - - - - - - TopToolBarArea - - - false - - - - - - - - - - - - - - - - - - - - - - false - - - - - Open HDT - - - Ctrl+O - - - - - Import RDF - - - Ctrl+I - - - - - false - - - Save HDT - - - Ctrl+S - - - - - false - - - Export RDF - - - Ctrl+E - - - - - false - - - false - - - Views: - - - - - true - - - true - - - Front - - - Front View - - - Ctrl+1 - - - - - true - - - Left - - - Left View - - - Ctrl+2 - - - - - true - - - Top - - - Top View - - - Ctrl+3 - - - - - true - - - 3D - - - 3D View - - - Ctrl+4 - - - - - About - - - About HDT-it! - - - Ctrl+A - - - - - Quit - - - Quit HDT-it! - - - Ctrl+Q - - - - - true - - - Full Screen - - - Switch Full Screen - - - Ctrl+F - - - - - Reset - - - Reset to Initial view - - - Ctrl+R - - - - - Close - - - Ctrl+W - - - - - SPARQL - - - - - - - MatrixViewWidget - QWidget -
matrixviewwidget.hpp
- - numMaxPredicateCountChanged(int) - predicateRangeChanged(int,int) - maxPredicateCountChanged(int) - updateGL() - selectAllPredicates() - selectNonePredicates() - setMinimumPredicateCount(int) - set3Dview() - -
- - QClearLineEdit - QLineEdit -
qclearlineedit.hpp
-
-
- - - - - - subjectPatternEdit - textChanged(QString) - HDTit - searchPatternEdited() - - - 170 - 106 - - - 354 - 261 - - - - - predicatePatternEdit - textChanged(QString) - HDTit - searchPatternEdited() - - - 170 - 142 - - - 354 - 261 - - - - - objectPatternEdit - textChanged(QString) - HDTit - searchPatternEdited() - - - 170 - 178 - - - 354 - 261 - - - - - objectView - activated(QModelIndex) - HDTit - setPatternObject(QModelIndex) - - - 95 - 280 - - - 354 - 261 - - - - - subjectView - activated(QModelIndex) - HDTit - setPatternSubject(QModelIndex) - - - 111 - 453 - - - 354 - 261 - - - - - actionQuit - triggered() - HDTit - close() - - - -1 - -1 - - - 354 - 261 - - - - - predicateCountSlider - valueChanged(int) - numPredicateCount - setNum(int) - - - 95 - 282 - - - 135 - 310 - - - - - resultsTable - doubleClicked(QModelIndex) - HDTit - setPatternGlobal(QModelIndex) - - - 483 - 96 - - - 354 - 261 - - - - - predicateView - activated(QModelIndex) - HDTit - setPatternPredicate(QModelIndex) - - - 65 - 293 - - - 395 - 255 - - - - -
diff --git a/hdt-it/hdtoperation.cpp b/hdt-it/hdtoperation.cpp deleted file mode 100644 index b7a202cb..00000000 --- a/hdt-it/hdtoperation.cpp +++ /dev/null @@ -1,284 +0,0 @@ -#include -#include -#include -#include -#include - -#include - -#include "hdtoperation.hpp" - -#define USE_DIALOG -//#define OPERATION_CANCELABLE - -#ifdef WIN32 -#include -#define sleep(a) Sleep((a)*1000) -#else -#include -#include -#define sleep(a) usleep(a) -#endif - - -HDTOperationDialog::HDTOperationDialog() -{ -} - -void HDTOperationDialog::closeEvent(QCloseEvent *event) -{ -#ifdef OPERATION_CANCELABLE - event->accept(); -#else - event->ignore(); -#endif -} - -HDTOperation::HDTOperation() : hdt(NULL), hdtInfo(NULL), errorMessage(NULL) -{ -} - -HDTOperation::HDTOperation(QString fileName) : fileName(fileName), hdt(NULL), hdtInfo(NULL), errorMessage(NULL) -{ -} - -HDTOperation::HDTOperation(hdt::HDT *hdt) : hdt(hdt), hdtInfo(NULL), errorMessage(NULL) -{ -} - -HDTOperation::HDTOperation(hdt::HDT *hdt, HDTCachedInfo *hdtInfo) : hdt(hdt), hdtInfo(hdtInfo), errorMessage(NULL) -{ -} - -void HDTOperation::execute() { - errorMessage=NULL; - try { - switch(op) { - case HDT_READ: { - hdt::IntermediateListener iListener(dynamic_cast(this)); - iListener.setRange(0,70); - - // TODO: Decompress GZIP here using progress bar. - // TODO: Detect whether .hdtcache and .hdt.index exist to be more accurate with the progress -#if 1 - hdt = hdt::HDTManager::mapIndexedHDT(fileName.toLatin1(), &iListener); -#else - hdt = hdt::HDTManager::loadIndexedHDT(fileName.toLatin1(), &iListener); -#endif - iListener.setRange(70, 100); - hdtInfo = new HDTCachedInfo(hdt); - if(fileName.endsWith('.gz')){ - fileName.left(fileName.length()-3); - } - QString infoFile = fileName + ".hdtcache"; - hdtInfo->load(infoFile, &iListener); - - break; - } - case RDF_READ:{ - hdt::IntermediateListener iListener(dynamic_cast(this)); - - iListener.setRange(0,80); - hdt = hdt::HDTManager::generateHDT(fileName.toLatin1(), baseUri.c_str(), notation, spec, &iListener); - - iListener.setRange(80, 90); - hdt = hdt::HDTManager::indexedHDT(hdt); - - iListener.setRange(90, 100); - hdtInfo = new HDTCachedInfo(hdt); - hdtInfo->generateGeneralInfo(&iListener); - hdtInfo->generateMatrix(&iListener); - - break; - } - case HDT_WRITE: - hdt->saveToHDT(fileName.toLatin1(), dynamic_cast(this)); - break; - case RDF_WRITE:{ - hdt::RDFSerializer *serializer = hdt::RDFSerializer::getSerializer(fileName.toLatin1(), notation); - hdt->saveToRDF(*serializer, dynamic_cast(this)); - delete serializer; - break; - } - case RESULT_EXPORT: { - hdt::RDFSerializer *serializer = hdt::RDFSerializer::getSerializer(fileName.toLatin1(), notation); - serializer->serialize(iterator, dynamic_cast(this), numResults ); - delete serializer; - delete iterator; - break; - } - } - emit processFinished(0); - } catch (char* err) { - cerr << "Error caught: " << err << endl; - errorMessage = err; - emit processFinished(1); - } catch (const char* err) { - cerr << "Error caught: " << err << endl; - errorMessage = (char *)err; - emit processFinished(1); - } - sleep(1); // To ensure that dialog receives the signal and closes. -} - - -void HDTOperation::notifyProgress(float level, const char *section) { -#ifdef OPERATION_CANCELABLE - if(isCancelled) { - cerr << "Throwing exception to cancel" << endl; - throw (char *)"Cancelled by user"; - } -#endif -#ifdef USE_DIALOG - emit progressChanged((int)level); - emit messageChanged(QString(section)); -#endif -} - -void HDTOperation::notifyProgress(float task, float level, const char *section) -{ -#ifdef OPERATION_CANCELABLE - if(isCancelled) { - cerr << "Throwing exception to cancel" << endl; - throw (char *)"Cancelled by user"; - } -#endif - int levelInt = (int) level; - if(levelInt<0) { - levelInt=0; - } - if(levelInt>=100) { - levelInt=99; - } - - emit progressChanged((int)level); - emit messageChanged(QString(section)); -} - -void HDTOperation::saveToRDF(QString &fileName, hdt::RDFNotation notation) -{ - this->op = RDF_WRITE; - this->fileName = fileName; - this->notation = notation; -} - -void HDTOperation::saveToHDT(QString &fileName) -{ - this->op = HDT_WRITE; - this->fileName = fileName; -} - -void HDTOperation::loadFromRDF(hdt::HDTSpecification &spec, QString &fileName, hdt::RDFNotation notation, const string &baseUri) -{ - this->op = RDF_READ; - this->spec = spec; - this->fileName = fileName; - this->notation = notation; - this->baseUri = baseUri; -} - -void HDTOperation::loadFromHDT(QString &fileName) -{ - this->op = HDT_READ; - this->fileName = fileName; -} - -void HDTOperation::exportResults(QString &fileName, hdt::IteratorTripleString *iterator, unsigned int numResults, hdt::RDFNotation notation) -{ - this->op = RESULT_EXPORT; - this->fileName = fileName; - this->iterator = iterator; - this->numResults = numResults; - this->notation = notation; -} - -hdt::HDT *HDTOperation::getHDT() -{ - return hdt; -} - -HDTCachedInfo *HDTOperation::getHDTInfo() -{ - return hdtInfo; -} - - -int HDTOperation::exec() -{ - -#ifdef USE_DIALOG - dialog.setRange(0,100); - dialog.setAutoClose(false); - dialog.setFixedSize(400,130); - - switch(op) { - case HDT_READ: - dialog.setWindowTitle(tr("Loading HDT File")); - break; - case RDF_READ: - dialog.setWindowTitle(tr("Importing RDF File to HDT")); - break; - case HDT_WRITE: - dialog.setWindowTitle(tr("Saving HDT File")); - break; - case RDF_WRITE: - dialog.setWindowTitle(tr("Exporting HDT File to RDF")); - break; - case RESULT_EXPORT: - dialog.setWindowTitle(tr("Exporting results to RDF")); - break; - } - -#ifndef OPERATION_CANCELABLE - QPushButton btn; - btn.setEnabled(false); - btn.setText(tr("Cancel")); - dialog.setCancelButton(&btn); -#endif - - QFutureWatcher watcher; - - connect(&watcher, SIGNAL(finished()), this, SLOT(finished()), Qt::QueuedConnection); - - connect(this, SIGNAL(progressChanged(int)), &dialog, SLOT(setValue(int)), Qt::QueuedConnection); - connect(this, SIGNAL(messageChanged(QString)), &dialog, SLOT(setLabelText(QString)), Qt::QueuedConnection); - connect(this, SIGNAL(processFinished(int)), &dialog, SLOT(done(int)), Qt::QueuedConnection); - -#ifdef OPERATION_CANCELABLE - connect(&dialog, SIGNAL(canceled()), this, SLOT(cancel())); -#endif - - isCancelled=false; - QFuture f = QtConcurrent::run(this, &HDTOperation::execute); - watcher.setFuture(f); - - int result = dialog.exec(); - - if(errorMessage) { - result = 1; - QMessageBox::critical(NULL, "ERROR", QString(errorMessage) ); - } - - QApplication::alert(QApplication::activeWindow()); - return result; -#else - this->execute(); - if(errorMessage!=NULL) { - return 1; - } else { - return 0; - } -#endif -} - -void HDTOperation::cancel() -{ - //cerr << "Operation cancelled" << endl; - isCancelled = true; -} - -void HDTOperation::finished() -{ - cerr << "Finished! :)" << endl; - emit processFinished(0); -} diff --git a/hdt-it/hdtoperation.hpp b/hdt-it/hdtoperation.hpp deleted file mode 100644 index 9bdf5e8d..00000000 --- a/hdt-it/hdtoperation.hpp +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef HDTOPERATION_HPP -#define HDTOPERATION_HPP - -#include -#include -#include -#include -#include -#include -#include - -#include "hdtcachedinfo.hpp" - - -class HDTOperationDialog : public QProgressDialog { - Q_OBJECT -public: - HDTOperationDialog(); - void closeEvent(QCloseEvent *event); -}; - -class HDTOperation : public QObject, public hdt::ProgressListener { - Q_OBJECT - -private: - hdt::HDTSpecification spec; - hdt::HDT *hdt; - HDTCachedInfo *hdtInfo; - hdt::IteratorTripleString *iterator; - unsigned int numResults; - QString fileName; - hdt::RDFNotation notation; - string baseUri; - char *errorMessage; - bool isCancelled; - HDTOperationDialog dialog; - - enum Operation { - HDT_READ, - RDF_READ, - HDT_WRITE, - RDF_WRITE, - RESULT_EXPORT - } op; - -public: - HDTOperation(); - HDTOperation(QString fileName); - HDTOperation(hdt::HDT *hdt); - HDTOperation(hdt::HDT *hdt, HDTCachedInfo *hdtInfo); - void saveToRDF(QString &fileName, hdt::RDFNotation notation); - void saveToHDT(QString &fileName); - void loadFromRDF(hdt::HDTSpecification &spec, QString &fileName, hdt::RDFNotation notation, const string &baseUri); - void loadFromHDT(QString &fileName); - void exportResults(QString &fileName, hdt::IteratorTripleString *iterator, unsigned int numResults, hdt::RDFNotation notation); - hdt::HDT *getHDT(); - HDTCachedInfo *getHDTInfo(); - void execute(); - int exec(); - void notifyProgress(float level, const char *section); - void notifyProgress(float task, float level, const char *section); -signals: - void progressChanged(int progress); - void messageChanged(QString message); - void processFinished(int status); -private slots: - void cancel(); - void finished(); -}; - -#endif // HDTOPERATION_HPP diff --git a/hdt-it/hdtresources.qrc b/hdt-it/hdtresources.qrc deleted file mode 100644 index 141fd6fd..00000000 --- a/hdt-it/hdtresources.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - editreset.png - logo-hdt.png - loading.gif - - diff --git a/hdt-it/hdtspecform.cpp b/hdt-it/hdtspecform.cpp deleted file mode 100644 index 11d59ca1..00000000 --- a/hdt-it/hdtspecform.cpp +++ /dev/null @@ -1,180 +0,0 @@ -#include -#include - -#include "hdtspecform.hpp" -#include "ui_hdtspecform.h" - -#include - -HDTSpecForm::HDTSpecForm(QWidget *parent) : - QDialog(parent), - ui(new Ui::HDTSpecForm) -{ - ui->setupUi(this); -} - -HDTSpecForm::~HDTSpecForm() -{ - delete ui; -} - -void HDTSpecForm::on_triplesTypeCombo_currentIndexChanged(int index) -{ - switch(index) { - case 0: - // BitmapTriples - ui->streamXcombo->setEnabled(false); - ui->streamYcombo->setEnabled(true); - ui->streamZcombo->setEnabled(true); - break; - case 1: - // TriplesList - ui->streamXcombo->setEnabled(false); - ui->streamYcombo->setEnabled(false); - ui->streamZcombo->setEnabled(false); - break; - case 2: - // PlainTriples - ui->streamXcombo->setEnabled(true); - ui->streamYcombo->setEnabled(true); - ui->streamZcombo->setEnabled(true); - break; - case 4: - // FoQTriples - ui->streamXcombo->setEnabled(false); - ui->streamYcombo->setEnabled(false); - ui->streamZcombo->setEnabled(false); - break; - } - ui->triplesOrderCombo->setEnabled(index!=4); -} - -void HDTSpecForm::on_inputFileButton_clicked() -{ - static QString lastDir = QDir::currentPath(); - QString file = QFileDialog::getOpenFileName(this,tr("Select Input RDF File"), lastDir, tr("RDF Files(*)"), 0, 0 ); - if(file!="") { - lastDir=file; - if(getBaseUri()=="") { - ui->baseUriText->setText(""); - } - - QString noCompression=file; - - if(file.endsWith(".gz", Qt::CaseInsensitive)) { - noCompression = file.left(file.length()-3); - } - - if(noCompression.endsWith(".ttl", Qt::CaseInsensitive)) { - ui->rdfInputCombo->setCurrentIndex(2); - } else if(noCompression.endsWith(".nt", Qt::CaseInsensitive)) { - ui->rdfInputCombo->setCurrentIndex(0); - } else if(noCompression.endsWith(".n3", Qt::CaseInsensitive)) { - ui->rdfInputCombo->setCurrentIndex(1); - } else if(noCompression.endsWith(".rdf", Qt::CaseInsensitive) || noCompression.endsWith(".xml", Qt::CaseInsensitive)) { - ui->rdfInputCombo->setCurrentIndex(3); - } - } - ui->rdfInputFile->setText(file); -} - -QString HDTSpecForm::getFileName() -{ - return ui->rdfInputFile->text(); -} - -QString HDTSpecForm::getBaseUri() -{ - return ui->baseUriText->text(); -} - -std::string HDTSpecForm::getStreamType(int index) { - switch(index) { - case 0: - // LogStream - return hdt::HDTVocabulary::SEQ_TYPE_LOG; - case 1: - // IntegerStream - return hdt::HDTVocabulary::SEQ_TYPE_INT32; - case 2: - // HuffmanStream - return hdt::HDTVocabulary::SEQ_TYPE_HUFFMAN; - case 3: - // WaveletStream - return hdt::HDTVocabulary::SEQ_TYPE_WAVELET; - } - return ""; -} - -void HDTSpecForm::fillHDTSpecification(hdt::HDTSpecification &hdt) -{ - hdt.set("triplesOrder", hdt::getOrderStr((hdt::TripleComponentOrder)(ui->triplesOrderCombo->currentIndex()+1))); - - hdt.set("header.type", hdt::HDTVocabulary::DICTIONARY_TYPE_PLAIN); - - switch(ui->dictionaryTypeCombo->currentIndex()) { - case 0: - // FourSectionDictionary - hdt.set("dictionary.type", hdt::HDTVocabulary::DICTIONARY_TYPE_FOUR); - break; - case 1: - // PlainDictionary - hdt.set("dictionary.type", hdt::HDTVocabulary::DICTIONARY_TYPE_PLAIN); - break; - case 2: - // LiteralDictionary - hdt.set("dictionary.type", hdt::HDTVocabulary::DICTIONARY_TYPE_LITERAL); - break; - } - - switch(ui->triplesTypeCombo->currentIndex()) { - case 0: - // BitmapTriples - hdt.set("triples.type", hdt::HDTVocabulary::TRIPLES_TYPE_BITMAP); - break; - case 1: - // TriplesList - hdt.set("triples.type", hdt::HDTVocabulary::TRIPLES_TYPE_TRIPLESLIST); - break; - case 2: - // PlainTriples - hdt.set("triples.type", hdt::HDTVocabulary::TRIPLES_TYPE_PLAIN); - break; - } - - if(ui->streamXcombo->isEnabled()) { - hdt.set("stream.x", getStreamType(ui->streamXcombo->currentIndex())); - } - - if(ui->streamYcombo->isEnabled()) { - hdt.set("stream.y", getStreamType(ui->streamYcombo->currentIndex())); - } - - if(ui->streamZcombo->isEnabled()) { - hdt.set("stream.z", getStreamType(ui->streamZcombo->currentIndex())); - } -} - -hdt::RDFNotation HDTSpecForm::getNotation() -{ - switch(ui->rdfInputCombo->currentIndex()) { - case 0: - return hdt::NTRIPLES; - case 1: - return hdt::N3; - case 2: - return hdt::TURTLE; - case 3: - return hdt::XML; - } - return hdt::NTRIPLES; -} - -void HDTSpecForm::accept() -{ - if(getFileName()=="") { - QMessageBox::warning(NULL, tr("Select a file name."), tr("Please insert a file name or URI.")); - } else { - done(1); - } -} diff --git a/hdt-it/hdtspecform.hpp b/hdt-it/hdtspecform.hpp deleted file mode 100644 index 50f41e5a..00000000 --- a/hdt-it/hdtspecform.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef HDTSPECFORM_HPP -#define HDTSPECFORM_HPP - -#include - -#include -#include -#include - -namespace Ui { - class HDTSpecForm; -} - -class HDTSpecForm : public QDialog -{ - Q_OBJECT - -public: - explicit HDTSpecForm(QWidget *parent = 0); - ~HDTSpecForm(); - -public: - QString getFileName(); - QString getBaseUri(); - void fillHDTSpecification(hdt::HDTSpecification &spec); - hdt::RDFNotation getNotation(); - -private: - Ui::HDTSpecForm *ui; - std::string getStreamType(int index); - -private slots: - void on_triplesTypeCombo_currentIndexChanged(int index); - void on_inputFileButton_clicked(); - void accept(); -}; - -#endif // HDTSPECFORM_HPP diff --git a/hdt-it/hdtspecform.ui b/hdt-it/hdtspecform.ui deleted file mode 100644 index ecc38d2d..00000000 --- a/hdt-it/hdtspecform.ui +++ /dev/null @@ -1,361 +0,0 @@ - - - HDTSpecForm - - - Qt::WindowModal - - - true - - - - 0 - 0 - 470 - 533 - - - - Import RDF File to HDT - - - - - - - - InputRDF file name or URI - - - - - - - - - - - - - ... - - - - - - - - NTRIPLES - - - - - N3 - - - - - TURTLE - - - - - RDF-XML - - - - - - - - - - - Base URI for the dataset - - - - - - - - - - - - - - - - Header - - - - - - - Plain - - - - - - - - Type: - - - - - - - - - - Dictionary - - - - - - - 0 - 0 - - - - Type: - - - - - - - - 0 - 0 - - - - - Plain Front Coding - - - - - Plain - - - - - - - - - - - Triples - - - - - - Type: - - - - - - - - BitmapTriples - - - - - TriplesList - - - - - PlainTriples - - - - - - - - - SPO - - - - - SOP - - - - - PSO - - - - - POS - - - - - OSP - - - - - OPS - - - - - - - - Order - - - - - - - false - - - - LogStream - - - - - IntegerStream - - - - - HuffmanStream - - - - - - - - - LogStream - - - - - IntegerStream - - - - - HuffmanStream - - - - - - - - - LogStream - - - - - IntegerStream - - - - - HuffmanStream - - - - - - - - StreamX: - - - - - - - StreamY: - - - - - - - StreamZ: - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - HDTSpecForm - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - HDTSpecForm - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/hdt-it/hdtsummarygenerator.cpp b/hdt-it/hdtsummarygenerator.cpp deleted file mode 100644 index c78d6f7e..00000000 --- a/hdt-it/hdtsummarygenerator.cpp +++ /dev/null @@ -1,109 +0,0 @@ -#include "hdtsummarygenerator.hpp" - -#include - -#include -#include -#include -#include - -#include "stringutils.hpp" - -QString HDTSummaryGenerator::getSummary(HDTController *hdtController) -{ - hdt::HDT *hdt = hdtController->getHDT(); - if(!hdt) { - return tr("No open file."); - } - - hdt::Header *head = hdt->getHeader(); - hdt::Dictionary *dict = hdt->getDictionary(); - hdt::Triples *triples = hdt->getTriples(); - QString output; - QLocale loc = QLocale::system(); - - output.append(tr("

Dataset:

")); - QString fileName = hdtController->getFileName(); - output.append(tr("File name: ")); - output.append(fileName); - output.append("
"); - - try { - QString baseUri = stringutils::escapeHTML(head->getSubject(hdt::HDTVocabulary::RDF_TYPE.c_str(), hdt::HDTVocabulary::HDT_DATASET.c_str()).c_str()); - output.append(tr("Dataset base URI: ")); - output.append(baseUri); - output.append("
"); - } catch (const char *e) { - } - - quint64 originalSize=0; - quint64 hdtSize=0; - try { - originalSize = head->getPropertyLong("_:statistics", hdt::HDTVocabulary::ORIGINAL_SIZE.c_str()); - output.append(tr("Original Size: ")); - output.append(stringutils::sizeHuman(originalSize)); - output.append("
"); - } catch (const char *e) { - } - - try { - hdtSize = head->getPropertyLong("_:statistics", hdt::HDTVocabulary::HDT_SIZE.c_str()); - output.append(tr("HDT Size: ")); - output.append(stringutils::sizeHuman(hdtSize)); - output.append("
"); - } catch (const char *e) { - } - - if(originalSize!=0 && hdtSize!=0) { - output.append(tr("Compression ratio: ")); - output.append(QString::number(hdtSize*100.0/originalSize, 'f', 2)); - output.append("%
"); - } - - try { - string issued = head->getProperty("_:publicationInformation", hdt::HDTVocabulary::DUBLIN_CORE_ISSUED.c_str()); - QString qissued =QString(issued.c_str()).replace("\"", ""); - int idx; - if((idx = qissued.lastIndexOf("+"))!=-1) { - qissued = qissued.left(idx); - } - QDateTime date = QDateTime::fromString(qissued, Qt::ISODate); - if(date.isValid()) { - output.append(QString(tr("Issued: %1
")).arg(loc.toString(date.date()))); - } - } catch (const char *e) { - } - - -#if 0 - output.append(tr("

Header:

")); - output.append(QString(tr("Number of triples: %1
").arg(loc.toString(head->getNumberOfElements()))); -#endif - - output.append(tr("

Dictionary:

")); - output.append(QString(tr("Number of entries: %1
")).arg(loc.toString((quint64)dict->getNumberOfElements()))); - output.append(QString(tr("Different subjects: %1
")).arg(loc.toString(dict->getNsubjects()))); - output.append(QString(tr("Different predicates: %1
")).arg(loc.toString(dict->getNpredicates()))); - output.append(QString(tr("Different objects: %1
")).arg(loc.toString(dict->getNobjects()))); - output.append(QString(tr("Shared area: %1
")).arg(loc.toString(dict->getNshared()))); - output.append(QString(tr("Type: %1
")).arg(stringutils::escapeHTML(dict->getType().c_str()))); - - output.append(tr("Dictionary Size: ")); - output.append(stringutils::sizeHuman(dict->size())); - output.append(tr("
")); - - output.append(tr("

Triples:

")); - output.append(QString(tr("Number of triples: %1
")).arg(loc.toString((quint64)triples->getNumberOfElements()))); - - output.append(QString(tr("Type: %1
")).arg(stringutils::escapeHTML(triples->getType().c_str()))); - - output.append(tr("Triples Size: ")); - output.append(stringutils::sizeHuman(triples->size())); - output.append(tr("
")); - - output.append(tr("Triples Order: ")); - output.append(hdt::getOrderStr(triples->getOrder())); - output.append("
"); - - return output; -} diff --git a/hdt-it/hdtsummarygenerator.hpp b/hdt-it/hdtsummarygenerator.hpp deleted file mode 100644 index 385fe885..00000000 --- a/hdt-it/hdtsummarygenerator.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef HDTSUMMARYGENERATOR_HPP -#define HDTSUMMARYGENERATOR_HPP - -#include -#include -#include "hdtcontroller.hpp" - -class HDTSummaryGenerator : public QObject -{ - Q_OBJECT -public: - static QString getSummary(HDTController *hdtController); -}; - -#endif // HDTSUMMARYGENERATOR_HPP diff --git a/hdt-it/hdtwinico.ico b/hdt-it/hdtwinico.ico deleted file mode 100644 index a19b922c..00000000 Binary files a/hdt-it/hdtwinico.ico and /dev/null differ diff --git a/hdt-it/hdtwinico2.ico b/hdt-it/hdtwinico2.ico deleted file mode 100644 index e18a3c15..00000000 Binary files a/hdt-it/hdtwinico2.ico and /dev/null differ diff --git a/hdt-it/headermodel.cpp b/hdt-it/headermodel.cpp deleted file mode 100644 index 4076373f..00000000 --- a/hdt-it/headermodel.cpp +++ /dev/null @@ -1,174 +0,0 @@ -#include "headermodel.hpp" -#include - -HeaderModel::HeaderModel(HDTController *view) : hdtController(view), triples(NULL) -{ - this->updateDatasetChanged(); -} - -HeaderModel::~HeaderModel() -{ - if(triples!=NULL) { - delete triples; - triples = NULL; - } -} - -int HeaderModel::rowCount(const QModelIndex &parent) const -{ - if(hdtController->hasHDT()) { - return (int)hdtController->getHDT()->getHeader()->getNumberOfElements(); - } - return 0; -} - -int HeaderModel::columnCount(const QModelIndex &parent) const -{ - return 3; -} - -QVariant HeaderModel::data(const QModelIndex &index, int role) const -{ - if(triples == NULL) { - return QVariant(); - } - - switch(role) { - case Qt::EditRole: - case Qt::ToolTipRole: - case Qt::DisplayRole: - { - //cout << "HeaderModel.data " << index.row() << "," << index.column() << endl; - // Compiler complains that by calling findTriple we are modifying internal - // state, which is illegal due to this function being const. But we need to - // modify the currentIndex and currentTriple, so we can avoid it. - HeaderModel *noConstThis = const_cast(this); - noConstThis->findTriple(index.row()); - - switch(index.column()) { - case 0: - return currentTriple->getSubject().c_str(); - case 1: - return currentTriple->getPredicate().c_str(); - case 2: - return currentTriple->getObject().c_str(); - } - - return QVariant(); - } - case Qt::FontRole: - { - static QFont font; - font.setPointSize(10); - return font; - } - - } - return QVariant(); -} - - -QVariant HeaderModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - - switch(role) { - case Qt::DisplayRole: - { - if(orientation == Qt::Horizontal) { - switch(section) { - case 0: - return tr("Subject"); - case 1: - return tr("Predicate"); - case 2: - return tr("Object"); - } - } else { - return QString::number(section+1); - } - break; - } - } - - return QVariant(); -} - -void HeaderModel::updateDatasetChanged() { - if(triples!=NULL) { - delete triples; - triples = NULL; - } - - if(hdtController->hasHDT()) { - triples = hdtController->getHDT()->getHeader()->search("","",""); - if(triples->hasNext()) { - currentTriple = triples->next(); - } - } else { - triples = NULL; - currentTriple = NULL; - } - currentIndex = 0; - - emit layoutChanged(); -} - - -void HeaderModel::findTriple(unsigned int index) -{ - if(triples == NULL) { - return; - } - - if(currentIndex > index) { - currentIndex = 0; - triples->goToStart(); - if(triples->hasNext()) { - currentTriple = triples->next(); - } - } - - while(currentIndex < index && triples->hasNext()) { - currentTriple = triples->next(); - currentIndex++; - } - - //cout << "Access " << currentIndex << " => " << *currentTriple << endl; -} - -Qt::ItemFlags HeaderModel::flags(const QModelIndex &index) const -{ - return Qt::ItemIsEnabled | Qt::ItemIsSelectable /*| Qt::ItemIsEditable*/; -} - -bool HeaderModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - if (index.isValid() && role == Qt::EditRole) { - - HeaderModel *noConstThis = const_cast(this); - noConstThis->findTriple(index.row()); - - string str(value.toString().toLatin1()); - switch(index.column()) { - case 0: - currentTriple->setSubject(str); - break; - case 1: - currentTriple->setPredicate(str); - break; - case 2: - currentTriple->setObject(str); - break; - } - - emit dataChanged(index, index); - return true; - } - return false; -} - - - - - - diff --git a/hdt-it/headermodel.hpp b/hdt-it/headermodel.hpp deleted file mode 100644 index 90eb32f6..00000000 --- a/hdt-it/headermodel.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef HEADERMODEL_HPP -#define HEADERMODEL_HPP - -#include - -#include - -#include "hdtcontroller.hpp" - -class HDTController; - -class HeaderModel : public QAbstractTableModel { - Q_OBJECT -private: - HDTController *hdtController; - hdt::IteratorTripleString *triples; - hdt::TripleString *currentTriple; - unsigned int currentIndex; - - void findTriple(unsigned int index); - -public: - HeaderModel(HDTController *view); - ~HeaderModel(); - - int rowCount(const QModelIndex &parent = QModelIndex()) const ; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - Qt::ItemFlags flags(const QModelIndex &index) const; - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - bool setData(const QModelIndex & index, const QVariant & value, int role); - - void updateDatasetChanged(); -signals: -}; - - -#endif // HEADERMODEL_HPP diff --git a/hdt-it/loading.gif b/hdt-it/loading.gif deleted file mode 100644 index 8add8e27..00000000 Binary files a/hdt-it/loading.gif and /dev/null differ diff --git a/hdt-it/logo-hdt.png b/hdt-it/logo-hdt.png deleted file mode 100644 index 306a25e0..00000000 Binary files a/hdt-it/logo-hdt.png and /dev/null differ diff --git a/hdt-it/logo-hdt2.png b/hdt-it/logo-hdt2.png deleted file mode 100644 index 0e4ea599..00000000 Binary files a/hdt-it/logo-hdt2.png and /dev/null differ diff --git a/hdt-it/main.cpp b/hdt-it/main.cpp deleted file mode 100644 index 10dc0c40..00000000 --- a/hdt-it/main.cpp +++ /dev/null @@ -1,39 +0,0 @@ - -#include -#include -#include -#include "myapplication.hpp" -#include "hdtit.hpp" - -#include - -int main(int argc, char *argv[]) -{ - MyApplication a(argc, argv); - - QTranslator qtTranslator; - qtTranslator.load("qt_" + QLocale::system().name(), - QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - a.installTranslator(&qtTranslator); - - QTranslator myappTranslator; -#ifdef __APPLE__ - myappTranslator.load("../Resources/hdt-it_"+QLocale::system().name()); -#else - myappTranslator.load("hdt-it_"+QLocale::system().name()); -#endif - a.installTranslator(&myappTranslator); - - HDTit w; - - a.setHDTit(&w); - - w.show(); - - if(argc>1) { - QString str(argv[1]); - w.openHDTFile(str); - } - - return a.exec(); -} diff --git a/hdt-it/matrixviewwidget.cpp b/hdt-it/matrixviewwidget.cpp deleted file mode 100644 index ad376039..00000000 --- a/hdt-it/matrixviewwidget.cpp +++ /dev/null @@ -1,501 +0,0 @@ -#include "matrixviewwidget.hpp" - -#include "Color.h" -#include -#include "stringutils.hpp" - - -MatrixViewWidget::MatrixViewWidget(QWidget *parent) : - QGLWidget(parent) -{ - setMouseTracking(true); - connect(&camera, SIGNAL(cameraChanged()), (QObject *)this, SLOT(updateGL())); - connect(&camera, SIGNAL(rotationChanged()), (QObject *)this, SIGNAL(rotationChanged())); - - timer.setInterval(20); - connect(&timer, SIGNAL(timeout()), this, SLOT(updateGL())); - - //timer.start(); - -#ifdef GESTURES - //grabGesture(Qt::PanGesture); - grabGesture(Qt::PinchGesture); - //grabGesture(Qt::SwipeGesture); -#endif -} - -MatrixViewWidget::~MatrixViewWidget() { - -} - -void MatrixViewWidget::setManager(HDTController *hdtManager) -{ - this->hdtController = hdtManager; -} - -Camera & MatrixViewWidget::getCamera() -{ - return camera; -} - -void MatrixViewWidget::initializeGL() -{ - glClearColor(BACKGROUND_COLOR); - //glClearDepth(1.0f); - - //glEnable(GL_DEPTH_TEST); - //glDepthFunc(GL_LEQUAL); - - // FIXME: Check support of alpha blending - glEnable (GL_BLEND); - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -} - -void MatrixViewWidget::paintShared() -{ - size_t nshared = hdtController->getHDT()->getDictionary()->getNshared(); - - glColor4d(SHARED_AREA_COLOR); - glBegin(GL_QUADS); - glVertex3f(0, 0, 0); - glVertex3f(0, nshared, 0); - glVertex3f(nshared, nshared, 0); - glVertex3f(nshared, 0, 0); - glEnd(); - - glColor4d(SHARED_AREA_BORDER_COLOR); - glBegin(GL_LINE_STRIP); - glVertex3f(0, nshared, 0); - glVertex3f(nshared, nshared, 0); - glVertex3f(nshared, 0, 0); - glEnd(); -} - -void MatrixViewWidget::paintScales() -{ - hdt::Dictionary *dict = hdtController->getHDT()->getDictionary(); - size_t nsubjects = dict->getMaxSubjectID(); - size_t nobjects = dict->getMaxObjectID(); - size_t npredicates = dict->getMaxPredicateID(); - - // Draw subject scale - for (size_t i = 0; i <= nsubjects; i += 1+nsubjects / 15) { - QString str; - if (nsubjects > 20000) { - str.append(QString("%1K").arg(i/1000)); - } else { - str.append(QString("%1").arg(i)); - } - glColor4d(TEXT_COLOR); - this->renderText(0.0, i+nsubjects*0.01, 0, str); - - glColor4d(GRID_COLOR); - glBegin(GL_LINES); - glVertex3f(0, i, 0); - glVertex3f(nobjects, i, 0); - glVertex3f(0, i, 0); - glVertex3f(0, i, npredicates); - glEnd(); - } - - // Draw object scale - for (size_t i = 0; i <= nobjects; i += 1+ nobjects / 15) { - QString str; - if (nobjects > 20000) { - str.append(QString("%1K").arg(i/1000)); - } else { - str.append(QString("%1").arg(i)); - } - glColor4d(TEXT_COLOR); - this->renderText(i, 0.0, 0, str); - - glColor4d(GRID_COLOR); - glBegin(GL_LINES); - glVertex3f(i, 0, 0); - glVertex3f(i, nsubjects, 0); - glVertex3f(i, 0, 0); - glVertex3f(i, 0, npredicates); - glEnd(); - } - - // Draw predicate scale - for (size_t i = 0; i <= npredicates; i += 1+npredicates / 10) { - QString str = QString::number(i); - //texto(str, 0, 0, i); - glColor4d(TEXT_COLOR); - this->renderText(0, 0, i, str, QFont()); - - glColor4d(GRID_COLOR); - glBegin(GL_LINES); - glVertex3f(0, 0, i); - glVertex3f(nobjects, 0, i); - glVertex3f(0, 0, i); - glVertex3f(0, nsubjects, i); - glEnd(); - } - - // Draw outter axis - glColor4d(AXIS_COLOR); - glBegin(GL_LINES); - glVertex3f(0, 0, 0); - glVertex3f(0, nsubjects, 0); - glVertex3f(0, 0, 0); - glVertex3f(nobjects, 0, 0); - - glVertex3f(0, 0, npredicates); - glVertex3f(0, nsubjects, npredicates); - glVertex3f(0, 0, npredicates); - glVertex3f(nobjects, 0, npredicates); - - glVertex3f(0, 0, 0); - glVertex3f(0, 0, npredicates); - - glVertex3f(0, nsubjects, 0); - glVertex3f(0, nsubjects, npredicates); - - glVertex3f(nobjects, 0, 0); - glVertex3f(nobjects, 0, npredicates); - - glVertex3f(nobjects, 0, 0); - glVertex3f(nobjects, nsubjects, 0); - - glVertex3f(nobjects, nsubjects, 0); - glVertex3f(0, nsubjects, 0); - glEnd(); - - // Draw labels - glColor4d(TEXT_COLOR); - renderText(0, nsubjects * 1.04, 0, "Subjects"); - renderText(nobjects * 1.05, 0, 0, "Objects"); - renderText(0, 0, npredicates*1.05, "Predicates"); -} - -void MatrixViewWidget::paintPoints() -{ - if(hdtController->getNumResults()==0) { - // Do not render anything - } else if(hdtController->getNumResults()<5000) { - // Render directly from iterator. - hdt::IteratorTripleID *it = hdtController->getHDT()->getTriples()->search(hdtController->getSearchPatternID()); - - glPointSize(3); - glBegin(GL_POINTS); - while(it->hasNext()) { - hdt::TripleID *tid = it->next(); - - Color *c = hdtController->getHDTCachedInfo()->getPredicateColor(tid->getPredicate()-1); - - if(hdtController->getPredicateStatus()->isPredicateActive(tid->getPredicate()-1)) { - glColor4d(c->r, c->g, c->b, 1.0); - } else { - glColor4d(c->r/4, c->g/4, c->b/4, 0.3); - } - - glVertex3f((float)tid->getObject(), (float)tid->getSubject(), (float)tid->getPredicate()); - } - glEnd(); - delete it; - - } else { - // Render from cached points. - glPointSize(RDF_POINT_SIZE); - glBegin(GL_POINTS); - vector triples = hdtController->getTriples(); - for(size_t i=0;imatch(hdtController->getSearchPatternID())) { - Color *c = hdtController->getHDTCachedInfo()->getPredicateColor(tid->getPredicate()-1); - - if(hdtController->getPredicateStatus()->isPredicateActive(tid->getPredicate()-1)) { - glColor4d(c->r, c->g, c->b, 1.0); - } else { - glColor4d(c->r/4, c->g/4, c->b/4, 0.3); - } - - glVertex3f((float)tid->getObject(), (float)tid->getSubject(), (float)tid->getPredicate()); - } - } - glEnd(); - } - -} - - - -void MatrixViewWidget::paintSelected() -{ - hdt::TripleID selectedTriple = hdtController->getSelectedTriple(); - - // Draw selected triple - if (selectedTriple.isValid()) { - size_t nsubjects = hdtController->getHDT()->getDictionary()->getMaxSubjectID(); - size_t npredicates = hdtController->getHDT()->getDictionary()->getMaxPredicateID(); - size_t nobjects = hdtController->getHDT()->getDictionary()->getMaxObjectID(); - - float x = selectedTriple.getObject(); - float y = selectedTriple.getSubject(); - float z = selectedTriple.getPredicate(); - - glColor4f(CROSS_COLOR); - glBegin(GL_LINES); - - // Draw + - glVertex3f(0, y, z); - glVertex3f(nobjects, y, z); - glVertex3f(x, 0, z); - glVertex3f(x, nsubjects, z); - - glEnd(); - - // Draw point - glPointSize(5); - glBegin(GL_POINTS); - Color c; - ColorRamp2 cr; - cr.apply(&c, z, 0, npredicates); - glColor4f(c.r, c.g, c.b, c.a); - glVertex3f(x, y, z); - glEnd(); - } -} - -void MatrixViewWidget::paintGL() -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - if(!hdtController->hasHDT()) { - return; - } - - glLoadIdentity(); - - camera.applyTransform(); - - size_t nsubjects = hdtController->getHDT()->getDictionary()->getMaxSubjectID(); - size_t nobjects = hdtController->getHDT()->getDictionary()->getMaxObjectID(); - size_t npredicates = hdtController->getHDT()->getDictionary()->getMaxPredicateID(); - - glScalef(1.0f / (float) nobjects, 1.0f / (float) nsubjects, 1.0f / (float) npredicates); - - // PAINT SHARED AREA - paintShared(); - - // RENDER SCALES - paintScales(); - - // RENDER POINTS - paintPoints(); - - // RENDER SELECTED - paintSelected(); -} - -void MatrixViewWidget::resizeGL(int w, int h) -{ - //std::cout << "Widget resize: " << w << ", " << h << std::endl; - camera.setScreenSize(w,h); - this->updateGL(); -} - -void MatrixViewWidget::mousePressEvent(QMouseEvent *event) -{ - //std::cout << event->type() << "DOW Btn: "<< event->buttons() << " Mod: " << event->modifiers() << " " << event->x() << ", " << event->y() << std::endl; - - lastClickX = lastX = event->x(); - lastClickY = lastY = event->y(); - buttonClick = event->buttons(); -} - -void MatrixViewWidget::mouseReleaseEvent(QMouseEvent *event) -{ - //std::cout << event->type() << "REL Btn: "<< event->buttons() << " Mod: " << event->modifiers() << " " << event->x() << ", " << event->y() << std::endl; - - if(event->x()==lastClickX && event->y()==lastClickY) { - //std::cout << "Mouse CLICK" << std::endl; - if(buttonClick & Qt::LeftButton) { - //std::cout << "Left Mouse CLICK" << std::endl; - if(hdtController->getSelectedTriple().isValid()) { - hdtController->getPredicateStatus()->selectPredicate(hdtController->getSelectedTriple().getPredicate()); - } - } else if (buttonClick & Qt::RightButton) { - //std::cout << "Right Mouse CLICK" << std::endl; - hdtController->getPredicateStatus()->selectAllPredicates(); - } - } -} - -void MatrixViewWidget::unProject(int x, int y, double *outx, double *outy, double *outz) -{ - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - camera.applyTransform(); - - hdt::Dictionary *dict = hdtController->getHDT()->getDictionary(); - - glScalef(1.0f / (float) dict->getMaxObjectID(), - 1.0f / (float) dict->getMaxSubjectID(), - 1.0f / (float) dict->getMaxPredicateID()); - - // UnProject - GLint viewport[4]; - GLdouble modelview[16], projection[16]; - GLdouble wx = x, wy, wz; - - glGetIntegerv(GL_VIEWPORT, viewport); - y = viewport[3] - y; - wy = y; - - glGetDoublev(GL_MODELVIEW_MATRIX, modelview); - glGetDoublev(GL_PROJECTION_MATRIX, projection); - glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &wz); - //printf("Orig: %f %f %f\n", wx, wy, wz); - gluUnProject(wx, wy, 0, modelview, projection, viewport, outx, outy, outz); - //printf("Dest: %f %f %f\n", *outx, *outy, *outz); -} - -void MatrixViewWidget::mouseMoveEvent(QMouseEvent *event) -{ - //std::cout << event->type() << "MOV Btn: "<< event->buttons() << " Mod: " << event->modifiers() << " " << event->x() << ", " << event->y() << std::endl; - - int diffx = event->x() - lastX; - int diffy = event->y() - lastY; - - lastX = event->x(); - lastY = event->y(); - - bool left = event->buttons() & Qt::LeftButton; - bool right = event->buttons() & Qt::RightButton; - bool shift = event->modifiers() & Qt::ShiftModifier; - - if(right || (left && shift)) { - camera.moveOffset(1.8*diffx, 1.8*diffy); - emit cameraChanged(); - } else if(left) { - camera.rotateCamera(diffx, diffy); - emit cameraChanged(); - } - - if(hdtController->getHDT()==NULL) - return; - - if(!camera.isFrontView()) { - hdtController->clearSelectedTriple(); - return; - } - - GLdouble subject, predicate, object; - this->unProject(event->x(), event->y(), &object, &subject, &predicate); - - hdt::Dictionary *dictionary = hdtController->getHDT()->getDictionary(); - if ( (subject > 0 && subject < dictionary->getMaxSubjectID()) && - (object > 0 && object <= dictionary->getMaxObjectID()) - ) { - hdtController->selectNearestTriple(subject,predicate, object); - - QString subjStr = stringutils::escapeHTML(stringutils::toQString(dictionary->idToString(hdtController->getSelectedTriple().getSubject(), hdt::SUBJECT).c_str())); - QString predStr = stringutils::escapeHTML(stringutils::toQString(dictionary->idToString(hdtController->getSelectedTriple().getPredicate(), hdt::PREDICATE).c_str())); - QString objStr = stringutils::escapeHTML(stringutils::toQString(dictionary->idToString(hdtController->getSelectedTriple().getObject(), hdt::OBJECT).c_str())); - stringutils::cut(objStr, 1000); - QString tooltip = QString("

S: %1

P: %2

O: %3

").arg(subjStr).arg(predStr).arg(objStr); - QPoint point = this->mapToGlobal(event->pos()); - QRect rect = QRect(point.x()-10, point.y()+10, 20, 20); - QToolTip::showText(point, tooltip, this, rect); - } else { - hdtController->clearSelectedTriple(); - QToolTip::hideText(); - } - - updateGL(); -} - - -void MatrixViewWidget::wheelEvent( QWheelEvent* e ) -{ - int delta = e->delta(); - if (e->orientation() == Qt::Horizontal) { -#ifdef GESTURES - camera.moveOffset(delta/2, 0); -#endif - } else { -#ifdef GESTURES - camera.moveOffset(0, delta/2); -#else - camera.increaseZoom(delta); -#endif - } - hdtController->clearSelectedTriple(); - e->accept(); -} - -#ifdef GESTURES -bool MatrixViewWidget::event(QEvent *event) -{ - static qreal previousZoom; - if (event->type() == QEvent::Gesture) { - QGestureEvent *gestureEvent = static_cast(event); - if (QGesture *swipe = gestureEvent->gesture(Qt::SwipeGesture)) { - QSwipeGesture *swipeGesture = static_cast(swipe); - } else if (QGesture *pan = gestureEvent->gesture(Qt::PanGesture)) { - QPanGesture *panGesture = static_cast(pan); - if(panGesture->state() == Qt::GestureStarted) { - //cout << "Panning start" << endl; - } - if(panGesture->state() == Qt::GestureFinished) { - //cout << "Panning end" << endl; - } - return true; - } else if (QGesture *pinch = gestureEvent->gesture(Qt::PinchGesture)) { - QPinchGesture *pinchGesture = static_cast(pinch); - - QPinchGesture::ChangeFlags changeFlags = pinchGesture->changeFlags(); - if (changeFlags & QPinchGesture::RotationAngleChanged) { - qreal value = pinchGesture->property("rotationAngle").toReal(); - qreal lastValue = pinchGesture->property("lastRotationAngle").toReal(); - camera.rotateCamera(2.0*(lastValue-value), 0); - return true; - } - - if (changeFlags & QPinchGesture::ScaleFactorChanged) { - if(pinchGesture->state() == Qt::GestureStarted) { - previousZoom = camera.getZoom(); - } - qreal value = pinchGesture->property("scaleFactor").toReal(); - camera.setZoom(previousZoom*value); - return true; - } - } - } - return QGLWidget::event(event); -} -#endif - -QSize MatrixViewWidget::minimumSizeHint() const -{ - return QSize(300,150); -} - -QSize MatrixViewWidget::sizeHint() const -{ - return QSize(800,600); -} - -void MatrixViewWidget::reloadHDTInfo() -{ - if(hdtController->getHDT()==NULL) { - return; - } - - updateGL(); -} - - - - - - - - - diff --git a/hdt-it/matrixviewwidget.hpp b/hdt-it/matrixviewwidget.hpp deleted file mode 100644 index 118683e1..00000000 --- a/hdt-it/matrixviewwidget.hpp +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef MATRIXVIEWWIDGET_HPP -#define MATRIXVIEWWIDGET_HPP - -#include -#include -#include - -#ifdef __APPLE__ -#include -#else -#include -#endif - -#include -#include - -#include "colors.hpp" -#include "Camera.h" -#include "StopWatch.hpp" - -#include "hdtcontroller.hpp" -#include "searchresultsmodel.hpp" -#include "triplecomponentmodel.hpp" - -class SearchResultsModel; -class TripleComponentModel; -class HDTController; - -#ifdef __APPLE__ -//#define GESTURES -#endif - -class MatrixViewWidget : public QGLWidget -{ - Q_OBJECT - -private: - QTimer timer; - Camera camera; - int lastX, lastY, lastClickX, lastClickY, buttonClick; - HDTController *hdtController; - - void unProject(int x, int y, double *outx, double *outy, double *outz); - - void paintShared(); - void paintScales(); - void paintPoints(); - void paintSelected(); - -public: - explicit MatrixViewWidget(QWidget *parent = 0); - ~MatrixViewWidget(); - - void setManager(HDTController *hdtManager); - - QSize minimumSizeHint() const; - QSize sizeHint() const; - - Camera &getCamera(); -protected: - void initializeGL(); - void paintGL(); - void resizeGL(int width, int height); - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void wheelEvent( QWheelEvent* e ); -#ifdef GESTURES - bool event(QEvent *); -#endif - -public slots: - void reloadHDTInfo(); - -signals: - void rotationChanged(); - void cameraChanged(); -}; - - -#endif // MATRIXVIEWWIDGET_HPP diff --git a/hdt-it/myapplication.cpp b/hdt-it/myapplication.cpp deleted file mode 100644 index 607b0843..00000000 --- a/hdt-it/myapplication.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "myapplication.hpp" - -MyApplication::MyApplication(int &argc, char **argv) : QApplication(argc, argv), hdtIt(NULL) -{ -} - -bool MyApplication::event(QEvent *event) -{ - switch (event->type()) { - case QEvent::FileOpen: - loadFile(static_cast(event)->file()); - return true; - default: - return QApplication::event(event); - } -} - -void MyApplication::loadFile(QString fileName) -{ - if(hdtIt) { - hdtIt->openHDTFile(fileName); - } -} - -void MyApplication::setHDTit(HDTit *hdtIt) -{ - this->hdtIt=hdtIt; -} - -bool MyApplication::notify(QObject *o, QEvent *e) -{ - try { - return QApplication::notify(o, e); - } catch (char *err) { - std::cerr << "Exception caugth in notify (char *): " << err << endl; - } catch (const char *err) { - std::cerr << "Exception caugth in notify (const char *): " << err << endl; - } catch (const std::exception& ex) { - std::cerr << "Exception caugth in notify (std::exception &): " << ex.what() << endl; - } catch (const std::string& ex) { - std::cerr << "Exception caugth in notify (std::string &): " << ex << endl; - } catch (...) { - std::cerr << "Unknown Exception caugth in notify: " << endl; - } -} diff --git a/hdt-it/myapplication.hpp b/hdt-it/myapplication.hpp deleted file mode 100644 index a0b78fe8..00000000 --- a/hdt-it/myapplication.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef MYAPPLICATION_HPP -#define MYAPPLICATION_HPP - -#include -#include "hdtit.hpp" - -class MyApplication : public QApplication -{ - Q_OBJECT -private: - HDTit *hdtIt; - void loadFile(QString fileName); -public: - explicit MyApplication(int &argc, char **argv); - bool event(QEvent *); - void setHDTit(HDTit *hdtIt); - bool notify(QObject *, QEvent *); -signals: - -public slots: - -}; - -#endif // MYAPPLICATION_HPP diff --git a/hdt-it/predicatestatus.cpp b/hdt-it/predicatestatus.cpp deleted file mode 100644 index 8c1a3d2c..00000000 --- a/hdt-it/predicatestatus.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "predicatestatus.hpp" - -PredicateStatus::PredicateStatus(HDTController *manager) : - controller(manager), minPredicateCount(0), maxPredicateCount(0) -{ -} - -size_t PredicateStatus::getMinimumPredicateCount() -{ - return minPredicateCount; -} - -size_t PredicateStatus::getMaximumPredicateCount() -{ - return maxPredicateCount; -} - -bool PredicateStatus::isPredicateActive(size_t i) -{ - return activePredicate[i]; -} - -void PredicateStatus::setPredicateActive(size_t i, bool b) -{ - if(activePredicate[i]!=b) { - activePredicate[i] = b; - setMinimumPredicateCountInternal(0); - emit predicatesChanged(i,i); - } -} - -void PredicateStatus::refreshAll() -{ - activePredicate.clear(); - if(controller->hasHDT()) { - activePredicate.resize(controller->getHDT()->getDictionary()->getNpredicates(), true); - this->maxPredicateCount = controller->getHDTCachedInfo()->getMaxPredicateCount(); - setMinimumPredicateCountInternal(0); - } -} - -void PredicateStatus::selectAllPredicates() -{ -// cout << "selectAllPredicates" << endl; - for(size_t i=0;igetHDTCachedInfo()->getPredicateUsages(i)>=(size_t)count; - } - emit predicatesChanged(0, activePredicate.size()); - emit minimumPredicateCountChanged(count); - } -} diff --git a/hdt-it/predicatestatus.hpp b/hdt-it/predicatestatus.hpp deleted file mode 100644 index aa81a906..00000000 --- a/hdt-it/predicatestatus.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef PREDICATESTATUS_HPP -#define PREDICATESTATUS_HPP - -#include -#include "hdtcontroller.hpp" - -class PredicateStatus : public QObject -{ - Q_OBJECT -private: - vector activePredicate; - size_t minPredicateCount; - size_t maxPredicateCount; - HDTController *controller; - - void setMinimumPredicateCountInternal(int count); -public: - explicit PredicateStatus(HDTController *controller); - - size_t getMinimumPredicateCount(); - size_t getMaximumPredicateCount(); - - bool isPredicateActive(size_t i); - void setPredicateActive(size_t i, bool b); - -signals: - void predicatesChanged(size_t min, size_t max); - void minimumPredicateCountChanged(size_t newval); - void predicateSelected(size_t npred); - -public slots: - void refreshAll(); - void selectPredicate(size_t pred); - void selectAllPredicates(); - void selectNonePredicates(); - void setMinimumPredicateCount(int count); -}; - -#endif // PREDICATESTATUS_HPP diff --git a/hdt-it/qclearlineedit.cpp b/hdt-it/qclearlineedit.cpp deleted file mode 100644 index 78ea3b43..00000000 --- a/hdt-it/qclearlineedit.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "qclearlineedit.hpp" -#include -#include - -QClearLineEdit::QClearLineEdit(QWidget *parent) - : QLineEdit(parent) -{ - clearButton = new QToolButton(this); - QPixmap pixmap(":/images/editreset.png"); - clearButton->setIcon(QIcon(pixmap)); - clearButton->setIconSize(pixmap.size()); - clearButton->setCursor(Qt::ArrowCursor); - clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }"); - clearButton->hide(); - connect(clearButton, SIGNAL(clicked()), this, SLOT(clear())); - connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateCloseButton(const QString&))); - int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); - setStyleSheet(QString("QLineEdit { padding-right: %1px; } ").arg(clearButton->sizeHint().width() + frameWidth + 1)); - QSize msz = minimumSizeHint(); - setMinimumSize(qMax(msz.width(), clearButton->sizeHint().height() + frameWidth * 2 + 2), - qMax(msz.height(), clearButton->sizeHint().height() + frameWidth * 2 + 2)); - - suggestions = new DictionarySuggestions(this); -} - -QClearLineEdit::~QClearLineEdit() -{ - delete suggestions; - delete clearButton; -} - -void QClearLineEdit::resizeEvent(QResizeEvent *) -{ - QSize sz = clearButton->sizeHint(); - int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); - clearButton->move(rect().right() - frameWidth - sz.width(), - (rect().bottom() + 1 - sz.height())/2); -} - -void QClearLineEdit::updateCloseButton(const QString& text) -{ - clearButton->setVisible(!text.isEmpty()); -} - -DictionarySuggestions * QClearLineEdit::getSuggestions() -{ - return suggestions; -} diff --git a/hdt-it/qclearlineedit.hpp b/hdt-it/qclearlineedit.hpp deleted file mode 100644 index d818da9e..00000000 --- a/hdt-it/qclearlineedit.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef QCLEARLINEEDIT_HPP -#define QCLEARLINEEDIT_HPP - -#include - -#include "dictionarysuggestions.hpp" - -class QToolButton; - -class QClearLineEdit: public QLineEdit -{ - Q_OBJECT - -public: - QClearLineEdit(QWidget *parent = 0); - ~QClearLineEdit(); - DictionarySuggestions *getSuggestions(); - -protected: - void resizeEvent(QResizeEvent *); - -private slots: - void updateCloseButton(const QString &text); - -private: - QToolButton *clearButton; - DictionarySuggestions *suggestions; -}; - -#endif // QCLEARLINEEDIT_HPP diff --git a/hdt-it/regexmodel.cpp b/hdt-it/regexmodel.cpp deleted file mode 100644 index 64891215..00000000 --- a/hdt-it/regexmodel.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include "stringutils.hpp" -#include "regexmodel.hpp" - -#include -#include - -class QFont; - -#include "../hdt-lib/src/dictionary/LiteralDictionary.hpp" - -RegexModel::RegexModel(HDTController *manager) : hdtController(manager), numResults(0), results(NULL) -{ -} - -RegexModel::~RegexModel() -{ - if(results!=NULL) { - free(results); - } -} - -void RegexModel::setQuery(QString query) -{ - if(hdtController->hasHDT()) { - hdt::LiteralDictionary *dict = dynamic_cast(hdtController->getHDT()->getDictionary()); - if(dict==NULL) { - QMessageBox::warning(NULL, tr("ERROR"), tr("This HDT does not support substring search")); - return; - } - if(query.length()==0) { - numResults = 0; - } else { - QByteArray arr = query.toUtf8(); - numResults = dict->substringToId((uchar *)arr.data(), arr.size(), &results); - } - emit layoutChanged(); - } -} - -int RegexModel::rowCount(const QModelIndex &parent) const -{ - return (int)numResults; -} - -int RegexModel::columnCount(const QModelIndex &parent) const -{ - return 2; -} - -QVariant RegexModel::data(const QModelIndex &index, int role) const -{ - if(results==NULL) { - return QVariant(); - } - - switch(role) { - case Qt::ToolTipRole: - case Qt::DisplayRole: - { - hdt::Dictionary *d = hdtController->getHDT()->getDictionary(); - - try { - switch(index.column()) { - case 0: - { - hdt::Triples *t = hdtController->getHDT()->getTriples(); - - hdt::TripleID tripleObject(0, 0, results[index.row()]); - hdt::IteratorTripleID *it = t->search(tripleObject); - - int nResults = it->estimatedNumResults(); - delete it; - - return nResults; - } - case 1: { - return stringutils::toQString(d->idToString(results[index.row()], hdt::OBJECT).c_str()); - } - } - - } catch (char *e) { - cerr << "Error accesing dictionary: " << e << endl; - } catch (const char *e) { - cerr << "Error accesing dictionary: " << e << endl; - } - return QVariant(); - - break; - } - case Qt::FontRole: - { - static QFont font; - font.setPointSize(10); - return font; - } - - } - return QVariant(); -} - -QVariant RegexModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - switch(role) { - case Qt::DisplayRole: - { - if(orientation == Qt::Horizontal) { - switch(section) { - case 0: - return tr("Triples "); - case 1: - return tr("Object Literal"); - } - } else { - return QString::number(results[section]); - } - break; - } - } - - return QVariant(); -} - -void RegexModel::updateDatasetChanged() -{ - if(results==NULL) { - free(results); - } - numResults = 0; - results=NULL; - - emit layoutChanged(); -} diff --git a/hdt-it/regexmodel.hpp b/hdt-it/regexmodel.hpp deleted file mode 100644 index 887e966d..00000000 --- a/hdt-it/regexmodel.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef REGEXMODEL_HPP -#define REGEXMODEL_HPP - -#include - -#include "hdtcontroller.hpp" - -class HDTController; - -class RegexModel : public QAbstractTableModel -{ - Q_OBJECT - -private: - HDTController *hdtController; - uint32_t numResults; - uint32_t *results; - -public: - explicit RegexModel(HDTController *manager); - ~RegexModel(); - - void setQuery(QString query); - - int rowCount(const QModelIndex &parent = QModelIndex()) const ; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - - void updateDatasetChanged(); -signals: - -public slots: - -}; - -#endif // REGEXMODEL_HPP diff --git a/hdt-it/resultcounter.cpp b/hdt-it/resultcounter.cpp deleted file mode 100644 index f831e2b6..00000000 --- a/hdt-it/resultcounter.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "resultcounter.hpp" -#include - - -ResultCounter::ResultCounter(QObject *parent, HDTController *controller) : - QObject(parent), - hdtController(controller), - iterator(NULL) -{ -} - -void ResultCounter::startCounting() -{ - if(!hdtController->hasHDT()){ - return; - } - iterator = hdtController->getHDT()->getTriples()->search(hdtController->getSearchPatternID()); - shouldCancel = false; - QtConcurrent::run(this, &ResultCounter::run); -} - -void ResultCounter::cancel() -{ - shouldCancel = true; -} - -void ResultCounter::run() -{ - if(iterator==NULL) { - return; - } - StopWatch cl; - unsigned int numResults = 0; - while(!shouldCancel && iterator->hasNext()) { - iterator->next(); - numResults++; - - cl.stop(); - if(cl.getReal()>10000) { - cl.reset(); - emit numResultsChanged(numResults); - } - } - delete iterator; - iterator = NULL; - emit finished(); -} diff --git a/hdt-it/resultcounter.hpp b/hdt-it/resultcounter.hpp deleted file mode 100644 index e2671ee9..00000000 --- a/hdt-it/resultcounter.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef RESULTCOUNTER_HPP -#define RESULTCOUNTER_HPP - -#include - -#include - -class ResultCounter : public QObject -{ - Q_OBJECT -private: - HDTController *hdtController; - hdt::IteratorTripleID *iterator; - bool shouldCancel; -public: - explicit ResultCounter(QObject *parent, HDTController *hdtController); - - void run(); -signals: - void numResultsChanged(int numResults); - void messageChanged(QString message); - void finished(); -private slots: - void startCounting(); - void cancel(); -public slots: - -}; - -#endif // RESULTCOUNTER_HPP diff --git a/hdt-it/searchresultsmodel.cpp b/hdt-it/searchresultsmodel.cpp deleted file mode 100644 index e03a38d3..00000000 --- a/hdt-it/searchresultsmodel.cpp +++ /dev/null @@ -1,179 +0,0 @@ -#include "stringutils.hpp" -#include "searchresultsmodel.hpp" -#include - -SearchResultsModel::SearchResultsModel(HDTController *view) : hdtController(view), triples(NULL) -{ - this->updateResultListChanged(); -} - -SearchResultsModel::~SearchResultsModel() -{ - if(triples!=NULL) { - delete triples; - triples = NULL; - } -} - -int SearchResultsModel::rowCount(const QModelIndex &parent) const -{ - // FIXME: QTableView crashes when returning more than 100 Million rows :( - return numResults > 100000000 ? 100000000 : numResults; -} - -int SearchResultsModel::columnCount(const QModelIndex &parent) const -{ - return 3; -} - -QVariant SearchResultsModel::data(const QModelIndex &index, int role) const -{ - if(triples == NULL) { - return QVariant(); - } - - switch(role) { - case Qt::ToolTipRole: - case Qt::DisplayRole: - { - // cerr << "SearchResultsModel.data " << index.row() << "," << index.column() << endl; - // Compiler complains that by calling findTriple we are modifying internal - // state, which is illegal due to this function being const. But we need to - // modify the currentIndex and currentTriple, so we can avoid it. - SearchResultsModel *noConstThis = const_cast(this); - noConstThis->findTriple(index.row()); - - hdt::Dictionary *d = hdtController->getHDT()->getDictionary(); - - try { - switch(index.column()) { - case 0: - return stringutils::toQString(d->idToString(currentTriple->getSubject(), hdt::SUBJECT).c_str()); - case 1: - return stringutils::toQString(d->idToString(currentTriple->getPredicate(), hdt::PREDICATE).c_str()); - case 2: - return stringutils::toQString(d->idToString(currentTriple->getObject(), hdt::OBJECT).c_str()); - } - } catch (char *e) { - cerr << "Error accesing dictionary: " << e << endl; - } catch (const char *e) { - cerr << "Error accesing dictionary: " << e << endl; - } - return QVariant(); - - break; - } - case Qt::FontRole: - { - static QFont font; - font.setPointSize(10); - return font; - } - - } - return QVariant(); -} - - -QVariant SearchResultsModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - - switch(role) { - case Qt::DisplayRole: - { - if(orientation == Qt::Horizontal) { - switch(section) { - case 0: - return tr("Subject"); - case 1: - return tr("Predicate"); - case 2: - return tr("Object"); - } - } else { - return QString::number(section+1); - } - break; - } - } - - return QVariant(); -} - -void SearchResultsModel::updateResultListChanged() { - if(triples!=NULL) { - delete triples; - triples = NULL; - } - - if(hdtController->hasHDT()) { - triples = hdtController->getHDT()->getTriples()->search(hdtController->getSearchPatternID()); - if(triples->hasNext()) { - currentTriple = triples->next(); - } - } else { - triples = NULL; - currentTriple = NULL; - numResults=0; - } - currentIndex = 0; - goingUp = true; - numResults = hdtController->getNumResults(); - - emit layoutChanged(); -} - -void SearchResultsModel::updateNumResultsChanged() -{ - unsigned int old = numResults; - numResults = hdtController->getNumResults(); - - if(old!=numResults) { -#if 0 - beginInsertRows(QModelIndex(), old+1, numResults); - endInsertRows(); - //emit dataChanged(createIndex(old+1,0), createIndex(numResults,2)); -#else - emit layoutChanged(); -#endif - } -} - - -void SearchResultsModel::findTriple(unsigned int index) -{ - if(triples == NULL) { - return; - } - - if(triples->canGoTo() && abs((long int)currentIndex-(long int)index)>5) { - triples->goTo(index); - goingUp = true; - currentTriple = triples->next(); - currentIndex = index; - //cerr << "Jump: " << currentIndex << " => " << *currentTriple << endl; - return; - } - - while(currentIndex > index && triples->hasPrevious()) { - if(goingUp) { - // On direction changes, we need to move one extra position. - goingUp = false; - currentIndex++; - } - currentTriple = triples->previous(); - currentIndex--; - } - - while(currentIndex < index && triples->hasNext()) { - if(!goingUp){ - // On direction changes, we need to move one extra position. - goingUp = true; - currentIndex--; - } - currentTriple = triples->next(); - currentIndex++; - } - - //cerr << "Access " << currentIndex << " => " << *currentTriple << endl; -} diff --git a/hdt-it/searchresultsmodel.hpp b/hdt-it/searchresultsmodel.hpp deleted file mode 100644 index f4afdcfc..00000000 --- a/hdt-it/searchresultsmodel.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef SEARCHRESULTSMODEL_HPP -#define SEARCHRESULTSMODEL_HPP - -#include - -#include - -#include "hdtcontroller.hpp" - -class HDTController; - -class SearchResultsModel : public QAbstractTableModel { - Q_OBJECT -private: - HDTController *hdtController; - hdt::IteratorTripleID *triples; - hdt::TripleID *currentTriple; - unsigned int currentIndex; - unsigned int numResults; - bool goingUp; - - void findTriple(unsigned int index); - -public: - SearchResultsModel(HDTController *view); - ~SearchResultsModel(); - - int rowCount(const QModelIndex &parent = QModelIndex()) const ; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - - void updateResultListChanged(); - void updateNumResultsChanged(); -signals: -}; - - -#endif // SEARCHRESULTSMODEL_HPP diff --git a/hdt-it/sparqlform.cpp b/hdt-it/sparqlform.cpp deleted file mode 100644 index a67a5891..00000000 --- a/hdt-it/sparqlform.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "sparqlform.hpp" -#include "ui_sparqlform.h" - -#include "sparqlmodel.hpp" -#include "hdtit.hpp" - -SparqlForm::SparqlForm(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::SparqlForm) -{ - ui->setupUi(this); - - HDTit *hdtit = reinterpret_cast(parent); - sparqlModel = new SparqlModel(hdtit->getManager()); - ui->sparqlResultTable->setModel(sparqlModel); -} - -SparqlForm::~SparqlForm() -{ - delete ui; -} - -void SparqlForm::on_pushButton_clicked() -{ - sparqlModel->setQuery(ui->sparqlTextEdit->toPlainText()); - ui->sparqlResultTable->scrollToTop(); -} diff --git a/hdt-it/sparqlform.hpp b/hdt-it/sparqlform.hpp deleted file mode 100644 index 03bada67..00000000 --- a/hdt-it/sparqlform.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef JOINFORM_HPP -#define JOINFORM_HPP - -#include - -#include "sparqlmodel.hpp" - -namespace Ui { - class SparqlForm; -} - -class SparqlForm : public QMainWindow -{ - Q_OBJECT - -public: - explicit SparqlForm(QWidget *parent = 0); - ~SparqlForm(); - -private slots: - void on_pushButton_clicked(); - -private: - Ui::SparqlForm *ui; - SparqlModel *sparqlModel; -}; - -#endif // JOINFORM_HPP diff --git a/hdt-it/sparqlform.ui b/hdt-it/sparqlform.ui deleted file mode 100644 index 9ffcf56c..00000000 --- a/hdt-it/sparqlform.ui +++ /dev/null @@ -1,112 +0,0 @@ - - - SparqlForm - - - - 0 - 0 - 603 - 664 - - - - SPARQL Search - - - - - 0 - 0 - - - - - - - Qt::Vertical - - - - - 0 - 0 - - - - SPARQL - - - - - - - 0 - 1 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">SELECT ?x ?y ?z WHERE {?x ?y ?z . }</p></body></html> - - - - - - - Search - - - - - - - - Qt::Horizontal - - - - - 0 - 4 - - - - true - - - Qt::ElideMiddle - - - 300 - - - 50 - - - 20 - - - - - - - - - - - 0 - 0 - 603 - 22 - - - - - - - - diff --git a/hdt-it/sparqlmodel.cpp b/hdt-it/sparqlmodel.cpp deleted file mode 100644 index f81c43d9..00000000 --- a/hdt-it/sparqlmodel.cpp +++ /dev/null @@ -1,155 +0,0 @@ -#include "sparqlmodel.hpp" -#include - -#include - -#include - -SparqlModel::SparqlModel(HDTController *controller) : - hdtController(controller), - binding(NULL), - currentIndex(0), - numresults(0) -{ -} - -void SparqlModel::find(unsigned int index) { - if(currentIndex>index) { - currentIndex=0; - binding->goToStart(); - binding->findNext(); - } - while(currentIndexfindNext()) { - currentIndex++; - } else { - numresults = currentIndex+1; - emit layoutChanged(); - break; - } - } -} - -SparqlModel::~SparqlModel() -{ - -} - -class SparqlQuery { -public: - set vars; - vector patterns; -}; - -SparqlQuery parseSparql(string query) { - struct SparqlQuery output; - string word; - unsigned int phase = 0; - vector pattern; - - stringstream in(query, ios::in); - - while(in >> word) { - cout << word << endl; - if(word.size()==0) { - continue; - } - if(phase==0) { - if(word.at(0)=='?') { - output.vars.insert(word); - } else if(word=="WHERE") { - phase++; - } - } else { - if(word.at(0)=='.') { - if(pattern.size()!=3) { - throw "Pattern should have 3 components"; - } - hdt::TripleString trip(pattern[0], pattern[1], pattern[2]); - output.patterns.push_back(trip); - pattern.clear(); - } else { - if(word.at(0)=='{') { - - } else if(word.at(0)!='.'){ - cout << "**"<< word << "**" << endl; - pattern.push_back(word); - } - } - } - } - return output; -} - -void SparqlModel::setQuery(QString queryTxt) -{ - throw "Not implemented"; -#if 0 - SparqlQuery query = parseSparql(string(queryTxt.toAscii())); - - if(binding) { - delete binding; - } - - binding = hdtManager->getHDT()->searchJoin(query.patterns, query.vars); - binding->findNext(); - numresults = binding->estimatedNumResults(); - currentIndex = 0; - - emit layoutChanged(); -#endif -} - -int SparqlModel::rowCount(const QModelIndex &parent) const { - return numresults; -} -int SparqlModel::columnCount(const QModelIndex &parent) const { - if(binding==NULL) { - return 0; - } - return binding->getNumVars(); -} -QVariant SparqlModel::data(const QModelIndex &index, int role) const { - if(binding == NULL) { - return QVariant(); - } - - switch(role) { - case Qt::ToolTipRole: - case Qt::DisplayRole: - { - // Compiler complains that by calling findTriple we are modifying internal - // state, which is illegal due to this function being const. But we need to - // modify the currentIndex and currentTriple, so we can avoid it. - SparqlModel *noConstThis = const_cast(this); - noConstThis->find(index.row()); - - return binding->getVar(index.column()).c_str(); - } - case Qt::FontRole: - { - static QFont font; - font.setPointSize(10); - return font; - } - - } - return QVariant(); -} -QVariant SparqlModel::headerData(int section, Qt::Orientation orientation, int role) const { - if(binding==NULL) { - return QVariant(); - } - switch(role) { - case Qt::DisplayRole: - { - if(orientation == Qt::Horizontal) { - return binding->getVarName(section); - } else { - return QString::number(section+1); - } - break; - } - } - return QVariant(); -} diff --git a/hdt-it/sparqlmodel.hpp b/hdt-it/sparqlmodel.hpp deleted file mode 100644 index 0e5147fd..00000000 --- a/hdt-it/sparqlmodel.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef JOINMODEL_HPP -#define JOINMODEL_HPP - -#include - -#include - -#include "hdtcontroller.hpp" - -class SparqlModel : public QAbstractTableModel { - Q_OBJECT -private: - HDTController *hdtController; - - hdt::VarBindingString *binding; - unsigned int currentIndex; - unsigned int numresults; - void find(unsigned int index); -public: - SparqlModel(HDTController *controller); - virtual ~SparqlModel(); - - void setQuery(QString query); - - int rowCount(const QModelIndex &parent = QModelIndex()) const ; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - QVariant headerData(int section, Qt::Orientation orientation, int role) const; -signals: -}; - -#endif // JOINMODEL_HPP diff --git a/hdt-it/stringutils.cpp b/hdt-it/stringutils.cpp deleted file mode 100644 index 1ce01a8a..00000000 --- a/hdt-it/stringutils.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include - -#include -#include "stringutils.hpp" - -QString stringutils::sizeHuman(unsigned long long size) -{ - static const char *sizes[] = { "EB", "PB", "TB", "GB", "MB", "KB", "B" }; - static const quint64 exbibytes = 1024ULL * 1024ULL * 1024ULL * 1024ULL * 1024ULL * 1024ULL; - - quint64 multiplier = exbibytes; - - if(size==0) { - return QString("0"); - } - - for (unsigned int i = 0; i < 7; i++, multiplier /= 1024) - { - if (size < multiplier) { - continue; - } - - return QString("%1 %2") - .arg(QString::number((double)size / multiplier, 'f', 1)) - .arg(sizes[i]); - } - return QString("0"); -} - -QString stringutils::toQString(const char *str) -{ - - QString out = QString::fromUtf8(str); - - return out; -} - -QString stringutils::escapeHTML(QString in) -{ - return in.replace("<", "<").replace(">", ">"); -} - -void stringutils::cut(QString &in, int size) -{ - if(in.length()>size) { - in = in.left(size)+"..."; - } -} diff --git a/hdt-it/stringutils.hpp b/hdt-it/stringutils.hpp deleted file mode 100644 index 3935e83d..00000000 --- a/hdt-it/stringutils.hpp +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef STRINGUTILS_HPP -#define STRINGUTILS_HPP - -#include -#include - -class stringutils -{ -public: - static QString sizeHuman(unsigned long long size); - static QString toQString(const char *str); - static QString escapeHTML(QString in); - static void cut(QString &in, int size); -}; - - - -#endif // STRINGUTILS_HPP diff --git a/hdt-it/triplecomponentmodel.cpp b/hdt-it/triplecomponentmodel.cpp deleted file mode 100644 index 85aeaa89..00000000 --- a/hdt-it/triplecomponentmodel.cpp +++ /dev/null @@ -1,146 +0,0 @@ - -#include - -#include "triplecomponentmodel.hpp" - -#include "stringutils.hpp" - -TripleComponentModel::TripleComponentModel(HDTController *view, hdt::TripleComponentRole compRole) : - hdtController(view), tripleComponentRole(compRole) -{ - -} - -int TripleComponentModel::rowCount(const QModelIndex &parent) const -{ - size_t numResults = 0; - - Q_UNUSED(parent); - if(hdtController->getHDT() != NULL) { - hdt::Dictionary *dict = hdtController->getHDT()->getDictionary(); - switch(tripleComponentRole) { - case hdt::SUBJECT: - numResults = dict->getNsubjects(); - break; - case hdt::PREDICATE: - numResults = dict->getNpredicates(); - break; - case hdt::OBJECT: - numResults = dict->getNobjects(); - break; - } - } - - // FIXME: QTableView crashes when returning more than 100 Million rows :( - return (int)(numResults > 100000000 ? 100000000 : numResults); -} - -int TripleComponentModel::columnCount(const QModelIndex &parent) const -{ - return 1; -} - -QVariant TripleComponentModel::data(const QModelIndex &index, int role) const -{ - if(!hdtController->hasHDT()) { - return QVariant(); - } - - switch(role) { - case Qt::ToolTipRole: - case Qt::DisplayRole: - { - //cerr << "Data: " << index.row() << " role: " << role << " type: " << tripleComponentRole << endl; - hdt::Dictionary *d = hdtController->getHDT()->getDictionary(); - try { - return stringutils::toQString(d->idToString(index.row()+1, tripleComponentRole).c_str()); - } catch (char *e) { - cerr << "Error accessing dictionary: " << e << endl; - } catch (const char *e) { - cerr << "Error accessing dictionary: " << e << endl; - } - return QVariant(); - } - case Qt::FontRole: - { - QFont font; - font.setPointSize(10); - return font; - } - case Qt::CheckStateRole: - if(tripleComponentRole==hdt::PREDICATE) { - return hdtController->getPredicateStatus()->isPredicateActive(index.row()) ? Qt::Checked : Qt::Unchecked; - } - break; - case Qt::DecorationRole: - if(tripleComponentRole==hdt::PREDICATE) { - HDTCachedInfo *info = hdtController->getHDTCachedInfo(); - Color *color = info->getPredicateColor(index.row()); - return color->asQColor(); - } - break; - } - return QVariant(); -} - -bool TripleComponentModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - if(hdtController->getHDT() == NULL) { - return false; - } - - switch(role) { - case Qt::CheckStateRole: - if(tripleComponentRole==hdt::PREDICATE) { - hdtController->getPredicateStatus()->setPredicateActive(index.row(), value.toBool()); - } - } - return true; -} - -QVariant TripleComponentModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - - switch(role) { - case Qt::DisplayRole: - { - if(orientation == Qt::Horizontal) { - switch(tripleComponentRole) { - case hdt::SUBJECT: - return tr("Subject"); - case hdt::PREDICATE: - return tr("Predicate"); - case hdt::OBJECT: - return tr("Object"); - } - } else { - return QString::number(section+1); - } - break; - } - } - - return QVariant(); -} - -Qt::ItemFlags TripleComponentModel::flags(const QModelIndex &index) const -{ - Q_UNUSED(index); - if(tripleComponentRole == hdt::PREDICATE) { - return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable; - } else { - return Qt::ItemIsEnabled | Qt::ItemIsSelectable; - } -} - -void TripleComponentModel::itemsChanged(unsigned int ini, unsigned int fin) -{ - QModelIndex first = createIndex(ini, 1); - QModelIndex last = createIndex(fin, 1); - emit dataChanged(first, last); -} - -void TripleComponentModel::notifyLayoutChanged() -{ - emit layoutChanged(); -} diff --git a/hdt-it/triplecomponentmodel.hpp b/hdt-it/triplecomponentmodel.hpp deleted file mode 100644 index 8c633279..00000000 --- a/hdt-it/triplecomponentmodel.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef TRIPLECOMPONENTMODEL_HPP -#define TRIPLECOMPONENTMODEL_HPP - -#include - -#include - -#include "hdtcontroller.hpp" - -class HDTController; - -class TripleComponentModel : public QAbstractTableModel { - Q_OBJECT -private: - HDTController *hdtController; - hdt::TripleComponentRole tripleComponentRole; -public: - TripleComponentModel(HDTController *view, hdt::TripleComponentRole compRole); - - int rowCount(const QModelIndex &parent = QModelIndex()) const ; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - bool setData(const QModelIndex & index, const QVariant & value, int role); - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - Qt::ItemFlags flags(const QModelIndex &index) const; - -public slots: - void itemsChanged(unsigned int ini, unsigned int fin); - void notifyLayoutChanged(); -signals: -}; - -#endif // TRIPLECOMPONENTMODEL_HPP diff --git a/lib/.gitignore b/lib/.gitignore deleted file mode 100644 index d9f53942..00000000 --- a/lib/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile.am -/dummy.c diff --git a/lib/Makefile.in b/lib/Makefile.in deleted file mode 100644 index 8664e08f..00000000 --- a/lib/Makefile.in +++ /dev/null @@ -1,803 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -# Copyright (C) 2002-2014 Free Software Foundation, Inc. -# -# This file is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This file is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this file. If not, see . -# -# As a special exception to the GNU General Public License, -# this file may be distributed as part of a program that -# contains a configuration script generated by Autoconf, under -# the same distribution terms as the rest of that program. -# -# Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build --no-conditional-dependencies --no-libtool --macro-prefix=gl warnings - - - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = lib -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ - $(top_srcdir)/m4/gnulib-common.m4 \ - $(top_srcdir)/m4/gnulib-comp.m4 $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/m4/warnings.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \ - $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/build/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -LIBRARIES = $(noinst_LIBRARIES) -AM_V_AR = $(am__v_AR_@AM_V@) -am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@) -am__v_AR_0 = @echo " AR " $@; -am__v_AR_1 = -libgnu_a_AR = $(AR) $(ARFLAGS) -am__DEPENDENCIES_1 = -am_libgnu_a_OBJECTS = dummy.$(OBJEXT) -libgnu_a_OBJECTS = $(am_libgnu_a_OBJECTS) -LTLIBRARIES = $(noinst_LTLIBRARIES) -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/build -depcomp = $(SHELL) $(top_srcdir)/build/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(libgnu_a_SOURCES) $(EXTRA_libgnu_a_SOURCES) -DIST_SOURCES = $(libgnu_a_SOURCES) $(EXTRA_libgnu_a_SOURCES) -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -HEADERS = $(noinst_HEADERS) -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - distdir -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/build/depcomp -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -ARFLAGS = @ARFLAGS@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GREP = @GREP@ -HAVE_ZLIB = @HAVE_ZLIB@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBCDS_CFLAGS = @LIBCDS_CFLAGS@ -LIBCDS_HDR = @LIBCDS_HDR@ -LIBCDS_LIB = @LIBCDS_LIB@ -LIBGNU_LIBDEPS = @LIBGNU_LIBDEPS@ -LIBGNU_LTLIBDEPS = @LIBGNU_LTLIBDEPS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -RANLIB = @RANLIB@ -RAPTOR2_CFLAGS = @RAPTOR2_CFLAGS@ -RAPTOR2_HDR = @RAPTOR2_HDR@ -RAPTOR2_LIB = @RAPTOR2_LIB@ -SED = @SED@ -SERD_CFLAGS = @SERD_CFLAGS@ -SERD_HDR = @SERD_HDR@ -SERD_LIB = @SERD_LIB@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -WARN_CFLAGS = @WARN_CFLAGS@ -ZLIB_LIB = @ZLIB_LIB@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -gl_LIBOBJS = @gl_LIBOBJS@ -gl_LTLIBOBJS = @gl_LTLIBOBJS@ -gltests_LIBOBJS = @gltests_LIBOBJS@ -gltests_LTLIBOBJS = @gltests_LTLIBOBJS@ -gltests_WITNESS = @gltests_WITNESS@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -zlib_CFLAGS = @zlib_CFLAGS@ -zlib_LIBS = @zlib_LIBS@ -AUTOMAKE_OPTIONS = 1.9.6 gnits -SUBDIRS = -noinst_HEADERS = -noinst_LIBRARIES = libgnu.a -noinst_LTLIBRARIES = -EXTRA_DIST = -BUILT_SOURCES = -SUFFIXES = -MOSTLYCLEANFILES = core *.stackdump -MOSTLYCLEANDIRS = -CLEANFILES = -DISTCLEANFILES = -MAINTAINERCLEANFILES = -AM_CPPFLAGS = -AM_CFLAGS = -libgnu_a_SOURCES = dummy.c -libgnu_a_LIBADD = $(gl_LIBOBJS) -libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) -EXTRA_libgnu_a_SOURCES = -all: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) all-recursive - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnits lib/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnits lib/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstLIBRARIES: - -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) - -libgnu.a: $(libgnu_a_OBJECTS) $(libgnu_a_DEPENDENCIES) $(EXTRA_libgnu_a_DEPENDENCIES) - $(AM_V_at)-rm -f libgnu.a - $(AM_V_AR)$(libgnu_a_AR) libgnu.a $(libgnu_a_OBJECTS) $(libgnu_a_LIBADD) - $(AM_V_at)$(RANLIB) libgnu.a - -clean-noinstLTLIBRARIES: - -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) - @list='$(noinst_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dummy.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) check-recursive -all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(HEADERS) -installdirs: installdirs-recursive -installdirs-am: -install: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." - -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) - -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) -clean: clean-recursive - -clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ - clean-noinstLTLIBRARIES mostlyclean-am - -distclean: distclean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool mostlyclean-local - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: - -.MAKE: $(am__recursive_targets) all check install install-am \ - install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-am clean clean-generic clean-libtool \ - clean-noinstLIBRARIES clean-noinstLTLIBRARIES cscopelist-am \ - ctags ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool mostlyclean-local pdf \ - pdf-am ps ps-am tags tags-am uninstall uninstall-am - -.PRECIOUS: Makefile - - -mostlyclean-local: mostlyclean-generic - @for dir in '' $(MOSTLYCLEANDIRS); do \ - if test -n "$$dir" && test -d $$dir; then \ - echo "rmdir $$dir"; rmdir $$dir; \ - fi; \ - done; \ - : - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/libcds/COPYRIGHT b/libcds/COPYRIGHT deleted file mode 100644 index a2a1d92d..00000000 --- a/libcds/COPYRIGHT +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - 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 Street, Fifth Floor, Boston, MA 02110-1301, USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/libcds/Changelog b/libcds/Changelog deleted file mode 100644 index fb874b85..00000000 --- a/libcds/Changelog +++ /dev/null @@ -1,38 +0,0 @@ - -Version 0.9: - -- static_bitsequence: - - added sdarray -- static_sequence: - - added sequence representation based in sdarray (no efficient access) - -Version 0.8: - -- trying: - - git -- missing: - - improve design and class names - - add namespaces - - reference counters for coders and util clases -- static_bitsequence: - - Added base class with virtual functions - - Added testing naive rank/select - - Added rank/select with one-level sampling - - Added compressed representation -- static_sequence - - Added wavelet tree without pointers - - Added wavelet tree with pointers - - Added coder for giving huffman/normal shape to the wavelet tree - - Added Golynski et al.'s data structure for large alphabets -- static_permutation - - Added Diego Arroyuelo's implementation of Munro et al.'s permutations - - Added base classes - - TODO: check interface and add functionality -- coders - - temporal coders for the wavelet tree - - TODO: add coders and a general interface for them -- utils - - Added the alphabet mapper interface - - Added a dummy alphabet mapper - - diff --git a/libcds/Doxyfile b/libcds/Doxyfile deleted file mode 100755 index 09423c4c..00000000 --- a/libcds/Doxyfile +++ /dev/null @@ -1,307 +0,0 @@ -# Doxyfile 1.5.5 - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- -DOXYFILE_ENCODING = UTF-8 -PROJECT_NAME = libcds -PROJECT_NUMBER = 1.0.3 -OUTPUT_DIRECTORY = docs/ -CREATE_SUBDIRS = NO -OUTPUT_LANGUAGE = English -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the -ALWAYS_DETAILED_SEC = NO -INLINE_INHERITED_MEMB = NO -FULL_PATH_NAMES = YES -STRIP_FROM_PATH = src/ -STRIP_FROM_INC_PATH = -SHORT_NAMES = NO -JAVADOC_AUTOBRIEF = NO -QT_AUTOBRIEF = NO -MULTILINE_CPP_IS_BRIEF = NO -DETAILS_AT_TOP = NO -INHERIT_DOCS = YES -SEPARATE_MEMBER_PAGES = NO -TAB_SIZE = 2 -ALIASES = -OPTIMIZE_OUTPUT_FOR_C = NO -OPTIMIZE_OUTPUT_JAVA = NO -OPTIMIZE_FOR_FORTRAN = NO -OPTIMIZE_OUTPUT_VHDL = NO -BUILTIN_STL_SUPPORT = NO -CPP_CLI_SUPPORT = NO -SIP_SUPPORT = NO -DISTRIBUTE_GROUP_DOC = NO -SUBGROUPING = YES -TYPEDEF_HIDES_STRUCT = NO -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- -EXTRACT_ALL = NO -EXTRACT_PRIVATE = NO -EXTRACT_STATIC = YES -EXTRACT_LOCAL_CLASSES = YES -EXTRACT_LOCAL_METHODS = NO -EXTRACT_ANON_NSPACES = NO -HIDE_UNDOC_MEMBERS = NO -HIDE_UNDOC_CLASSES = NO -HIDE_FRIEND_COMPOUNDS = NO -HIDE_IN_BODY_DOCS = NO -INTERNAL_DOCS = NO -CASE_SENSE_NAMES = YES -HIDE_SCOPE_NAMES = NO -SHOW_INCLUDE_FILES = YES -INLINE_INFO = YES -SORT_MEMBER_DOCS = YES -SORT_BRIEF_DOCS = NO -SORT_GROUP_NAMES = NO -SORT_BY_SCOPE_NAME = NO -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -GENERATE_DEPRECATEDLIST= YES -ENABLED_SECTIONS = -MAX_INITIALIZER_LINES = 30 -SHOW_USED_FILES = YES -SHOW_DIRECTORIES = NO -FILE_VERSION_FILTER = -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = NO -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_IF_DOC_ERROR = YES -WARN_NO_PARAMDOC = NO -WARN_FORMAT = "$file:$line: $text" -WARN_LOGFILE = -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = src -INPUT_ENCODING = UTF-8 -FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.cpp \ - *.c++ \ - *.d \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ - *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.idl \ - *.odl \ - *.cs \ - *.php \ - *.php3 \ - *.inc \ - *.m \ - *.mm \ - *.dox \ - *.py \ - *.f90 \ - *.f \ - *.vhd \ - *.vhdl \ - *.C \ - *.CC \ - *.C++ \ - *.II \ - *.I++ \ - *.H \ - *.HH \ - *.H++ \ - *.CS \ - *.PHP \ - *.PHP3 \ - *.M \ - *.MM \ - *.PY \ - *.F90 \ - *.F \ - *.VHD \ - *.VHDL -RECURSIVE = YES -EXCLUDE = -EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = -EXCLUDE_SYMBOLS = cds_static::sperm \ - cds_static::table_offset \ - cds_static::THuff \ - cds_static::Ttree \ - cds_utils::Array::ArrayModifier \ - cds_static::selects3 \ - cds_static::selectd2 \ - cds_static::auxbwd \ - cds_static::wt_node_internal \ - cds_static::wt_node_leaf \ - cds_static::wt_node -EXAMPLE_PATH = -EXAMPLE_PATTERNS = * -EXAMPLE_RECURSIVE = NO -IMAGE_PATH = -INPUT_FILTER = -FILTER_PATTERNS = -FILTER_SOURCE_FILES = NO -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = YES -INLINE_SOURCES = NO -STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = NO -REFERENCES_RELATION = NO -REFERENCES_LINK_SOURCE = YES -USE_HTAGS = NO -VERBATIM_HEADERS = NO -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = NO -COLS_IN_ALPHA_INDEX = 5 -IGNORE_PREFIX = -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = YES -HTML_OUTPUT = html -HTML_FILE_EXTENSION = .html -HTML_HEADER = -HTML_FOOTER = -HTML_STYLESHEET = -HTML_ALIGN_MEMBERS = YES -GENERATE_HTMLHELP = NO -GENERATE_DOCSET = NO -DOCSET_FEEDNAME = "Doxygen generated docs" -DOCSET_BUNDLE_ID = org.doxygen.Project -HTML_DYNAMIC_SECTIONS = NO -CHM_FILE = -HHC_LOCATION = -GENERATE_CHI = NO -BINARY_TOC = NO -TOC_EXPAND = NO -DISABLE_INDEX = NO -ENUM_VALUES_PER_LINE = 4 -GENERATE_TREEVIEW = NO -TREEVIEW_WIDTH = 250 -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = YES -LATEX_OUTPUT = latex -LATEX_CMD_NAME = latex -MAKEINDEX_CMD_NAME = makeindex -COMPACT_LATEX = NO -PAPER_TYPE = a4wide -EXTRA_PACKAGES = -LATEX_HEADER = -PDF_HYPERLINKS = YES -USE_PDFLATEX = YES -LATEX_BATCHMODE = NO -LATEX_HIDE_INDICES = NO -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = NO -RTF_OUTPUT = rtf -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = NO -MAN_OUTPUT = man -MAN_EXTENSION = .3 -MAN_LINKS = NO -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = NO -XML_OUTPUT = xml -XML_SCHEMA = -XML_DTD = -XML_PROGRAMLISTING = YES -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- -GENERATE_AUTOGEN_DEF = NO -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- -GENERATE_PERLMOD = NO -PERLMOD_LATEX = NO -PERLMOD_PRETTY = YES -PERLMOD_MAKEVAR_PREFIX = -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = NO -EXPAND_ONLY_PREDEF = NO -SEARCH_INCLUDES = YES -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = -EXPAND_AS_DEFINED = -SKIP_FUNCTION_MACROS = YES -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = -ALLEXTERNALS = NO -EXTERNAL_GROUPS = YES -PERL_PATH = /usr/bin/perl -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- -CLASS_DIAGRAMS = YES -MSCGEN_PATH = -HIDE_UNDOC_RELATIONS = YES -HAVE_DOT = YES -CLASS_GRAPH = YES -COLLABORATION_GRAPH = YES -GROUP_GRAPHS = YES -UML_LOOK = NO -TEMPLATE_RELATIONS = NO -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES -CALL_GRAPH = NO -CALLER_GRAPH = NO -GRAPHICAL_HIERARCHY = YES -DIRECTORY_GRAPH = YES -DOT_IMAGE_FORMAT = png -DOT_PATH = -DOTFILE_DIRS = -DOT_GRAPH_MAX_NODES = 50 -MAX_DOT_GRAPH_DEPTH = 1000 -DOT_TRANSPARENT = YES -DOT_MULTI_TARGETS = NO -GENERATE_LEGEND = YES -DOT_CLEANUP = YES -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- -SEARCHENGINE = NO diff --git a/libcds/Makefile.am b/libcds/Makefile.am deleted file mode 100644 index 9b772df3..00000000 --- a/libcds/Makefile.am +++ /dev/null @@ -1,172 +0,0 @@ -SUBDIRS = . tests - -AUTOMAKE_OPTIONS = subdir-objects - -AM_CPPFLAGS = -I$(builddir)/include $(WARN_CFLAGS) - -include_HEADERS = -lib_LTLIBRARIES = - -if WANTS_LIBCDS -include_HEADERS += \ - include/Array.h \ - include/BitmapsSequence.h\ - include/BitSequenceBuilderDArray.h\ - include/BitSequenceBuilder.h\ - include/BitSequenceBuilderRG.h\ - include/BitSequenceBuilderRRR.h\ - include/BitSequenceBuilderSDArray.h\ - include/BitSequenceDArray.h\ - include/BitSequence.h\ - include/BitSequenceRG.h\ - include/BitSequenceRRR.h\ - include/BitSequenceSDArray.h\ - include/BitString.h\ - include/Coder.h\ - include/comparray4.h\ - include/cppUtils.h\ - include/factorization.h\ - include/factorization_var.h\ - include/huff.h\ - include/HuffmanCoder.h\ - include/interface.h\ - include/LCP_DAC.h\ - include/LCP_DAC_VAR.h\ - include/LCP_FMN.h\ - include/LCP.h\ - include/LCP_naive.h\ - include/LCP_PhiSpare.h\ - include/LCP_PT.h\ - include/LCP_Sad.h\ - include/libcdsBasics.h\ - include/libcdsSDArray.h\ - include/libcdsTrees.h\ - include/MapperCont.h\ - include/Mapper.h\ - include/MapperNone.h\ - include/MapperRev.h\ - include/mmap.h\ - include/NPR_CN.h\ - include/NPR_FMN.h\ - include/NPR.h\ - include/NSV.h\ - include/perm.h\ - include/PermutationBuilder.h\ - include/PermutationBuilderMRRR.h\ - include/PermutationBuilderWT.h\ - include/Permutation.h\ - include/PermutationMRRR.h\ - include/PermutationWT.h\ - include/PSV.h\ - include/RMQ_succinct.h\ - include/RMQ_succinct_lcp.h\ - include/sdarraySadakane.h\ - include/SequenceAlphPart.h\ - include/SequenceBuilderAlphPart.h\ - include/SequenceBuilderGMRChunk.h\ - include/SequenceBuilderGMR.h\ - include/SequenceBuilder.h\ - include/SequenceBuilderStr.h\ - include/SequenceBuilderWaveletMatrix.h\ - include/SequenceBuilderWaveletTree.h\ - include/SequenceBuilderWaveletTreeNoptrs.h\ - include/SequenceBuilderWaveletTreeNoptrsS.h\ - include/SequenceGMRChunk.h\ - include/SequenceGMR.h\ - include/Sequence.h\ - include/SuffixTree.h\ - include/SuffixTreeY.h\ - include/TableOffsetRRR.h\ - include/TextIndexCSA.h\ - include/TextIndex.h\ - include/timing.h\ - include/WaveletMatrix.h\ - include/WaveletTree.h\ - include/WaveletTreeNoptrs.h\ - include/WaveletTreeNoptrsS.h\ - include/wt_coder_binary.h\ - include/wt_coder.h\ - include/wt_coder_huff.h\ - include/wt_node.h\ - include/wt_node_internal.h\ - include/wt_node_leaf.h -lib_LTLIBRARIES += libcds.la -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = cds.pc -endif -libcds_la_SOURCES = \ -src/static/bitsequence/BitSequenceBuilderDArray.cpp\ -src/static/bitsequence/BitSequenceBuilderRG.cpp\ -src/static/bitsequence/BitSequenceBuilderRRR.cpp\ -src/static/bitsequence/BitSequenceBuilderSDArray.cpp\ -src/static/bitsequence/BitSequence.cpp\ -src/static/bitsequence/BitSequenceDArray.cpp\ -src/static/bitsequence/BitSequenceRG.cpp\ -src/static/bitsequence/BitSequenceRRR.cpp\ -src/static/bitsequence/BitSequenceSDArray.cpp\ -src/static/bitsequence/sdarraySadakane.cpp\ -src/static/bitsequence/TableOffsetRRR.cpp\ -src/static/coders/huff.cpp\ -src/static/coders/HuffmanCoder.cpp\ -src/static/mapper/MapperCont.cpp\ -src/static/mapper/Mapper.cpp\ -src/static/mapper/MapperNone.cpp\ -src/static/mapper/MapperRev.cpp\ -src/static/permutation/perm.cpp\ -src/static/permutation/PermutationBuilderMRRR.cpp\ -src/static/permutation/PermutationBuilderWT.cpp\ -src/static/permutation/Permutation.cpp\ -src/static/permutation/PermutationMRRR.cpp\ -src/static/permutation/PermutationWT.cpp\ -src/static/sequence/BitmapsSequence.cpp\ -src/static/sequence/SequenceAlphPart.cpp\ -src/static/sequence/SequenceBuilderAlphPart.cpp\ -src/static/sequence/SequenceBuilderGMRChunk.cpp\ -src/static/sequence/SequenceBuilderGMR.cpp\ -src/static/sequence/SequenceBuilderStr.cpp\ -src/static/sequence/SequenceBuilderWaveletMatrix.cpp\ -src/static/sequence/SequenceBuilderWaveletTree.cpp\ -src/static/sequence/SequenceBuilderWaveletTreeNoptrs.cpp\ -src/static/sequence/SequenceBuilderWaveletTreeNoptrsS.cpp\ -src/static/sequence/Sequence.cpp\ -src/static/sequence/SequenceGMRChunk.cpp\ -src/static/sequence/SequenceGMR.cpp\ -src/static/sequence/WaveletMatrix.cpp\ -src/static/sequence/WaveletTree.cpp\ -src/static/sequence/WaveletTreeNoptrs.cpp\ -src/static/sequence/WaveletTreeNoptrsS.cpp\ -src/static/sequence/wt_coder_binary.cpp\ -src/static/sequence/wt_coder.cpp\ -src/static/sequence/wt_coder_huff.cpp\ -src/static/sequence/wt_node.cpp\ -src/static/sequence/wt_node_internal.cpp\ -src/static/sequence/wt_node_leaf.cpp\ -src/static/suffixtree/factorization.cpp\ -src/static/suffixtree/factorization_var.cpp\ -src/static/suffixtree/LCP.cpp\ -src/static/suffixtree/LCP_DAC.cpp\ -src/static/suffixtree/LCP_DAC_VAR.cpp\ -src/static/suffixtree/LCP_FMN.cpp\ -src/static/suffixtree/LCP_naive.cpp\ -src/static/suffixtree/LCP_PhiSpare.cpp\ -src/static/suffixtree/LCP_PT.cpp\ -src/static/suffixtree/LCP_Sad.cpp\ -src/static/suffixtree/NPR_CN.cpp\ -src/static/suffixtree/NPR.cpp\ -src/static/suffixtree/NPR_FMN.cpp\ -src/static/suffixtree/NSV.cpp\ -src/static/suffixtree/PSV.cpp\ -src/static/suffixtree/RMQ_succinct.cpp\ -src/static/suffixtree/RMQ_succinct_lcp.cpp\ -src/static/suffixtree/SuffixTree.cpp\ -src/static/suffixtree/SuffixTreeY.cpp\ -src/static/textindex/comparray4.cpp\ -src/static/textindex/mmap.cpp\ -src/static/textindex/qsufsort.cpp\ -src/static/textindex/suftest3.test.cpp\ -src/static/textindex/TextIndex.cpp\ -src/static/textindex/TextIndexCSA.cpp\ -src/utils/Array.cpp\ -src/utils/BitString.cpp\ -src/utils/cppUtils.cpp\ -src/utils/timing.cpp diff --git a/libcds/README b/libcds/README deleted file mode 100644 index 4ea46337..00000000 --- a/libcds/README +++ /dev/null @@ -1,12 +0,0 @@ -libcds implements low-level succinct data structures such as bitmaps, -sequences, permutations, etc. The main goal is to provide a set of -structures that form the building block of most compressed/succinct -solutions. In the near future we are planning to add compression -algorithms and support for succinct trees. - -You can find more information at http://libcds.recoded.cl/ - -Right now we are just fixing bugs and testing some new things in here, -but most of the effort is being put into libcds2, this rewrite aims at -solving many problems with 64bits systems. This is necessary in order -to index bigger inputs. \ No newline at end of file diff --git a/libcds/cds.pc.in b/libcds/cds.pc.in deleted file mode 100644 index ad88e76e..00000000 --- a/libcds/cds.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libcds -Description: CDS library -Version: 1.0.12 -URL: @PACKAGE_URL@ -Libs: -L${libdir} -lcds -Cflags: -I${includedir} diff --git a/libcds/docs/delete_me b/libcds/docs/delete_me deleted file mode 100644 index e69de29b..00000000 diff --git a/libcds/include/Array.h b/libcds/include/Array.h deleted file mode 100644 index e7814c3e..00000000 --- a/libcds/include/Array.h +++ /dev/null @@ -1,184 +0,0 @@ -/* array.h - * Copyright (C) 2009, Francisco Claude, all rights reserved. - * - * Array interface - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include -#include -#include - -#ifndef ARRAY_H -#define ARRAY_H - -#include - -using namespace std; - -namespace cds_utils -{ - /** Class for arrays with variable bit-width - * @author Francisco Claude - */ - class Array - { - public: - class ArrayModifier - { - protected: - uint * data; - size_t len; - uint bitsPerItem; - size_t pos; - public: - ArrayModifier(uint * _data, size_t _len, uint _bitsPerItem, size_t _pos) - : data(_data), len(_len), bitsPerItem(_bitsPerItem), pos(_pos) {} - inline uint operator=(const uint v) { - set_field(data, bitsPerItem, pos, v); - return v; - } - }; - public: - /** Reads and Array from a file stream - * @param input input file stream - */ - Array(istream & input); - - /** Creates an array from a vector - * @param A vector with the elements - * @bpe bits per element - */ - Array(const vector & A, uint bpe=0); - - /** Creates an array from a vector iterator - * @param ini initial position - * @param fin final position - * @bpe bits per element - */ - Array(const vector::iterator & ini, const vector::iterator & fin, uint bpe=0); - - /** Creates an array from a set iterator - * @param ini initial position - * @param fin final position - * @bpe bits per element - */ - Array(const set::iterator & ini, const set::iterator & fin, uint bpe=0); - - /** Creates an array copying part of a previously existing array - * @param A source array - * @param n length of the source array - * @param bpe bits per element (0 uses the max in A[i,j] - */ - Array(uint * A, size_t n, uint bpe = 0); - - /** Creates an array copying part of a previously existing array - * @param A source array - * @param i initial position - * @param j final position - * @param bpe bits per element (0 uses the max in A[i,j] - */ - Array(uint * A, size_t i, size_t j, uint bpe = 0); - - /** Creates and array with n elements that can store elements between 0 and _maxValue - * @param n length (in elements) of the array - * @param _maxValue maximum value that could be stored in the array - */ - Array(size_t n, uint _maxValue); - - /** Destroys the array */ - ~Array(); - - /** Retrieves Array[pos] - * @paran pos position - * @return Array[pos] - */ - inline uint getField(const size_t pos) const - { - assert(pos - -#define RRR02_HDR 2 -#define BRW32_HDR 3 -#define RRR02_LIGHT_HDR 4 -#define SDARRAY_HDR 5 -#define DARRAY_HDR 6 -#define BS375_HDR 7 - -#include -#include -#include - -using namespace std; -using namespace cds_utils; - -namespace cds_static -{ - - /** Base class for static bitsequences, contains many abstract functions, so this can't - * be instantiated. It includes base implementations for rank0, select0 and select1 based - * on rank0. - * - * @author Francisco Claude - */ - class BitSequence - { - - public: - virtual ~BitSequence() {}; - - /** Returns the number of zeros until position i */ - virtual size_t rank0(const size_t i) const; - - /** Returns the position of the i-th zero - * @return (size_t)-1 if i=0, len if i>num_zeros or the position */ - virtual size_t select0(const size_t i) const; - - /** Returns the number of ones until position i */ - virtual size_t rank1(const size_t i) const; - - /** Returns the position of the i-th one - * @return (size_t)-1 if i=0, len if i>num_ones or the position */ - virtual size_t select1(const size_t i) const; - - /** Return the first position starting at i that contains a 1. - * In case there are no more ones in the bitsequence, the function - * returns the length of the bitmap - */ - virtual size_t selectNext1(const size_t i) const; - - /** Return the first position starting at i that contains a 0. - * In case there are no more zeros in the bitsequence, the function - * returns the length of the bitmap - */ - virtual size_t selectNext0(const size_t i) const; - - /** Return the first position starting at i moving to the left that contains a 1. - * In case there are no more ones to the left in the bitsequence, the function - * returns (size_t)-1. - */ - virtual size_t selectPrev1(const size_t i) const; - - /** Return the first position starting at i moving to the left that contains a 0. - * In case there are no more zeros to the left in the bitsequence, the function - * returns (size_t)-1. - */ - virtual size_t selectPrev0(const size_t i) const; - - /** Returns the i-th bit */ - virtual bool access(const size_t i) const; - virtual bool access(const size_t i, size_t &r) const; - - /** Returns the length in bits of the bitmap */ - virtual size_t getLength() const; - - /** Returns how many ones are in the bitstring */ - virtual size_t countOnes() const; - - /** Returns how many zeros are in the bitstring */ - virtual size_t countZeros() const; - - /** Returns the size of the structure in bytes */ - virtual size_t getSize() const=0; - - /** Stores the bitmap given a file pointer*/ - virtual void save(ostream & fp) const=0; - - /** Reads a bitmap determining the type */ - static BitSequence * load(istream & fp); - - protected: - /** Length of the bitstring */ - size_t length; - /** Number of ones in the bitstring */ - size_t ones; - - }; - -}; - -#include -#include -#include -#include -#endif /* _STATIC_BITSEQUENCE_H */ diff --git a/libcds/include/BitSequenceBuilder.h b/libcds/include/BitSequenceBuilder.h deleted file mode 100644 index e015af2a..00000000 --- a/libcds/include/BitSequenceBuilder.h +++ /dev/null @@ -1,59 +0,0 @@ -/* BitSequenceBuilder.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef BITSEQUENCEBUILDER_H -#define BITSEQUENCEBUILDER_H - -#include -#include -#include - -using namespace cds_utils; - -namespace cds_static -{ - /** Base class for BitSequence builders, it defines the build function - * that takes only a bitmap. The parameters for construction are can - * be set in any way by the builder, but none are received when - * the actual building takes place. - * - * @author Francisco Claude - */ - class BitSequenceBuilder - { - public: - BitSequenceBuilder() { userCount=0; } - virtual ~BitSequenceBuilder() {} - virtual void use() { userCount++; } - virtual void unuse() { userCount--; assert(userCount>=0); if(userCount==0) delete this; } - virtual BitSequence * build(uint * bitseq, size_t len) const = 0; - virtual BitSequence * build(const BitString & bs) const = 0; - - protected: - int userCount; - }; -}; - -#include -#include -#include -#include -#endif diff --git a/libcds/include/BitSequenceBuilderDArray.h b/libcds/include/BitSequenceBuilderDArray.h deleted file mode 100644 index c31eb423..00000000 --- a/libcds/include/BitSequenceBuilderDArray.h +++ /dev/null @@ -1,47 +0,0 @@ -/* BitSequenceBuilderDArray.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * Rodrigo Canovas - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef BITSEQUENCEBUILDERDARRAY_H -#define BITSEQUENCEBUILDERDARRAY_H - -#include -#include -#include - -namespace cds_static -{ - /** Base class for BitSequence builders, it defines the build function - * that takes only a bitmap. The parameters for construction are can - * be set in any way by the builder, but none are received when - * the actual building takes place. - * - * @author Rodrigo Canovas - */ - class BitSequenceBuilderDArray : public BitSequenceBuilder - { - public: - BitSequenceBuilderDArray(); - virtual ~BitSequenceBuilderDArray(); - virtual BitSequence * build(uint * bitseq, size_t len) const; - virtual BitSequence * build(const BitString & bs) const; - }; -}; -#endif diff --git a/libcds/include/BitSequenceBuilderRG.h b/libcds/include/BitSequenceBuilderRG.h deleted file mode 100644 index 7f64e1a8..00000000 --- a/libcds/include/BitSequenceBuilderRG.h +++ /dev/null @@ -1,46 +0,0 @@ -/* BitSequenceBuilderRG.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef BITSEQUENCEBUILDERRG_H -#define BITSEQUENCEBUILDERRG_H - -#include -#include -#include - -namespace cds_static -{ - /** BitSequence builder for BitSequenceRG - * - * @author Francisco Claude - */ - class BitSequenceBuilderRG : public BitSequenceBuilder - { - public: - BitSequenceBuilderRG(uint factor); - virtual ~BitSequenceBuilderRG() {} - virtual BitSequence * build(uint * bitseq, size_t len) const; - virtual BitSequence * build(const BitString & bs) const; - protected: - uint factor; - }; -}; -#endif diff --git a/libcds/include/BitSequenceBuilderRRR.h b/libcds/include/BitSequenceBuilderRRR.h deleted file mode 100644 index e9fb0655..00000000 --- a/libcds/include/BitSequenceBuilderRRR.h +++ /dev/null @@ -1,48 +0,0 @@ -/* BitSequenceBuilderRRR.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef BITSEQUENCEBUILDERRRR_H -#define BITSEQUENCEBUILDERRRR_H - -#include -#include -#include - -using namespace cds_utils; - -namespace cds_static -{ - /** BitSequence builder for RRR BitSequences. - * - * @author Francisco Claude - */ - class BitSequenceBuilderRRR : public BitSequenceBuilder - { - public: - BitSequenceBuilderRRR(uint sample_rate); - virtual ~BitSequenceBuilderRRR() {} - virtual BitSequence * build(uint * bitseq, size_t len) const; - virtual BitSequence * build(const BitString & bs) const; - protected: - uint sample_rate; - }; -}; -#endif diff --git a/libcds/include/BitSequenceBuilderSDArray.h b/libcds/include/BitSequenceBuilderSDArray.h deleted file mode 100644 index edf83141..00000000 --- a/libcds/include/BitSequenceBuilderSDArray.h +++ /dev/null @@ -1,47 +0,0 @@ -/* BitSequenceBuilderSDArray.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef BITSEQUENCEBUILDERSDARRAY_H -#define BITSEQUENCEBUILDERSDARRAY_H - -#include -#include -#include - -namespace cds_static -{ - /** Base class for BitSequence builders, it defines the build function - * that takes only a bitmap. The parameters for construction are can - * be set in any way by the builder, but none are received when - * the actual building takes place. - * - * @author Francisco Claude - */ - class BitSequenceBuilderSDArray : public BitSequenceBuilder - { - public: - BitSequenceBuilderSDArray(); - virtual ~BitSequenceBuilderSDArray(); - virtual BitSequence * build(uint * bitseq, size_t len) const; - virtual BitSequence * build(const BitString & bs) const; - }; -}; -#endif diff --git a/libcds/include/BitSequenceDArray.h b/libcds/include/BitSequenceDArray.h deleted file mode 100644 index 3745f61d..00000000 --- a/libcds/include/BitSequenceDArray.h +++ /dev/null @@ -1,74 +0,0 @@ -/* BitSequenceSDArray.h - * Copyright (C) 2009, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This class is a wrapper for the file sdarraySadakane, - * implemented by K. Sadakane. - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef _BITSEQUENCEDARRAY_H -#define _BITSEQUENCEDARRAY_H - -#include -#include -#include -#include - -using namespace cds_utils; - -namespace cds_static -{ - class BitSequenceDArray: public BitSequence - { - - public: - /** Builds the DArray (Sadakane's dense version for rank/select*/ - BitSequenceDArray(const BitString & bs); - /** Builds the DArray */ - BitSequenceDArray(uint * buff, size_t len); - virtual ~BitSequenceDArray(); - virtual size_t select1(const size_t i) const; - virtual size_t rank0(const size_t i) const; - virtual size_t rank1(const size_t i) const; - virtual size_t getSize() const; - virtual void save(ostream & fp) const; - static BitSequenceDArray * load(istream & fp); - - protected: - uint m; //number of 1's - uint nl, s_ss, s_sl; - uint *a; //bitarray - uint *lp; - uint *sl; - uint *ss; - uint *p; - uint *rl; - uchar *rs; - - /** Internal building function, same parameters as the base constructor. */ - void build(uint *buff, size_t len); - - /** Protected constructor for loaders, you have to initialize data before - *using an object built with this constructor. - */ - BitSequenceDArray(); - - }; -}; -#endif diff --git a/libcds/include/BitSequenceRG.h b/libcds/include/BitSequenceRG.h deleted file mode 100644 index bd18cf43..00000000 --- a/libcds/include/BitSequenceRG.h +++ /dev/null @@ -1,101 +0,0 @@ -/* BitSequenceRG.h - Copyright (C) 2005, Rodrigo Gonzalez, all rights reserved. - - New RANK, SELECT, SELECT-NEXT and SPARSE RANK implementations. - Adaptation to libcds by Francisco Claude - - 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. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - 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 - -*/ - -#ifndef _STATIC_BITSEQUENCE_BRW32_H -#define _STATIC_BITSEQUENCE_BRW32_H - -#include -#include -#include - -namespace cds_static -{ - - ///////////// - //Rank(B,i)// - ///////////// - //_factor = 0 => s=W*lgn - //_factor = P => s=W*P - //Is interesting to notice - //factor=2 => overhead 50% - //factor=3 => overhead 33% - //factor=4 => overhead 25% - //factor=20=> overhead 5% - - /** Implementation of Rodrigo Gonzalez et al. practical rank/select solution [1]. - * The interface was adapted. - * - * [1] Rodrigo Gonzalez, Szymon Grabowski, Veli Makinen, and Gonzalo Navarro. - * Practical Implementation of Rank and Select Queries. WEA05. - * - * @author Rodrigo Gonzalez - */ - class BitSequenceRG : public BitSequence - { - private: - //bool owner; - size_t n,integers; - size_t factor,b,s; - uint *Rs; //superblock array - - //uso interno para contruir el indice rank - size_t BuildRankSub(size_t ini,size_t fin); - void BuildRank(); //crea indice para rank - BitSequenceRG(); - size_t SpaceRequirementInBits() const; - size_t SpaceRequirement() const; - - public: - uint *data; - /** Build the BitSequenceRG with a sampling factor factor - * The factor value has to be either 2,3,4 or 20, being the first one the fastest/bigger. - */ - BitSequenceRG(uint *bitarray, size_t n, uint factor); - - /** Build the BitSequenceRG with a sampling factor factor - * The factor value has to be either 2,3,4 or 20, being the first one the fastest/bigger. - */ - BitSequenceRG(const BitString & bs, uint factor); - - ~BitSequenceRG(); //destructor - - virtual bool access(const size_t i) const; - //Nivel 1 bin, nivel 2 sec-pop y nivel 3 sec-bit - virtual size_t rank1(const size_t i) const; - - // gives the largest index i<=start such that IsBitSet(i)=true - virtual size_t selectPrev1(const size_t start) const; - // gives the smallest index i>=start such that IsBitSet(i)=true - virtual size_t selectNext1(const size_t start) const; - // gives the position of the x:th 1. - virtual size_t select0(const size_t x) const; - // gives the position of the x:th 1. - virtual size_t select1(const size_t x) const; - virtual size_t getSize() const; - - /*load-save functions*/ - virtual void save(ostream & f) const; - static BitSequenceRG * load(istream & f); - }; - -} -#endif diff --git a/libcds/include/BitSequenceRRR.h b/libcds/include/BitSequenceRRR.h deleted file mode 100644 index 5c2a4598..00000000 --- a/libcds/include/BitSequenceRRR.h +++ /dev/null @@ -1,126 +0,0 @@ -/* BitSequenceRRR.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * RRR02 Bitsequence - - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef _STATIC_BITSEQUENCE_RRR02_H -#define _STATIC_BITSEQUENCE_RRR02_H - -#include -#include -#include -#include - -using namespace cds_utils; - -namespace cds_static -{ - - // block size can't be changed in this implementation - // it would require more than just changing the constant - #define BLOCK_SIZE 15 - - #define DEFAULT_SAMPLING 32 - - /** Implementation of Raman, Raman and Rao's [1] proposal for rank/select capable - * data structures, it achieves space nH_0, O(sample_rate) time for rank and O(log len) - * for select. The practial implementation is based on [2] - * - * [1] R. Raman, V. Raman and S. Rao. Succinct indexable dictionaries with applications - * to encoding $k$-ary trees and multisets. SODA02. - * [2] F. Claude and G. Navarro. Practical Rank/Select over Arbitrary Sequences. SPIRE08. - * - * @author Francisco Claude - */ - class BitSequenceRRR : public BitSequence - { - public: - /** Builds an RRR bitsequence. - * @param bitseq bitstring - * @param len lenght of the bitstring - * @param sample_rate sampling for partial sums - */ - BitSequenceRRR(uint * bitseq, size_t len, uint sample_rate=DEFAULT_SAMPLING); - - /** Builds an RRR bitsequence. - * @param bs bitstring - * @param sample_rate sampling for partial sums - */ - BitSequenceRRR(const BitString & bs, uint sample_rate=DEFAULT_SAMPLING); - - virtual ~BitSequenceRRR(); - - virtual size_t rank0(const size_t i) const; - - virtual size_t rank1(const size_t i) const; - - virtual size_t select0(const size_t i) const; - - virtual size_t select1(const size_t i) const; - - virtual bool access(const size_t i) const; - - virtual bool access(const size_t i, size_t &r) const; - - virtual size_t getSize() const; - - virtual void save(ostream & fp) const; - - /** Reads the bitmap from a file pointer, returns NULL in case of error */ - static BitSequenceRRR * load(istream & fp); - - /** Creates a new sampling for the queries */ - void create_sampling(uint sampling_rate); - - /** Frees the space required by the table E, which is static and global - * to all instances. - */ - static void delete_E() { - delete E; - } - - protected: - /** Internal building function, same parameters as the base constructor. */ - void build(const uint * bitseq, size_t len, uint sample_rate=DEFAULT_SAMPLING); - - /** Protected constructor for loaders, you have to initialize data before - * using an object built with this constructor. - */ - BitSequenceRRR(); - - /** Classes and offsets */ - uint *C, *O; - /** Length of C and O (in uints) */ - uint C_len, O_len; - /** Bits required per field for C and in total for O */ - uint C_field_bits, O_bits_len; - /** C and O samplings */ - uint *C_sampling, *O_pos; - /** Length of the samplings */ - uint C_sampling_len,O_pos_len; - /** Lenght in bits per field */ - uint C_sampling_field_bits,O_pos_field_bits; - /** Sample rate */ - uint sample_rate; - - static table_offset * E; - }; - -} -#endif /* _STATIC_BITSEQUENCE_RRR02_H */ diff --git a/libcds/include/BitSequenceSDArray.h b/libcds/include/BitSequenceSDArray.h deleted file mode 100644 index c0657a9b..00000000 --- a/libcds/include/BitSequenceSDArray.h +++ /dev/null @@ -1,60 +0,0 @@ -/* BitSequenceSDArray.h - * Copyright (C) 2009, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This class is a wrapper for the file sdarraySadakane, - * implemented by K. Sadakane. - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef _BITSEQUENCESDARRAY_H -#define _BITSEQUENCESDARRAY_H - -#include -#include -#include -#include - -#include -using namespace cds_utils; - -namespace cds_static -{ - class BitSequenceSDArray: public BitSequence - { - - public: - /** Builds the SDArray */ - BitSequenceSDArray(const BitString & bs); - /** Builds the SDArray */ - BitSequenceSDArray(uint * buff, size_t len); - virtual ~BitSequenceSDArray(); - virtual size_t select1(const size_t i) const; - virtual size_t rank1(const size_t i) const; - virtual size_t selectNext1(const size_t i) const; - virtual size_t getSize() const; - virtual void save(ostream & fp) const; - static BitSequenceSDArray * load(istream & fp); - - protected: - selects3 sd; - BitSequenceSDArray(); - - }; -}; -#endif diff --git a/libcds/include/BitString.h b/libcds/include/BitString.h deleted file mode 100644 index 6d2f9bb6..00000000 --- a/libcds/include/BitString.h +++ /dev/null @@ -1,114 +0,0 @@ -/* BitString.h - * Copyright (C) 2009, Francisco Claude, all rights reserved. - * - * BitString definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef BITSTRING_H -#define BITSTRING_H - -#include - -#include - -using namespace std; - -namespace cds_utils -{ - /** BitString class - * @author Francisco Claude - */ - class BitString - { - public: - - /** Reads a BitString from a file stream - * @param input input file stream - */ - BitString(istream & input); - - /** Creates a BitString with len bits of space */ - BitString(const size_t len); - - /** Creates a bitmap from a vector (up to len bits) */ - BitString(const vector fields, const size_t len); - - /** Creates a bitmap from an array (len bits) */ - BitString(const uint * array, const size_t len); - - /** Destroys a bitmap */ - ~BitString(); - - /** Sets the pos-th bit - * @param pos position - * @param bit value [0-1] - */ - inline void setBit(const size_t pos, const bool bit=true) { - if(bit) bitset(data,pos); - else bitclean(data,pos); - } - - /** Gets the pos-th bit - * @param pos position - */ - inline bool getBit(const size_t pos) const - { - return bitget(data,pos); - } - - /** operator [] for getBit - */ - inline bool operator[](const size_t pos) const - { - return bitget(data,pos); - } - - /** Saves the bitmap to a file - * @param out file stream - */ - void save(ostream & out) const; - - /** Returns the size in bytes of the BitString */ - inline size_t getSize() const - { - return uintLength*sizeof(uint)+sizeof(this); - } - - /** Returns the length in bits of the BitString */ - inline size_t getLength() const - { - return length; - } - - /** Returns a pointer to the buffer storing the values - */ - inline uint * getData() const - { - return data; - } - - protected: - size_t length; - size_t uintLength; - uint * data; - - /** Initializes the class fields */ - void initData(const size_t len); - }; -}; -#endif diff --git a/libcds/include/BitmapsSequence.h b/libcds/include/BitmapsSequence.h deleted file mode 100644 index e4879d03..00000000 --- a/libcds/include/BitmapsSequence.h +++ /dev/null @@ -1,73 +0,0 @@ -/* static_sequence.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * static_sequence definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef _BITMAPSSEQUENCE_H -#define _BITMAPSSEQUENCE_H - -#include -#include -#include -#include -#include - -using namespace cds_utils; - -namespace cds_static -{ - - /** static_sequence represented using one bitmap per symbol, doesn't support efficient access - * - * @author Francisco Claude - */ - class BitmapsSequence : public Sequence - { - - public: - BitmapsSequence(uint * seq, size_t n, Mapper * am, BitSequenceBuilder * bsb); - BitmapsSequence(const Array & a, Mapper * am, BitSequenceBuilder * bsb); - - virtual ~BitmapsSequence(); - - virtual size_t rank(uint c, size_t i) const; - - virtual size_t select(uint c, size_t i) const; - virtual size_t selectNext(uint c, size_t i) const; - - virtual uint access(size_t i) const; - - virtual size_t getSize() const; - - virtual void save(ostream & fp) const; - - /** Reads a bitmap determining the type */ - static BitmapsSequence * load(istream & fp); - - protected: - uint sigma; - BitSequence ** bitmaps; - Mapper * am; - - BitmapsSequence(); - - }; - -}; -#endif /* _BITMAPSSEQUENCE_H */ diff --git a/libcds/include/Coder.h b/libcds/include/Coder.h deleted file mode 100644 index 8f1d4bd7..00000000 --- a/libcds/include/Coder.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Coder.h - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef CODER_H -#define CODER_H - -#include -#include -namespace cds_static -{ - - class Coder - { - public: - virtual size_t encode(uint symb, uint * stream, size_t pos) const = 0; - virtual size_t decode(uint * symb, uint *stream, size_t pos) const = 0; - virtual size_t maxLength() const = 0; - virtual size_t getSize() const = 0; - virtual void save(ostream & fp) const = 0; - static Coder * load(istream & fp); - }; - -}; - -#include -#endif diff --git a/libcds/include/HuffmanCoder.h b/libcds/include/HuffmanCoder.h deleted file mode 100644 index 2a086d87..00000000 --- a/libcds/include/HuffmanCoder.h +++ /dev/null @@ -1,77 +0,0 @@ -/* HuffmanCoder.h - Copyright (C) 2008, Francisco Claude, all rights reserved. - - Wrapper for huff written by Gonzalo Navarro - - 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. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - 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 - -*/ - -#ifndef HUFFMAN_CODES_H -#define HUFFMAN_CODES_H - -#include -#include -#include -#include - -using namespace cds_utils; -namespace cds_static -{ - - #define HUFF_HDR 1 - - /** Wrapper for the canonical huffman implementation of Gonzalo Navarro. - * - * @author Francisco Claude - */ - class HuffmanCoder : public Coder - { - - public: - /** Creates the codes for the sequence seq of length n */ - HuffmanCoder(uint * seq, size_t n); - HuffmanCoder(uchar * seq, size_t n); - HuffmanCoder(Array & seq); - - virtual ~HuffmanCoder(); - - /** Encodes symb into stream at bit-position pos, - * returns the ending position (bits) */ - virtual size_t encode(uint symb, uint * stream, size_t pos) const; - - /** decodes into symb from stream at bit-position - * pos, returns the new position */ - virtual size_t decode(uint * symb, uint * stream, size_t pos) const; - - /** Returns the maximum length of a code */ - virtual size_t maxLength() const; - - /** Returns the size of the table */ - virtual size_t getSize() const; - - /** Saves the coder to a file */ - virtual void save(ostream & fp) const; - - /** Loads a coder from a file */ - static HuffmanCoder * load(istream & fp); - - protected: - HuffmanCoder(); - THuff huff_table; - }; - -}; -#endif diff --git a/libcds/include/LCP.h b/libcds/include/LCP.h deleted file mode 100644 index 9af2015e..00000000 --- a/libcds/include/LCP.h +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef _LCP_H -#define _LCP_H - -#include -#include -#include - -using namespace std; -using namespace cds_utils; - -namespace cds_static -{ - - static const size_t NAIVE = 2; - static const size_t SAD_GON_OS = 3; - static const size_t FMN_RRR_OS = 4; - static const size_t PT = 5; - static const size_t PHI = 6; - static const size_t DAC = 7; - static const size_t DAC_VAR = 8; - - /** Base class for LCP, contains many abstract functions, so this can't - * be instantiated. - * @author Rodrigo Cnovas - */ - class LCP - { - public: - size_t lcp_type; - - virtual ~LCP() {}; - - /**Return LCP[i], being faster if sequential acceses to the LCP had been done*/ - virtual size_t get_seq_LCP(size_t i, TextIndex *csa, size_t **next_pos, size_t *n_next, bool dir) const=0; - - /**Return LCP[i]*/ - virtual size_t get_LCP(size_t i, TextIndex *csa) const= 0; - - /** Returns the size of the structure in bytes */ - virtual size_t getSize() const= 0; - - /**compute the LCP array, using Karkkainen, Manzini, and Puglisi (2009) Algorithm - * @param csa The Compressed Suffix Array - * @param text The text - * @param n The length of the text - * @param q Sample interval*/ - virtual uint * create_lcp(TextIndex *csa, char *text, uint n, int q) const; - - /** Stores the structure given a file pointer*/ - virtual void save(ostream & fp) const=0; - - /** Reads a LCP determining the type */ - static LCP * load(istream & fp); - }; -}; - -#include -#include -#include -#include -#include -#include -#include -#endif diff --git a/libcds/include/LCP_DAC.h b/libcds/include/LCP_DAC.h deleted file mode 100644 index 9c758df4..00000000 --- a/libcds/include/LCP_DAC.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef LCP_DAC_H -#define LCP_DAC_H - -#include -#include - -namespace cds_static -{ - - class LCP_DAC: public LCP - { - - private: - size_t *next_p; //usefull for get_seq_LCP - factorization *rep; - LCP_DAC(); - - public: - size_t n; - - /* LCP encoding using Susana's static factorization, - * @param csa The compressed suffix array of the text - * @param text The text - * @param n The length of the text - * */ - LCP_DAC(TextIndex *csa, char *text, size_t n); - virtual size_t get_LCP(size_t i, TextIndex *csa) const; - virtual size_t get_seq_LCP(size_t i, TextIndex *csa, size_t **next_pos, size_t *n_next, bool dir) const; - virtual size_t getSize() const; - virtual void save(ostream & fp) const; - static LCP_DAC * load(istream & fp); - virtual ~LCP_DAC(); - }; -}; -#endif diff --git a/libcds/include/LCP_DAC_VAR.h b/libcds/include/LCP_DAC_VAR.h deleted file mode 100644 index c8690bf9..00000000 --- a/libcds/include/LCP_DAC_VAR.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef LCP_DAC_VAR_H -#define LCP_DAC_VAR_H - -#include -#include - -namespace cds_static -{ - - class LCP_DAC_VAR: public LCP - { - private: - LCP_DAC_VAR(); - - factorization_var *rep; - size_t *next_p_var; - - public: - size_t n; - - /*Compute the "optimal" block size given an array of frequencies - * @param max_lcp Maximun value in the array - * @param frec_acu Array that contain the acumulate frequency - * @param kvalues Array where the block sizes obtained will be stored - * @param nkvalues Size of the array kvalues - * */ - void calc_kvalues(uint max_lcp, uint *frec_acu, ushort **kvalues, uint *nkvalues) const; - - /* LCP encoding using Susana's factorization_var, - * @param csa The compressed suffix array of the text - * @param text The text - * @param n The length of the text - * */ - LCP_DAC_VAR(TextIndex *csa, char *text, size_t n); - virtual size_t get_LCP(size_t i, TextIndex *csa) const; - virtual size_t get_seq_LCP(size_t i, TextIndex *csa, size_t **next_pos, size_t *n_next, bool dir) const; - virtual size_t getSize() const; - virtual void save(ostream & fp) const; - static LCP_DAC_VAR * load(istream & fp); - virtual ~LCP_DAC_VAR(); - }; - -}; -#endif diff --git a/libcds/include/LCP_FMN.h b/libcds/include/LCP_FMN.h deleted file mode 100644 index a0780c8e..00000000 --- a/libcds/include/LCP_FMN.h +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef LCP_FMN_H -#define LCP_FMN_H - -#include -#include - -using namespace cds_static; - -namespace cds_static -{ - - class LCP_FMN: public LCP - { - private: - LCP_FMN(); - virtual void generate_OZ(BitSequence *U, uint **O, uint **Z, uint length); - - BitSequence *O, *Z; - size_t b_length; //length of the bitmaps - size_t OZ_type; - - public: - - /*Johannes, Veli & Gonzalo LCP encode - * @param csa The compressed suffix array of the text - * @param text The text - * @param n The length of the text - * @param op_rs Choose rank/select implementation that will be used (must be RRR02_HDR or SDARRAY_HDR) - * */ - LCP_FMN(TextIndex *csa, char *text, size_t n, size_t op_rs=RRR02_HDR); - - LCP_FMN(LCP *lcp, TextIndex *csa, size_t n, size_t op_rs=RRR02_HDR); - - /**Return LCP[i]*/ - virtual size_t get_LCP(size_t i, TextIndex *csa) const; - - /**Return LCP[i], being faster if sequential acceses to the LCP had been done*/ - virtual size_t get_seq_LCP(size_t i, TextIndex *csa, size_t **next_pos, size_t *n_next, bool dir) const; - - /** Returns the size of the structure in bytes */ - virtual size_t getSize() const; - - /** Stores the structure given a file pointer, return 0 in case of success */ - virtual void save(ostream & fp) const; - - /** Reads a LCP determining the type */ - static LCP_FMN * load(istream & fp); - - virtual ~LCP_FMN(); - }; -}; -#endif diff --git a/libcds/include/LCP_PT.h b/libcds/include/LCP_PT.h deleted file mode 100644 index abc3f4ba..00000000 --- a/libcds/include/LCP_PT.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef LCP_PT_H -#define LCP_PT_H - -#include -#include - -namespace cds_static -{ - - class LCP_PT: public LCP - { - private: - LCP_PT(); - - virtual int calc_delta(unsigned int i, unsigned int j) const; - - int logv; - size_t length; - int mask; - int v; - int m; /*size of rev_ess*/ - int *rev_cover; - int *delta; - int cover_size; - int *rev_ess; - RMQ_succinct *rmq; - - public: - /*Puglisi and Turpin encoding of the LCP, - * @param csa The compressed suffix array of the text - * @param text The text - * @param n The length of the text - * @param _logv logarithm (base 2) of the period of the difference cover you would like to use. Valid values for "logv" are 2,3,4,5,6,7 and 8 - * */ - LCP_PT(TextIndex *csa, char *text, size_t n, int _logv=8); - virtual size_t get_LCP(size_t i, TextIndex *csa) const; - virtual size_t get_seq_LCP(size_t i, TextIndex *csa, size_t **next_pos, size_t *n_next, bool dir) const; - virtual size_t getSize() const; - virtual void save(ostream & fp) const; - static LCP_PT * load(istream & fp); - virtual ~LCP_PT(); - }; -}; -#endif diff --git a/libcds/include/LCP_PhiSpare.h b/libcds/include/LCP_PhiSpare.h deleted file mode 100644 index 14a2a893..00000000 --- a/libcds/include/LCP_PhiSpare.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef LCP_PHISPARE_H -#define LCP_PHISPARE_H - -#include - -namespace cds_static -{ - - class LCP_PhiSpare: public LCP - { - private: - int q; - size_t n; //length of LCP - int *plcp; //psi lcp - - LCP_PhiSpare(); - - public: - /*Karkkainen, Manzini, and Puglisi encoding of the LCP, - * @param csa The compressed suffix array of the text - * @param text The text - * @param n The length of the text - * @param _q The sample period to use (if q = -1 its mean that we will not use any sample) - * */ - LCP_PhiSpare(TextIndex *csa, char *text, size_t _n, int _q = 32); - virtual size_t get_LCP(size_t i, TextIndex *csa) const; - virtual size_t get_seq_LCP(size_t i, TextIndex *csa, size_t **next_pos, size_t *n_next, bool dir) const; - virtual size_t getSize() const; - virtual void save(ostream & fp) const; - static LCP_PhiSpare * load(istream & fp); - virtual ~LCP_PhiSpare(); - }; -}; -#endif diff --git a/libcds/include/LCP_Sad.h b/libcds/include/LCP_Sad.h deleted file mode 100644 index 40f72f24..00000000 --- a/libcds/include/LCP_Sad.h +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef LCP_SAD_H -#define LCP_SAD_H - -#include -#include - -namespace cds_static -{ - class LCP_Sad: public LCP - { - private: - LCP_Sad(); - size_t U_type; - - public: - BitSequence *U; - size_t U_length; //length of bitmap U - - /*Create Sadakane encoding of the LCP, that use 2n+o(n) bits, - * @param csa The compressed suffix array of the text - * @param text The text - * @param n The length of the text - * */ - LCP_Sad(TextIndex *csa, char *text, size_t n, size_t op_rs = BRW32_HDR); - - /*Create the LCP representation starting from a precomputed LCP array*/ - LCP_Sad(LCP *lcp, TextIndex *csa, size_t n, size_t op_rs = BRW32_HDR); - - /**Return LCP[i]*/ - virtual size_t get_LCP(size_t i, TextIndex *csa) const; - - /**Return LCP[i], being faster if sequential acceses to the LCP had been done*/ - virtual size_t get_seq_LCP(size_t i, TextIndex *csa, size_t **next_pos, size_t *n_next, bool dir) const; - - /** Returns the size of the structure in bytes */ - virtual size_t getSize() const; - - /** Stores the structure given a file pointer*/ - virtual void save(ostream & fp) const; - - /** Reads a LCP determining the type */ - static LCP_Sad * load(istream & fp); - - virtual ~LCP_Sad(); - }; -}; -#endif diff --git a/libcds/include/LCP_naive.h b/libcds/include/LCP_naive.h deleted file mode 100644 index 911ea210..00000000 --- a/libcds/include/LCP_naive.h +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef LCP_NAIVE_H -#define LCP_NAIVE_H - -#include - -namespace cds_static -{ - - class LCP_naive: public LCP - { - private: - LCP_naive(); - uint *lcp_array; - size_t b; - size_t length; - - public: - - LCP_naive(TextIndex *csa, char *text, size_t n); - - /**Return LCP[i]*/ - virtual size_t get_LCP(size_t i, TextIndex *csa) const; - - /**Return LCP[i], being faster if sequential acceses to the LCP had been done*/ - virtual size_t get_seq_LCP(size_t i, TextIndex *csa, size_t **next_pos, size_t *n_next, bool dir) const; - - /** Returns the size of the structure in bytes */ - virtual size_t getSize() const; - - /** Stores the structure given a file pointer, return 0 in case of success */ - virtual void save(ostream & fp) const; - - /** Reads a LCP determining the type */ - static LCP_naive * load(istream & fp); - - virtual ~LCP_naive(); - }; -}; -#endif diff --git a/libcds/include/Mapper.h b/libcds/include/Mapper.h deleted file mode 100644 index 950c0cf9..00000000 --- a/libcds/include/Mapper.h +++ /dev/null @@ -1,70 +0,0 @@ -/* Mapper.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * Mapper definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef _MAPPER_H -#define _MAPPER_H - -#include -#include - -using namespace std; - -namespace cds_static -{ - - #define MAPPER_NONE_HDR 2 - #define MAPPER_CONT_HDR 3 - #define MAPPER_REV_HDR 4 - - /** Base class for alphabet mappers - * - * @author Francisco Claude - */ - class Mapper - { - public: - Mapper(); - virtual ~Mapper() {} - /** Maps the symbol */ - virtual uint map(uint s) const=0; - /** Unmaps the symbol */ - virtual uint unmap(uint s) const=0; - /** Returns the size of the mapper */ - virtual size_t getSize() const=0; - /** Saves the mapper to a file */ - virtual void save(ostream & out) const=0; - /** Loads the mapper from a file */ - static Mapper * load(istream & input); - /** Reference counter incrementor */ - virtual void use(); - /** Reference counter decrementor */ - virtual void unuse(); - - protected: - /** Nr of references */ - int userCount; - }; -}; - -#include -#include -#include -#endif /* _MAPPER_H */ diff --git a/libcds/include/MapperCont.h b/libcds/include/MapperCont.h deleted file mode 100644 index 9b93d2c0..00000000 --- a/libcds/include/MapperCont.h +++ /dev/null @@ -1,64 +0,0 @@ -/* mapper_cont.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * mapper_cont definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef _MAPPERCONT_H -#define _MAPPERCONT_H - -#include -#include - -#include -#include -#include -#include - -using namespace std; -using namespace cds_utils; - -namespace cds_static -{ - - /** Mapper that makes the values in the set contiguous - * - * @author Francisco Claude - */ - class MapperCont : public Mapper - { - public: - MapperCont(const Array & seq, const BitSequenceBuilder & bsb); - MapperCont(const uint * A, const size_t len, const BitSequenceBuilder & bsb); - - virtual ~MapperCont(); - - virtual uint map(uint s) const; - virtual uint unmap(uint s) const; - virtual size_t getSize() const; - - virtual void save(ostream & out) const; - static MapperCont * load(istream & input); - - protected: - MapperCont(); - BitSequence * m; - }; - -}; -#endif /* _MAPPERCONT_H */ diff --git a/libcds/include/MapperNone.h b/libcds/include/MapperNone.h deleted file mode 100644 index 3c267050..00000000 --- a/libcds/include/MapperNone.h +++ /dev/null @@ -1,51 +0,0 @@ -/* MapperNone.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * MapperNone definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef _MAPPERNONE_H -#define _MAPPERNONE_H - -#include - -#include -#include - -using namespace std; - -namespace cds_static -{ - - /** Mapper that doesn't change the value (identity) - * - * @author Francisco Claude - */ - class MapperNone : public Mapper - { - public: - MapperNone(); - virtual ~MapperNone() {} - virtual uint map(uint s) const; - virtual uint unmap(uint s) const; - virtual size_t getSize() const; - virtual void save(ostream & out) const; - static MapperNone * load(istream & input); - }; -}; -#endif /* __MAPPER_NONE_H */ diff --git a/libcds/include/MapperRev.h b/libcds/include/MapperRev.h deleted file mode 100644 index 13b50007..00000000 --- a/libcds/include/MapperRev.h +++ /dev/null @@ -1,61 +0,0 @@ -/* MapperRev.h - * Copyright (C) 2012, Francisco Claude, all rights reserved. - * - * MapperRev definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef _MAPPERREV_H -#define _MAPPERREV_H - -#include -#include - -#include -#include -#include -#include - -using namespace std; -using namespace cds_utils; - -namespace cds_static -{ - - /** Mapper that reverses the bits (considering how many bits are required - * to represent the maximum value in the sequence) - * - * @author Francisco Claude - */ - class MapperRev : public Mapper - { - public: - MapperRev(const Array &a); - MapperRev(const uint *A, const size_t len); - virtual ~MapperRev() {} - virtual uint map(const uint s) const; - virtual uint unmap(const uint s) const; - virtual size_t getSize() const; - virtual void save(ostream & out) const; - static MapperRev * load(istream & input); - - protected: - MapperRev(); - uint bits; - }; -}; -#endif /* __MAPPER_REV_H */ diff --git a/libcds/include/NPR.h b/libcds/include/NPR.h deleted file mode 100644 index 3211ee82..00000000 --- a/libcds/include/NPR.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef NPR_H -#define NPR_H - -#include - -namespace cds_static -{ - - static const size_t FMN_NPR = 2; - static const size_t CN_NPR = 3; - - class NPR - { - public: - size_t npr_type; - - virtual ~NPR() {}; - - // Return the position of the next smaller value of i (NSV[i]) - virtual size_t find_NSV(size_t i, TextIndex *csa, LCP *lcp) const= 0; - - // Return the position of the previous smaller value of i plus one (PSV[i]+1) - virtual size_t find_PSV(size_t i, TextIndex *csa, LCP *lcp) const= 0; - - //Return the first previous position, from i, that contains a value < d - virtual size_t bwd_PSV(size_t i, TextIndex *csa, LCP *lcp, size_t d) const= 0; - - //Return the first next position, from i, that contains a value < d - virtual size_t fwd_NSV(size_t i, TextIndex *csa, LCP *lcp, size_t d) const= 0; - - //Return the range minimum query over the LCP array, between the positions x and y - virtual size_t find_RMQ(size_t x, size_t y, TextIndex *csa, LCP *lcp) const= 0; - - //Return the size, in bytes, of the NPR structure - virtual size_t getSize() const = 0; - - virtual void save(ostream & fp) const=0; - - static NPR * load(istream & fp); - }; - -}; -#include -#include -#endif diff --git a/libcds/include/NPR_CN.h b/libcds/include/NPR_CN.h deleted file mode 100644 index e1adad65..00000000 --- a/libcds/include/NPR_CN.h +++ /dev/null @@ -1,80 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef NPR_CN_H -#define NPR_CN_H - -#include - -namespace cds_static -{ - /***************************** - There are r=(log(n)/log(b))-1 levels - ****************************/ - - class NPR_CN: public NPR - { - private: - NPR_CN(); - void create_first_level(LCP *lcp, TextIndex *csa); - void create_next_level(size_t r); - size_t find_NSV_level_r(size_t value_v, size_t next_pos, size_t r) const; - size_t find_PSV_level_r(size_t value_v, size_t next_pos, size_t r) const; - size_t find_RMQ(size_t x, size_t y, size_t r, size_t *min_r) const; - - size_t n; //size of lcp - size_t b; //block Size - size_t bits_b; //bits for representated b - size_t l; //number of levels - uint **min_level; //array for each level that contain the min value of each block - uint **min_pos; // array for each level that contain the local position of the min value of each block - uint *level_size; //size of each level - - public: - /*NPR Data structure base on Canovas and Navarro "Practical Compressed Suffix Trees" - * @param lcp Any LCP array data structure - * @param block_Size Block size that will be used - * @param csa The compresses suffix array - */ - NPR_CN(LCP *lcp, size_t block_Size, TextIndex *csa); - - virtual ~NPR_CN(); - - // Return the position of NSV[i] - virtual size_t find_NSV(size_t i, TextIndex *csa, LCP *lcp) const; - - // Return the position of PSV[i]+1 - virtual size_t find_PSV(size_t i, TextIndex *csa, LCP *lcp) const; - - virtual size_t bwd_PSV(size_t i, TextIndex *csa, LCP *lcp, size_t d) const; - - virtual size_t fwd_NSV(size_t i, TextIndex *csa, LCP *lcp, size_t d) const; - - //Return the left-most position j, x<= j <= y , where is the minimun in the range [x,y] - virtual size_t find_RMQ(size_t x, size_t y, TextIndex *csa, LCP *lcp) const; - - virtual size_t getSize() const; - - virtual void save(ostream & fp) const; - - static NPR_CN * load(istream & fp); - - }; - -}; -#endif diff --git a/libcds/include/NPR_FMN.h b/libcds/include/NPR_FMN.h deleted file mode 100644 index 88103952..00000000 --- a/libcds/include/NPR_FMN.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef NPR_FMN_H -#define NPR_FMN_H - -#include -#include -#include -#include - -namespace cds_static -{ - - class NPR_FMN: public NPR - { - private: - NSV *nsv; - PSV *psv; - RMQ_succinct_lcp *rmq; - - NPR_FMN(); - - public: - - /*NPR Data structure base on Fisher, Makinnen, and Navarro "Faster Entropy-Bounded Compressed Suffix Trees" - * @param lcp Any LCP array data structure - * @param block_Size Block size that will be used - * @param csa The compresses suffix array - * @param levels Number of levels that the recursion will use. (in general is better to use only 2 or 3 levels) - * */ - NPR_FMN(LCP *lcp, size_t block_Size, TextIndex *csa, size_t levels = 2); - - virtual ~NPR_FMN(); - - virtual size_t find_NSV(size_t i, TextIndex *csa, LCP *lcp) const; - - virtual size_t find_PSV(size_t i, TextIndex *csa, LCP *lcp) const; - - virtual size_t bwd_PSV(size_t i, TextIndex *csa, LCP *lcp, size_t d) const; - - virtual size_t fwd_NSV(size_t i, TextIndex *csa, LCP *lcp, size_t d) const; - - virtual size_t find_RMQ(size_t x, size_t y, TextIndex *csa, LCP *lcp) const; - - virtual size_t getSize() const; - - virtual void save(ostream & fp) const; - - static NPR_FMN * load(istream & fp); - }; - -}; -#endif diff --git a/libcds/include/NSV.h b/libcds/include/NSV.h deleted file mode 100644 index 4c7d8bec..00000000 --- a/libcds/include/NSV.h +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef NSV_H -#define NSV_H - -#include -#include - -namespace cds_static -{ - class NSV - { - - private: - NSV(); - virtual void create_first_level(LCP *lcp, TextIndex *csa); - virtual void create_level_r(LCP *lcp, size_t level, TextIndex *csa); - virtual void create_last_level(LCP *lcp, TextIndex *csa); - virtual size_t find_NSV_r(size_t v, size_t level, TextIndex *csa, LCP *lcp) const; - - size_t r; /*levels*/ - size_t b; /*block size*/ - size_t n; /*number of element of lcp*/ - BitSequence **P; /*bitarray with the pioneer for each level*/ - BitSequence **R; /*bitarray with the pioneer and their answers*/ - uint *A; /*stored values for the last level*/ - size_t b_A; /*bits needed per value in A*/ - - public: - - /*NSV Data structure base on Fisher, Makinnen, and Navarro "Faster Entropy-Bounded Compressed Suffix Trees" - * @param lcp Any LCP array data structure - * @param levels Number of levels that the recursion will use (in general is better to use only 2 or 3 levels). - * @param block Block size that will be used - * @param csa The compresses suffix array*/ - NSV(LCP *lcp, size_t levels, size_t block, TextIndex *csa); - - //return the position where is the NSV of v - virtual size_t find_NSV(size_t v, TextIndex *csa, LCP *lcp) const; - - //memory use for NSV in bytes - virtual size_t getSize() const; - - virtual void save(ostream & fp) const; - - static NSV* load(istream & fp); - - virtual ~NSV(); - }; - -}; -#endif diff --git a/libcds/include/PSV.h b/libcds/include/PSV.h deleted file mode 100644 index 4a0636b4..00000000 --- a/libcds/include/PSV.h +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef PSV_H -#define PSV_H - -#include -#include - -namespace cds_static -{ - class PSV - { - - private: - PSV(); - virtual void create_first_level(LCP *lcp, TextIndex *csa); - virtual void create_level_r(LCP *lcp, size_t level, TextIndex *csa); - virtual void create_last_level(LCP *lcp, TextIndex *csa); - virtual size_t find_PSV_r(size_t v, size_t level, TextIndex *csa, LCP *lcp) const; - - size_t r; /*levels*/ - size_t b; /*block size*/ - size_t n; /*number of element of lcp*/ - BitSequence **P; /*bitarray with the pioneer for each level*/ - BitSequence **R; /*bitarray with the pioneer and their answers*/ - uint *A; /*stored values for the last level*/ - size_t b_A; /*bits needed per value in A*/ - - public: - /*PSV Data structure base on Fisher, Makinnen, and Navarro "Faster Entropy-Bounded Compressed Suffix Trees" - * @param lcp Any LCP array data structure - * @param levels Number of levels that the recursion will use (in general is better to use only 2 or 3 levels). - * @param block Block size that will be use - * @param csa The compresses suffix array*/ - PSV(LCP *lcp, size_t levels, size_t block, TextIndex *csa); - - //Return the position (plus 1) where is the PSV of v - virtual size_t find_PSV(size_t v, TextIndex *SA, LCP *lcp) const; - - //Memory use for PSV in bytes - virtual size_t getSize() const; - - virtual void save(ostream & fp) const; - - static PSV* load(istream & fp); - - virtual ~PSV(); - }; - -}; -#endif diff --git a/libcds/include/Permutation.h b/libcds/include/Permutation.h deleted file mode 100644 index 90b2635d..00000000 --- a/libcds/include/Permutation.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Permutation.h - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include - -#ifndef __PERMUTATION_H -#define __PERMUTATION_H - -using namespace cds_utils; - -namespace cds_static -{ - class Permutation - { - public: - Permutation(); - virtual ~Permutation(); - - /** Compute the value at position i - */ - virtual uint pi(uint i) const; - - /** Compute the position where i appears */ - virtual uint revpi(uint i) const; - - /** Compose pi k times. - */ - virtual uint pi(uint i, uint k) const; - - /** Compose revpi k times - */ - virtual uint revpi(uint i, uint k) const; - - /** retrieves the length of the permutation - */ - virtual size_t getLength() const; - - /** Size in bytes - */ - virtual size_t getSize() const = 0; - - /** Saves permutation to stream */ - virtual void save(ostream & fp) const; - - /** Loads the permutation */ - static Permutation * load(istream & fp); - - protected: - size_t length; - }; -}; - -#define MRRRPERM 1 -#define WTPERM 2 - -#include -#include -#endif diff --git a/libcds/include/PermutationBuilder.h b/libcds/include/PermutationBuilder.h deleted file mode 100644 index 56e276ec..00000000 --- a/libcds/include/PermutationBuilder.h +++ /dev/null @@ -1,46 +0,0 @@ -/* PermutationBuilder.h - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#ifndef PERMUTATIONBUILDER_H -#define PERMUTATIONBUILDER_H - -#include -#include - -namespace cds_static -{ - - class PermutationBuilder - { - public: - PermutationBuilder() { userCount=0; } - virtual ~PermutationBuilder() {} - virtual Permutation * build(uint * perm, uint n) const = 0; - virtual void use() { userCount++; } - virtual void unuse() { userCount--; assert(userCount>=0); if(userCount==0) delete this; } - - protected: - int userCount; - }; -}; - -#include -#include -#endif diff --git a/libcds/include/PermutationBuilderMRRR.h b/libcds/include/PermutationBuilderMRRR.h deleted file mode 100644 index f00ad3a7..00000000 --- a/libcds/include/PermutationBuilderMRRR.h +++ /dev/null @@ -1,42 +0,0 @@ -/* PermutationBuilderMRRR.h - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#ifndef PERMUTATIONBUILDERMRRR_H -#define PERMUTATIONBUILDERMRRR_H - -#include -#include -#include - -namespace cds_static -{ - - class PermutationBuilderMRRR : public PermutationBuilder - { - public: - PermutationBuilderMRRR(uint sample, BitSequenceBuilder * bmb); - virtual ~PermutationBuilderMRRR(); - virtual Permutation * build(uint * perm, uint len) const; - protected: - uint sample; - BitSequenceBuilder * bmb; - }; -}; -#endif diff --git a/libcds/include/PermutationBuilderWT.h b/libcds/include/PermutationBuilderWT.h deleted file mode 100644 index 623ebc9b..00000000 --- a/libcds/include/PermutationBuilderWT.h +++ /dev/null @@ -1,39 +0,0 @@ -/* PermutationBuilderWT.h - * Copyright (C) 2011, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#ifndef PERMUTATIONBUILDERWT_H -#define PERMUTATIONBUILDERWT_H - -#include -#include -#include - -namespace cds_static -{ - - class PermutationBuilderWT : public PermutationBuilder - { - public: - PermutationBuilderWT() {} - virtual ~PermutationBuilderWT() {} - virtual Permutation * build(uint * perm, uint len) const; - }; -}; -#endif diff --git a/libcds/include/PermutationMRRR.h b/libcds/include/PermutationMRRR.h deleted file mode 100644 index e1c0bf30..00000000 --- a/libcds/include/PermutationMRRR.h +++ /dev/null @@ -1,58 +0,0 @@ -/* PermutationMRRR.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * Permutation - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef _STATIC_PERMUTATION_MRRR_H -#define _STATIC_PERMUTATION_MRRR_H - -#include -#include -#include - -using namespace cds_utils; - -namespace cds_static -{ - - /** Wrapper for Diego Arroyuelo's implementation of Munro et al.'s permutations. - * @author Francisco Claude - */ - class PermutationMRRR : public Permutation - { - public: - PermutationMRRR(uint * elems, uint nelems, uint t, BitSequenceBuilder * bmb); - virtual ~PermutationMRRR(); - /** Computes the i-th element of the permutation */ - virtual uint pi(uint i) const; - /** Computes the inverse of i */ - virtual uint revpi(uint i) const; - /** Saves the permutation to fp, returns 0 in case of success */ - virtual void save(ostream & fp) const; - /** Returns the size of the permutation */ - virtual size_t getSize() const; - /** Loads a static_permutation from fp */ - static PermutationMRRR * load(istream & fp); - protected: - perm permutation; - PermutationMRRR(); - }; - -}; -#endif diff --git a/libcds/include/PermutationWT.h b/libcds/include/PermutationWT.h deleted file mode 100644 index 0b4df593..00000000 --- a/libcds/include/PermutationWT.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Permutation.h - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#ifndef __PERMUTATIONWT_H -#define __PERMUTATIONWT_H - -#include - -#include -#include -#include - -using namespace cds_utils; - -namespace cds_static -{ - class WaveletTree; - - class PermutationWT:public Permutation - { - public: - PermutationWT(uint * perm, size_t len); - virtual ~PermutationWT(); - - /** Compute the value at position i - */ - virtual uint pi(uint i) const; - - /** Compute the position where i appears */ - virtual uint revpi(uint i) const; - - /** Size in bytes - */ - virtual size_t getSize() const; - - /** Saves permutation to stream */ - virtual void save(ostream & fp) const; - - /** Loads the permutation */ - static PermutationWT * load(istream & fp); - - protected: - PermutationWT() {} - BitSequence * marks; - Sequence * wt; - uint runs; - }; -}; -#endif diff --git a/libcds/include/RMQ_succinct.h b/libcds/include/RMQ_succinct.h deleted file mode 100644 index 6e79d9cb..00000000 --- a/libcds/include/RMQ_succinct.h +++ /dev/null @@ -1,111 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef _RMQ_succinct_h -#define _RMQ_succinct_h - -#define MEM_COUNT - -#include -#include -#include -#include -#include -using namespace std; -using namespace cds_utils; - -typedef unsigned char DTsucc; -typedef unsigned short DTsucc2; - -namespace cds_static -{ - class RMQ_succinct - { - private: - RMQ_succinct(); - public: - /*array*/ - int *a; - - /* liefert RMQ[i,j]*/ - virtual unsigned int query(unsigned int, unsigned int); - - /*Johannes RMQ encode - * @param a The array - * @param n Number of elements in the array - * */ - RMQ_succinct(int* a, unsigned int n); - - uint getSize(); - void save(ostream & fp); - RMQ_succinct * load(istream & fp); - - ~RMQ_succinct(); - - protected: - /* size of array a*/ - unsigned int n; - /* table M for the out-of-block queries (contains indices of block-minima)*/ - DTsucc** M; - /* because M just stores offsets (rel. to start of block), this method re-calculates the true index:*/ - inline unsigned int m(unsigned int k, unsigned int block) { return M[k][block]+(block*sprime); } - /* depth of table M:*/ - unsigned int M_depth; - /* table M' for superblock-queries (contains indices of block-minima)*/ - unsigned int** Mprime; - /* depth of table M':*/ - unsigned int Mprime_depth; - /* type of blocks*/ - DTsucc2 *type; - /* precomputed in-block queries*/ - DTsucc** Prec; - /* microblock size*/ - unsigned int s; - /* block size*/ - unsigned int sprime; - /* superblock size*/ - unsigned int sprimeprime; - /* number of blocks (always n/sprime)*/ - unsigned int nb; - /* number of superblocks (always n/sprimeprime)*/ - unsigned int nsb; - /* number of microblocks (always n/s)*/ - unsigned int nmb; - /* return microblock-number of entry i:*/ - inline unsigned int microblock(unsigned int i) { return i/s; } - /* return block-number of entry i:*/ - inline unsigned int block(unsigned int i) { return i/sprime; } - /* return superblock-number of entry i:*/ - inline unsigned int superblock(unsigned int i) { return i/sprimeprime; } - /* precomputed Catalan triangle (17 is enough for 64bit computing):*/ - static const unsigned int Catalan[17][17]; - /* minus infinity (change for 64bit version)*/ - static const int minus_infinity; - /* stuff for clearing the least significant x bits (change for 64-bit computing)*/ - static const DTsucc HighestBitsSet[8]; - virtual DTsucc clearbits(DTsucc, unsigned int); - /* Least Significant Bits for 8-bit-numbers:*/ - static const char LSBTable256[256]; - /* return least signigicant bit in constant time (change for 64bit version)*/ - virtual unsigned int lsb(DTsucc); - /* the following stuff is for fast base 2 logarithms: (currently only implemented for 32 bit numbers)*/ - static const char LogTable256[256]; - virtual unsigned int log2fast(unsigned int); - }; -}; -#endif diff --git a/libcds/include/RMQ_succinct_lcp.h b/libcds/include/RMQ_succinct_lcp.h deleted file mode 100644 index 2ee55ff3..00000000 --- a/libcds/include/RMQ_succinct_lcp.h +++ /dev/null @@ -1,113 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef _RMQ_succinct_LCP_H -#define _RMQ_succinct_LCP_H - -#define MEM_COUNT - -#include - -typedef unsigned char DTsucc; -typedef unsigned short DTsucc2; - -namespace cds_static -{ - - class RMQ_succinct_lcp - { - private: - RMQ_succinct_lcp(); - - public: - // liefert RMQ[i,j] - virtual uint query(uint i, uint j, TextIndex *csa, LCP *lcp); - - /*Johannes RMQ encode - * @param lcp The LCP array - * @param n Number of elements in the array - * @param csa The compressed suffix array - **/ - RMQ_succinct_lcp(LCP *lcp, TextIndex *csa); - - virtual uint getSize(); - - virtual void save(ostream & fp); - - static RMQ_succinct_lcp * load(istream & fp); - - virtual ~RMQ_succinct_lcp(); - - protected: - // array DT *a; - uint n; //number of element of lcp - DTsucc** M; // table M for the out-of-block queries (contains indices of block-minima) - - uint M_depth; //depth of table M - uint **Mprime; // table M' for superblock-queries (contains indices of block-minima) - uint Mprime_depth; // depth of table M': - DTsucc2 *type; // type of blocks - DTsucc** Prec; // precomputed in-block queries - uint s; // microblock size - uint sprime; // block size - uint sprimeprime; // superblock size - uint nb; // number of blocks (always n/sprime) - uint nsb; // number of superblocks (always n/sprimeprime) - uint nmb; // number of microblocks (always n/s) - - // because M just stores offsets (rel. to start of block), this method - // re-calculates the true index: - inline uint m(uint k, uint block) { - return M[k][block]+(block*sprime); - } - - // return microblock-number of entry i: - inline uint microblock(uint i) { return i/s; } - - // return block-number of entry i: - inline uint block(uint i) { return i/sprime; } - - // return superblock-number of entry i: - inline uint superblock(uint i) { return i/sprimeprime; } - - // precomputed Catalan triangle (17 is enough for 64bit computing): - static const uint Catalan[17][17]; - - // minus infinity (change for 64bit version) - static const int minus_infinity; - - // stuff for clearing the least significant x bits (change for 64-bit computing) - static const DTsucc HighestBitsSet[8]; - - DTsucc clearbits(DTsucc, uint); - - // Least Significant Bits for 8-bit-numbers: - static const char LSBTable256[256]; - - // return least signigicant bit in constant time (change for 64bit version) - uint lsb(DTsucc); - - // the following stuff is for fast base 2 logarithms: - // (currently only implemented for 32 bit numbers) - static const char LogTable256[256]; - - uint log2fast(uint); - }; - -}; -#endif diff --git a/libcds/include/Sequence.h b/libcds/include/Sequence.h deleted file mode 100644 index c8c04943..00000000 --- a/libcds/include/Sequence.h +++ /dev/null @@ -1,111 +0,0 @@ -/* Sequence.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * Sequence definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef _SEQUENCE_H -#define _SEQUENCE_H - -#include -#include - -using namespace cds_utils; -using namespace std; - -namespace cds_static -{ - - #define BS_HDR 1 - #define WVTREE_HDR 2 - #define WVTREE_NOPTRS_HDR 3 - #define GMR_HDR 4 - #define GMR_CHUNK_HDR 5 - #define ALPHPART_HDR 6 - #define WVMATRIX_HDR 7 - #define WVTREE_NOPTRSS_HDR 8 - - /** Sequence base class - * - * @author Francisco Claude - */ - class Sequence - { - - public: - /** Builds and sets the length */ - Sequence(size_t length); - virtual ~Sequence() {} - - /** Count the number of occurrences of c up to position i included - */ - virtual size_t rank(uint c, size_t i) const; - - /** Retrieve the i-th position where c appears. - * It returns (size_t)-1 if i=0 and length if the number of - * c's is less than i - */ - virtual size_t select(uint c, size_t i) const; - - /** Retrieves the next occurrence of a c starting at position i (included). - * It return length if there are no occurrences of c after position i. - */ - virtual size_t selectNext(uint c, size_t i) const; - - /** Retrieve the symbol at position i. - */ - virtual uint access(size_t i) const; - - /** Retrieve the symbol at position i and its rank. - */ - virtual uint access(size_t i, size_t & r) const; - - /** Size of the structure in bytes. - */ - virtual size_t getSize() const = 0; - - /** Length of the sequence. - */ - virtual size_t getLength() const { return length; } - - /** Saves the structure to the stream - */ - virtual void save(ostream & fp) const = 0; - - /** Reads a bitmap determining the type */ - static Sequence * load(istream & fp); - - protected: - size_t length; - uint sigma; - - }; - -}; - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#endif /* _SEQUENCE_H */ diff --git a/libcds/include/SequenceAlphPart.h b/libcds/include/SequenceAlphPart.h deleted file mode 100644 index d6121d98..00000000 --- a/libcds/include/SequenceAlphPart.h +++ /dev/null @@ -1,83 +0,0 @@ -/* SequenceAlphPart.h - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Sequence definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef _SEQUENCEALPHPART_H -#define _SEQUENCEALPHPART_H - -#include -#include - -using namespace cds_utils; -using namespace std; - -namespace cds_static -{ - - /** Sequence Alphabet Partitioning - * - * @author Francisco Claude - */ - class SequenceAlphPart : public Sequence - { - - public: - - SequenceAlphPart(uint * seq, size_t n, uint cut, SequenceBuilder * lenIndexBuilder, SequenceBuilder * seqsBuilder); - SequenceAlphPart(const Array & values, uint cut, SequenceBuilder * lenIndexBuilder, SequenceBuilder * seqsBuilder); - - SequenceAlphPart(); - - virtual ~SequenceAlphPart(); - - virtual size_t rank(uint c, size_t i) const; - - virtual size_t select(uint c, size_t i) const; - - virtual uint access(size_t i) const; - - virtual size_t getSize() const; - - virtual size_t getLength() const { return length; } - - virtual void save(ostream & fp) const; - - static SequenceAlphPart * load(istream & fp); - - protected: - // reverse permutation for sorted symbols - uint * revPermFreq; - // symbols sorted by frequency - uint * alphSortedByFreq; - // the sequence indexing the lengths of the symbol in each position - Sequence * groupsIndex; - // sequences indexing the elements groupes by length - Sequence ** indexesByLength; - // cut corresponds to the number of symbols that are not represented in indexesByLength (the most frequent ones) - uint cut; - uint origsigma; - // maxLen corresponds to the maximum length of a symbol in bits, - // this-cut+1 corresponds to the maximum index in indexesByLength. - uint maxLen; - - }; - -}; -#endif /* _SEQUENCEALPHPART_H */ diff --git a/libcds/include/SequenceBuilder.h b/libcds/include/SequenceBuilder.h deleted file mode 100644 index 572c0080..00000000 --- a/libcds/include/SequenceBuilder.h +++ /dev/null @@ -1,53 +0,0 @@ -/* SequenceBuilder.h - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include - -#include - -#ifndef SEQUENCEBUILDER_H -#define SEQUENCEBUILDER_H - -namespace cds_static -{ - - class SequenceBuilder - { - public: - SequenceBuilder() { userCount=0; } - virtual ~SequenceBuilder() {} - virtual Sequence * build(uint * seq, size_t len)=0; - virtual Sequence * build(const Array & seq)=0; - virtual void use() { userCount++; } - virtual void unuse() { userCount--; assert(userCount>=0); if(userCount==0) delete this; } - - protected: - int userCount; - }; -}; - -#include -#include -#include -#include -#include -#include -#include -#endif diff --git a/libcds/include/SequenceBuilderAlphPart.h b/libcds/include/SequenceBuilderAlphPart.h deleted file mode 100644 index 0c26be4e..00000000 --- a/libcds/include/SequenceBuilderAlphPart.h +++ /dev/null @@ -1,45 +0,0 @@ -/* SequenceBuilderAlphPart.h - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include - -#include -#include - -#ifndef SequenceBuilderAlphPart_H -#define SequenceBuilderAlphPart_H - -namespace cds_static -{ - class SequenceBuilderAlphPart : public SequenceBuilder - { - public: - SequenceBuilderAlphPart(SequenceBuilder * groupIndexBuilder, SequenceBuilder * indexBuilder, uint cut); - virtual ~SequenceBuilderAlphPart(); - virtual Sequence * build(uint * seq, size_t len); - virtual Sequence * build(const Array & seq); - - protected: - SequenceBuilder * groupIndexBuilder; - SequenceBuilder * indexBuilder; - uint cut; - }; -}; -#endif diff --git a/libcds/include/SequenceBuilderGMR.h b/libcds/include/SequenceBuilderGMR.h deleted file mode 100644 index 03c1ba12..00000000 --- a/libcds/include/SequenceBuilderGMR.h +++ /dev/null @@ -1,45 +0,0 @@ -/* SequenceBuilderGMR.h - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include - -#include -#include - -#ifndef SequenceBuilderGMR_H -#define SequenceBuilderGMR_H - -namespace cds_static -{ - class SequenceBuilderGMR : public SequenceBuilder - { - public: - SequenceBuilderGMR(BitSequenceBuilder * bsb, SequenceBuilder * sqb, uint chunk_len=0); - virtual ~SequenceBuilderGMR(); - virtual Sequence * build(uint * seq, size_t len); - virtual Sequence * build(const Array & seq); - - protected: - BitSequenceBuilder * bsb; - SequenceBuilder * sqb; - uint chunk_len; - }; -}; -#endif diff --git a/libcds/include/SequenceBuilderGMRChunk.h b/libcds/include/SequenceBuilderGMRChunk.h deleted file mode 100644 index b0b6c976..00000000 --- a/libcds/include/SequenceBuilderGMRChunk.h +++ /dev/null @@ -1,45 +0,0 @@ -/* SequenceBuilderGMRChunk.h - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include - -#include -#include -#include - -#ifndef SequenceBuilderGMRChunk_H -#define SequenceBuilderGMRChunk_H - -namespace cds_static -{ - class SequenceBuilderGMRChunk : public SequenceBuilder - { - public: - SequenceBuilderGMRChunk(BitSequenceBuilder * bsb, PermutationBuilder * pmb); - virtual ~SequenceBuilderGMRChunk(); - virtual Sequence * build(uint * seq, size_t len); - virtual Sequence * build(const Array & seq); - - protected: - BitSequenceBuilder * bsb; - PermutationBuilder * pmb; - }; -}; -#endif diff --git a/libcds/include/SequenceBuilderStr.h b/libcds/include/SequenceBuilderStr.h deleted file mode 100644 index 8bebfb0a..00000000 --- a/libcds/include/SequenceBuilderStr.h +++ /dev/null @@ -1,46 +0,0 @@ -/* SequenceBuilderStr.h - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include - -#include -#include -#include - -#ifndef SequenceBuilderStr_H -#define SequenceBuilderStr_H - -namespace cds_static -{ - class SequenceBuilderStr : public SequenceBuilder - { - public: - SequenceBuilderStr(const string & options); - virtual ~SequenceBuilderStr(); - virtual Sequence * build(uint * seq, size_t len); - virtual Sequence * build(const Array & seq); - - protected: - virtual SequenceBuilder * getBuilder(const Array & seq); - - string str; - }; -}; -#endif diff --git a/libcds/include/SequenceBuilderWaveletMatrix.h b/libcds/include/SequenceBuilderWaveletMatrix.h deleted file mode 100644 index cea5cdfb..00000000 --- a/libcds/include/SequenceBuilderWaveletMatrix.h +++ /dev/null @@ -1,45 +0,0 @@ -/* SequenceBuilderWaveletTreeNoptrs.h - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include - -#include -#include -#include - -#ifndef SEQUENCEBUILDERWAVELETMATRIX_H -#define SEQUENCEBUILDERWAVELETMATRIX_H - -namespace cds_static -{ - class SequenceBuilderWaveletMatrix : public SequenceBuilder - { - public: - SequenceBuilderWaveletMatrix(BitSequenceBuilder * bsb, Mapper * am); - virtual ~SequenceBuilderWaveletMatrix(); - virtual Sequence * build(uint * seq, size_t len); - virtual Sequence * build(const Array & seq); - - protected: - BitSequenceBuilder * bsb; - Mapper * am; - }; -}; -#endif diff --git a/libcds/include/SequenceBuilderWaveletTree.h b/libcds/include/SequenceBuilderWaveletTree.h deleted file mode 100644 index 3c09caa3..00000000 --- a/libcds/include/SequenceBuilderWaveletTree.h +++ /dev/null @@ -1,46 +0,0 @@ -/* SequenceBuilderWaveletTree.h - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include - -#include -#include -#include - -#ifndef SEQUENCEBUILDERWAVELETTREE_H -#define SEQUENCEBUILDERWAVELETTREE_H - -namespace cds_static -{ - class SequenceBuilderWaveletTree : public SequenceBuilder - { - public: - SequenceBuilderWaveletTree(BitSequenceBuilder * bsb, Mapper * am, wt_coder * wc=NULL); - virtual ~SequenceBuilderWaveletTree(); - virtual Sequence * build(uint * seq, size_t len); - virtual Sequence * build(const Array & seq); - - protected: - BitSequenceBuilder * bsb; - Mapper * am; - wt_coder * wc; - }; -}; -#endif diff --git a/libcds/include/SequenceBuilderWaveletTreeNoptrs.h b/libcds/include/SequenceBuilderWaveletTreeNoptrs.h deleted file mode 100644 index 02e591f9..00000000 --- a/libcds/include/SequenceBuilderWaveletTreeNoptrs.h +++ /dev/null @@ -1,45 +0,0 @@ -/* SequenceBuilderWaveletTreeNoptrs.h - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include - -#include -#include -#include - -#ifndef SEQUENCEBUILDERWAVELETTREENOPTRS_H -#define SEQUENCEBUILDERWAVELETTREENOPTRS_H - -namespace cds_static -{ - class SequenceBuilderWaveletTreeNoptrs : public SequenceBuilder - { - public: - SequenceBuilderWaveletTreeNoptrs(BitSequenceBuilder * bsb, Mapper * am); - virtual ~SequenceBuilderWaveletTreeNoptrs(); - virtual Sequence * build(uint * seq, size_t len); - virtual Sequence * build(const Array & seq); - - protected: - BitSequenceBuilder * bsb; - Mapper * am; - }; -}; -#endif diff --git a/libcds/include/SequenceBuilderWaveletTreeNoptrsS.h b/libcds/include/SequenceBuilderWaveletTreeNoptrsS.h deleted file mode 100644 index 15af9ab1..00000000 --- a/libcds/include/SequenceBuilderWaveletTreeNoptrsS.h +++ /dev/null @@ -1,45 +0,0 @@ -/* SequenceBuilderWaveletTreeNoptrsS.h - * Copyright (C) 2012, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include - -#include -#include -#include - -#ifndef SEQUENCEBUILDERWAVELETTREENOPTRSS_H -#define SEQUENCEBUILDERWAVELETTREENOPTRSS_H - -namespace cds_static { - class SequenceBuilderWaveletTreeNoptrsS : public SequenceBuilder { - public: - SequenceBuilderWaveletTreeNoptrsS(BitSequenceBuilder * bsb, Mapper * am); - virtual ~SequenceBuilderWaveletTreeNoptrsS(); - virtual Sequence * build(uint * seq, size_t len); - virtual Sequence * build(const Array & seq); - - protected: - BitSequenceBuilder * bsb; - Mapper * am; - }; -}; - -#endif - diff --git a/libcds/include/SequenceGMR.h b/libcds/include/SequenceGMR.h deleted file mode 100644 index 6aaba089..00000000 --- a/libcds/include/SequenceGMR.h +++ /dev/null @@ -1,72 +0,0 @@ -/* SequenceGMR.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * GMR - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef SEQUENCEGMR_H -#define SEQUENCEGMR_H - -#include -#include -#include -#include -#include -#include -#include - -using namespace cds_utils; -namespace cds_static -{ - //using namespace std; - - class SequenceGMR : public Sequence - { - public: - /** Builds the GMR structure. - * @param sequence Sequence of unsigned ints - * @param n length of the sequence - * @param chunk_length length of the regular partitioning (called chunks in the paper) - * @param bmb builder for the bitmap B (as called in the paper) - * @param ssb builder for the representation used for each chunk. - */ - SequenceGMR(uint * sequence, size_t n, uint chunk_length, BitSequenceBuilder * bmb, SequenceBuilder * ssb); - SequenceGMR(const Array & sequence, uint chunk_length, BitSequenceBuilder * bmb, SequenceBuilder * ssb); - - ~SequenceGMR(); - virtual size_t rank(uint c, size_t j) const; - virtual size_t select(uint c, size_t j) const; - virtual uint access(size_t j) const; - virtual size_t getSize() const; - virtual void save(ostream & fp) const; - /** Loads the SequenceGMR object from the stream. - */ - static SequenceGMR * load(istream & fp); - - protected: - SequenceGMR(); - void build(uint * sequence, BitSequenceBuilder * bmb, SequenceBuilder * ssb); - uint * get_ones(uint * sequence); - - uint sigma, chunk_length; - Sequence ** chunk; - BitSequence * B; - }; - -}; -#endif diff --git a/libcds/include/SequenceGMRChunk.h b/libcds/include/SequenceGMRChunk.h deleted file mode 100644 index fe5b5a84..00000000 --- a/libcds/include/SequenceGMRChunk.h +++ /dev/null @@ -1,80 +0,0 @@ -/* SequenceGMRChunk.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * gmr_chunk - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef SEQUENCEGMRCHUNK_H -#define SEQUENCEGMRCHUNK_H - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace cds_static -{ - //using namespace std; - - /** Implementation of the Chunk of Golynski et al's rank/select - * data structure [1]. - * - * [1] A. Golynski and I. Munro and S. Rao. - * Rank/select operations on large alphabets: a tool for text indexing. - * SODA 06. - * - * @author Francisco Claude - */ - class SequenceGMRChunk: public Sequence - { - public: - /** Builds the structures needed for the chunk - * @param sequence sequence as array of unsigned integers. - * @param chunk_length length of the sequence. - * @param bmb bitmap builder for X (as named in the paper). - * @param pmb permutation builder for Pi (as named in the paper). - * */ - SequenceGMRChunk(uint * sequence, uint chunk_length, BitSequenceBuilder *bmb, PermutationBuilder *pmb); - SequenceGMRChunk(const Array & sequence, BitSequenceBuilder *bmb, PermutationBuilder *pmb); - - /** Destroy the chunk */ - ~SequenceGMRChunk(); - - virtual uint access(size_t j) const; - virtual size_t select(uint i, size_t j) const; - virtual size_t rank(uint i, size_t j) const; - virtual size_t getSize() const; - virtual void save(ostream & fp) const; - static SequenceGMRChunk * load(istream & fp); - - protected: - /** Bitmap */ - BitSequence * X; - /** Permutation */ - Permutation * permutation; - /** Size of the alphabet */ - uint sigma; - - SequenceGMRChunk(); - }; -}; -#endif diff --git a/libcds/include/SuffixTree.h b/libcds/include/SuffixTree.h deleted file mode 100644 index 63568a6f..00000000 --- a/libcds/include/SuffixTree.h +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef SUFFIXTREE_H -#define SUFFIXTREE_H - -#include -using namespace cds_utils; - -namespace cds_static -{ - - static const size_t CSTY = 1; - - class SuffixTree - { - protected: - size_t length; - - public: - /*Operations*/ - - //Return true is [vl,vr] is the root - virtual bool isRoot(size_t vl,size_t vr) const=0; - - //Return, in [vl,vr], the Root - virtual void Root(size_t *vl, size_t *vr) const=0; - - //Return vr-vl+1 - virtual size_t Count(size_t vl, size_t vr) const=0; - - //Return true if [wl,wr] is ancestor of [vl,vr] - virtual bool Ancestor(size_t wl, size_t wr, size_t vl, size_t vr) const=0; - - //Return the String Depth of the node [vl,vr] - virtual size_t SDepth(size_t vl, size_t vr) const=0; - - //If [vl,vr] is a leaf (vr == vl), then return the suxffix array value at position v_l, Otherwise NULL. - virtual size_t Locate(size_t vl, size_t vr) const=0; - - //Return, in [parent_l, parent_r], the parent of the node [vl,vr] - virtual void Parent(size_t vl, size_t vr, size_t *parent_l, size_t *parent_r) const =0; - - //Return, in [fchild_l, fchild_r], the first child of the node [vl,vr] - virtual void FChild(size_t vl, size_t vr, size_t *fchild_l, size_t *fchild_r) const =0; - - //Return, in [nsibling_l, nsibling_r], the next sibling of the node [vl,vr] - virtual void NSibling(size_t vl, size_t vr, size_t *nsibling_l, size_t *nsibling_r) const =0; - - //Return, in [slink_l, slink_r], the suffix link of the node [vl,vr] - virtual void SLink(size_t vl, size_t vr, size_t *slink_l, size_t *slink_r) const =0; - - //Return, in [slinki_l, slinki_r], the suffix link applied i times over the node [vl,vr] - virtual void SLink_i(size_t vl, size_t vr, size_t i, size_t *slinki_l, size_t *slinki_r) const =0; - - //Return, in [lca_l, lca_r], the lower common ancestor between nodes [vl,vr] and [wl,wr] - virtual void LCA(size_t vl, size_t vr, size_t wl, size_t wr, size_t *lca_l, size_t *lca_r) const =0; - - //Return, in [child_l, child_r], the child of the node [vl,vr] which label path start with the char a - virtual void Child(size_t vl, size_t vr, uchar a, size_t *child_l, size_t *child_r) const =0; - - //Return the i-th letter of the label-path of the node [vl,vr] - virtual uchar Letter(size_t vl, size_t vr, int i) const =0; - - //Return the tree depth of the node [vl,vr] - virtual size_t TDepth(size_t vl, size_t vr) const =0; - - //Return, in [laq_s_l, laq_s_r], the highest ancestor of [vl,vr] with string-depth >=d - virtual void LAQs(size_t vl, size_t vr, size_t d, size_t *laq_s_l, size_t *laq_s_r) const =0; - - //Return, in [laq_t_l, laq_t_r], the highest ancestor of [vl,vr] with tree-depth >=d - virtual void LAQt(size_t vl, size_t vr, size_t d, size_t *laq_t_l, size_t *laq_t_r) const =0; - - //Memory use in bytes - virtual size_t getSize() const =0; - - virtual void save(ostream & fp) const =0; - - static SuffixTree * load(istream & fp); - - virtual ~SuffixTree() {}; - }; - -}; - -#include -#endif diff --git a/libcds/include/SuffixTreeY.h b/libcds/include/SuffixTreeY.h deleted file mode 100644 index f45eda57..00000000 --- a/libcds/include/SuffixTreeY.h +++ /dev/null @@ -1,119 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef SUFFIXY_H -#define SUFFIXY_H - -#include -#include -#include - -namespace cds_static -{ - - class SuffixTreeY : public SuffixTree - { - private: - SuffixTreeY(); - - TextIndex *csa; - LCP *lcp; - NPR *npr; - - public: - /*Create the compressed suffix tree data structure base on Canovas and Navarro "Practical Compressed Suffix Trees" - * @param text The text from where the suffix tree will be create - * @param n The length of the text - * @param lcp_type The lcp data structure that will be use (NAIVE|SAD_GON_OS|FMN_RRR_OS|PT|PHI|DAC|DAC_VAR). - * @param npr_type The npr data structute that will be use (FMN_NPR|CN_NPR). - * @param b The block size used in NPR - * */ - SuffixTreeY(char *text, size_t n, size_t lcp_type = DAC, size_t npr_type = CN_NPR, size_t b = 32); - - /*Create the compressed suffix tree data structure base on Canovas and Navarro "Practical Compressed Suffix Trees" - * @param _lcp The LCP array data structure - * @param _npr The NPR data structure - * @param csa The Compressed suffix array data structure - * */ - SuffixTreeY(LCP *_lcp, NPR *_npr, TextIndex *csa); - - /*Operations*/ - - //Return true is [vl,vr] is the root - virtual bool isRoot(size_t vl,size_t vr) const; - - //Return, in [vl,vr], the Root - virtual void Root(size_t *vl, size_t *vr) const; - - //Return vr-vl+1 - virtual size_t Count(size_t vl, size_t vr) const; - - //Return true if [wl,wr] is ancestor of [vl,vr] - virtual bool Ancestor(size_t wl, size_t wr, size_t vl, size_t vr) const; - - //Return the String Depth of the node [vl,vr] - virtual size_t SDepth(size_t vl, size_t vr) const; - - //If [vl,vr] is a leaf (vr == vl), then return the suxffix array value at position v_l, Otherwise NULL. - virtual size_t Locate(size_t vl, size_t vr) const; - - //Return, in [parent_l, parent_r], the parent of the node [vl,vr] - virtual void Parent(size_t vl, size_t vr, size_t *parent_l, size_t *parent_r) const; - - //Return, in [fchild_l, fchild_r], the first child of the node [vl,vr] - virtual void FChild(size_t vl, size_t vr, size_t *fchild_l, size_t *fchild_r) const; - - //Return, in [nsibling_l, nsibling_r], the next sibling of the node [vl,vr] - virtual void NSibling(size_t vl, size_t vr, size_t *nsibling_l, size_t *nsibling_r) const; - - //Return, in [slink_l, slink_r], the suffix link of the node [vl,vr] - virtual void SLink(size_t vl, size_t vr, size_t *slink_l, size_t *slink_r) const; - - //Return, in [slinki_l, slinki_r], the suffix link applied i times over the node [vl,vr] - virtual void SLink_i(size_t vl, size_t vr, size_t i, size_t *slinki_l, size_t *slinki_r) const; - - //Return, in [lca_l, lca_r], the lower common ancestor between nodes [vl,vr] and [wl,wr] - virtual void LCA(size_t vl, size_t vr, size_t wl, size_t wr, size_t *lca_l, size_t *lca_r) const; - - //Return, in [child_l, child_r], the child of the node [vl,vr] which label path start with the char a - virtual void Child(size_t vl, size_t vr, uchar a, size_t *child_l, size_t *child_r) const; - - //Return the i-th letter of the label-path of the node [vl,vr] - virtual uchar Letter(size_t vl, size_t vr, int i) const; - - //Return the tree depth of the node [vl,vr] - virtual size_t TDepth(size_t vl, size_t vr) const; - - //Return, in [laq_s_l, laq_s_r], the highest ancestor of [vl,vr] with string-depth >=d - virtual void LAQs(size_t vl, size_t vr, size_t d, size_t *laq_s_l, size_t *laq_s_r) const; - - //Return, in [laq_t_l, laq_t_r], the highest ancestor of [vl,vr] with tree-depth >=d - virtual void LAQt(size_t vl, size_t vr, size_t d, size_t *laq_t_l, size_t *laq_t_r) const; - - //Memory use in bytes - virtual size_t getSize() const; - - virtual void save(ostream & fp) const; - - static SuffixTreeY * load(istream & fp); - - virtual ~SuffixTreeY(); - }; - -}; -#endif diff --git a/libcds/include/TableOffsetRRR.h b/libcds/include/TableOffsetRRR.h deleted file mode 100644 index 2f5833c4..00000000 --- a/libcds/include/TableOffsetRRR.h +++ /dev/null @@ -1,109 +0,0 @@ -/* table_offset.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * Table for offsets definition. - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef _TABLE_OFFSET_H -#define _TABLE_OFFSET_H - -#include -#include - -using namespace cds_utils; - -namespace cds_static -{ - /** Universal table required for BitSequenceRRR, Raman, Raman and Rao's [1] - * proposal for rank/select capable data structures, it achieves space nH_0, - * O(sample_rate) time for rank and O(log len) for select. The practial implementation - * is based on [2] - * - * [1] R. Raman, V. Raman and S. Rao. Succinct indexable dictionaries with applications - * to encoding $k$-ary trees and multisets. SODA02. - * [2] F. Claude and G. Navarro. Practical Rank/Select over Arbitrary Sequences. SPIRE08. - * - * @author Francisco Claude - */ - class table_offset - { - - public: - /** builds a universal table, designed for u<=15 */ - table_offset(uint u); - ~table_offset(); - - /** Increments the counter of users for the table */ - inline void use() { - users_count++; - } - - /** Tells the object that the user is not going to need the table anymore. */ - inline table_offset * unuse() { - users_count--; - if(!users_count) { - delete this; - return NULL; - } - return this; - } - - /** Computes binomial(n,k) for n,k<=u */ - inline uint get_binomial(uint n, uint k) { - return binomial[n][k]; - } - - /** Computes ceil(log2(binomial(n,k))) for n,k<=u */ - inline ushort get_log2binomial(uint n, uint k) { - return log2binomial[n][k]; - } - - /** Returns the bitmap represented by the given class and inclass offsets */ - inline ushort short_bitmap(uint class_offset, uint inclass_offset) { - if(class_offset==0) return 0; - if(class_offset==u) return (ushort)(((uint)1< -using namespace cds_utils; -using namespace std; - -#ifndef uchar -#define uchar unsigned char -#endif -#ifndef uint -#define uint unsigned int -#endif -#ifndef ulong -#define ulong unsigned long -#endif - -namespace cds_static -{ - - static const unsigned int CSA_HDR = 2; - - class TextIndex - { - public: - ~TextIndex(){}; - - /* Writes in numocc the number of occurrences of the substring - * pattern[0..length-1] found in the text indexed by index. */ - virtual size_t count (uchar *pattern, ulong length, ulong *numocc) const=0; - - /* Writes in numocc the number of occurrences of the substring - * pattern[0..length-1] in the text indexed by index. It also allocates - * occ (which must be freed by the caller) and writes the locations of - * the numocc occurrences in occ, in arbitrary order. */ - virtual size_t locate (uchar *pattern, ulong length, ulong **occ, ulong *numocc) const=0; - - /* Allocates snippet (which must be freed by the caller) and writes - * the substring text[from..to] into it. Returns in snippet_length the - * length of the text snippet actually extracted (that could be less - * than to-from+1 if to is larger than the text size). */ - virtual size_t extract (ulong from, ulong to, uchar **snippet, ulong *snippet_length) const=0; - - /* Displays the text (snippet) surrounding any occurrence of the - * substring pattern[0..length-1] within the text indexed by index. - * The snippet must include numc characters before and after the - * pattern occurrence, totalizing length+2*numc characters, or less if - * the text boundaries are reached. Writes in numocc the number of - * occurrences, and allocates the arrays snippet_text and - * snippet_lengths (which must be freed by the caller). The first is a - * character array of numocc*(length+2*numc) characters, with a new - * snippet starting at every multiple of length+2*numc. The second - * gives the real length of each of the numocc snippets. */ - - virtual size_t display (uchar *pattern, ulong length, ulong numc, ulong *numocc, uchar **snippet_text, ulong **snippet_lengths) const=0; - - /*Return the length of the Index*/ - virtual size_t index_length() const=0; - - /***The next four methods (getSA, getISA, and getPsi, getT) are - * only valid for text indexes that are base on Suffix - * Array*/ - - /*Get the suffix array at position i*/ - virtual size_t getSA(size_t i) const=0; - - /*Get the inverse of the suffix array at position i*/ - virtual size_t getISA(size_t i) const=0; - - /*Get Psi at position i*/ - virtual size_t getPsi(size_t i) const=0; - - /*Get the first letter of the i-th suffix in the suffix array*/ - virtual size_t getT(size_t i) const=0; - - /** Returns the size of the structure in bytes */ - virtual size_t getSize() const=0; - - /** Stores the text index in the given a file pointer*/ - virtual void save(ostream & fp) const=0; - - /** Reads a text index determining the type */ - static TextIndex * load(istream & fp); - }; -}; - -#include -#endif diff --git a/libcds/include/TextIndexCSA.h b/libcds/include/TextIndexCSA.h deleted file mode 100644 index 64670875..00000000 --- a/libcds/include/TextIndexCSA.h +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef _TEXTINDEXCSA_H_ -#define _TEXTINDEXCSA_H_ - -#include -#include -#include - -namespace cds_static -{ - - class TextIndexCSA: public TextIndex - { - private: - CSA *csa; - TextIndexCSA(); - - public: - - /*K. Sadakane's CSA (refactory by Rodrigo Cnovas) - * @param text The text. - * @param length Length of the text. - * @param build_options The options could be: - * free_text: The text will be freed immediately after using it. - * samplerate=: samplerate will be interval between two indices - * of the suffix array stored explicitly. That is, - * SA[i*samplerate] is stored explicitly. The default - * value is 16. - * samplepsi=: samplepsi will be interval between two indices of the - * psi function stored explicitly. That is, Psi[i*samplepsi] - * is stored explicitly. The default value is 128. - **/ - TextIndexCSA(uchar *text, ulong length, char *build_options); - - ~TextIndexCSA(); - - /* Writes in numocc the number of occurrences of the substring - * pattern[0..length-1] found in the text indexed by index. */ - virtual size_t count (uchar *pattern, ulong length, ulong *numocc) const; - - /* Writes in numocc the number of occurrences of the substring - * pattern[0..length-1] in the text indexed by index. It also allocates - * occ (which must be freed by the caller) and writes the locations of - * the numocc occurrences in occ, in arbitrary order. */ - virtual size_t locate (uchar *pattern, ulong length, ulong **occ, ulong *numocc) const; - - /* Allocates snippet (which must be freed by the caller) and writes - * the substring text[from..to] into it. Returns in snippet_length the - * length of the text snippet actually extracted (that could be less - * than to-from+1 if to is larger than the text size). */ - virtual size_t extract (ulong from, ulong to, uchar **snippet, ulong *snippet_length) const; - - /* Displays the text (snippet) surrounding any occurrence of the - * substring pattern[0..length-1] within the text indexed by index. - * The snippet must include numc characters before and after the - * pattern occurrence, totalizing length+2*numc characters, or less if - * the text boundaries are reached. Writes in numocc the number of - * occurrences, and allocates the arrays snippet_text and - * snippet_lengths (which must be freed by the caller). The first is a - * character array of numocc*(length+2*numc) characters, with a new - * snippet starting at every multiple of length+2*numc. The second - * gives the real length of each of the numocc snippets. */ - - virtual size_t display (uchar *pattern, ulong length, ulong numc, ulong *numocc, uchar **snippet_text, ulong **snippet_lengths) const; - - /*Return the length of the Index*/ - virtual size_t index_length() const; - - /*Get the suffix array at position i*/ - virtual size_t getSA(size_t i) const; - - /*Get the inverse of the suffix array at position i*/ - virtual size_t getISA(size_t i) const; - - /*Get Psi at position i*/ - virtual size_t getPsi(size_t i) const; - - /*Get the first letter of the i-th suffix in the suffix array*/ - virtual size_t getT(size_t i) const; - - /** Returns the size of the structure in bytes */ - virtual size_t getSize() const; - - /** Stores the text index in the given a file pointer*/ - virtual void save(ostream & fp) const; - - /** Reads a text index determining the type */ - static TextIndexCSA * load(istream & fp); - - }; -}; -#endif diff --git a/libcds/include/WaveletMatrix.h b/libcds/include/WaveletMatrix.h deleted file mode 100644 index f4ca88c6..00000000 --- a/libcds/include/WaveletMatrix.h +++ /dev/null @@ -1,95 +0,0 @@ -/* WaveletTreeNoptrs.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * WaveletTreeNoptrs definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef _WVTREE_MATRIX_H -#define _WVTREE_MATRIX_H - -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -namespace cds_static -{ - - class WaveletMatrix : public Sequence - { - public: - - /** Builds a Wavelet Tree for the string - * pointed by symbols assuming its length - * equals n and uses bmb to build the bitsequence - * @param bmb builder for the bitmaps in each level. - * @param am alphabet mapper (we need all symbols to be used). - * */ - WaveletMatrix(uint * symbols, size_t n, BitSequenceBuilder * bmb, Mapper * am, bool deleteSymbols = false); - WaveletMatrix(const Array &symbols2, BitSequenceBuilder * bmb, Mapper * am); - - // - /** Destroys the Wavelet Tree */ - virtual ~WaveletMatrix(); - - virtual size_t rank(uint symbol, size_t pos) const; - virtual size_t select(uint symbol, size_t j) const; - virtual uint access(size_t pos) const; - virtual size_t getSize() const; - - virtual void save(ostream & fp) const; - static WaveletMatrix * load(istream & fp); - - protected: - WaveletMatrix(); - - Mapper * am; - - BitSequence **bitstring; - - /** Length of the string. */ - size_t n; - - /** Height of the Wavelet Tree. */ - uint height, max_v; - uint *C, *OCC; - - /** Obtains the maximum value from the string - * symbols of length n */ - uint max_value(uint *symbols, size_t n); - - /** How many bits are needed to represent val */ - uint bits(uint val); - - /** Returns true if val has its ind-th bit set - * to one. */ - bool is_set(uint val, uint ind) const; - - /** Sets the ind-th bit in val */ - uint set(uint val, uint ind) const; - - /** Recursive function for building the Wavelet Tree. */ - void build_level(uint **bm, uint *symbols, uint length, uint *occs); - }; -}; -#endif diff --git a/libcds/include/WaveletTree.h b/libcds/include/WaveletTree.h deleted file mode 100644 index 7bf538ef..00000000 --- a/libcds/include/WaveletTree.h +++ /dev/null @@ -1,114 +0,0 @@ -/* WaveletTree.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * WaveletTree definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef STATIC_SEQUENCE_WVTREE_H -#define STATIC_SEQUENCE_WVTREE_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -namespace cds_static -{ - - /** Wavelet tree implementation using pointers. - * - * @author Francisco Claude - */ - class WaveletTree : public Sequence - { - public: - - /** Builds a Wavelet Tree for the string stored in a - * - * @param coder corresponds to the coder used to give the shape to the tree. - * @param bmb builder for the bitmaps in each node. - * @param am mapper for the alphabet. - * */ - WaveletTree(const Array & a, wt_coder * coder, BitSequenceBuilder *bmb, Mapper *am); - /** Builds a Wavelet Tree for the string - * pointed by symbols assuming its length - * equals n - * @param coder corresponds to the coder used to give the shape to the tree. - * @param bmb builder for the bitmaps in each node. - * @param am mapper for the alphabet. - * */ - WaveletTree(uint * symbols, size_t n, wt_coder * coder, BitSequenceBuilder * bmb, Mapper * am, bool free=false); - - /** Builds a Wavelet Tree for the string - * pointed by symbols assuming its length - * equals n - * @param coder corresponds to the coder used to give the shape to the tree. - * @param bmb builder for the bitmaps in each node. - * @param am mapper for the alphabet. - * */ - WaveletTree(uchar * symbols, size_t n, wt_coder * coder, BitSequenceBuilder * bmb, Mapper * am, bool free=false); - - virtual ~WaveletTree(); - - virtual size_t rank(uint symbol, size_t pos) const; - - virtual size_t select(uint symbol, size_t j) const; - - virtual uint access(size_t pos) const; - virtual uint access(size_t pos, size_t &rank) const; - - /* find the q-th smallest element in T[l..r] */ - uint quantile(size_t left,size_t right,uint q) const; - /* find the q-th smallest element in T[l..r] and return it's freq */ - pair quantile_freq(size_t left,size_t right,uint q) const; - - virtual size_t count(uint s) const; - - virtual size_t getSize() const; - - virtual void save(ostream & fp) const; - static WaveletTree * load(istream & fp); - - protected: - - WaveletTree(); - - wt_node * root; - wt_coder * c; - Mapper * am; - - /** Length of the string. */ - size_t n; - - /** Height of the Wavelet Tree. */ - uint max_v; - - /** Flag for testing for correcteness. */ - bool test; - - }; - -}; -#endif /* _STATIC_SEQUENCE_WVTREE_H */ diff --git a/libcds/include/WaveletTreeNoptrs.h b/libcds/include/WaveletTreeNoptrs.h deleted file mode 100644 index 63da4752..00000000 --- a/libcds/include/WaveletTreeNoptrs.h +++ /dev/null @@ -1,115 +0,0 @@ -/* WaveletTreeNoptrs.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * WaveletTreeNoptrs definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef _WVTREE_NOPTRS_H -#define _WVTREE_NOPTRS_H - -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -namespace cds_static -{ - - class WaveletTreeNoptrs : public Sequence - { - public: - - /** Builds a Wavelet Tree for the string stored in a. - * @param bmb builder for the bitmaps in each level. - * @param am alphabet mapper (we need all symbols to be used). - * */ - WaveletTreeNoptrs(const Array & a, BitSequenceBuilder * bmb, Mapper * am); - /** Builds a Wavelet Tree for the string - * pointed by symbols assuming its length - * equals n and uses bmb to build the bitsequence - * @param bmb builder for the bitmaps in each level. - * @param am alphabet mapper (we need all symbols to be used). - * */ - WaveletTreeNoptrs(uint * symbols, size_t n, BitSequenceBuilder * bmb, Mapper * am, bool deleteSymbols = false); - - // - /** Builds a Wavelet Tree for the string - * pointed by symbols is an array of elements of "width" bits and length - * n. - * @param bmb builder for the bitmaps in each level. - * @param am alphabet mapper (we need all symbols to be used). - * */ - WaveletTreeNoptrs(uint * symbols, size_t n, uint width, BitSequenceBuilder * bmb, Mapper * am, bool deleteSymbols = false); - - /** Destroys the Wavelet Tree */ - virtual ~WaveletTreeNoptrs(); - - virtual size_t rank(uint symbol, size_t pos) const; - virtual size_t select(uint symbol, size_t j) const; - virtual uint access(size_t pos) const; - virtual uint access(size_t pos, size_t &r) const; - virtual size_t getSize() const; - - /* find the q-th smallest element in T[l..r] */ - virtual uint quantile(size_t left,size_t right,uint q); - - /* find the q-th smallest element in T[l..r] and return the freq */ - pair quantile_freq(size_t left,size_t right,uint q); - - virtual size_t count(uint symbol) const; - - virtual void save(ostream & fp) const; - static WaveletTreeNoptrs * load(istream & fp); - - protected: - WaveletTreeNoptrs(); - - Mapper * am; - /** Only one bit-string for the Wavelet Tree. */ - BitSequence **bitstring; - uint *OCC; - - /** Length of the string. */ - size_t n; - - /** Height of the Wavelet Tree. */ - uint height, max_v; - - /** Obtains the maximum value from the string - * symbols of length n */ - uint max_value(uint * symbols, size_t n); - uint max_value(uint * symbols, unsigned width, size_t n); - - /** How many bits are needed to represent val */ - uint bits(uint val); - - /** Returns true if val has its ind-th bit set - * to one. */ - bool is_set(uint val, uint ind) const; - - /** Recursive function for building the Wavelet Tree. */ - void build_level(uint **bm, uint *symbols, uint level, uint length, uint offset); - void build_level(uint **bm, uint *symbols, unsigned width, uint level, uint length, uint offset); - }; -}; -#endif diff --git a/libcds/include/WaveletTreeNoptrsS.h b/libcds/include/WaveletTreeNoptrsS.h deleted file mode 100644 index 816bd67f..00000000 --- a/libcds/include/WaveletTreeNoptrsS.h +++ /dev/null @@ -1,95 +0,0 @@ -/* WaveletTreeNoptrs.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * WaveletTreeNoptrs definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef _WVTREE_NOPTRSS_H -#define _WVTREE_NOPTRSS_H - -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -namespace cds_static -{ - - class WaveletTreeNoptrsS : public Sequence - { - public: - - /** Builds a Wavelet Tree for the string - * pointed by symbols assuming its length - * equals n and uses bmb to build the bitsequence - * @param bmb builder for the bitmaps in each level. - * @param am alphabet mapper (we need all symbols to be used). - * */ - WaveletTreeNoptrsS(uint * symbols, size_t n, BitSequenceBuilder * bmb, Mapper * am, bool deleteSymbols = false); - WaveletTreeNoptrsS(const Array &symb, BitSequenceBuilder * bmb, Mapper * am); - // - /** Destroys the Wavelet Tree */ - virtual ~WaveletTreeNoptrsS(); - - virtual size_t rank(uint symbol, size_t pos) const; - virtual size_t select(uint symbol, size_t j) const; - virtual uint access(size_t pos) const; - virtual size_t getSize() const; - - size_t count(uint symbol) const; - - virtual void save(ostream & fp) const; - static WaveletTreeNoptrsS * load(istream & fp); - - protected: - WaveletTreeNoptrsS(); - - Mapper * am; - /** Only one bit-string for the Wavelet Tree. */ - BitSequence **bitstring, *occ; - - /** Length of the string. */ - size_t n; - - /** Height of the Wavelet Tree. */ - uint height, max_v; - - /** Obtains the maximum value from the string - * symbols of length n */ - uint max_value(uint *symbols, size_t n); - - /** How many bits are needed to represent val */ - uint bits(uint val); - - /** Returns true if val has its ind-th bit set - * to one. */ - bool is_set(uint val, uint ind) const; - - /** Sets the ind-th bit in val */ - uint set(uint val, uint ind) const; - - /** Recursive function for building the Wavelet Tree. */ - void build_level(uint **bm, uint *symbols, uint length, uint *occs); - }; -}; -#endif diff --git a/libcds/include/comparray4.h b/libcds/include/comparray4.h deleted file mode 100644 index b296e845..00000000 --- a/libcds/include/comparray4.h +++ /dev/null @@ -1,88 +0,0 @@ -/* comparray4.cpp - Copyright (C) 2005, K. Sadakane, all rights reserved. - - This file contains an implementation of CSA. - For more information, see - - K. Sadakane. Compressed text databases with efficient query - algorithms based on the compressed suffix array. - In Proceedings 11th Annual International Symposium on Algorithms - and Computation (ISAAC)}, LNCS v. 1969, pages 410--421, 2000. - - K. Sadakane. Succinct representations of lcp information and - improvements in the compressed suffix arrays. - In Proceedings 13th Annual ACM-SIAM Symposium on Discrete - Algorithms (SODA), 2002. - - K. Sadakane. New text indexing functionalities of the compressed - suffix arrays. Journal of Algorithms, 48(2):294--313, 2003. - - 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. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - 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 - -*/ - -#ifndef _COMPARRAY_H_ -#define _COMPARRAY_H_ - -#include -using namespace cds_utils; -#define USE_MMAP - -#ifdef USE_MMAP -#include -#endif - -#define SIGMA 256 - -namespace cds_static -{ - - using namespace std; - - typedef struct csa - { - int n,m; - int l,two,two2; - int K[SIGMA+2],C[SIGMA+1],C2[SIGMA+1]; - int *SA,*ISA,*R; - unsigned short *B; /* bit */ - #ifdef USE_MMAP - MMAP *mapp,*mapi; - int p_size, i_size, r_size, sa_size, isa_size; - #endif - } CSA; - - int csa_psi(CSA *SA,int i); - int csa_T(CSA *SA,int i); - int csa_inverse(CSA *SA, int suf); - void csa_decode(unsigned char *p,CSA *SA,int suf,int len); - void csa_decode2(unsigned char *p,CSA *SA,int pos,int len); - int csa_write(CSA *SA,char *fname1,char *fname2); - void csa_new(int n, int *p, unsigned char *s, char *fname1, char *fname2, int rankb_w,int rankb_w2); - int csa_read(CSA *SA,char *fname1,char *fname2); - int initranktables(void); - void mkdecodetable(void); - int csa_lookup(CSA *SA, int i); - int *csa_batchlookup(CSA *SA,int l, int r); - unsigned long *csa_batchlookup2(CSA *SA,int l, int r); - int csa_bsearch(unsigned char *key,int keylen,CSA *SA,int *li,int *ri); - void csa_decode1line(unsigned char *p,CSA *SA,int suf,int maxlen); - void csa_decodeall(unsigned char *p,CSA *SA); - void csa_save(CSA *csa, ostream & fp); - CSA *csa_load(istream & fp); - void csa_free(CSA *csa); - void csa_init(CSA *csa); -}; -#endif diff --git a/libcds/include/cppUtils.h b/libcds/include/cppUtils.h deleted file mode 100644 index 1750b6ac..00000000 --- a/libcds/include/cppUtils.h +++ /dev/null @@ -1,94 +0,0 @@ - -#ifndef _CPPUTILS -#define _CPPUTILS - -#include -#include - -#include -using namespace std; - -namespace cds_utils -{ - - uint transform(const string & s); - - template void saveValue(ostream & out, const T val) { - //assert(out.good()); - //cout << "saveValue: " << sizeof(T) << " " << val << endl; - if(!out.good()) { - throw "Output not ready"; - } - out.write((char*)&val,sizeof(T)); - } - - template T loadValue(istream & in) { - //assert(in.good()); - if(!in.good()) { - throw "Input not ready"; - } - T ret; - in.read((char*)&ret,sizeof(T)); - //cout << "loadValue: " << in.tellg() << " " << sizeof(T) << " " << ret << endl; - if((size_t)in.gcount()!=sizeof(T)) { - cout << "1Reading: " << sizeof(T) << " Read: " << in.gcount() << endl; - throw "Could not read the expected bytes from input"; - } - return ret; - } - - template void saveValue(ostream & out, const T * val, const size_t len) { - //assert(out.good()); - if(!out.good()) { - throw "Output not ready"; - } - //cout << "saveValueM: " << sizeof(T) << " " << len << endl; - out.write((char*)val,len*sizeof(T)); - } - - template T * loadValue(istream & in, const size_t len) { - //assert(in.good()); - if(!in.good()) { - throw "Input not ready"; - } - T * ret = new T[len]; - - //cout << "loadValueM: " << in.tellg() << " " << sizeof(T) << " " << len << endl; -#if 0 - unsigned int counter=0; - char *ptr = (char *)ret; - while(counter 1024 ? 1024 : len-counter); - ptr += fp.gcount(); - counter += fp.gcount(); - } - if(counter!=len*sizeof(T)) { - throw "Could not read the expected bytes from input"; - } -#else - in.read((char*)ret,len*sizeof(T)); - if((size_t)in.gcount()!=len*sizeof(T)) { - cout << "Reading: " << sizeof(T) << " Read: " << in.gcount() << endl; - throw "Could not read the expected bytes from input"; - } -#endif - return ret; - } - - template T * loadValue(const char * name, size_t & slen) { - ifstream in(name); - assert(in.good()); - in.seekg(0,ios_base::end); - size_t len = in.tellg(); - slen = len/sizeof(T); - if(len%sizeof(T)) slen--; - in.seekg(0,ios_base::beg); - T * ret = loadValue(in,slen); - in.close(); - return ret; - } - - void tokenize(string str, vector &tokens, char delim); - -}; -#endif diff --git a/libcds/include/factorization.h b/libcds/include/factorization.h deleted file mode 100644 index 4b79c4fb..00000000 --- a/libcds/include/factorization.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -/*----------------------------------------------------------------------- - Factorizacion version - ------------------------------------------------------------------------*/ -#ifndef _FACTORIZATION -#define _FACTORIZATION - -#include -#include -#include -#include -#include -#include - -namespace cds_static -{ - class factorization - { - private: - factorization(); - public: - uint listLength; //longitud de la lista - unsigned char nLevels; //numero de niveles de arrays - uint * levelsIndex; //inicio de cada array - unsigned char * levels; //array con los bytes - BitSequence * bS; //bitmap para indicar fin de codigo - uint * rankLevels; //rank de 1s hasta el principio de cada array - - /*Susana implementation of Directly Addressable Variable-Length Codes with blocks of size 4 - * @param list Array with the values - * @param l_Length Size of the array - * */ - factorization(uint *list,uint l_Length); - virtual uint access(uint param); - virtual uint access_seq(uint param, size_t *next_pos, bool dir); - virtual void save(ostream & fp); - virtual uint getSize(); - static factorization* load(istream & fp); - virtual ~factorization(); - }; -}; -#endif diff --git a/libcds/include/factorization_var.h b/libcds/include/factorization_var.h deleted file mode 100644 index c9f4572b..00000000 --- a/libcds/include/factorization_var.h +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -/*----------------------------------------------------------------------- - Factorizacion with Variable block size - ------------------------------------------------------------------------*/ -#ifndef _FACTORIZATION_VAR -#define _FACTORIZATION_VAR - -#include -#include -#include -#include -#include -#include - -namespace cds_static -{ - - class factorization_var - { - private: - factorization_var(); - public: - uint tamCode; - uint * iniLevel; - ushort * base; - ushort * base_bits; - uint * tablebase; - uint tamtablebase; - uint listLength; //list length - unsigned char nLevels; //number of levels - uint * levelsIndex; //start point of each array - uint * levels; //array with the bytes - BitSequence * bS; //bitmap para indicar fin de codigo - uint * rankLevels; //rank de 1s hasta el principio de cada array - - /*Susana implementation of Directly Addressable Variable-Length Codes with variable length blocks - * @param list Array with the values - * @param l_Length Size of the array - * @param kvalues Array with the block length for each level - * @param nkvalues Length of the array kvalues - * */ - factorization_var(uint *list, uint l_Length, ushort* kvalues, uint nkvalues); - virtual uint access(uint param); - virtual uint access_seq(uint param, size_t *next_pos, bool dir); - virtual uint getSize(); - virtual void save(ostream & fp); - static factorization_var* load(istream & fp); - virtual ~factorization_var(); - }; -}; -#endif diff --git a/libcds/include/huff.h b/libcds/include/huff.h deleted file mode 100644 index e138201d..00000000 --- a/libcds/include/huff.h +++ /dev/null @@ -1,94 +0,0 @@ -/* huff.h - Copyright (C) 2008, Gonzalo Navarro, all rights reserved. - - Canonical Huffman - - 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. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - 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 - -*/ - -#ifndef HUFFINCLUDED -#define HUFFINCLUDED - -#include -#include - -using namespace cds_utils; - -namespace cds_static -{ - - typedef struct - { // maximum symbol (0..max), same excluding zero freqs - uint max,lim; - uint depth; // max symbol length - union - { // symbol positions after sorting by decr freq (enc) - uint *spos; - uint *symb; // symbols sorted by freq (dec) - } s; - uint *num; // first pos of each length (dec), number of each length (enc) - uint *fst; // first code (numeric) of each length (dec) - unsigned long long total;// total length to achieve, in bits - } THuff; - - /** Creates Huffman encoder given symbols 0..lim with frequencies - * freq[i], ready for compression - * - * @author Gonzalo Navarro - */ - THuff createHuff (uint *freq, uint lim); - - /** Encodes symb using H, over stream[ptr...lim] (ptr and lim are - * bit positions of stream). Returns the new ptr. - * - * @author Gonzalo Navarro - */ - size_t encodeHuff (const THuff H, uint symb, uint *stream, size_t ptr); - - /** Decodes *symb using H, over stream[ptr...lim] (ptr and lim are - * bit positions of stream). Returns the new ptr. - * - * @author Gonzalo Navarro - */ - size_t decodeHuff (const THuff H, uint *symb, uint *stream, size_t ptr); - - /** Writes H in file f - * - * @author Gonzalo Navarro - */ - void saveHuff (const THuff H, ostream & f); - - /** Size of H written on file - * - * @author Gonzalo Navarro - */ - uint sizeHuff (const THuff H); - - /** Frees H - * - * @author Gonzalo Navarro - */ - void freeHuff (THuff H); - - /** Loads H from file f, prepared for encoding or decoding depending - * on enc - * - * @author Gonzalo Navarro - */ - THuff loadHuff (istream &f, int enc); - -}; -#endif diff --git a/libcds/include/interface.h b/libcds/include/interface.h deleted file mode 100644 index ffbcabbb..00000000 --- a/libcds/include/interface.h +++ /dev/null @@ -1,116 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -/* General interface for using the compressed index libraries */ - -#ifndef uchar -#define uchar unsigned char -#endif -#ifndef uint -#define uint unsigned int -#endif -#ifndef ulong -#define ulong unsigned long -#endif - -namespace cds_static -{ - /* Error management */ - - /* Returns a string describing the error associated with error number - e. The string must not be freed, and it will be overwritten with - subsequent calls. */ - - char *error_index (int e); - - /* Building the index */ - - /* Creates index from text[0..length-1]. Note that the index is an - opaque data type. Any build option must be passed in string - build_options, whose syntax depends on the index. The index must - always work with some default parameters if build_options is NULL. - The returned index is ready to be queried. */ - - int build_index (uchar *text, ulong length, char *build_options, void **index); - - /* Saves index on disk by using single or multiple files, having - proper extensions. */ - - int save_index (void *index, char *filename); - - /* Loads index from one or more file(s) named filename, possibly - adding the proper extensions. */ - - int load_index (char *filename, void **index); - - /* Frees the memory occupied by index. */ - - int free_index (void *index); - - /* Gives the memory occupied by index in bytes. */ - - int index_size(void *index, ulong *size); - - /* Querying the index */ - - /* Writes in numocc the number of occurrences of the substring - pattern[0..length-1] found in the text indexed by index. */ - - int count (void *index, uchar *pattern, ulong length, ulong *numocc); - - /* Writes in numocc the number of occurrences of the substring - pattern[0..length-1] in the text indexed by index. It also allocates - occ (which must be freed by the caller) and writes the locations of - the numocc occurrences in occ, in arbitrary order. */ - - int locate (void *index, uchar *pattern, ulong length, ulong **occ, - ulong *numocc); - - /* Gives the length of the text indexed */ - - int get_length(void *index, ulong *length); - - /* Accessing the indexed text */ - - /* Allocates snippet (which must be freed by the caller) and writes - the substring text[from..to] into it. Returns in snippet_length the - length of the text snippet actually extracted (that could be less - than to-from+1 if to is larger than the text size). */ - - int extract (void *index, ulong from, ulong to, uchar **snippet, - ulong *snippet_length); - - /* Displays the text (snippet) surrounding any occurrence of the - substring pattern[0..length-1] within the text indexed by index. - The snippet must include numc characters before and after the - pattern occurrence, totalizing length+2*numc characters, or less if - the text boundaries are reached. Writes in numocc the number of - occurrences, and allocates the arrays snippet_text and - snippet_lengths (which must be freed by the caller). The first is a - character array of numocc*(length+2*numc) characters, with a new - snippet starting at every multiple of length+2*numc. The second - gives the real length of each of the numocc snippets. */ - - int display (void *index, uchar *pattern, ulong length, ulong numc, - ulong *numocc, uchar **snippet_text, ulong **snippet_lengths); - - /* Obtains the length of the text indexed by index. */ - - int length (void *index, ulong *length); - -}; diff --git a/libcds/include/libcdsBasics.h b/libcds/include/libcdsBasics.h deleted file mode 100644 index dea735ba..00000000 --- a/libcds/include/libcdsBasics.h +++ /dev/null @@ -1,253 +0,0 @@ -/* basics.h - * Copyright (C) 2005, Rodrigo Gonzalez, all rights reserved. - * - * Some preliminary stuff - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef _BASICS_H -#define _BASICS_H - -#include -#ifndef WIN32 -#include -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef WIN32 -typedef unsigned int uint; -typedef unsigned short ushort; -#endif - - -namespace cds_utils -{ - - using namespace std; - typedef unsigned char uchar; - - /** mask for obtaining the first 5 bits */ - const uint mask31 = 0x0000001F; - - /** number of bits in a uint */ - const uint W = 32; - - const uint LOGW = 5; - - /** W-1 */ - const uint Wminusone = 31; - - /** 2W*/ - const uint WW = 64; - - /** number of bits per uchar */ - const uint bitsM = 8; - - /** number of bytes per uint */ - const uint BW = 4; - - /** number of different uchar values 0..255 */ - const uint size_uchar = 256; - - /** popcount array for uchars */ - const unsigned char __popcount_tab[] = { - 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, - 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, - 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, - 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, - 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, - 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, - 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, - 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, - }; - - /** select array for uchars */ - const unsigned char select_tab[] = { - 0, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 7, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 8, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 7, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - }; - - /** prev array for uchars */ - const unsigned char prev_tab[] = { - 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - }; - - /** bits needed to represent a number between 0 and n */ - inline uint bits(uint n) { - uint b = 0; - while (n) { b++; n >>= 1; } - return b; - } - - /** reads bit p from e */ - #define bitget(e,p) ((((e)[(p)/W] >> ((p)%W))) & 1) - - /** sets bit p in e */ - inline void bitset(uint * e, size_t p) { - e[p/W] |= (1<<(p%W)); - } - - /** cleans bit p in e */ - inline void bitclean(uint * e, size_t p) { - e[p/W] &= ~(1<<(p%W)); - } - - /** uints required to represent n integers of e bits each */ - inline uint uint_len(const uint e, const size_t n) { - //+((unsigned long long)e*n%W>0)); - return ((unsigned long long)e*n+W-1)/W; - } - - /** Retrieve a given index from array A where every value uses len bits - * @param A Array - * @param len Length in bits of each field - * @param index Position to be retrieved - */ - inline uint get_field(const uint *A, const size_t len, const size_t index) { - if(len==0) return 0; - size_t i=index*len/W, j=index*len-W*i; - uint result; - if (j+len <= W) - result = (A[i] << (W-j-len)) >> (W-len); - else { - result = A[i] >> j; - result = result | (A[i+1] << (WW-j-len)) >> (W-len); - } - return result; - } - - /** Store a given value in index into array A where every value uses len bits - * @param A Array - * @param len Length in bits of each field - * @param index Position to store in - * @param x Value to be stored - */ - inline void set_field(uint *A, const size_t len, const size_t index, const uint x) { - if(len==0) return; - size_t i=index*len/W, j=index*len-i*W; - uint mask = ((j+len) < W ? ~0u << (j+len) : 0) - | ((W-j) < W ? ~0u >> (W-j) : 0); - A[i] = (A[i] & mask) | x << j; - if (j+len>W) { - mask = ((~0u) << (len+j-W)); - A[i+1] = (A[i+1] & mask)| x >> (W-j); - } - } - - /** Retrieve a given bitsequence from array A - * @param A Array - * @param ini Starting position - * @param fin Retrieve until end-1 - */ - inline uint get_var_field(const uint *A, const size_t ini, const size_t fin) { - if(ini==fin+1) return 0; - size_t i=ini/W, j=ini-W*i; - uint result; - uint len = (uint)(fin-ini+1); - if (j+len <= W) - result = (A[i] << (W-j-len)) >> (W-len); - else { - result = A[i] >> j; - result = result | (A[i+1] << (WW-j-len)) >> (W-len); - } - return result; - } - - /** Stores a given bitsequence into array A - * @param A Array - * @param ini Starting position - * @param fin Store until end-1 - * @param x Value to be stored - */ - inline void set_var_field(uint *A, const size_t ini, const size_t fin, const uint x) { - if(ini==fin+1) return; - uint i=ini/W, j=ini-i*W; - uint len = (fin-ini+1); - uint mask = ((j+len) < W ? ~0u << (j+len) : 0) - | ((W-j) < W ? ~0u >> (W-j) : 0); - A[i] = (A[i] & mask) | x << j; - if (j+len>W) { - mask = ((~0u) << (len+j-W)); - A[i+1] = (A[i+1] & mask)| x >> (W-j); - } - } - - /** Retrieve a given index from array A where every value uses 4 bits - * @param A Array - * @param index Position to be retrieved - */ - inline uint get_field4(const uint *A, const size_t index) { - size_t i=index/8, j=(index&0x7)<<2; - return (A[i] << (28-j)) >> (28); - } - - /** Counts the number of 1s in x */ - inline uint popcount(const unsigned int x) { -#ifdef __SSE4_2__ - return __builtin_popcount(x); -#else - return __popcount_tab[(x >> 0) & 0xff] + __popcount_tab[(x >> 8) & 0xff] - + __popcount_tab[(x >> 16) & 0xff] + __popcount_tab[(x >> 24) & 0xff]; -#endif - } - - /** Counts the number of 1s in the first 16 bits of x */ - inline uint popcount16(const unsigned int x) { -#ifdef __SSE4_2__ - return __builtin_popcount(x & 0xffff); -#else - return __popcount_tab[x & 0xff] + __popcount_tab[(x >> 8) & 0xff]; -#endif - } - - /** Counts the number of 1s in the first 8 bits of x */ - inline uint popcount8(const unsigned int x) { -#ifdef __SSE4_2__ - return __builtin_popcount(x & 0xff); -#else - return __popcount_tab[x & 0xff]; -#endif - } -}; - -#include -#endif /* _BASICS_H */ diff --git a/libcds/include/libcdsSDArray.h b/libcds/include/libcdsSDArray.h deleted file mode 100644 index e3bfa0c7..00000000 --- a/libcds/include/libcdsSDArray.h +++ /dev/null @@ -1,187 +0,0 @@ -/* basics.h - * Copyright (C) 2010, Rodrigo Canovas, all rights reserved. - * - * Some preliminary stuff - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * */ - -#ifndef _BASICS_SDARRAY_H -#define _BASICS_SDARRAY_H -#include - -namespace cds_utils -{ - typedef unsigned long long qword; - static const unsigned int logD = 5; - static const unsigned int PBS = (sizeof(uint)*8); - static const unsigned int D = (1<0) { - x>>=1; - l++; - } - return l; - } - - inline int __setbit(uint *B, const int i, const int x) { - int j,l; - j = i / D; - l = i % D; - if (x==0) B[j] &= (~(1<<(D-1-l))); - else if (x==1) B[j] |= (1<<(D-1-l)); - else { - printf("error __setbit x=%d\n",x); - exit(1); - } - return x; - } - - inline int __setbit2(unsigned char *B, const int i, const int x) { - int j,l; - j = i / 8; - l = i % 8; - if (x==0) B[j] &= (~(1<<(8-1-l))); - else if (x==1) B[j] |= (1<<(8-1-l)); - else { - printf("error __setbit2 x=%d\n",x); - exit(1); - } - return x; - } - - inline int __setbits(uint *B, const int i, const int d, const int x) { - int j; - for (j=0; j>(d-j-1))&1); - } - return x; - } - - inline int __getbit(const uint *B, const int i) { - int j,l; - j = i >> logD; - l = i & (D-1); - return (B[j] >> (D-1-l)) & 1; - } - - inline int __getbit2(const unsigned char *B, const int i) { - int j,l; - j = i >> 3; - l = i & (8-1); - return (B[j] >> (8-1-l)) & 1; - } - - #if 1 - inline uint __getbits(const uint *B, const int i1, const int d) { - qword x,z; - int i = i1; - B += (i >> logD); - i &= (D-1); - if (i+d <= 2*(int)D) { - x = (((qword)B[0]) << D) + B[1]; - x <<= i; - x >>= (D*2-1-d); - x >>= 1; - } - else { - x = (((qword)B[0])<>= D; - x += z; - x >>= (2*D-d); - } - return x; - } - #endif - #if 0 - inline uint __getbits(uint *B, int i, int d) { - uint j,x; - x = 0; - for (j=0; j>1) + (r & 0x55555555); - r = ((r & 0xcccccccc)>>2) + (r & 0x33333333); - r = ((r>>4) + r) & 0x0f0f0f0f; - r = (r>>8) + r; - r = ((r>>16) + r) & 63; - return r; - } - - inline unsigned int __popCount8(const uint x) { - uint r; - #if 1 - r = x; - r = ((r & 0xaa)>>1) + (r & 0x55); - r = ((r & 0xcc)>>2) + (r & 0x33); - r = ((r>>4) + r) & 0x0f; - #else - r = _popCount[x & 0xff]; - #endif - return r; - } - -}; -#endif diff --git a/libcds/include/libcdsTrees.h b/libcds/include/libcdsTrees.h deleted file mode 100644 index f633a4ce..00000000 --- a/libcds/include/libcdsTrees.h +++ /dev/null @@ -1,120 +0,0 @@ -#ifndef _BASICS_TREES_H -#define _BASICS_TREES_H - -#include -using namespace std; - -#define MAX(i,j) (((i) > (j)) ? (i) : (j)) - -namespace cds_utils -{ - static const unsigned int MAXINT=0x7fffffff; - static const unsigned int FACT_RANK = 20; - - /** Retrieve a given index from array A where every value uses len bits - * @param A Array - * @param len Length in bits of each field - * @param index Position to be retrieved - * */ - inline size_t get_field_64(uint *A, size_t len, size_t index) { - if(len==0) return 0; - uint result; - long long i=1, j=1; - i=i*index*len/W, j=j*index*len-W*i; - if (j+len <= W) - result = (A[i] << (W-j-len)) >> (W-len); - else { - result = A[i] >> j; - result = result | (A[i+1] << (WW-j-len)) >> (W-len); - } - return (size_t)result; - } - - inline void set_field_64(uint *A, size_t len, size_t index, size_t x) { - if(len==0) return; - long long i=1, j=1; - i= i*index*len/W, j= j*index*len-i*W; - uint mask = ((j+len) < W ? ~0u << (j+len) : 0) - | ((W-j) < W ? ~0u >> (W-j) : 0); - A[i] = (A[i] & mask) | x << j; - if (j+len>W) { - mask = ((~0u) << (len+j-W)); - A[i+1] = (A[i+1] & mask)| x >> (W-j); - } - } - - /*Compute the longest common prefix between the suffix (with max length = lim) that starts in t1 and t2 - * @param text The text - * @param t1 Position in the text where start the first suffix - * @param t2 Position in the text where start the second suffix - * @param lim Maximum value that can be returned - * */ - inline size_t lcp_length(char *text, size_t t1, size_t t2, size_t lim) { - size_t cont=0; - for(size_t i=0; i> p; - if (len == W) { - if (p) - answ |= (*(e+1)) << (W-p); - } - else { - if (p+len > W) - answ |= (*(e+1)) << (W-p); - answ &= (1<> (W-p)); - } - else { - if (p+len <= W) { - *e = (*e & ~(((1<> (W-p)); - } - } - - inline size_t loadText(char *filename, char **textt, size_t *length) { - char *text; - ifstream in(filename); - if(!in.good()) - return 1; - in.seekg(0,ios_base::end); - size_t len = in.tellg(); - text = new char[len+1]; - in.seekg(0,ios_base::beg); - in.read(text,len); - in.close(); - text[len] = '\0'; - *textt = text; - *length = len+1; - return 0; - } - -}; -#endif diff --git a/libcds/include/mmap.h b/libcds/include/mmap.h deleted file mode 100644 index 505dc63c..00000000 --- a/libcds/include/mmap.h +++ /dev/null @@ -1,62 +0,0 @@ - -/* mman.h - Copyright (C) 2005, K. Sadakane, all rights reserved. - - This file contains an implementation of memory manager - - 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. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - 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 - -*/ - -#ifndef _MYMMAP_H_ -#define _MYMMAP_H_ - -#ifdef WIN32 -#include -#else -#include -#include -#include -#include -#include -#include -#include -#endif - -#ifdef WIN32 -#define PAGE_READONLY 0x02 -#define SECTION_MAP_READ 0x0004 -#define FILE_MAP_READ SECTION_MAP_READ -#endif - -namespace cds_static -{ - - typedef struct - { - void *addr; - int len; - #ifdef WIN32 - HANDLE h1,h2; - #else - int fd; - #endif - } MMAP; - - MMAP *mymmap (char *fname); - int mymunmap (MMAP *m); - -}; -#endif diff --git a/libcds/include/perm.h b/libcds/include/perm.h deleted file mode 100644 index a0003be7..00000000 --- a/libcds/include/perm.h +++ /dev/null @@ -1,95 +0,0 @@ -/* perm.h - * Copyright (C) 2005, Diego Arroyuelo, all rights reserved. - * Copyright (C) 2009, Francisco Claude - * - * Permutation - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef PERMINCLUDED -#define PERMINCLUDED - -#include -#include -#include - -using namespace cds_utils; - -namespace cds_static -{ - - typedef struct sperm - { - uint *elems; // elements of the permutation - uint nelems; // # of elements - BitSequence * bmap; // bitmap allowing rank() queries in O(1) time - uint *bwdptrs; // array of backward pointers - uint nbits; // log(nelems) - uint nbwdptrs; // # of backward pointers - uint t; - } *perm; - - typedef struct - { - uint key; - uint pointer; - } auxbwd; - - /** Creates a permutation - * - * @author Diego Arroyuelo - */ - perm createPerm(uint *elems, uint nelems, uint t, BitSequenceBuilder * bmb); - - /** Gets the i-th element of the permutation - * - * @author Diego Arroyuelo - */ - uint getelemPerm(const perm P, uint i); - - /** Destroys a permutation - * - * @author Diego Arroyuelo - */ - void destroyPerm(perm P); - - /** Get pi(i)^{-1} - * - * @author Diego Arroyuelo - */ - uint inversePerm(const perm P, uint i); - - /** Saves a permutation - * - * @author Diego Arroyuelo - */ - uint savePerm(const perm P, ostream & f); - - /** Loads a permutation - * - * @author Diego Arroyuelo - */ - perm loadPerm(istream & f); - - /** Returns the size of the data structure - * - * @author Diego Arroyuelo - */ - uint sizeofPerm(const perm P); - -}; -#endif diff --git a/libcds/include/sdarraySadakane.h b/libcds/include/sdarraySadakane.h deleted file mode 100644 index af40ec5c..00000000 --- a/libcds/include/sdarraySadakane.h +++ /dev/null @@ -1,80 +0,0 @@ -/* sdarraySadakane.h - * Copyright (C) 2009, K. Sadakane, all rights reserved. - * - * This is an adapatation of the original sdarray implementation - * by K. Sadakane. Modifications and probable bugs were introduced - * by Francisco Claude. - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef SDARRAY_H -#define SDARRAY_H - -#include -#include -#include -#include - -#include -#include -#include - -namespace cds_static -{ - - using namespace cds_utils; - - typedef struct - { - int n,m; - int size; - unsigned char *buf; - uint *lp; - uint *sl; - ushort *ss; - uint ss_len, sl_len; - uint *p; - } selectd2; - - typedef struct - { - int n,m,d; - int size; - unsigned char *hi; - uint *low; - selectd2 *sd0,*sd1; - uint hi_len, low_len; - //uint lasti, lasts; - } selects3; - - int selects3_construct(selects3 *select, const int n, const uint *buf); - int selects3_select(const selects3 *select, const int i); - int selects3_rank(const selects3 *select, const int i); - int selects3_selectnext(const selects3 *select, const int i); - - void make___selecttbl(void); - void selectd2_save(const selectd2 * s, ostream & fp); - void selects3_save(const selects3 * s, ostream & fp); - - void selectd2_load(selectd2 * s, istream & fp); - void selects3_load(selects3 * s, istream & fp); - - void selectd2_free(selectd2 * s); - void selects3_free(selects3 * s); - -} -#endif diff --git a/libcds/include/timing.h b/libcds/include/timing.h deleted file mode 100644 index a302ce32..00000000 --- a/libcds/include/timing.h +++ /dev/null @@ -1,46 +0,0 @@ -/* timing.h - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -namespace cds_utils -{ - /** Resets the system timer (yes, we only have one) - */ - void start_timing(); - - /** Obtains the number of milliseconds since the last timer start - */ - double get_timing(); - -}; diff --git a/libcds/include/wt_coder.h b/libcds/include/wt_coder.h deleted file mode 100644 index 933b2bc7..00000000 --- a/libcds/include/wt_coder.h +++ /dev/null @@ -1,75 +0,0 @@ -/* wt_coder.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * wt_coder definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef wt_coder_h -#define wt_coder_h - -#include -#include - -using namespace std; - -namespace cds_static -{ - - #define WT_CODER_HUFF_HDR 2 - #define WT_CODER_BINARY_HDR 3 - - class wt_coder_binary; - class wt_coder_huff; - - /** Coder that defines the shape of a wavelet tree - * - * @author Francisco Claude - */ - class wt_coder - { - public: - wt_coder(); - virtual void use(); - virtual void unuse(); - virtual ~wt_coder() {}; - /** Tells if at level l the symbol is represented by a one or a zero */ - virtual bool is_set(uint symbol, uint l) const=0; - virtual bool is_set(uint *symbol, uint l) const=0; - /** Tells if the path of symbol becomes unique at level l */ - virtual bool done(uint symbol, uint l) const =0; - virtual uint * get_symbol(uint symbol) const = 0; - /** Returns the size of the coder */ - virtual size_t getSize() const = 0; - /** Returns the depth of the tree */ - virtual uint depth() const - { - return -1; // Implemented in wt_coder_binary - } - /** Saves the coder to a file, returns 0 in case of success */ - virtual void save(ostream & fp) const = 0; - /** Loads a coder from a file, returns NULL in case of error */ - static wt_coder * load(istream & fp); - protected: - uint user_count; - }; - -}; - -#include -#include -#endif diff --git a/libcds/include/wt_coder_binary.h b/libcds/include/wt_coder_binary.h deleted file mode 100644 index 2d8e2447..00000000 --- a/libcds/include/wt_coder_binary.h +++ /dev/null @@ -1,61 +0,0 @@ -/* wt_coder_binary.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * wt_coder_binary definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef wt_coder_binary_h -#define wt_coder_binary_h - -#include -#include -#include - -using namespace std; - -namespace cds_static -{ - - /** Considers the binary representation of the symbols as the code - * - * @author Francisco Claude - */ - class wt_coder_binary: public wt_coder - { - public: - wt_coder_binary(const Array & a, Mapper *am); - /** Buils a wt_coder_binary using the sequence of length n and the alphabet_mapper - * to determine the length of the binary codes */ - wt_coder_binary(uint * seq, size_t n, Mapper * am); - wt_coder_binary(uchar * seq, size_t n, Mapper * am); - virtual ~wt_coder_binary(); - virtual bool is_set(uint symbol, uint l) const; - virtual bool is_set(uint *symbol, uint l) const; - virtual bool done(uint symbol, uint l) const; - virtual uint depth() const{ return h; } - virtual uint * get_symbol(uint symbol) const; - virtual size_t getSize() const; - virtual void save(ostream & fp) const; - static wt_coder_binary * load(istream & fp); - - protected: - wt_coder_binary(); - uint h; - }; -}; -#endif diff --git a/libcds/include/wt_coder_huff.h b/libcds/include/wt_coder_huff.h deleted file mode 100644 index 6c8d773e..00000000 --- a/libcds/include/wt_coder_huff.h +++ /dev/null @@ -1,61 +0,0 @@ -/* wt_coder_huff.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * wt_coder_huff definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef wt_coder_huff_h -#define wt_coder_huff_h - -#include -#include -#include -#include - -namespace cds_static -{ - - /** Uses huffman codes to determine the shape of the wavelet tree - * - * @author Francisco Claude - */ - class wt_coder_huff: public wt_coder - { - public: - /** Buils a wt_coder_huff using the sequence of length n and the alphabet_mapper - * to determine the huffman codes */ - wt_coder_huff(const Array & a, Mapper *am); - wt_coder_huff(uint *symbs, size_t n, Mapper * am); - wt_coder_huff(uchar *symbs, size_t n, Mapper * am); - virtual ~wt_coder_huff(); - virtual bool is_set(uint symbol, uint l) const; - virtual bool is_set(uint *symbol, uint l) const; - virtual bool done(uint symbol, uint l) const; - virtual size_t getSize() const; - virtual uint * get_symbol(uint symbol) const; - virtual void save(ostream & fp) const; - static wt_coder_huff * load(istream & fp); - //uint * get_buffer(uint symbol, uint *n); - - protected: - wt_coder_huff(); - HuffmanCoder * hc; - uint maxBuffer; - }; -}; -#endif diff --git a/libcds/include/wt_node.h b/libcds/include/wt_node.h deleted file mode 100644 index b9668d96..00000000 --- a/libcds/include/wt_node.h +++ /dev/null @@ -1,60 +0,0 @@ -/* wt_node.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * wt_node - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef wt_node_h -#define wt_node_h - -#include -#include -#include - -using namespace cds_utils; - -namespace cds_static -{ - - #define WT_NODE_NULL_HDR 0 - #define WT_NODE_INTERNAL_HDR 2 - #define WT_NODE_LEAF_HDR 3 - - /** Base clase for nodes in the wavelet tree - * - * @author Francisco Claude - */ - class wt_node - { - public: - virtual ~wt_node() {} - virtual size_t rank(uint *symbol, size_t pos, uint l, wt_coder *c) const = 0; - virtual size_t select(uint *symbol, size_t pos, uint l, wt_coder *c) const = 0; - virtual pair quantile_freq(size_t left,size_t right,uint q) const = 0; - virtual uint access(size_t pos) const = 0; - virtual uint access(size_t pos, size_t & rankp) const = 0; - virtual size_t getSize() const = 0; - virtual void save(ostream & fp) const = 0; - static wt_node * load(istream & fp); - }; - -}; - -#include -#include -#endif diff --git a/libcds/include/wt_node_internal.h b/libcds/include/wt_node_internal.h deleted file mode 100644 index 1ff414c6..00000000 --- a/libcds/include/wt_node_internal.h +++ /dev/null @@ -1,61 +0,0 @@ -/* wt_node_internal.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * wt_node_internal - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef wt_node_internal_h -#define wt_node_internal_h - -#include -#include -#include -#include -#include - -namespace cds_static -{ - - /** Class for representing internal nodes - * - * @author Francisco Claude - */ - class wt_node_internal: public wt_node - { - public: - wt_node_internal(uint * seq, size_t n, uint l, wt_coder * c, BitSequenceBuilder * bmb); - wt_node_internal(uchar * seq, size_t n, uint l, wt_coder * c, BitSequenceBuilder * bmb, size_t left, uint * done); - virtual ~wt_node_internal(); - virtual size_t rank(uint *symbol, size_t pos, uint level, wt_coder *c) const; - //virtual size_t rankLessThan(uint &symbol, size_t pos) const; - virtual size_t select(uint *symbol, size_t pos, uint level, wt_coder *c) const; - virtual pair quantile_freq(size_t left,size_t right,uint q) const; - virtual uint access(size_t pos) const; - virtual uint access(size_t pos, size_t & rankp) const; - virtual size_t getSize() const; - virtual void save(ostream & fp) const; - static wt_node_internal * load(istream & fp); - - protected: - wt_node_internal(); - wt_node *left_child, *right_child; - BitSequence * bitmap; - //uint length; - }; -}; -#endif diff --git a/libcds/include/wt_node_leaf.h b/libcds/include/wt_node_leaf.h deleted file mode 100644 index 91eb4dd3..00000000 --- a/libcds/include/wt_node_leaf.h +++ /dev/null @@ -1,58 +0,0 @@ -/* wt_node_leaf.h - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * wt_node_leaf - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#ifndef wt_node_leaf_h -#define wt_node_leaf_h - -#include -#include -#include -#include -#include - -namespace cds_static -{ - - /** Class for representing leaves of the wavelet tree. - * - * @author Francisco Claude - */ - class wt_node_leaf: public wt_node - { - public: - wt_node_leaf(uint symbol, size_t count); - virtual ~wt_node_leaf(); - virtual size_t rank(uint *symbol, size_t pos, uint l, wt_coder *c) const; - virtual size_t select(uint *symbol, size_t pos, uint l, wt_coder *c) const; - virtual pair quantile_freq(size_t left,size_t right,uint q) const; - virtual uint access(size_t pos) const; - virtual uint access(size_t pos, size_t &rank) const; - virtual size_t getSize() const; - virtual void save(ostream & fp) const; - static wt_node_leaf * load(istream & fp); - - protected: - wt_node_leaf(); - uint symbol; - size_t count; - }; -}; -#endif diff --git a/libcds/src/static/bitsequence/BitSequence.cpp b/libcds/src/static/bitsequence/BitSequence.cpp deleted file mode 100644 index a16b320b..00000000 --- a/libcds/src/static/bitsequence/BitSequence.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* BitSequence.cpp - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * BitSequence definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - size_t BitSequence::rank0(const size_t i) const - { - return i+1-rank1(i); - } - - size_t BitSequence::rank1(const size_t i) const - { - if(i>=length) return (size_t)-1; - if(ones==0) return 0; - if(ones==length) return i+1; - size_t ini = 1; - size_t fin = ones; - while(inii) return ini-1; - return ini; - } - - size_t BitSequence::select0(const size_t i) const - { - if(i>length-ones) return -1; - if(i==0) return -1; - if(ones==0) return i-1; - size_t ini = 0; - size_t fin = length-1; - while(iniones) return -1; - if(i==0) return -1; - if(ones==length) return i-1; - size_t ini = 0; - size_t fin = length-1; - while(ini0; - } - - bool BitSequence::access(const size_t i, size_t &r) const - { - r = rank1(i); - if(!access(i)) { - r = i-r+1; - return false; - } - else { - return true; - } - } - - size_t BitSequence::getLength() const - { - return length; - } - - size_t BitSequence::countOnes() const - { - return ones; - } - - size_t BitSequence::countZeros() const - { - return length-ones; - } - - BitSequence * BitSequence::load(istream & fp) { - uchar r = loadValue(fp); - size_t pos = fp.tellg(); - fp.seekg(pos-sizeof(uchar)); - switch(r) { - case RRR02_HDR: return BitSequenceRRR::load(fp); - case BRW32_HDR: return BitSequenceRG::load(fp); - //case RRR02_LIGHT_HDR: return BitSequence_rrr02_light::load(fp); - case SDARRAY_HDR: return BitSequenceSDArray::load(fp); - case DARRAY_HDR: return BitSequenceDArray::load(fp); - } - return NULL; - } -}; diff --git a/libcds/src/static/bitsequence/BitSequenceBuilderDArray.cpp b/libcds/src/static/bitsequence/BitSequenceBuilderDArray.cpp deleted file mode 100644 index be820c6b..00000000 --- a/libcds/src/static/bitsequence/BitSequenceBuilderDArray.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* BitSequenceBuilderDArray.cpp - * Copyright (C) 2010, Rodrigo Canovas, all rights reserved. - * - * Rodrigo Canovas - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include "BitSequenceBuilderDArray.h" - -namespace cds_static -{ - - BitSequenceBuilderDArray::BitSequenceBuilderDArray() { - } - - BitSequenceBuilderDArray::~BitSequenceBuilderDArray() { - } - - BitSequence * BitSequenceBuilderDArray::build(uint * bitseq, size_t len) const - { - return new BitSequenceDArray(bitseq,len); - } - - BitSequence * BitSequenceBuilderDArray::build(const BitString & bs) const - { - return new BitSequenceDArray(bs); - } - -}; diff --git a/libcds/src/static/bitsequence/BitSequenceBuilderRG.cpp b/libcds/src/static/bitsequence/BitSequenceBuilderRG.cpp deleted file mode 100644 index 80247aed..00000000 --- a/libcds/src/static/bitsequence/BitSequenceBuilderRG.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* BitSequenceBuilderRG.cpp - * Copyright (C) 2009, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - BitSequenceBuilderRG::BitSequenceBuilderRG(uint factor) { - this->factor = factor; - } - - BitSequence * BitSequenceBuilderRG::build(uint * bitseq, size_t len) const - { - return new BitSequenceRG(bitseq,len,factor); - } - - BitSequence * BitSequenceBuilderRG::build(const BitString & bs) const - { - return new BitSequenceRG(bs,factor); - } - -}; diff --git a/libcds/src/static/bitsequence/BitSequenceBuilderRRR.cpp b/libcds/src/static/bitsequence/BitSequenceBuilderRRR.cpp deleted file mode 100644 index 3b973613..00000000 --- a/libcds/src/static/bitsequence/BitSequenceBuilderRRR.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* BitSequenceBuilderRRR.cpp - * Copyright (C) 2009, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - BitSequenceBuilderRRR::BitSequenceBuilderRRR(uint sample_rate) { - this->sample_rate = sample_rate; - } - - BitSequence * BitSequenceBuilderRRR::build(uint * bitseq, size_t len) const - { - return new BitSequenceRRR(bitseq,len,sample_rate); - } - - BitSequence * BitSequenceBuilderRRR::build(const BitString & bs) const - { - return new BitSequenceRRR(bs,sample_rate); - } - -}; diff --git a/libcds/src/static/bitsequence/BitSequenceBuilderSDArray.cpp b/libcds/src/static/bitsequence/BitSequenceBuilderSDArray.cpp deleted file mode 100644 index 679f4170..00000000 --- a/libcds/src/static/bitsequence/BitSequenceBuilderSDArray.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* BitSequenceBuilderSDArray.cpp - * Copyright (C) 2009, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - BitSequenceBuilderSDArray::BitSequenceBuilderSDArray() { - } - - BitSequenceBuilderSDArray::~BitSequenceBuilderSDArray() { - } - - BitSequence * BitSequenceBuilderSDArray::build(uint * bitseq, size_t len) const - { - return new BitSequenceSDArray(bitseq,len); - } - - BitSequence * BitSequenceBuilderSDArray::build(const BitString & bs) const - { - return new BitSequenceSDArray(bs); - } - -}; diff --git a/libcds/src/static/bitsequence/BitSequenceDArray.cpp b/libcds/src/static/bitsequence/BitSequenceDArray.cpp deleted file mode 100644 index 7827cb95..00000000 --- a/libcds/src/static/bitsequence/BitSequenceDArray.cpp +++ /dev/null @@ -1,337 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - static unsigned int __selecttbl_D[8*256]; - static int built_D = 0; - - void make___selecttbl_D(void) { - if(built_D) return; - built_D = 1; - int i,x,r; - uint buf[1]; - buf[0] = 0; - for (x = 0; x < 256; x++) { - __setbits(buf,0,8,x); - for (r=0; r<8; r++) __selecttbl_D[(r<<8)+x] = -1; - r = 0; - for (i=0; i<8; i++) { - if (__getbit(buf,i)) { - __selecttbl_D[(r<<8)+x] = i; - r++; - } - } - } - } - - BitSequenceDArray::BitSequenceDArray() { - length = m = nl = 0; - a = NULL; - lp = NULL; - sl = NULL; - ss = NULL; - p = NULL; - rl = NULL; - rs = NULL; - } - - BitSequenceDArray::BitSequenceDArray(const BitString & bs) { - uint * tmp_seq = new uint[uint_len(bs.getLength(),1)+1]; - ones = 0; - for(uint i=0;iowner = true; - this->n=_n; - uint lgn=bits(n-1); - this->factor=_factor; - if (_factor==0) this->factor=lgn; - else this->factor=_factor; - b=32; - s=b*this->factor; - integers = n/W+1; - BuildRank(); - this->length = n; - this->ones = rank1(n-1); - } - - BitSequenceRG::BitSequenceRG( uint *bitarray, size_t _n, uint _factor) { - /*cout << "*****" << endl; - cout << bitarray << endl; - cout << _n << endl; - cout << _factor << endl; */ - if(_factor==0) exit(-1); - data=new uint[_n/W+1]; - for(size_t i=0;iowner = true; - this->n=_n; - uint lgn=bits(n-1); - this->factor=_factor; - if (_factor==0) this->factor=lgn; - else this->factor=_factor; - b=32; - s=b*this->factor; - integers = n/W+1; - BuildRank(); - this->length = n; - this->ones = rank1(n-1); - } - - BitSequenceRG::~BitSequenceRG() { - delete [] Rs; - delete [] data; - } - - //Metodo que realiza la busqueda d - void BitSequenceRG::BuildRank() { - size_t num_sblock = n/s; - // +1 pues sumo la pos cero - Rs = new uint[num_sblock+5]; - for(uint i=0;i(f,n); - saveValue(f,factor); - saveValue(f,data,integers); - saveValue(f,Rs,n/s+1); - } - - BitSequenceRG * BitSequenceRG::load(istream & f) { - assert(f.good()); - uchar type = loadValue(f); - if(type!=BRW32_HDR) { // throw exception - abort(); - } - BitSequenceRG * ret = new BitSequenceRG(); - ret->n = loadValue(f); - ret->b = 32; - ret->factor = loadValue(f); - ret->s = ret->b*ret->factor; - ret->integers = (ret->n+1)/W+((ret->n+1)%W!=0?1:0); - ret->data = loadValue(f,ret->integers); - ret->Rs = loadValue(f,ret->n/ret->s+1); - ret->length = ret->n; - ret->ones = ret->rank1(ret->n-1); - return ret; - } - - size_t BitSequenceRG::SpaceRequirementInBits() const - { - return uint_len(n,1)*sizeof(uint)*8+(n/s)*sizeof(uint)*8 +sizeof(this)*8; - } - - size_t BitSequenceRG::getSize() const - { - //cout << "n=" << n << " size=" << SpaceRequirementInBits() << endl; - return /*sizeof(BitSequenceRG)+*/SpaceRequirementInBits()/8; - } - - size_t BitSequenceRG::SpaceRequirement() const - { - return n/8+(n/s)*sizeof(uint)+sizeof(BitSequenceRG); - } - - size_t BitSequenceRG::selectPrev1(const size_t start) const - { - // returns the position of the previous 1 bit before and including start. - // tuned to 32 bit machine - - uint i = start >> 5; - int offset = (start % W); - uint aux2 = data[i] & (-1u >> (31-offset)); - - if (aux2 > 0) { - if ((aux2&0xFF000000) > 0) return i*W+23+prev_tab[(aux2>>24)&0xFF]; - else if ((aux2&0xFF0000) > 0) return i*W+15+prev_tab[(aux2>>16)&0xFF]; - else if ((aux2&0xFF00) > 0) return i*W+7+prev_tab[(aux2>>8)&0xFF]; - else return i*W+prev_tab[aux2&0xFF]-1; - } - for (uint k=i-1;;k--) { - aux2=data[k]; - if (aux2 > 0) { - if ((aux2&0xFF000000) > 0) return k*W+23+prev_tab[(aux2>>24)&0xFF]; - else if ((aux2&0xFF0000) > 0) return k*W+15+prev_tab[(aux2>>16)&0xFF]; - else if ((aux2&0xFF00) > 0) return k*W+7+prev_tab[(aux2>>8)&0xFF]; - else return k*W+prev_tab[aux2&0xFF]-1; - } - } - return 0; - } - - size_t BitSequenceRG::selectNext1(const size_t k1) const - { - uint k = (uint)k1; - uint count = k; - uint des,aux2; - des=count%W; - aux2= data[count/W] >> des; - if (aux2 > 0) { - if ((aux2&0xff) > 0) return count+select_tab[aux2&0xff]-1; - else if ((aux2&0xff00) > 0) return count+8+select_tab[(aux2>>8)&0xff]-1; - else if ((aux2&0xff0000) > 0) return count+16+select_tab[(aux2>>16)&0xff]-1; - else {return count+24+select_tab[(aux2>>24)&0xff]-1;} - } - - for (uint i=count/W+1;i 0) { - if ((aux2&0xff) > 0) return i*W+select_tab[aux2&0xff]-1; - else if ((aux2&0xff00) > 0) return i*W+8+select_tab[(aux2>>8)&0xff]-1; - else if ((aux2&0xff0000) > 0) return i*W+16+select_tab[(aux2>>16)&0xff]-1; - else {return i*W+24+select_tab[(aux2>>24)&0xff]-1;} - } - } - return n; - } - - size_t BitSequenceRG::select1(const size_t x1) const - { - uint x=x1; - // returns i such that x=rank(i) && rank(i-1)ones) return (uint)(-1); - - //binary search over first level rank structure - uint l=0, r=n/s; - uint mid=(l+r)/2; - uint rankmid = Rs[mid]; - while (l<=r) { - if (rankmid integers) return n; - j = data[left]; - ones = popcount(j); - } - //sequential search using popcount over a char - left=left*b; - rankmid = popcount8(j); - if (rankmid < x) { - j=j>>8; - x-=rankmid; - left+=8; - rankmid = popcount8(j); - if (rankmid < x) { - j=j>>8; - x-=rankmid; - left+=8; - rankmid = popcount8(j); - if (rankmid < x) { - j=j>>8; - x-=rankmid; - left+=8; - } - } - } - - // then sequential search bit a bit - while (x>0) { - if (j&1) x--; - j=j>>1; - left++; - } - return left-1; - } - - size_t BitSequenceRG::select0(const size_t x1) const - { - uint x = (uint)x1; - // returns i such that x=rank_0(i) && rank_0(i-1)n-ones) return (uint)(-1); - - //binary search over first level rank structure - if(x==0) return 0; - uint l=0, r=n/s; - uint mid=(l+r)/2; - uint rankmid = mid*factor*W-Rs[mid]; - while (l<=r) { - if (rankmid integers) return n; - j = data[left]; - zeros = W-popcount(j); - } - //sequential search using popcount over a char - left=left*b; - rankmid = 8-popcount8(j); - if (rankmid < x) { - j=j>>8; - x-=rankmid; - left+=8; - rankmid = 8-popcount8(j); - if (rankmid < x) { - j=j>>8; - x-=rankmid; - left+=8; - rankmid = 8-popcount8(j); - if (rankmid < x) { - j=j>>8; - x-=rankmid; - left+=8; - } - } - } - - // then sequential search bit a bit - while (x>0) { - if (j%2 == 0 ) x--; - j=j>>1; - left++; - } - left--; - if (left > n) return n; - else return left; - } -}; diff --git a/libcds/src/static/bitsequence/BitSequenceRRR.cpp b/libcds/src/static/bitsequence/BitSequenceRRR.cpp deleted file mode 100644 index de16e66f..00000000 --- a/libcds/src/static/bitsequence/BitSequenceRRR.cpp +++ /dev/null @@ -1,430 +0,0 @@ -/* BitSequenceRRR.cpp - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * BitSequenceRRR definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - table_offset * BitSequenceRRR::E = NULL; - - BitSequenceRRR::BitSequenceRRR() { - ones=0; - length=0; - if(E==NULL) E = new table_offset(BLOCK_SIZE); - E->use(); - C = NULL; - O = NULL; - C_sampling = NULL; - O_pos = NULL; - sample_rate = DEFAULT_SAMPLING; - C_len = O_len = C_sampling_len = O_pos_len = 0; - O_bits_len = C_sampling_field_bits = O_pos_field_bits = 0; - } - - BitSequenceRRR::BitSequenceRRR(uint * bitseq, size_t len, uint sample_rate) { - build(bitseq,len,sample_rate); - } - - BitSequenceRRR::BitSequenceRRR(const BitString & bs, uint sample_rate) { - build(bs.getData(),bs.getLength(),sample_rate); - } - - void BitSequenceRRR::build(const uint * bitseq, size_t len, uint sample_rate) { - ones = 0; - this->length = len; - if(E==NULL) E = new table_offset(BLOCK_SIZE); - E->use(); - - // Table C - C_len = len/BLOCK_SIZE + (len%BLOCK_SIZE!=0); - C_field_bits = bits(BLOCK_SIZE); - C = new uint[uint_len(C_len,C_field_bits)]; - for(uint i=0;iget_log2binomial(BLOCK_SIZE,value); - } - - // Table O - O_len = uint_len(1,O_bits_len); - O = new uint[O_len]; - for(uint i=0;iget_log2binomial(BLOCK_SIZE,popcount(value))-1,E->compute_offset((ushort)value)); - O_pos += E->get_log2binomial(BLOCK_SIZE,popcount(value)); - } - C_sampling = NULL; - this->O_pos = NULL; - - create_sampling(sample_rate); - } - - void BitSequenceRRR::create_sampling(uint sample_rate) { - this->sample_rate = sample_rate; - /*cout << "===================" << endl; - cout << "length = " << length << endl; - cout << "ones = " << ones << endl; - cout << "C_len = " << C_len << endl; - cout << "C_field_bits = " << C_field_bits << endl; - cout << "O_len = " << O_len << endl; - cout << "O_bits_len = " << O_bits_len << endl; - cout << "sample_rate = " << sample_rate << endl; - cout << "C_alen = " << uint_len(C_len,C_field_bits) << endl; - cout << "O_alen = " << O_len << endl;*/ - - // Sampling for C - C_sampling_len = C_len/sample_rate+2; - C_sampling_field_bits = bits(ones); - if(C_sampling!=NULL) delete [] C_sampling; - C_sampling = new uint[max((uint)1,uint_len(C_sampling_len,C_sampling_field_bits))]; - for(uint i=0;iget_log2binomial(BLOCK_SIZE,get_field(C,C_field_bits,i)); - } - } - - bool BitSequenceRRR::access(const size_t i) const - { - size_t nearest_sampled_value = i/BLOCK_SIZE/sample_rate; - size_t pos_O = get_field(O_pos,O_pos_field_bits,nearest_sampled_value); - size_t pos = i/BLOCK_SIZE; - assert(pos<=C_len); - for(size_t k=nearest_sampled_value*sample_rate;kget_log2binomial(BLOCK_SIZE,aux); - } - size_t c = get_field(C,C_field_bits,pos); - return ((1<<(i%BLOCK_SIZE))&E->short_bitmap(c,get_var_field(O,pos_O,pos_O+E->get_log2binomial(BLOCK_SIZE,c)-1)))!=0; - } - - bool BitSequenceRRR::access(const size_t i, size_t &r) const - { - if(i+1==0) return 0; - // patch for 32-64 bits bad coding, to be removed in the future - if((uint)(i+1)==0) return 0; - uint nearest_sampled_value = i/BLOCK_SIZE/sample_rate; - uint sum = get_field(C_sampling,C_sampling_field_bits,nearest_sampled_value); - uint pos_O = get_field(O_pos,O_pos_field_bits,nearest_sampled_value); - uint pos = i/BLOCK_SIZE; - uint k=nearest_sampled_value*sample_rate; - if(k%2==1 && kget_log2binomial(BLOCK_SIZE,aux); - k++; - } - unsigned char * a = (unsigned char *)C; - size_t mask = 0x0F; - a += k/2; - while(k<(uint)max(0,(int)pos-1)) { - assert(((*a)&mask)==get_field(C,C_field_bits,k)); - assert((*a)/16==get_field(C,C_field_bits,k+1)); - sum += ((*a)&mask)+(*a)/16; - pos_O += E->get_log2binomial(BLOCK_SIZE,((*a)&mask))+E->get_log2binomial(BLOCK_SIZE,((*a)/16)); - a++; - k+=2; - } - if(kget_log2binomial(BLOCK_SIZE,aux); - k++; - } - size_t c = get_field(C,C_field_bits,pos); - short v = E->short_bitmap(c,get_var_field(O,pos_O,pos_O+E->get_log2binomial(BLOCK_SIZE,c)-1)); - sum += popcount(((2<<(i%BLOCK_SIZE))-1) & v); - r = sum; - if( ((1<<(i%BLOCK_SIZE)) & v) != 0 ) { - return true; - } - else { - r = i-r+1; - return false; - } - } - - size_t BitSequenceRRR::rank0(size_t i) const - { - if(i+1==0) return 0; - return 1+i-rank1(i); - } - - size_t BitSequenceRRR::rank1(size_t i) const - { - if(i+1==0) return 0; - // patch for 32-64 bits bad coding, to be removed in the future - if((uint)(i+1)==0) return 0; - uint nearest_sampled_value = i/BLOCK_SIZE/sample_rate; - uint sum = get_field(C_sampling,C_sampling_field_bits,nearest_sampled_value); - uint pos_O = get_field(O_pos,O_pos_field_bits,nearest_sampled_value); - uint pos = i/BLOCK_SIZE; - uint k=nearest_sampled_value*sample_rate; - if(k%2==1 && kget_log2binomial(BLOCK_SIZE,aux); - k++; - } - unsigned char * a = (unsigned char *)C; - size_t mask = 0x0F; - a += k/2; - while(k<(uint)max(0,(int)pos-1)) { - assert(((*a)&mask)==get_field(C,C_field_bits,k)); - assert((*a)/16==get_field(C,C_field_bits,k+1)); - sum += ((*a)&mask)+(*a)/16; - pos_O += E->get_log2binomial(BLOCK_SIZE,((*a)&mask))+E->get_log2binomial(BLOCK_SIZE,((*a)/16)); - a++; - k+=2; - } - if(kget_log2binomial(BLOCK_SIZE,aux); - k++; - } - size_t c = get_field(C,C_field_bits,pos); - sum += popcount(((2<<(i%BLOCK_SIZE))-1) & E->short_bitmap(c,get_var_field(O,pos_O,pos_O+E->get_log2binomial(BLOCK_SIZE,c)-1))); - return sum; - } - - size_t BitSequenceRRR::select0(size_t i) const - { - if(i==0) return (uint)-1; - if(i>length-ones) return (uint)-1; - - // Search over partial sums - size_t start=0; - size_t end=C_sampling_len-1; - size_t med, acc=0, pos; - while(start=i) break; - pos_O += E->get_log2binomial(BLOCK_SIZE,s); - acc += BLOCK_SIZE-s; - } - pos = (pos)*BLOCK_SIZE; - - // Search inside the block - while(accget_log2binomial(BLOCK_SIZE,s); - size_t block = E->short_bitmap(s,get_var_field(O,pos_O,new_posO-1)); - pos_O = new_posO; - new_posO = 0; - while(accones) return -1; - // Search over partial sums - size_t start=0; - size_t end=C_sampling_len-1; - size_t med, acc=0, pos; - while(start=i) break; - pos_O += E->get_log2binomial(BLOCK_SIZE,s); - acc += s; - } - pos = (pos)*BLOCK_SIZE; - - // Search inside the block - while(accget_log2binomial(BLOCK_SIZE,s); - size_t block = E->short_bitmap(s,get_var_field(O,pos_O,new_posO-1)); - pos_O = new_posO; - new_posO = 0; - while(accunuse(); - } - - void BitSequenceRRR::save(ostream & f) const - { - /*cout << "===================" << endl; - cout << "length = " << length << endl; - cout << "ones = " << ones << endl; - cout << "C_len = " << C_len << endl; - cout << "C_field_bits = " << C_field_bits << endl; - cout << "O_len = " << O_len << endl; - cout << "O_bits_len = " << O_bits_len << endl; - cout << "sample_rate = " << sample_rate << endl; - cout << "C_alen = " << uint_len(C_len,C_field_bits) << endl; - cout << "O_alen = " << O_len << endl;*/ - uchar wr = RRR02_HDR; - saveValue(f,wr); - saveValue(f,length); - saveValue(f,ones); - saveValue(f,C_len); - saveValue(f,C_field_bits); - saveValue(f,O_len); - saveValue(f,O_bits_len); - saveValue(f,sample_rate); - saveValue(f,C,uint_len(C_len,C_field_bits)); - saveValue(f,O,O_len); - } - - BitSequenceRRR * BitSequenceRRR::load(istream & f) { - BitSequenceRRR * ret = NULL; - try - { - ret = new BitSequenceRRR(); - uchar type = loadValue(f); - // TODO:throw an exception! - if(type!=RRR02_HDR) { - abort(); - } - ret->length = loadValue(f); - //cout << ret->length << endl; - ret->ones = loadValue(f); - //cout << ret->ones << endl; - ret->C_len = loadValue(f); - //cout << ret->C_len << endl; - ret->C_field_bits = loadValue(f); - //cout << ret->C_field_bits << endl; - ret->O_len = loadValue(f); - //cout << ret->O_len << endl; - ret->O_bits_len = loadValue(f); - //cout << ret->O_bits_len << endl; - ret->sample_rate = loadValue(f); - //cout << ret->sample_rate << endl; - //ret->length = loadValue(f); - ret->C = loadValue(f,uint_len(ret->C_len,ret->C_field_bits)); - ret->O = loadValue(f,ret->O_len); - ret->create_sampling(ret->sample_rate); - return ret; - } - catch(exception e) { - delete ret; - } - return NULL; - } -} diff --git a/libcds/src/static/bitsequence/BitSequenceSDArray.cpp b/libcds/src/static/bitsequence/BitSequenceSDArray.cpp deleted file mode 100644 index 3b16d05c..00000000 --- a/libcds/src/static/bitsequence/BitSequenceSDArray.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* BitSequenceSDArray.cpp - * Copyright (C) 2009, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This class is a wrapper for sdarraySadakane.cpp, which was implemented - * by K. Sadakane. - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - BitSequenceSDArray::BitSequenceSDArray(const BitString & bs) { - uint * tmp_seq = new uint[uint_len(bs.getLength(),1)+1]; - ones = 0; - for(uint i=0;ilength = bs.getLength(); - delete [] tmp_seq; - } - - BitSequenceSDArray::BitSequenceSDArray(uint * buff, size_t len) { - uint * tmp_seq = new uint[uint_len(len,1)+1]; - ones = 0; - for(uint i=0;ilength = len; - delete [] tmp_seq; - } - - BitSequenceSDArray::BitSequenceSDArray() { - make___selecttbl(); - } - - BitSequenceSDArray::~BitSequenceSDArray() { - if(ones) - selects3_free(&sd); - } - - size_t BitSequenceSDArray::rank1(size_t i) const - { - if(i>=length) return -1; - if(ones) - return selects3_rank(&sd,i); - else - return 0; - } - - size_t BitSequenceSDArray::select1(size_t i) const - { - if(i>ones || i==0) return -1; - if(ones) - return selects3_select(&sd,(uint)i); - else - return (uint)-1; - } - - size_t BitSequenceSDArray::selectNext1(size_t i) const - { - return selects3_selectnext(&sd,(uint)i); - } - - size_t BitSequenceSDArray::getSize() const - { - return sizeof(BitSequenceSDArray)+(ones?(sd.size + sd.sd0->size + sd.sd1->size):0); - } - - void BitSequenceSDArray::save(ostream & fp) const - { - uchar wr = SDARRAY_HDR; - saveValue(fp,wr); - saveValue(fp,length); - saveValue(fp,ones); - if(ones) - selects3_save(&sd,fp); - } - - BitSequenceSDArray * BitSequenceSDArray::load(istream & fp) { - uchar id = loadValue(fp); - if(id!=SDARRAY_HDR) return NULL; - BitSequenceSDArray * ret = new BitSequenceSDArray(); - ret->length = loadValue(fp); - ret->ones = loadValue(fp); - if(ret->ones) - selects3_load(&ret->sd,fp); - return ret; - } - -}; diff --git a/libcds/src/static/bitsequence/TableOffsetRRR.cpp b/libcds/src/static/bitsequence/TableOffsetRRR.cpp deleted file mode 100644 index bd8cb148..00000000 --- a/libcds/src/static/bitsequence/TableOffsetRRR.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* table_offset.cpp - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * Table for offsets. - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include "TableOffsetRRR.h" - -namespace cds_static -{ - // Interface for old implementation - void genera(ushort * bch, uint u, ushort * F, uint lF); - uint generaClase(ushort * bch, uint u, uint clase, uint puestos, uint pos_ini, uint generado); - uint offset_func(uint u, uint busca); - uint offsetRecursivo(uint u, uint busca, uint clase, uint puestos, uint pos_ini, uint generado); - uint __indiceFunc; - uint __indAcumulado; - ushort * __Lis; - // End interface old implementation - - table_offset::table_offset(uint u) { - this->u = u; - users_count = 0; - short_bitmaps = new ushort[((1< - -namespace cds_static -{ - static unsigned int __selecttbl[8*256]; - static int built = 0; - - void make___selecttbl(void) { - if(built) return; - built = 1; - int i,x,r; - uint buf[1]; - buf[0] = 0; - - for (x = 0; x < 256; x++) { - __setbits(buf,0,8,x); - for (r=0; r<8; r++) __selecttbl[(r<<8)+x] = -1; - r = 0; - for (i=0; i<8; i++) { - if (__getbit(buf,i)) { - __selecttbl[(r<<8)+x] = i; - r++; - } - } - } - } - - void selectd2_save(const selectd2 * s, ostream & fp) { - assert(fp.good()); - saveValue(fp,s->n); - saveValue(fp,s->m); - saveValue(fp,s->size); - saveValue(fp,s->ss_len); - saveValue(fp,s->sl_len); - saveValue(fp,s->buf,(s->n+7)/8+1); - uint nl = (s->m-1) / L + 1; - saveValue(fp,s->lp,nl+1); - saveValue(fp,s->p,nl+1); - saveValue(fp,s->ss,s->ss_len); - saveValue(fp,s->sl,s->sl_len); - } - - void selectd2_load(selectd2 * s, istream & fp) { - s->n = loadValue(fp); - s->m = loadValue(fp); - s->size = loadValue(fp); - s->ss_len = loadValue(fp); - s->sl_len = loadValue(fp); - s->buf = loadValue(fp,(s->n+7)/8+1); - uint nl = (s->m-1) / L + 1; - s->lp = loadValue(fp, nl+1); - s->p = loadValue(fp, nl+1); - s->ss = loadValue(fp, s->ss_len); - s->sl = loadValue(fp, s->sl_len); - } - - void selectd2_free(selectd2 * s) { - //delete [] s->buf; - delete [] s->lp; - delete [] s->p; - delete [] s->ss; - delete [] s->sl; - } - - int selectd2_construct(selectd2 *select, const int n, const unsigned char *buf) { - int i,m; - int nl; - int p,pp; - int il,is,ml,ms; - int r; - uint *s; - - make___selecttbl(); - - if (L/LLL == 0) { - printf("ERROR: L=%d LLL=%d\n",L,LLL); - exit(1); - } - - m = 0; - for (i=0; in = n; - select->m = m; - //printf("n=%d m=%d\n",n,m); - - select->buf = (unsigned char*)buf; - - s = new uint[m]; - m = 0; - for (i=0; isize = 0; //ignoring buf, shared with selects3 - select->lp = new uint[nl+1]; - for(int k=0;klp[k]=0; - select->size += (nl+1)*sizeof(uint); - select->p = new uint[nl+1]; - for(int k=0;kp[k]=0; - select->size += (nl+1)*sizeof(uint); - - for (r = 0; r < 2; r++) { - ml = ms = 0; - for (il = 0; il < nl; il++) { - pp = s[il*L]; - select->lp[il] = pp; - i = min((il+1)*(int)L-1,m-1); - p = s[i]; - //printf("%d ",p-pp); - if (p - pp >= (int)LL) { - if (r == 1) { - for (is = 0; is < (int)L; is++) { - if (il*(int)L+is >= m) break; - select->sl[ml*L+is] = s[il*L+is]; - } - } - select->p[il] = -((ml<= m) break; - select->ss[ms*(L/LLL)+is] = s[il*L+is*LLL] - pp; - } - } - select->p[il] = ms << (logL-logLLL); - ms++; - } - } - if (r == 0) { - select->sl = new uint[ml*L+1]; - for(int k=0;ksl[k]=0; - select->size += sizeof(uint)*(ml*L+1); - select->sl_len = ml*L+1; - select->ss = new ushort[ms*(L/LLL)+1]; - for(int k=0;kss[k]=0; - select->ss_len = ms*(L/LLL)+1; - select->size += sizeof(ushort)*(ms*(L/LLL)+1); - } - } - delete [] s; - return 0; - } - - int selectd2_select(const selectd2 *select, const int i1, const int f) { - int i = i1; - int p,r; - int il; - int rr; - unsigned char *q; - - if (i == 0) return -1; - - #if 0 - if (i > select->m) { - printf("ERROR: m=%d i=%d\n",select->m,i); - exit(1); - } - #endif - - i--; - - il = select->p[i>>logL]; - if (il < 0) { - il = -il-1; - //p = select->sl[(il<sl[il+(i & (L-1))]; - } - else { - p = select->lp[i>>logL]; - //p += select->ss[(il<<(logL-logLLL))+(i & (L-1))/LLL]; - p += select->ss[il+((i & (L-1))>>logLLL)]; - r = i - (i & (LLL-1)); - - q = &(select->buf[p>>3]); - - if (f == 1) { - rr = p & (8-1); - r -= _popCount[*q >> (8-1-rr)]; - //p = p - rr; - - while (1) { - rr = _popCount[*q]; - if (r + rr >= i) break; - r += rr; - //p += 8; - q++; - } - p = (q - select->buf) << 3; - p += __selecttbl[((i-r-1)<<8)+(*q)]; - } - else { - rr = p & (8-1); - r -= _popCount[(*q ^ 0xff) >> (8-1-rr)]; - //p = p - rr; - - while (1) { - rr = _popCount[*q ^ 0xff]; - if (r + rr >= i) break; - r += rr; - //p += 8; - q++; - } - p = (q - select->buf) << 3; - p += __selecttbl[((i-r-1)<<8)+(*q ^ 0xff)]; - } - } - return p; - } - - int selectd2_select2(const selectd2 *select, const int i1, const int f, int *st, int *en) { - int i = i1; - int p,r,p2; - int il; - int rr; - unsigned char *q; - - if (i == 0) { - *st = -1; - return -1; - } - - #if 0 - if (i > select->m) { - printf("ERROR: m=%d i=%d\n",select->m,i); - exit(1); - } - #endif - - i--; - - il = select->p[i>>logL]; - if (il < 0) { - il = -il-1; - //p = select->sl[(il<sl[il+(i & (L-1))]; - - if ((i>>logL) == ((i+1)>>logL)) { - p2 = select->sl[il+((i+1) & (L-1))]; - } - else { - p2 = selectd2_select(select,i+2,f); - } - } - else { - p = select->lp[i>>logL]; - //p += select->ss[(il<<(logL-logLLL))+(i & (L-1))/LLL]; - p += select->ss[il+((i & (L-1))>>logLLL)]; - r = i - (i & (LLL-1)); - - q = &(select->buf[p>>3]); - - if (f == 1) { - rr = p & (8-1); - r -= _popCount[*q >> (8-1-rr)]; - //p = p - rr; - - while (1) { - rr = _popCount[*q]; - if (r + rr >= i) break; - r += rr; - //p += 8; - q++; - } - p = (q - select->buf) << 3; - p += __selecttbl[((i-r-1)<<8)+(*q)]; - - if ((i>>logL) == ((i+1)>>logL)) { - i++; - while (1) { - rr = _popCount[*q]; - if (r + rr >= i) break; - r += rr; - q++; - } - p2 = (q - select->buf) << 3; - p2 += __selecttbl[((i-r-1)<<8)+(*q)]; - } - else { - p2 = selectd2_select(select,i+2,f); - } - - } - else { - rr = p & (8-1); - r -= _popCount[(*q ^ 0xff) >> (8-1-rr)]; - //p = p - rr; - - while (1) { - rr = _popCount[*q ^ 0xff]; - if (r + rr >= i) break; - r += rr; - //p += 8; - q++; - } - p = (q - select->buf) << 3; - p += __selecttbl[((i-r-1)<<8)+(*q ^ 0xff)]; - - if ((i>>logL) == ((i+1)>>logL)) { - i++; - while (1) { - rr = _popCount[*q ^ 0xff]; - if (r + rr >= i) break; - r += rr; - q++; - } - p2 = (q - select->buf) << 3; - p2 += __selecttbl[((i-r-1)<<8)+(*q ^ 0xff)]; - } - else { - p2 = selectd2_select(select,i+2,f); - } - } - } - *st = p; - *en = p2; - return p; - } - - void selects3_save(const selects3 * s, ostream & fp) { - saveValue(fp,s->n); - saveValue(fp,s->m); - saveValue(fp,s->size); - saveValue(fp,s->d); - saveValue(fp,s->hi_len); - saveValue(fp,s->low_len); - saveValue(fp,s->hi,s->hi_len); - saveValue(fp,s->low,s->low_len); - selectd2_save(s->sd0,fp); - selectd2_save(s->sd1,fp); - } - - void selects3_load(selects3 * s, istream & fp) { - s->n = loadValue(fp); - s->m = loadValue(fp); - s->size = loadValue(fp); - s->d = loadValue(fp); - s->hi_len = loadValue(fp); - s->low_len = loadValue(fp); - s->hi = loadValue(fp,s->hi_len); - s->low = loadValue(fp, s->low_len); - s->sd0 = new selectd2; - selectd2_load(s->sd0,fp); - s->sd1 = new selectd2; - selectd2_load(s->sd1,fp); - delete [] s->sd0->buf; - delete [] s->sd1->buf; - s->sd0->buf = s->hi; - s->sd1->buf = s->hi; - } - - void selects3_free(selects3 * s) { - delete [] s->hi; - delete [] s->low; - //delete [] s->sd0->buf; - selectd2_free(s->sd0); - delete s->sd0; - selectd2_free(s->sd1); - delete s->sd1; - } - - int selects3_construct(selects3 *select, const int n, const uint *buf) { - int i,m; - int d,mm; - uint *low; - unsigned char *buf2; - selectd2 *sd0,*sd1; - - m = 0; - for (i=0; in = n; - select->m = m; - - if (m == 0) return 0; - - mm = m; - d = 0; - while (mm < n) { - mm <<= 1; - d++; - } - - select->d = d; - - buf2 = new unsigned char[(2*m+8-1)/8+1]; - for(int k=0;k<(2*m+8-1)/8+1;k++) buf2[k]=0; - select->hi_len = (2*m+8-1)/8+1; - low = new uint[(d*m+PBS-1)/PBS+1]; - for(uint k=0;k<(d*m+PBS-1)/PBS+1;k++) low[k]=0; - select->low_len = (d*m+PBS-1)/PBS+1; - - select->hi = buf2; - select->low = low; - select->size = sizeof(unsigned char)*((2*m+8-1)/8+1) + sizeof(uint)*((d*m+PBS-1)/PBS+1); - - for (i=0; i>d)+m,1); - __setbits(low,m*d,d,i & ((1<size += 2*sizeof(selectd2); - - selectd2_construct(sd1,m*2,buf2); - select->sd1 = sd1; - - for (i=0; isd0 = sd0; - - for (i=0; i select->m) { - printf("ERROR: m=%d i=%d\n",select->m,i); - exit(1); - } - #endif - - if (i == 0) return -1; - - d = select->d; - /*if(select->lasti==(uint)i-1) { - while(!__getbit2(select->sd1->buf,++select->lasts)); - } - else { - select->lasts = selectd2_select(select->sd1,i,1); - } - select->lasti = i; - //lasts3 = select; */ - x = selectd2_select(select->sd1,i,1) - (i-1); - //x = (select->lasts-(i-1)) << d; - x <<= d; - x += __getbits(select->low,(i-1)*d,d); - return x; - } - - int selects3_selectnext(const selects3 *select, const int i) { - //return selects3_select(select,selects3_rank(select,i)+1); - int i2; - if(i>0) i2=i-1; - else i2=i; - int d,x,w,y; - int r,j; - int z,ii; - uint *q; - d = select->d; - q = select->low; - ii = i2>>d; - y = selectd2_select(select->sd0,ii,0)+1; - int k2=y-ii; - x = y - ii; - int x_orig = x; - j = i2 - (ii<>= 3; - z = select->hi[y]; - while (1) { - if (((z << r) & 0x80) == 0) { - if(x!=x_orig) k2++; - break; - } - w = __getbits(q,x*d,d); - if (w >= j) { - if (w == j) { - if(__getbit2(select->hi,(8*y+r))) k2++; - x++; - r++; - } - break; - } - x++; - r++; - if(__getbit2(select->hi,(8*y+r))) k2++; - if (r == 8) { - r = 0; - y++; - z = select->hi[y]; - } - } - if(x==select->m) - return (uint)-1; - int c=8*y+r; - int fin=0; - for(int kk=0;kk<8-r;kk++) { - if(__getbit2(select->hi,c)) { - fin=1; - break; - } - c++; - } - if(!fin) { - int pp = c/8; - while(select->hi[pp]==0) { - pp++; - c+=8; - } - while(!__getbit2(select->hi,c)) c++; - } - c -= (k2); - return __getbits(q,x*d,d)+((c)<d; - q = select->low; - - ii = i>>d; - - y = selectd2_select(select->sd0,ii,0)+1; - // selectd2_select2(select->sd0,ii,0,&y1,&y2); - //y1++; y2++; - //printf("y %d y1 %d %d\n",y,y1,y2-y1); - - x = y - ii; - - j = i - (ii<>= 3; - z = select->hi[y]; - while (1) { - if (((z << r) & 0x80) == 0) break; - w = __getbits(q,x*d,d); - if (w >= j) { - if (w == j) x++; - break; - } - x++; - r++; - if (r == 8) { - r = 0; - y++; - z = select->hi[y]; - } - } - - return x; - } -} diff --git a/libcds/src/static/coders/HuffmanCoder.cpp b/libcds/src/static/coders/HuffmanCoder.cpp deleted file mode 100644 index 88e331b6..00000000 --- a/libcds/src/static/coders/HuffmanCoder.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* HuffmanCoder.cpp - Copyright (C) 2008, Francisco Claude, all rights reserved. - - Wrapper for huff written by Gonzalo Navarro - - 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. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - 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 - -*/ - -#include - -namespace cds_static -{ - using namespace cds_utils; - - HuffmanCoder::HuffmanCoder(uint * symb, size_t n) { - uint max_v = 0; - for(size_t i=0;i(fp,HUFF_HDR); - saveHuff(huff_table,fp); - } - - HuffmanCoder * HuffmanCoder::load(istream & fp) { - uint type = loadValue(fp); - if(type != HUFF_HDR) { //throw exception - return NULL; - } - HuffmanCoder * ret = new HuffmanCoder(); - ret->huff_table = loadHuff(fp,1); - return ret; - } - -}; diff --git a/libcds/src/static/coders/huff.cpp b/libcds/src/static/coders/huff.cpp deleted file mode 100644 index 07396857..00000000 --- a/libcds/src/static/coders/huff.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/* huff.cpp - Copyright (C) 2008, Gonzalo Navarro, all rights reserved. - - Canonical Huffman - - 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. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - 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 - -*/ -// implements canonical Huffman - -#include -using namespace cds_utils; - -namespace cds_static -{ - - typedef struct - { - uint freq; - uint symb; - union - { - int prev; - uint depth; - } h; - int ch1,ch2; - } Ttree; - - static void sort (Ttree *tree, int lo, int up) { - uint i, j; - Ttree temp; - while (up>lo) { - i = lo; - j = up; - temp = tree[lo]; - while (i temp.freq) j--; - tree[i] = tree[j]; - while (i0) { - tree[j].freq = freq[i]; - tree[j].symb = i; - j++; - } - } - H.lim = lim = j-1; - // now run Huffman algorithm - sort (tree,0,lim); - for (i=0;i<=(int)lim;i++) { - tree[i].h.prev = i+1; - tree[i].ch1 = tree[i].ch2 = -1; - } - tree[lim].h.prev = -1; - // last = next node to process, ptr = search point, fre = next free cell - // leaves are in 0..lim in decreasing freq order - // internal nodes are in lim+1.. 2*lim, created in incr. fre order - last=0; ptr = 0; fre = lim+1; - for (i=0;i<(int)lim;i++) { - tree[fre].ch1 = last; - last = tree[last].h.prev; - tree[fre].ch2 = last; - tree[fre].freq = tree[tree[fre].ch1].freq+tree[tree[fre].ch2].freq; - while ((tree[ptr].h.prev != -1) && - (tree[tree[ptr].h.prev].freq <= tree[fre].freq)) - ptr = tree[ptr].h.prev; - tree[fre].h.prev = tree[ptr].h.prev; - tree[ptr].h.prev = fre; - last = tree[last].h.prev; - fre++; - } - // now assign depths recursively - setdepths (tree,2*lim,0); - H.s.spos = new uint[H.max+1]; - for (i=0;i<=(int)H.max;i++) H.s.spos[i] = ~0; - //H.num = (uint*)malloc(sizeof(uint)*(lim+1)); // - H.num = new uint[lim+1]; // max possible depth - d=0; - for (i=lim;i>=0;i--) { - H.s.spos[tree[i].symb] = i; - while ((int)tree[i].h.depth > d) - { H.num[d] = i+1; d++; } - } - H.num[d] = 0; - H.depth = d; - for (d=H.depth;d>0;d--) H.num[d] = H.num[d-1] - H.num[d]; - H.num[0] = (lim == 0); - //H.num = (uint*)realloc(H.num,(H.depth+1)*sizeof(uint)); - uint * Htmp = new uint[H.depth+1]; - for(uint i=0;i= W) { - *e &= ~((1<= W) { - *e++ = 0; - len -= W; - } - if (len > 0) - *e &= ~(((1<= H.num[d]) { - code = (code + H.num[d]) >> 1; - pos -= H.num[d--]; - } - code += pos; - if (d > W) { bitzero(stream,ptr,d-W); ptr += d-W; d = W; } - while (d--) { - if ((code >> d) & 1) cds_utils::bitset(stream,ptr); - else bitclean(stream,ptr); - ptr++; - } - return ptr; - } - - size_t decodeHuff (const THuff H, uint *symb, uint *stream, size_t ptr) { - uint pos; - uint d; - pos = 0; - d = 0; - while (pos < H.fst[d]) { - pos = (pos << 1) | bitget(stream,ptr); - ptr++; d++; - } - *symb = H.s.symb[H.num[d]+pos-H.fst[d]]; - return ptr; - } - - void saveHuff (const THuff H, ostream & f) { - uint *symb = new uint[H.lim+1]; - uint i; - for(i=0;i<(H.lim+1);i++) symb[i] = 0; - for (i=0;i<=H.max;i++) - if (H.s.spos[i] != (uint)~0) symb[H.s.spos[i]] = i; - saveValue(f,H.max); - saveValue(f,H.lim); - saveValue(f,H.depth); - saveValue(f,symb,H.lim+1); - saveValue(f,H.num,H.depth+1); - delete [] (symb); - } - - uint sizeHuff (const THuff H) { - return (4+(H.lim+1)+(H.depth+1))*sizeof(uint); - } - - void freeHuff (THuff H) { - delete [] H.s.spos; - //free(H.num); - delete [] H.num; - } - - THuff loadHuff (istream & f, int enc) { - THuff H; - uint *symb; - //uint *num; - uint i,d,dold,dact; - H.max = loadValue(f); - H.lim = loadValue(f); - H.depth = loadValue(f); - symb = loadValue(f,H.lim+1); - if (enc) { - H.s.spos = new uint[H.max+1]; - for (i=0;i<=H.max;i++) H.s.spos[i] = (uint)~0; - for (i=0;i<=H.lim;i++) H.s.spos[symb[i]] = i; - delete [] symb; - } - else H.s.symb = symb; - H.num = new uint[H.depth+1]; - H.num = loadValue(f,H.depth+1); - if (!enc) { - H.fst = new uint[H.depth+1]; - H.fst[H.depth] = 0; dold = 0; - for (d=H.depth-1;d!=(uint)-1;d--) { - dact = H.num[d+1]; - H.fst[d] = (H.fst[d+1]+dact) >> 1; - H.num[d+1] = dold; - dold += dact; - } - H.num[0] = dold; - } - return H; - } - -}; diff --git a/libcds/src/static/mapper/Makefile b/libcds/src/static/mapper/Makefile deleted file mode 100644 index 149d50b8..00000000 --- a/libcds/src/static/mapper/Makefile +++ /dev/null @@ -1,3 +0,0 @@ - -all: - @cp -f *.h ../../../includes/ diff --git a/libcds/src/static/mapper/Mapper.cpp b/libcds/src/static/mapper/Mapper.cpp deleted file mode 100644 index 45f3c565..00000000 --- a/libcds/src/static/mapper/Mapper.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* mapper.cpp - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * static_bitsequence definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - Mapper::Mapper() { - userCount=0; - } - - void Mapper::use() { - userCount++; - } - - void Mapper::unuse() { - userCount--; - assert(userCount>=0); - if(userCount==0) - delete this; - } - - Mapper * Mapper::load(istream & input) { - uint rd; - input.read((char*)&rd,sizeof(uint)); - size_t pos = input.tellg(); - input.seekg(pos-sizeof(uint)); - switch(rd) { - case MAPPER_NONE_HDR: return MapperNone::load(input); - case MAPPER_CONT_HDR: return MapperCont::load(input); - case MAPPER_REV_HDR: return MapperRev::load(input); - } - return NULL; - } -}; diff --git a/libcds/src/static/mapper/MapperCont.cpp b/libcds/src/static/mapper/MapperCont.cpp deleted file mode 100644 index 9f9aff7b..00000000 --- a/libcds/src/static/mapper/MapperCont.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* alphabet_mapper_cont.cpp - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * alphabet_mapper_cont definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - MapperCont::MapperCont(const Array & seq, const BitSequenceBuilder & bmb) { - BitString bs(seq.getMax()+1); - for(size_t i=0;irank1(s); - } - - uint MapperCont::unmap(uint s) const - { - return m->select1(s); - } - - size_t MapperCont::getSize() const - { - return sizeof(MapperCont)+m->getSize(); - } - - void MapperCont::save(ostream & out) const - { - assert(out.good()); - uint wr = MAPPER_CONT_HDR; - saveValue(out,wr); - m->save(out); - } - - MapperCont * MapperCont::load(istream & input) { - assert(input.good()); - uint rd = loadValue(input); - if(rd!=MAPPER_CONT_HDR) return NULL; - MapperCont * ret = new MapperCont(); - ret->m = BitSequence::load(input); - if(ret->m==NULL) { - delete ret; - return NULL; - } - return ret; - } -}; diff --git a/libcds/src/static/mapper/MapperNone.cpp b/libcds/src/static/mapper/MapperNone.cpp deleted file mode 100644 index 6dd75365..00000000 --- a/libcds/src/static/mapper/MapperNone.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* MapperNone.cpp - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * mapper definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - MapperNone::MapperNone() { } - - uint MapperNone::map(const uint s) const {return s;} - - uint MapperNone::unmap(const uint s) const {return s;} - - size_t MapperNone::getSize() const { return sizeof(MapperNone); } - - void MapperNone::save(ostream & out) const - { - uint wr = MAPPER_NONE_HDR; - out.write((char*)&wr,sizeof(uint)); - } - - MapperNone * MapperNone::load(istream & input) { - uint rd; - input.read((char*)&rd,sizeof(uint)); - if(rd!=MAPPER_NONE_HDR) return NULL; - return new MapperNone(); - } -}; diff --git a/libcds/src/static/mapper/MapperRev.cpp b/libcds/src/static/mapper/MapperRev.cpp deleted file mode 100644 index 2137cff0..00000000 --- a/libcds/src/static/mapper/MapperRev.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* MapperRev.cpp - * Copyright (C) 2012, Francisco Claude, all rights reserved. - * - * MapperRev definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include -#include - - using namespace cds_utils; - -namespace cds_static -{ - - // based on http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith64BitsDiv - uint reverse(const uint v) { - uint res = v; - const uchar *c = (const uchar*)&v; - uchar *c2 = (uchar*)&res; - c2[0] = (c[3] * 0x0202020202ULL & 0x010884422010ULL) % 1023; - c2[1] = (c[2] * 0x0202020202ULL & 0x010884422010ULL) % 1023; - c2[2] = (c[1] * 0x0202020202ULL & 0x010884422010ULL) % 1023; - c2[3] = (c[0] * 0x0202020202ULL & 0x010884422010ULL) % 1023; - return res; - } - - MapperRev::MapperRev() { } - MapperRev::MapperRev(const Array &a) { - uint maxv = 0; - for(uint i=0; i < a.getLength(); i++) - maxv = max(maxv, a.getField(i)); - this->bits = cds_utils::bits(maxv); - } - - MapperRev::MapperRev(const uint *A, const size_t len) { - uint maxv = 0; - for(uint i=0; i < len; i++) - maxv = max(maxv, A[i]); - this->bits = cds_utils::bits(maxv); - } - - uint MapperRev::map(const uint s) const { - uint rev = reverse(s); - return rev >> (31 - this->bits); - } - - uint MapperRev::unmap(const uint s) const {return map(s);} - - size_t MapperRev::getSize() const { return sizeof(MapperNone); } - - void MapperRev::save(ostream & out) const - { - uint wr = MAPPER_REV_HDR; - out.write((char*)&wr,sizeof(uint)); - out.write((char*)&this->bits,sizeof(uint)); - } - - MapperRev * MapperRev::load(istream & input) { - uint rd; - input.read((char*)&rd,sizeof(uint)); - if(rd!=MAPPER_REV_HDR) return NULL; - MapperRev * ret = new MapperRev(); - input.read((char*)&ret->bits, sizeof(uint)); - return ret; - } -}; diff --git a/libcds/src/static/permutation/Permutation.cpp b/libcds/src/static/permutation/Permutation.cpp deleted file mode 100644 index 8fc712b3..00000000 --- a/libcds/src/static/permutation/Permutation.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* Permutation.cpp - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include - -namespace cds_static -{ - - Permutation::Permutation() { length = 0; } - - Permutation::~Permutation() {} - - uint Permutation::pi(uint i) const - { - return pi(i,1); - } - - uint Permutation::revpi(uint i) const - { - return revpi(i,1); - } - - uint Permutation::pi(uint i, uint k) const - { - uint ret = i; - while(k-->0) - ret = pi(ret); - return ret; - } - - uint Permutation::revpi(uint i, uint k) const - { - uint ret = i; - while(k-->0) - ret = revpi(ret); - return ret; - } - - size_t Permutation::getLength() const - { - return length; - } - - void Permutation::save(ostream & fp) const - { - saveValue(fp,length); - } - - Permutation * Permutation::load(istream & fp) { - uint rd = loadValue(fp); - size_t pos = fp.tellg(); - fp.seekg(pos - sizeof(uint),ios::beg); - switch(rd) { - case MRRRPERM: return PermutationMRRR::load(fp); - break; - case WTPERM: return PermutationWT::load(fp); - break; - } - return NULL; - } - -}; diff --git a/libcds/src/static/permutation/PermutationBuilderMRRR.cpp b/libcds/src/static/permutation/PermutationBuilderMRRR.cpp deleted file mode 100644 index 9124c0c6..00000000 --- a/libcds/src/static/permutation/PermutationBuilderMRRR.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* PermutationBuilderMRRR.cpp - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include -#include - -namespace cds_static -{ - PermutationBuilderMRRR::PermutationBuilderMRRR(uint sample, BitSequenceBuilder * bmb) { - this->sample = sample; - this->bmb = bmb; - bmb->use(); - } - - PermutationBuilderMRRR::~PermutationBuilderMRRR() { - bmb->unuse(); - } - - Permutation * PermutationBuilderMRRR::build(uint * perm, uint len) const - { - return new PermutationMRRR(perm,len,sample,bmb); - } - -}; diff --git a/libcds/src/static/permutation/PermutationBuilderWT.cpp b/libcds/src/static/permutation/PermutationBuilderWT.cpp deleted file mode 100644 index b57cc02b..00000000 --- a/libcds/src/static/permutation/PermutationBuilderWT.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/** - * PermutationBuilderWT.cpp - * Copyright (C) 2011 Francisco Claude F. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -namespace cds_static -{ - Permutation * PermutationBuilderWT::build(uint * perm, uint len) const - { - return new PermutationWT(perm,len); - } -} diff --git a/libcds/src/static/permutation/PermutationMRRR.cpp b/libcds/src/static/permutation/PermutationMRRR.cpp deleted file mode 100644 index 935072aa..00000000 --- a/libcds/src/static/permutation/PermutationMRRR.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* PermutationMRRR.cpp - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * Permutation - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - PermutationMRRR::PermutationMRRR(uint * elems, uint nelems, uint t, BitSequenceBuilder * bmb) { - permutation = createPerm(elems, nelems, t, bmb); - } - - PermutationMRRR::PermutationMRRR() { - } - - PermutationMRRR::~PermutationMRRR() { - destroyPerm(permutation); - } - - size_t PermutationMRRR::getSize() const - { - return sizeof(PermutationMRRR)+sizeofPerm(permutation); - } - - uint PermutationMRRR::pi(uint i) const - { - return getelemPerm(permutation,i); - } - - uint PermutationMRRR::revpi(uint i) const - { - return inversePerm(permutation,i); - } - - void PermutationMRRR::save(ostream & fp) const - { - uint wr = MRRRPERM; - saveValue(fp,wr); - savePerm(permutation,fp); - } - - PermutationMRRR * PermutationMRRR::load(istream & fp) { - uint rd = loadValue(fp); - if(rd!=MRRRPERM) return NULL; - PermutationMRRR * ret = new PermutationMRRR(); - ret->permutation = loadPerm(fp); - return ret; - } - -}; diff --git a/libcds/src/static/permutation/PermutationWT.cpp b/libcds/src/static/permutation/PermutationWT.cpp deleted file mode 100644 index 34c862e7..00000000 --- a/libcds/src/static/permutation/PermutationWT.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/** - * PermutationWT.cpp - * Copyright (C) 2011 Francisco Claude F. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -namespace cds_static -{ - - PermutationWT::PermutationWT(uint *perm, size_t len) { - uint b = bits(len-1); - uint * seq = new uint[len]; - uint * marker = new uint[uint_len(len,1)]; - for(size_t i=0;i get_field(perm,b,i)) { - runs++; - cds_utils::bitset(marker,i); - } - seq[get_field(perm,b,i)] = runs; - last = get_field(perm,b,i); - } - - wt = new WaveletTreeNoptrs(seq, len, new BitSequenceBuilderRRR(40), new MapperNone()); - marks = new BitSequenceRG(marker, len, 20); - delete [] seq; - } - - PermutationWT::~PermutationWT() { - delete wt; - } - - uint PermutationWT::pi(uint k) const - { - uint v = (uint)marks->rank1(k); - return (uint)wt->select(v-1, k - marks->select1(v) + 1); - } - - uint PermutationWT::revpi(uint k) const - { - size_t val = 0; - uint s = wt->access(k, val); - return marks->select1(s+1) + val - 1; - } - - size_t PermutationWT::getSize() const - { - return marks->getSize()+wt->getSize()+sizeof(PermutationWT); - } - - void PermutationWT::save(ostream & out) const - { - saveValue(out,WTPERM); - saveValue(out, length); - wt->save(out); - marks->save(out); - } - - PermutationWT * PermutationWT::load(istream &in) { - uint rd = loadValue(in); - if(rd!=WTPERM) return NULL; - PermutationWT * ret = new PermutationWT(); - ret->length = loadValue(in); - ret->wt = Sequence::load(in); - ret->marks = BitSequence::load(in); - return ret; - } -}; diff --git a/libcds/src/static/permutation/perm.cpp b/libcds/src/static/permutation/perm.cpp deleted file mode 100644 index dbbf1719..00000000 --- a/libcds/src/static/permutation/perm.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/* perm.cpp - * Copyright (C) 2005, Diego Arroyuelo, all rights reserved. - * Copyright (C) 2009, Francisco Claude - * - * Permutation - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - int compare(const void *p1, const void *p2) { - return ((auxbwd *)p1)->key - ((auxbwd *)p2)->key; - } - - perm createPerm(uint *elems, uint nelems, uint t, BitSequenceBuilder * bmb) { - perm P; - uint *b, *baux, nextelem, i, j, bptr, - aux, antbptr,nbwdptrs, elem,nbits, cyclesize; - auxbwd *auxbwdptr; - P = new struct sperm; - P->elems = elems; - P->nelems = nelems; - P->nbits = bits(nelems-1); - nbits = bits(nelems-1); - P->t = t; - if (t==1) { - P->bwdptrs = new uint[uint_len(nelems,nbits)]; - assert(P->bwdptrs!=NULL); - P->nbwdptrs = nelems; - for (i=0; ibwdptrs, nbits, bg, i); - } - P->bmap = NULL; - } - else { - b = new uint[uint_len(nelems,1)]; - for(i=0;i= t) { - nbwdptrs++; - antbptr = bptr; - bptr = j; - aux = 0; - cds_utils::bitset(b, j); - } - cyclesize++; - } - if (cyclesize >= t) { - nbwdptrs++; - cds_utils::bitset(b, nextelem); - } - } - } - auxbwdptr = new auxbwd[nbwdptrs]; - assert(auxbwdptr!=NULL); - for(i=0;i= t) { - auxbwdptr[nbwdptrs].key = j; - auxbwdptr[nbwdptrs++].pointer = bptr; - antbptr = bptr; - bptr = j; - aux = 0; - cds_utils::bitset(b, j); - } - cyclesize++; - } - if (cyclesize >= t) { - auxbwdptr[nbwdptrs].key = nextelem; - auxbwdptr[nbwdptrs++].pointer = bptr; - cds_utils::bitset(b, nextelem); - } - } - } - qsort(auxbwdptr, nbwdptrs, sizeof(auxbwd), &compare); - aux = uint_len(nbwdptrs,P->nbits); - P->bwdptrs = new uint[aux]; - assert(P->bwdptrs!=NULL); - for(i=0;ibwdptrs[i] = 0; - P->nbwdptrs = nbwdptrs; - for (i = 0; i < nbwdptrs; i++) { - set_field(P->bwdptrs, nbits, i, auxbwdptr[i].pointer); - //if(i<5) - // printf(" %d ",get_field(P->bwdptrs,nbits,i)); - } - //printf("\n"); - P->bmap = bmb->build(b, nelems); - //delete [] P->bmap; - delete [] b; - delete [] (baux); - delete [] (auxbwdptr); - } - return P; - } - - void destroyPerm(perm P) { - delete [] P->elems; - if (P->bmap) delete P->bmap; - delete [] P->bwdptrs; - delete P; - } - - // Computes P-1[i] - uint inversePerm(const perm P, uint i) { - uint j, elem; - if (P->t==1) { - j = get_field(P->bwdptrs,P->nbits,i); - } - else { - j = i; - while (((elem=get_field(P->elems,P->nbits,j)) != i)&&(!P->bmap->access(j))) - j = elem; - - if (elem != i) { - // follows the backward pointer - j = get_field(P->bwdptrs, P->nbits, P->bmap->rank1(j-1)); - while ((elem = get_field(P->elems,P->nbits,j))!= i) - j = elem; - } - } - return j; - } - - // gets the ith element of a perm P - - uint getelemPerm(const perm P, uint i) { - return get_field(P->elems, P->nbits, i); - } - - uint savePerm(const perm P, ostream & f) { - uint aux; - uint v; - - saveValue(f,P->nelems); - saveValue(f,P->elems,uint_len(P->nelems,P->nbits)); - - aux = ((P->nelems+W-1)/W); - - if (P->bmap) { - v=1; - saveValue(f,v); - P->bmap->save(f); - } - else { - v=0; - saveValue(f,v); - } - - saveValue(f,P->nbwdptrs); - aux = uint_len(P->nbwdptrs,P->nbits); - saveValue(f,P->bwdptrs,aux); - saveValue(f,P->t); - return 0; - } - - perm loadPerm(istream & f) { - uint aux; - perm P; - uint v; - - P = new struct sperm; //(struct sperm*) malloc(sizeof(struct sperm)); - - P->nelems = loadValue(f); - - P->nbits = bits(P->nelems-1); - aux = uint_len(P->nelems,P->nbits); - P->elems = loadValue(f,aux); - - v = loadValue(f); - - if (v) { - P->bmap = BitSequence::load(f); - } - else P->bmap = NULL; - - P->nbwdptrs = loadValue(f); - - aux = uint_len(P->nbwdptrs,P->nbits); - P->bwdptrs = loadValue(f,aux); - - P->t = loadValue(f); - - return P; - } - - uint sizeofPerm(perm P) { - return sizeof(struct sperm) + - ((uint_len(P->nelems,P->nbits))*sizeof(uint)) + - ((P->bmap)?(P->bmap->getSize()):0) + - ((uint_len(P->nbwdptrs,P->nbits))*sizeof(uint)); - } - -}; diff --git a/libcds/src/static/sequence/BitmapsSequence.cpp b/libcds/src/static/sequence/BitmapsSequence.cpp deleted file mode 100644 index 7cf3d508..00000000 --- a/libcds/src/static/sequence/BitmapsSequence.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/* BitmapsSequence.cpp - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include - -namespace cds_static -{ - BitmapsSequence::BitmapsSequence(uint * seq, size_t n, Mapper * am, BitSequenceBuilder * bsb) : Sequence(n) { - bsb->use(); - sigma = 0; - //length = n; - this->am = am; - am->use(); - for(uint i=0;imap(seq[i])); - sigma++; - uint * occ = new uint[sigma+1]; - for(uint i=0;i<=sigma;i++) occ[i] = 0; - for(uint i=0;imap(seq[i])+1]++; - for(uint i=1;imap(seq[i])]++]=i; - bitmaps = new BitSequence*[sigma]; - uint * bm = new uint[uint_len(n,1)]; - uint pp=0; - for(uint i=0;ibuild(bm,length); - } - delete [] bm; - delete [] occ; - delete [] pos; - bsb->unuse(); - } - - BitmapsSequence::BitmapsSequence() : Sequence(0) { - length = 0; - sigma = 0; - bitmaps = NULL; - am = NULL; - } - - BitmapsSequence::BitmapsSequence(const Array &a, Mapper * am, BitSequenceBuilder * bsb) : Sequence(0) { - bsb->use(); - length = a.getLength(); - //cout << "length=" << length << endl; - sigma = a.getMax()+1; - //cout << "sigma=" << sigma << endl; - this->am = am; - am->use(); - uint * occ = new uint[sigma+1]; - for(uint i=0;i<=sigma;i++) occ[i] = 0; - for(uint i=0;imap(a[i])+1]++; - for(uint i=1;imap(a[i])]++]=i; - bitmaps = new BitSequence*[sigma]; - uint * bm = new uint[uint_len(length,1)]; - uint pp=0; - for(uint i=0;igetSize()=" << groupsIndex->getSize() << endl; - ret += sizeof(SequenceAlphPart); - return ret; - } - - void SequenceAlphPart::save(ostream & fp) const - { - uint type = ALPHPART_HDR; - saveValue(fp,type); - saveValue(fp,length); - saveValue(fp,sigma); - saveValue(fp,origsigma); - saveValue(fp,maxLen); - saveValue(fp,cut); - saveValue(fp,revPermFreq,sigma+1); - saveValue(fp,alphSortedByFreq,sigma+1); - groupsIndex->save(fp); - for(uint i=0;maxLen>cut && isave(fp); - } - - SequenceAlphPart * SequenceAlphPart::load(istream & fp) { - uint type = loadValue(fp); - if(type!=ALPHPART_HDR) - return NULL; - SequenceAlphPart * ret = new SequenceAlphPart(); - ret->length = loadValue(fp); - ret->sigma = loadValue(fp); - ret->origsigma = loadValue(fp); - ret->maxLen = loadValue(fp); - ret->cut = loadValue(fp); - ret->revPermFreq = loadValue(fp,ret->sigma+1); - ret->alphSortedByFreq = loadValue(fp,ret->sigma+1); - ret->groupsIndex = Sequence::load(fp); - ret->indexesByLength = new Sequence*[(ret->maxLen<=ret->cut)?0:(ret->maxLen-ret->cut)]; - for(uint i=0;ret->maxLen>ret->cut && imaxLen-ret->cut;i++) - ret->indexesByLength[i] = Sequence::load(fp); - return ret; - } - -}; diff --git a/libcds/src/static/sequence/SequenceBuilderAlphPart.cpp b/libcds/src/static/sequence/SequenceBuilderAlphPart.cpp deleted file mode 100644 index c3adb2a3..00000000 --- a/libcds/src/static/sequence/SequenceBuilderAlphPart.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* SequenceBuilderAlphPart.cpp - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include - -namespace cds_static -{ - - SequenceBuilderAlphPart::SequenceBuilderAlphPart(SequenceBuilder * groupIndexBuilder, SequenceBuilder * indexBuilder, uint cut) { - this->groupIndexBuilder = groupIndexBuilder; - this->indexBuilder = indexBuilder; - this->cut = cut; - groupIndexBuilder->use(); - indexBuilder->use(); - } - - SequenceBuilderAlphPart::~SequenceBuilderAlphPart() { - groupIndexBuilder->unuse(); - indexBuilder->unuse(); - } - - Sequence * SequenceBuilderAlphPart::build(uint * sequence, size_t len) { - return new SequenceAlphPart(sequence,len,cut,groupIndexBuilder,indexBuilder); - } - - Sequence * SequenceBuilderAlphPart::build(const Array & seq) { - return new SequenceAlphPart(seq,cut,groupIndexBuilder,indexBuilder); - } -}; diff --git a/libcds/src/static/sequence/SequenceBuilderGMR.cpp b/libcds/src/static/sequence/SequenceBuilderGMR.cpp deleted file mode 100644 index 4bd203ba..00000000 --- a/libcds/src/static/sequence/SequenceBuilderGMR.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* SequenceBuilderGMR.cpp - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include - -namespace cds_static -{ - - SequenceBuilderGMR::SequenceBuilderGMR(BitSequenceBuilder * bsb, SequenceBuilder * sqb, uint chunk_len) { - this->bsb = bsb; - this->sqb = sqb; - this->chunk_len = chunk_len; - bsb->use(); - sqb->use(); - } - - SequenceBuilderGMR::~SequenceBuilderGMR() { - bsb->unuse(); - sqb->unuse(); - } - - Sequence * SequenceBuilderGMR::build(uint * sequence, size_t len) { - uint cl = chunk_len; - if(chunk_len==0) { - uint s=0; - for(size_t i=0;i - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include - -namespace cds_static -{ - - SequenceBuilderGMRChunk::SequenceBuilderGMRChunk(BitSequenceBuilder * bsb, PermutationBuilder * pmb) { - this->bsb = bsb; - this->pmb = pmb; - bsb->use(); - pmb->use(); - } - - SequenceBuilderGMRChunk::~SequenceBuilderGMRChunk() { - bsb->unuse(); - pmb->unuse(); - } - - Sequence * SequenceBuilderGMRChunk::build(uint * sequence, size_t len) { - return new SequenceGMRChunk(sequence, len, bsb, pmb); - } - - Sequence * SequenceBuilderGMRChunk::build(const Array & seq) { - return new SequenceGMRChunk(seq, bsb, pmb); - } - -}; diff --git a/libcds/src/static/sequence/SequenceBuilderStr.cpp b/libcds/src/static/sequence/SequenceBuilderStr.cpp deleted file mode 100644 index ad83e72c..00000000 --- a/libcds/src/static/sequence/SequenceBuilderStr.cpp +++ /dev/null @@ -1,320 +0,0 @@ -/* SequenceBuilderStr.cpp - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -#include -#include - -namespace cds_static -{ - SequenceBuilderStr::SequenceBuilderStr(const string & str) { - this->str = str; - } - - SequenceBuilderStr::~SequenceBuilderStr() { } - - Sequence * SequenceBuilderStr::build(uint *seq, size_t len) { - /*SequenceBuilder * b = getBuilder(seq,len); - Sequence * ret = b->build(seq,len); - delete b; - return ret; - */ - return NULL; - } - - Sequence * SequenceBuilderStr::build(const Array & seq) { - SequenceBuilder * b = getBuilder(seq); - Sequence * ret = b->build(seq); - delete b; - return ret; - } - - SequenceBuilder * SequenceBuilderStr::getBuilder(const Array & seq) { - vector params; - tokenize(str,params,';'); - map values; - for(uint i=1;i res; - tokenize(params[i],res,'='); - if(res.size()==2) - values[res[0]]=res[1]; - else - values[params[i]]=""; - } - #ifdef VERBOSE - cout << "params[0]=" << params[0] << endl; - #endif - if(params[0]=="WaveletTree") { - BitSequenceBuilder * bsb = NULL; - if(values.find("bitseq")==values.end()) return NULL; - if(values.find("bitsamp")==values.end()) return NULL; - uint samp = transform(values["bitsamp"]); - if(values["bitseq"]=="BitSequenceRG") { - bsb = new BitSequenceBuilderRG(samp); - #ifdef VERBOSE - cout << "bitseq=BitSequenceRG" << endl; - #endif - } - else if(values["bitseq"]=="BitSequenceRRR") { - bsb = new BitSequenceBuilderRRR(samp); - #ifdef VERBOSE - cout << "bitseq=BitSequenceRRR" << endl; - #endif - } - else if(values["bitseq"]=="BitSequenceSDArray") { - bsb = new BitSequenceBuilderSDArray(); - #ifdef VERBOSE - cout << "bitseq=BitSequenceSDArray" << endl; - #endif - } - else if(values["bitseq"]=="BitSequenceDArray") { - bsb = new BitSequenceBuilderDArray(); - #ifdef VERBOSE - cout << "bitseq=BitSequenceDArray" << endl; - #endif - } - else { - return NULL; - } - #ifdef VERBOSE - cout << "samp=" << samp << endl; - #endif - if(values.find("mapper")==values.end()) return NULL; - Mapper * am = NULL; - if(values["mapper"]=="MapperCont") { - am = new MapperCont(seq, *bsb); - #ifdef VERBOSE - cout << "mapper=MapperCont" << endl; - #endif - } - else if(values["mapper"]=="MapperNone") { - am = new MapperNone(); - #ifdef VERBOSE - cout << "mapper=MapperNone" << endl; - #endif - } - else { - delete bsb; - return NULL; - } - if(values.find("shape")==values.end()) return NULL; - wt_coder * wc = NULL; - if(values["shape"]=="Huffman") { - wc = new wt_coder_huff(seq, am); - #ifdef VERBOSE - cout << "shape=Huffman" << endl; - #endif - } - else if(values["shape"]=="Plain") { - wc = new wt_coder_binary(seq, am); - #ifdef VERBOSE - cout << "shape=Plain" << endl; - #endif - } - else { - delete bsb; - delete am; - return NULL; - } - return new SequenceBuilderWaveletTree(bsb, am, wc); - } - else if(params[0]=="WaveletTreeNoptrs") { - BitSequenceBuilder * bsb = NULL; - if(values.find("bitseq")==values.end()) return NULL; - if(values.find("bitsamp")==values.end()) return NULL; - uint samp = transform(values["bitsamp"]); - if(values["bitseq"]=="BitSequenceRG") { - bsb = new BitSequenceBuilderRG(samp); - } - else if(values["bitseq"]=="BitSequenceRRR") { - bsb = new BitSequenceBuilderRRR(samp); - } - else if(values["bitseq"]=="BitSequenceSDArray") { - bsb = new BitSequenceBuilderSDArray(); - } - else if(values["bitseq"]=="BitSequenceDArray") { - bsb = new BitSequenceBuilderDArray(); - } - else { - return NULL; - } - if(values.find("mapper")==values.end()) return NULL; - Mapper * am = NULL; - if(values["mapper"]=="MapperCont") { - am = new MapperCont(seq,*bsb); - } - else if(values["mapper"]=="MapperNone") { - am = new MapperNone(); - } - else { - delete bsb; - return NULL; - } - return new SequenceBuilderWaveletTreeNoptrs(bsb,am); - } - else if(params[0]=="WaveletMatrix") { - BitSequenceBuilder * bsb = NULL; - if(values.find("bitseq")==values.end()) return NULL; - if(values.find("bitsamp")==values.end()) return NULL; - uint samp = transform(values["bitsamp"]); - if(values["bitseq"]=="BitSequenceRG") { - bsb = new BitSequenceBuilderRG(samp); - } - else if(values["bitseq"]=="BitSequenceRRR") { - bsb = new BitSequenceBuilderRRR(samp); - } - else if(values["bitseq"]=="BitSequenceSDArray") { - bsb = new BitSequenceBuilderSDArray(); - } - else if(values["bitseq"]=="BitSequenceDArray") { - bsb = new BitSequenceBuilderDArray(); - } - else { - return NULL; - } - if(values.find("mapper")==values.end()) return NULL; - Mapper * am = NULL; - if(values["mapper"]=="MapperCont") { - am = new MapperCont(seq,*bsb); - } - else if(values["mapper"]=="MapperNone") { - am = new MapperNone(); - } - else if(values["mapper"]=="MapperRev") { - am = new MapperRev(seq); - } - else { - delete bsb; - return NULL; - } - return new SequenceBuilderWaveletMatrix(bsb,am); - } - else if(params[0]=="SequenceGMR") { - BitSequenceBuilder * bsb = NULL; - if(values.find("bitseq")==values.end()) return NULL; - if(values.find("bitsamp")==values.end()) return NULL; - uint samp = transform(values["bitsamp"]); - if(values.find("chunklen")==values.end()) return NULL; - uint chunklen = transform(values["chunklen"]); - if(values.find("permsamp")==values.end()) return NULL; - uint permsamp = transform(values["permsamp"]); - if(values["bitseq"]=="BitSequenceRG") { - bsb = new BitSequenceBuilderRG(samp); - } - else if(values["bitseq"]=="BitSequenceRRR") { - bsb = new BitSequenceBuilderRRR(samp); - } - else if(values["bitseq"]=="BitSequenceSDArray") { - bsb = new BitSequenceBuilderSDArray(); - } - else if(values["bitseq"]=="BitSequenceDArray") { - bsb = new BitSequenceBuilderDArray(); - } - else { - return NULL; - } - if(values.find("mapper")==values.end()) return NULL; - Mapper * am = NULL; - if(values["mapper"]=="MapperCont") { - am = new MapperCont(seq,*bsb); - } - else if(values["mapper"]=="MapperNone") { - am = new MapperNone(); - } - else { - delete bsb; - return NULL; - } - PermutationBuilder * pb = new PermutationBuilderMRRR(permsamp,bsb); - SequenceBuilder * sb1 = new SequenceBuilderGMRChunk(bsb,pb); - return new SequenceBuilderGMR(bsb,sb1,chunklen); - } - else if(params[0]=="SequenceAlphPart") { - BitSequenceBuilder * bsb = NULL; - if(values.find("bitseq")==values.end()) return NULL; - if(values.find("bitsamp")==values.end()) return NULL; - uint samp = transform(values["bitsamp"]); - if(values["bitseq"]=="BitSequenceRG") { - bsb = new BitSequenceBuilderRG(samp); - } - else if(values["bitseq"]=="BitSequenceRRR") { - bsb = new BitSequenceBuilderRRR(samp); - } - else if(values["bitseq"]=="BitSequenceSDArray") { - bsb = new BitSequenceBuilderSDArray(); - } - else if(values["bitseq"]=="BitSequenceDArray") { - bsb = new BitSequenceBuilderDArray(); - } - else { - return NULL; - } - if(values.find("mapper")==values.end()) return NULL; - Mapper * am = NULL; - if(values["mapper"]=="MapperCont") { - am = new MapperCont(seq,*bsb); - } - else if(values["mapper"]=="MapperNone") { - am = new MapperNone(); - } - else { - delete bsb; - return NULL; - } - if(values.find("shape")==values.end()) return NULL; - wt_coder * wc = NULL; - if(values["shape"]=="Huffman") { - wc = NULL; // new wt_coder_huff(seq,am); - } - else if(values["shape"]=="Plain") { - wc = new wt_coder_binary(seq,am); - } - else { - delete bsb; - delete am; - return NULL; - } - SequenceBuilder * fstin = new SequenceBuilderWaveletTree(bsb,am,wc); - if(values.find("cut")==values.end()) return NULL; - uint cut = transform(values["cut"]); - if(values.find("permsamp")==values.end()) return NULL; - uint permsamp = transform(values["permsamp"]); - PermutationBuilder * pb = new PermutationBuilderMRRR(permsamp,bsb); - SequenceBuilder * scb = new SequenceBuilderGMRChunk(bsb,pb); - SequenceBuilder * sec = new SequenceBuilderGMR(bsb,scb); - return new SequenceBuilderAlphPart(fstin,sec,cut); - //return new SequenceBuilderAlphPart(fstin,fstin,cut); - } - return NULL; - } -}; diff --git a/libcds/src/static/sequence/SequenceBuilderWaveletMatrix.cpp b/libcds/src/static/sequence/SequenceBuilderWaveletMatrix.cpp deleted file mode 100644 index 9cf719b8..00000000 --- a/libcds/src/static/sequence/SequenceBuilderWaveletMatrix.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* SequenceBuilderWaveletMatrix.cpp - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include - -namespace cds_static -{ - - SequenceBuilderWaveletMatrix::SequenceBuilderWaveletMatrix(BitSequenceBuilder * bsb, Mapper * am) { - this->bsb = bsb; - this->am = am; - bsb->use(); - am->use(); - } - - SequenceBuilderWaveletMatrix::~SequenceBuilderWaveletMatrix() { - bsb->unuse(); - am->unuse(); - } - - Sequence * SequenceBuilderWaveletMatrix::build(uint * sequence, size_t len) { - return new WaveletMatrix(sequence, len, bsb, am); - } - - Sequence * SequenceBuilderWaveletMatrix::build(const Array & seq) { - return new WaveletMatrix(seq, bsb, am); - } -}; diff --git a/libcds/src/static/sequence/SequenceBuilderWaveletTree.cpp b/libcds/src/static/sequence/SequenceBuilderWaveletTree.cpp deleted file mode 100644 index d927600b..00000000 --- a/libcds/src/static/sequence/SequenceBuilderWaveletTree.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* SequenceBuilderWaveletTree.cpp - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include - -namespace cds_static -{ - - SequenceBuilderWaveletTree::SequenceBuilderWaveletTree(BitSequenceBuilder * bsb, Mapper * am, wt_coder * wc) { - this->bsb = bsb; - this->am = am; - this->wc = wc; - bsb->use(); - am->use(); - if(wc!=NULL) - wc->use(); - } - - SequenceBuilderWaveletTree::~SequenceBuilderWaveletTree() { - bsb->unuse(); - am->unuse(); - if(wc!=NULL) - wc->unuse(); - } - - Sequence * SequenceBuilderWaveletTree::build(uint * sequence, size_t len) { - Sequence * ret; - if(wc==NULL) { - wt_coder * wcaux = new wt_coder_huff(sequence,len,am); - wcaux->use(); - ret = new WaveletTree(sequence, len, wcaux, bsb, am); - wcaux->unuse(); - } - else { - ret = new WaveletTree(sequence, len, wc, bsb, am); - } - return ret; - } - - Sequence * SequenceBuilderWaveletTree::build(const Array & seq) { - Sequence * ret; - if(wc==NULL) { - wt_coder * wcaux = new wt_coder_huff(seq,am); - wcaux->use(); - ret = new WaveletTree(seq, wcaux, bsb, am); - wcaux->unuse(); - } - else { - ret = new WaveletTree(seq, wc, bsb, am); - } - return ret; - } -}; diff --git a/libcds/src/static/sequence/SequenceBuilderWaveletTreeNoptrs.cpp b/libcds/src/static/sequence/SequenceBuilderWaveletTreeNoptrs.cpp deleted file mode 100644 index a4253d18..00000000 --- a/libcds/src/static/sequence/SequenceBuilderWaveletTreeNoptrs.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* SequenceBuilderWaveletTreeNoptrs.cpp - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include - -namespace cds_static -{ - - SequenceBuilderWaveletTreeNoptrs::SequenceBuilderWaveletTreeNoptrs(BitSequenceBuilder * bsb, Mapper * am) { - this->bsb = bsb; - this->am = am; - bsb->use(); - am->use(); - } - - SequenceBuilderWaveletTreeNoptrs::~SequenceBuilderWaveletTreeNoptrs() { - bsb->unuse(); - am->unuse(); - } - - Sequence * SequenceBuilderWaveletTreeNoptrs::build(uint * sequence, size_t len) { - return new WaveletTreeNoptrs(sequence, len, bsb, am); - } - - Sequence * SequenceBuilderWaveletTreeNoptrs::build(const Array & seq) { - return new WaveletTreeNoptrs(seq, bsb, am); - } -}; diff --git a/libcds/src/static/sequence/SequenceBuilderWaveletTreeNoptrsS.cpp b/libcds/src/static/sequence/SequenceBuilderWaveletTreeNoptrsS.cpp deleted file mode 100644 index 70bae4c1..00000000 --- a/libcds/src/static/sequence/SequenceBuilderWaveletTreeNoptrsS.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* SequenceBuilderWaveletTreeNoptrsS.cpp - * Copyright (C) 2012, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include - -namespace cds_static { - - SequenceBuilderWaveletTreeNoptrsS::SequenceBuilderWaveletTreeNoptrsS(BitSequenceBuilder * bsb, Mapper * am) { - this->bsb = bsb; - this->am = am; - bsb->use(); - am->use(); - } - - SequenceBuilderWaveletTreeNoptrsS::~SequenceBuilderWaveletTreeNoptrsS() { - bsb->unuse(); - am->unuse(); - } - - Sequence * SequenceBuilderWaveletTreeNoptrsS::build(uint * sequence, size_t len) { - return new WaveletTreeNoptrsS(sequence, len, bsb, am); - } - - Sequence * SequenceBuilderWaveletTreeNoptrsS::build(const Array & seq) { - return new WaveletTreeNoptrsS(seq, bsb, am); - } -}; - - diff --git a/libcds/src/static/sequence/SequenceGMR.cpp b/libcds/src/static/sequence/SequenceGMR.cpp deleted file mode 100644 index 28ec50b8..00000000 --- a/libcds/src/static/sequence/SequenceGMR.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/* SequenceGMR.cpp - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * GMR - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include -namespace cds_static -{ - -#ifndef WIN32 - using std::max; -#endif - SequenceGMR::SequenceGMR(uint * sequence, size_t n, uint chunk_length, BitSequenceBuilder * bmb, SequenceBuilder * ssb) : Sequence(n) { - bmb->use(); - ssb->use(); - length = n; - - //cout << "length1=" << length << endl; - if(length%chunk_length) length+=chunk_length-length%chunk_length; - //cout << "length2=" << length << endl; - uint * new_seq = new uint[length]; - sigma = 0; - for(uint i=0;iuse(); - bmb->use(); - sigma = 0; - for(uint i=0;iX = bmb->build(X_bitmap,X_pos); - assert(X!=NULL); - delete [] X_bitmap; - this->permutation = pmb->build(pi,chunk_length); - assert(permutation!=NULL); - delete [] counter; - pmb->unuse(); - bmb->unuse(); - } - - SequenceGMRChunk::SequenceGMRChunk(const Array & sequence, BitSequenceBuilder *bmb, PermutationBuilder *pmb) : Sequence(0) { - pmb->use(); - bmb->use(); - uint chunk_length = sequence.getLength(); - length = chunk_length; - sigma = 0; - for(uint i=0;iX = bmb->build(X_bitmap,X_pos); - assert(X!=NULL); - delete [] X_bitmap; - this->permutation = pmb->build(pi,chunk_length); - assert(permutation!=NULL); - delete [] counter; - pmb->unuse(); - bmb->unuse(); - } - SequenceGMRChunk::SequenceGMRChunk() : Sequence(0) { - } - - SequenceGMRChunk::~SequenceGMRChunk() { - delete X; - delete permutation; - } - - uint SequenceGMRChunk::access(size_t j2) const - { - uint j = (uint)j2; - uint invPerm = permutation->revpi(j); - uint rank_pos = X->select1(invPerm+1); - uint ret = rank_pos - X->rank1(rank_pos); - return ret; - } - - size_t SequenceGMRChunk::select(uint i, size_t j2) const - { - uint j = (uint)j2; - uint pos = X->select0(i+1) + j - i -1; - return permutation->pi(pos); - } - - size_t SequenceGMRChunk::rank(uint i, size_t j2) const - { - uint j = (uint)j2; - uint ini = X->select0(i+1)-i; - uint ini_o = ini; - uint fin = X->select0(i+2); - if(fin+1==0) return 0; - if(finpi(ini) > j) return 0; - if(permutation->pi(ini) == j) return 1; - if(ini==fin) return 1; - if(ini>fin) return 0; - while(ini < fin-1) { - uint med = (ini+fin)/2; - uint elem = permutation->pi(med); - if(elem >= j) fin = med; - else ini = med; - } - while(fin>ini_o && permutation->pi(fin)>j) fin--; - return fin-ini_o+1; - } - - size_t SequenceGMRChunk::getSize() const - { - return sizeof(SequenceGMRChunk)+permutation->getSize()+X->getSize(); - } - - void SequenceGMRChunk::save(ostream & fp) const - { - uint wr = GMR_CHUNK_HDR; - saveValue(fp,wr); - saveValue(fp,length); - saveValue(fp,sigma); - X->save(fp); - permutation->save(fp); - } - - SequenceGMRChunk * SequenceGMRChunk::load(istream & fp) { - uint rd = loadValue(fp); - if(rd!=GMR_CHUNK_HDR) return NULL; - SequenceGMRChunk * ret = new SequenceGMRChunk(); - ret->length = loadValue(fp); - ret->sigma = loadValue(fp); - ret->X = BitSequence::load(fp); - ret->permutation = Permutation::load(fp); - return ret; - } - -}; diff --git a/libcds/src/static/sequence/WaveletMatrix.cpp b/libcds/src/static/sequence/WaveletMatrix.cpp deleted file mode 100644 index c92a156d..00000000 --- a/libcds/src/static/sequence/WaveletMatrix.cpp +++ /dev/null @@ -1,363 +0,0 @@ -/* WaveletMatrix.cpp - * Copyright (C) 2012, Francisco Claude & Gonzalo Navarro, all rights reserved. - * - * WaveletMatrix definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - WaveletMatrix::WaveletMatrix(const Array &symbols2, BitSequenceBuilder * bmb, Mapper * am) : Sequence(n) { - bmb->use(); - n = symbols2.getLength(); - uint *symbols = new uint[n]; - this->am = am; - am->use(); - for(uint i = 0; i < n; i++) - symbols[i] = am->map(symbols2.getField(i)); - max_v = max_value(symbols, n); - height = bits(max_v); - - OCC = new uint[max_v + 2]; - for (uint i = 0; i <= max_v + 1; i++) - OCC[i] = 0; - for (uint i = 0; i < n; i++) - OCC[symbols[i] + 1]++; - - uint to_add = 0; - for (uint i = 1; i <= max_v + 1; i++) - if (OCC[i] == 0) to_add++; - - uint * new_symb = new uint[n + to_add]; - for (uint i = 0; i < n; i++) - new_symb[i] = symbols[i]; - delete [] symbols; - - to_add = 0; - for (uint i = 1; i <= max_v + 1; i++) - if (OCC[i] == 0) { - OCC[i]++; - new_symb[n + to_add] = i - 1; - to_add++; - } - - uint new_n = n + to_add; - for(uint i = 1;i <= max_v + 1; i++) - OCC[i] += OCC[i - 1]; - this->n = new_n; - - uint **_bm=new uint*[height]; - for(uint i = 0; i < height; i++) { - _bm[i] = new uint[new_n / W + 1]; - for(uint j = 0;j < new_n / W + 1; j++) - _bm[i][j] = 0; - } - - build_level(_bm, new_symb, new_n, NULL); - bitstring = new BitSequence*[height]; - C = new uint[height]; - for(uint i = 0; i < height; i++) { - bitstring[i] = bmb->build(_bm[i], new_n); - C[i] = bitstring[i]->rank0(new_n - 1); - delete [] _bm[i]; - } - delete [] _bm; - // delete [] oc; - bmb->unuse(); - - this->length = n; - } - - WaveletMatrix::WaveletMatrix(uint * symbols, size_t n, BitSequenceBuilder * bmb, Mapper * am, bool deleteSymbols) : Sequence(n) { - bmb->use(); - this->n=n; - this->am=am; - am->use(); - for(uint i=0;imap(symbols[i]); - max_v=max_value(symbols,n); - height=bits(max_v); - - OCC = new uint[max_v + 2]; - for (uint i = 0; i <= max_v + 1; i++) - OCC[i] = 0; - for (uint i = 0; i < n; i++) - OCC[symbols[i] + 1]++; - - uint to_add = 0; - for (uint i = 1; i <= max_v + 1; i++) - if (OCC[i] == 0) to_add++; - - uint * new_symb = new uint[n + to_add]; - for (uint i = 0; i < n; i++) - new_symb[i] = symbols[i]; - - if (deleteSymbols) { - delete [] symbols; - symbols = 0; - } - - to_add = 0; - for (uint i = 1; i <= max_v + 1; i++) - if (OCC[i] == 0) { - OCC[i]++; - new_symb[n + to_add] = i - 1; - to_add++; - } - - uint new_n = n + to_add; - for(uint i = 1;i <= max_v + 1; i++) - OCC[i] += OCC[i - 1]; - this->n = new_n; - - uint ** _bm=new uint*[height]; - for(uint i=0;ibuild(_bm[i],new_n); - C[i] = bitstring[i]->rank0(new_n - 1); - // cout << "C=" << C[i] << endl; - delete [] _bm[i]; - } - delete [] _bm; - - if (!deleteSymbols) - for(uint i=0;iunmap(symbols[i]); - - // delete [] new_symb; // already deleted in build_level()! - // delete [] oc; - bmb->unuse(); - // for(uint i=0;iheight << endl; - delete ret; - return NULL; - } - } - ret->OCC = loadValue(fp, ret->max_v + 2); - // ret->occ = BitSequence::load(fp); - // if(ret->occ==NULL) { - // delete ret; - // return NULL; - // } - return ret; - } - - inline uint get_start(uint symbol, uint mask) { - return symbol&mask; - } - - inline uint get_end(uint symbol, uint mask) { - return get_start(symbol,mask)+!mask+1; - } - - bool WaveletMatrix::is_set(uint val, uint ind) const - { - assert(indaccess(pos, optR)) { - pos = C[level] + optR - 1; - ret = ret | (1 << level); - } - else { - pos = optR - 1; - } - } - return am->unmap(ret); - } - - size_t WaveletMatrix::rank(uint symbol, size_t pos) const - { - symbol = am->map(symbol); - size_t start = 0; - for (uint level = 0; level < height; level++) { - if(is_set(symbol, height - level - 1)) { - if (start > 0) - start = bitstring[level]->rank1(start - 1); - start += C[level]; - pos = bitstring[level]->rank1(pos) + C[level] - 1; - } - else { - if (start > 0) - start = start - bitstring[level]->rank1(start - 1); - pos = pos - bitstring[level]->rank1(pos); - } - if (pos + 1 - start == 0) return 0; - } - return pos + 1 - start;; - } - - size_t WaveletMatrix::select(uint symbol, size_t j) const - { - symbol = am->map(symbol); - size_t pos = OCC[symbol] + j - 1; //(symbol == 0? -1 : occ->select1(symbol)) + j; - for (int level = height - 1; level >= 0; level--) { - // left - if (pos < C[level]) { - pos = bitstring[level]->select0(pos + 1); - } // right - else { - pos = bitstring[level]->select1(pos - C[level] + 1); - } - } - return pos; - } - - size_t WaveletMatrix::getSize() const - { - size_t ptrs = sizeof(WaveletMatrix)+height*sizeof(Sequence*); - size_t bytesBitstrings = 0; - for(uint i=0;igetSize(); - return bytesBitstrings /* + occ->getSize() */ + ptrs - + height * sizeof(uint) + sizeof(uint) * (max_v + 2); - } - - void WaveletMatrix::build_level(uint **bm, uint *symbols, uint length, uint *occs) { - uint sigma = max_value(symbols, length); - uint *new_order = new uint[sigma + 1]; - for (uint level = 0; level < height; level++) { - uint zeroes = 0; - for (uint i = 0; i < sigma + 1; i++) - if (!is_set(i, height - level - 1)) { - new_order[i] = 0; - } - else { - new_order[i] = 1; - } - for (uint i = 0; i < length; i++) - if (!new_order[symbols[i]]) - zeroes++; - uint *new_symbols = new uint[length]; - uint new_pos0 = 0, new_pos1 = zeroes; - for (uint i = 0; i < length; i++) { - if (!new_order[symbols[i]]) { - new_symbols[new_pos0++] = symbols[i]; - bitclean(bm[level], i); - } - else { - new_symbols[new_pos1++] = symbols[i]; - cds_utils::bitset(bm[level], i); - } - } - delete [] symbols; - symbols = new_symbols; - } - delete [] symbols; - delete [] new_order; - } - - uint WaveletMatrix::max_value(uint *symbols, size_t n) { - uint max_v = 0; - for(size_t i=0;i>= 1; - } - return ret; - } - -}; diff --git a/libcds/src/static/sequence/WaveletTree.cpp b/libcds/src/static/sequence/WaveletTree.cpp deleted file mode 100644 index f715b26e..00000000 --- a/libcds/src/static/sequence/WaveletTree.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* WaveletTree.cpp - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * WaveletTree definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - WaveletTree::WaveletTree(const Array & a, wt_coder * coder, BitSequenceBuilder *bmb, Mapper *am) : Sequence(0) { - bmb->use(); - this->n = a.getLength(); - this->length = n; - this->am = am; - am->use(); - this->c=coder; - c->use(); - uint * symbols = new uint[n]; - for(size_t i=0;imap(a[i]); - } - root = new wt_node_internal(symbols, n, 0, c, bmb); - delete [] symbols; - bmb->unuse(); - } - - WaveletTree::WaveletTree(uint * symbols, size_t n, wt_coder * c, BitSequenceBuilder * bmb, Mapper * am, bool free) : Sequence(n) { - bmb->use(); - this->n = n; - for(size_t i=0;imap(symbols[i]); - this->am = am; - am->use(); - this->c=c; - c->use(); - root = new wt_node_internal(symbols, n, 0, c, bmb); - if(free) { - delete [] symbols; - } - else { - for(size_t i=0;iunmap(symbols[i]); - } - bmb->unuse(); - } - - WaveletTree::WaveletTree(uchar * symbols, size_t n, wt_coder * c, BitSequenceBuilder * bmb, Mapper * am, bool free) : Sequence(n) { - bmb->use(); - this->n = n; - for(size_t i=0;imap((uint)symbols[i]); - this->am = am; - am->use(); - this->c=c; - c->use(); - uint *done = new uint[n/W+1]; - for (uint i = 0; i < n/W+1; i++) - done[i] = 0; - root = new wt_node_internal(symbols, n, 0, c, bmb, 0, done); - delete [] done; - if(free) { - delete [] symbols; - } - else { - for(uint i=0;iunmap((uint)symbols[i]); - } - bmb->unuse(); - } - - WaveletTree::WaveletTree():Sequence(0) {} - - WaveletTree::~WaveletTree() { - delete root; - am->unuse(); - c->unuse(); - } - - size_t WaveletTree::rank(uint symbol, size_t pos) const - { - uint * s = c->get_symbol(am->map(symbol)); - size_t ret = root->rank(s, pos, 0, c); - delete [] s; - return ret; - } - - size_t WaveletTree::count(uint s) const - { - uint * s2 = c->get_symbol(am->map(s)); - size_t ret = root->rank(s2, length-1, 0, c); - delete [] s2; - return ret; - } - - size_t WaveletTree::select(uint symbol, size_t pos) const - { - uint * s = c->get_symbol(am->map(symbol)); - uint ret = root->select(s, pos, 0, c); - if(ret==((uint)-1)) { delete [] s; return (uint)-1;} - delete [] s; - return ret-1; - } - - uint WaveletTree::access(size_t pos) const - { - return am->unmap(root->access(pos)); - } - - uint WaveletTree::quantile(size_t left,size_t right,uint q) const - { - return quantile_freq(left,right,q).first; - } - - pair WaveletTree::quantile_freq(size_t left,size_t right,uint q) const - { - /* q=1 -> q=0 */ - q--; - - pair res = root->quantile_freq(left,right,q); - return std::make_pair( am->unmap(res.first) , res.second ); - } - - uint WaveletTree::access(size_t pos, size_t &rank) const - { - return am->unmap(root->access(pos, rank)); - } - - size_t WaveletTree::getSize() const - { - // cout << "sizeof(WT): " << sizeof(WaveletTree) << endl; - // cout << "root: " << root->getSize() << endl; - // cout << "am: " << am->getSize() << endl; - // cout << "cdr: " << c->getSize() << endl; - return sizeof(WaveletTree)+root->getSize()+am->getSize()+c->getSize(); - } - - void WaveletTree::save(ostream & fp) const - { - uint wr = WVTREE_HDR; - saveValue(fp, wr); - saveValue(fp, n); - c->save(fp); - am->save(fp); - root->save(fp); - } - - WaveletTree * WaveletTree::load(istream & fp) { - uint rd = loadValue(fp); - if(rd!=WVTREE_HDR) return NULL; - WaveletTree * ret = new WaveletTree(); - ret->n = loadValue(fp); - ret->length = ret->n; - ret->c = wt_coder::load(fp); - ret->c->use(); - assert(ret->c!=NULL); - ret->am = Mapper::load(fp); - ret->am->use(); - assert(ret->am!=NULL); - ret->root = wt_node::load(fp); - assert(ret->root!=NULL); - return ret; - } - -}; diff --git a/libcds/src/static/sequence/WaveletTreeNoptrs.cpp b/libcds/src/static/sequence/WaveletTreeNoptrs.cpp deleted file mode 100644 index 5937b425..00000000 --- a/libcds/src/static/sequence/WaveletTreeNoptrs.cpp +++ /dev/null @@ -1,572 +0,0 @@ -/* WaveletTreeNoptrs.cpp - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * WaveletTreeNoptrs definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - WaveletTreeNoptrs::WaveletTreeNoptrs(const Array & a, BitSequenceBuilder * bmb, Mapper * am) : Sequence(0) { - bmb->use(); - this->n = a.getLength(); - this->length = n; - this->am = am; - am->use(); - uint * symbols = new uint[n]; - for(size_t i = 0; i < n; i++) - symbols[i] = am->map(a[i]); - max_v = am->map(a.getMax()); - height = bits(max_v); - - OCC = new uint[max_v + 2]; - for (uint i = 0; i <= max_v + 1; i++) - OCC[i] = 0; - for (uint i = 0; i < n; i++) - OCC[symbols[i] + 1]++; - - uint to_add = 0; - for (uint i = 1; i <= max_v + 1; i++) - if (OCC[i] == 0) to_add++; - - uint * new_symb = new uint[n + to_add]; - for (uint i = 0; i < n; i++) - new_symb[i] = symbols[i]; - delete [] symbols; - - to_add = 0; - for (uint i = 1; i <= max_v + 1; i++) - if (OCC[i] == 0) { - OCC[i]++; - new_symb[n + to_add] = i - 1; - to_add++; - } - - uint new_n = n + to_add; - for(uint i = 1;i <= max_v + 1; i++) - OCC[i] += OCC[i - 1]; - this->n = new_n; - - uint **_bm = new uint*[height]; - for(uint i = 0; i < height; i++) { - _bm[i] = new uint[new_n / W + 1]; - for(uint j = 0; j < new_n / W + 1; j++) - _bm[i][j] = 0; - } - build_level(_bm, new_symb, 0, new_n, 0); - bitstring = new BitSequence*[height]; - for(uint i = 0; i < height; i++) { - bitstring[i] = bmb->build(_bm[i], new_n); - delete [] _bm[i]; - } - delete [] _bm; - - bmb->unuse(); - } - - WaveletTreeNoptrs::WaveletTreeNoptrs(uint * symbols, size_t n, BitSequenceBuilder * bmb, Mapper * am, bool deleteSymbols) : Sequence(n) { - bmb->use(); - this->n = n; - this->am = am; - am->use(); - for(uint i = 0; i < n; i++) - symbols[i] = am->map(symbols[i]); - max_v = max_value(symbols, n); - height = bits(max_v); - - OCC = new uint[max_v + 2]; - for (uint i = 0; i <= max_v + 1; i++) - OCC[i] = 0; - for (uint i = 0; i < n; i++) - OCC[symbols[i] + 1]++; - - uint to_add = 0; - for (uint i = 1; i <= max_v + 1; i++) - if (OCC[i] == 0) to_add++; - - uint * new_symb = new uint[n + to_add]; - for (uint i = 0; i < n; i++) - new_symb[i] = symbols[i]; - - if (deleteSymbols) { - delete [] symbols; - symbols = 0; - } - - to_add = 0; - for (uint i = 1; i <= max_v + 1; i++) - if (OCC[i] == 0) { - OCC[i]++; - new_symb[n + to_add] = i - 1; - to_add++; - } - - uint new_n = n + to_add; - for(uint i = 1;i <= max_v + 1; i++) - OCC[i] += OCC[i - 1]; - this->n = new_n; - - uint **_bm = new uint*[height]; - for(uint i = 0; i < height; i++) { - _bm[i] = new uint[new_n / W + 1]; - for(uint j = 0; j < new_n / W + 1; j++) - _bm[i][j] = 0; - } - build_level(_bm, new_symb, 0, new_n, 0); - bitstring = new BitSequence*[height]; - for (uint i = 0; i < height; i++) { - bitstring[i] = bmb->build(_bm[i], new_n); - delete [] _bm[i]; - } - delete [] _bm; - - if (!deleteSymbols) - for(uint i = 0; i < n; i++) - symbols[i] = am->unmap(symbols[i]); - - bmb->unuse(); - } - - // symbols is an array of elements of "width" bits - WaveletTreeNoptrs::WaveletTreeNoptrs(uint * symbols, size_t n, uint width, BitSequenceBuilder * bmb, Mapper * am, bool deleteSymbols) : Sequence(n) { - bmb->use(); - this->n = n; - this->am = am; - am->use(); - for(uint i = 0; i < n; i++) - set_field(symbols, width, i, am->map(get_field(symbols, width, i))); - max_v = max_value(symbols, width, n); - height = bits(max_v); - - OCC = new uint[max_v + 2]; - for (uint i = 0; i <= max_v + 1; i++) - OCC[i] = 0; - for (uint i = 0; i < n; i++) - OCC[symbols[i] + 1]++; - - uint to_add = 0; - for (uint i = 1; i <= max_v + 1; i++) - if (OCC[i] == 0) to_add++; - - uint * new_symb = new uint[n + to_add]; - for (uint i = 0; i < n; i++) - new_symb[i] = symbols[i]; - - if (deleteSymbols) { - delete [] symbols; - symbols = 0; - } - - to_add = 0; - for (uint i = 1; i <= max_v + 1; i++) - if (OCC[i] == 0) { - OCC[i]++; - new_symb[n + to_add] = i - 1; - to_add++; - } - - uint new_n = n + to_add; - for(uint i = 1; i <= max_v + 1; i++) - OCC[i] += OCC[i - 1]; - this->n = new_n; - - uint **_bm = new uint*[height]; - for(uint i = 0; i < height; i++) { - _bm[i] = new uint[new_n / W + 1]; - for(uint j = 0; j < new_n / W + 1; j++) - _bm[i][j] = 0; - } - - build_level(_bm, new_symb, width, 0, new_n, 0); - bitstring = new BitSequence*[height]; - for(uint i=0;i< height; i++) { - bitstring[i] = bmb->build(_bm[i], new_n); - delete [] _bm[i]; - } - delete [] _bm; - - if (!deleteSymbols) - for (uint i = 0; i < n; i++) - set_field(symbols, width, i, am->unmap(get_field(symbols, width, i))); - - bmb->unuse(); - } - - WaveletTreeNoptrs::WaveletTreeNoptrs():Sequence(0) { - bitstring = NULL; - OCC = NULL; - am = NULL; - } - - WaveletTreeNoptrs::~WaveletTreeNoptrs() { - if (bitstring) { - for (uint i = 0; i < height; i++) - if (bitstring[i]) - delete bitstring[i]; - delete [] bitstring; - } - delete [] OCC; - if (am) - am->unuse(); - } - - void WaveletTreeNoptrs::save(ostream & fp) const - { - uint wr = WVTREE_NOPTRS_HDR; - saveValue(fp, wr); - saveValue(fp,n); - saveValue(fp,length); - saveValue(fp, max_v); - saveValue(fp, height); - am->save(fp); - for (uint i = 0; i < height; i++) - bitstring[i]->save(fp); - saveValue(fp, OCC, max_v + 2); - } - - WaveletTreeNoptrs * WaveletTreeNoptrs::load(istream & fp) { - uint rd = loadValue(fp); - if (rd != WVTREE_NOPTRS_HDR) return NULL; - WaveletTreeNoptrs * ret = new WaveletTreeNoptrs(); - ret->n = loadValue(fp); - ret->length = loadValue(fp); - ret->max_v = loadValue(fp); - ret->height = loadValue(fp); - ret->am = Mapper::load(fp); - if (ret->am == NULL) { - delete ret; - return NULL; - } - ret->am->use(); - ret->bitstring = new BitSequence*[ret->height]; - for(uint i = 0; i < ret->height; i++) - ret->bitstring[i] = NULL; - for(uint i = 0; i < ret->height; i++) { - ret->bitstring[i] = BitSequence::load(fp); - if (ret->bitstring[i] == NULL) { - delete ret; - return NULL; - } - } - ret->OCC = loadValue(fp, ret->max_v + 2); - return ret; - } - - inline uint get_start(uint symbol, uint mask) { - return symbol & mask; - } - - inline uint get_end(uint symbol, uint mask) { - return get_start(symbol, mask) + ~mask + 1; - } - - bool WaveletTreeNoptrs::is_set(uint val, uint ind) const - { - assert (ind < height); - return (val & (1 << (height - ind - 1))) != 0; - } - - uint WaveletTreeNoptrs::access(size_t pos) const - { - uint ret = 0; - - size_t start = 0; - for (uint level = 0; level < height; level++) { - size_t optR, before = 0; - if (start > 0) - before = bitstring[level]->rank1(start - 1); - - if (bitstring[level]->access(pos, optR)) { - ret |= (1 << (height - level - 1)); - pos = optR - 1 - before; - start = OCC[ret]; - pos += start; - } else { - pos = optR - 1 + before; - } - } - - return am->unmap(ret); - } - - uint WaveletTreeNoptrs::access(size_t pos, size_t &r) const - { - uint ret = 0; - - size_t start = 0; - for (uint level = 0; level < height; level++) { - size_t optR, before=0; - if (start > 0) - before = bitstring[level]->rank1(start-1); - - if(bitstring[level]->access(pos, optR)) { - ret |= (1 << (height - level - 1)); - r = optR - before; - start = OCC[ret]; - pos = r - 1 + start; - } - else { - pos = optR - 1 + before; - r = pos + 1 - start; - } - } - - return am->unmap(ret); - } - - size_t WaveletTreeNoptrs::rank(uint symbol, size_t pos) const - { - symbol = am->map(symbol);; - - size_t start = 0; - size_t count = 0; - - for(uint level = 0; level < height; level++) { - - uint masked = (symbol >> (height - level - 1)) << (height - level - 1); - - size_t before = 0; - if (start > 0) - before = bitstring[level]->rank1(start - 1); - - if (is_set(symbol, level)) { - count = bitstring[level]->rank1(pos) - before; - start = OCC[masked]; - pos = count + start - 1; - } else { - count = pos - start + before - bitstring[level]->rank1(pos) + 1; - masked += (1 << (height - level - 1)); - pos = count + start - 1; - } - - if (count == 0) return 0; - } - return count; - } - - size_t WaveletTreeNoptrs::select(uint symbol, size_t j) const - { - symbol = am->map(symbol); - - uint mask = (1 << height) - 2; - uint sum = 2; - - size_t pos = j; - - for (int level = height - 1; level >= 0; level--) { - - size_t start = get_start(symbol, mask); - size_t end = min(static_cast(max_v), start + sum); - start = OCC[start]; - end = OCC[end + 1] - 1; - - uint ones_start = 0; - if (start > 0) - ones_start = bitstring[level]->rank1(start - 1); - - if (is_set(symbol,level)) { - pos = bitstring[level]->select1(ones_start + pos) - start + 1; - } else { - pos = bitstring[level]->select0(start - ones_start + pos) - start + 1; - } - - mask <<= 1; - sum <<= 1; - } - - return pos - 1; - } - - size_t WaveletTreeNoptrs::getSize() const - { - size_t ptrs = sizeof(WaveletTreeNoptrs) + height * sizeof(Sequence*); - size_t bytesBitstrings = 0; - for(uint i = 0; i < height; i++) - bytesBitstrings += bitstring[i]->getSize(); - return bytesBitstrings + sizeof(uint) * (max_v + 2) + ptrs; - } - - void WaveletTreeNoptrs::build_level(uint **bm, uint *symbols, uint level, uint length, uint offset) { - if (level == height) { - delete [] symbols; - return; - } - - uint cleft = 0; - for (size_t i = 0; i < length; i++) - if (!is_set(symbols[i],level)) - cleft++; - - uint cright = length - cleft; - - uint *left = new uint[cleft]; - uint *right = new uint[cright]; - cleft = cright = 0; - for (size_t i = 0; i < length; i++) { - if (!is_set(symbols[i], level)) { - left[cleft++] = symbols[i]; - bitclean(bm[level], offset + i); - } else { - right[cright++] = symbols[i]; - cds_utils::bitset(bm[level], offset + i); - } - } - - delete [] symbols; - symbols = NULL; - - build_level(bm, left, level + 1, cleft, offset); - left = NULL; // Gets deleted in recursion. - build_level(bm, right, level + 1, cright, offset + cleft); - right = NULL; // Gets deleted in recursion. - } - - // symbols is an array of elements of "width" bits. - void WaveletTreeNoptrs::build_level(uint **bm, uint *symbols, unsigned width, uint level, uint length, uint offset) { - if (level == height) { - delete [] symbols; - return; - } - - uint cleft = 0; - for (size_t i = 0; i < length; i++) - if (!is_set(get_field(symbols, width, i), level)) - cleft++; - - uint cright = length - cleft; - - uint *left = new uint[(cleft * width) / W + 1]; - uint *right = new uint[(cright * width) / W + 1]; - cleft = cright = 0; - for (size_t i = 0; i < length; i++) { - if (!is_set(get_field(symbols, width, i), level)) { - set_field(left, width, cleft++, get_field(symbols, width, i)); - bitclean(bm[level], offset + i); - } - else { - set_field(right, width, cright++, get_field(symbols, width, i)); - cds_utils::bitset(bm[level], offset + i); - } - } - - delete [] symbols; - symbols = NULL; - - build_level(bm, left, width, level + 1, cleft, offset); - left = NULL; // Gets deleted in recursion. - build_level(bm, right, width, level + 1, cright, offset + cleft); - right = NULL; // Gets deleted in recursion. - } - - uint WaveletTreeNoptrs::max_value(uint *symbols, size_t n) { - uint max_v = 0; - for (size_t i = 0; i < n; i++) - max_v = max(symbols[i], max_v); - return max_v; - } - - uint WaveletTreeNoptrs::max_value(uint *symbols, unsigned width, size_t n) { - uint max_v = 0; - for (size_t i = 0; i < n; i++) - max_v = max(get_field(symbols, width, i), max_v); - return max_v; - } - - uint WaveletTreeNoptrs::bits(uint val) { - uint ret = 0; - while (val!=0) { - ret++; - val >>= 1; - } - return ret; - } - - size_t WaveletTreeNoptrs::count(uint symbol) const - { - uint mapped = am->map(symbol); - return OCC[mapped + 1] - OCC[mapped] + 1; - } - - uint WaveletTreeNoptrs::quantile(size_t left,size_t right,uint q) { - pair res = quantile_freq(left,right,q); - return res.first; - } - - pair WaveletTreeNoptrs::quantile_freq(size_t left,size_t right,uint q) { - /* decrease q as the smallest element q=1 is - * found by searching for 0 */ - q--; - - assert( right >= left ); - assert( (right-left+1) >= q ); - assert( right < length ); - - uint sym = 0; - uint freq = 0; - uint level = 0; - size_t start = 0, end = n-1; - size_t before; - BitSequence* bs; - - while(levelrank1(start-1); - - /* number of 1s before T[l..r] */ - size_t rank_before_left = bs->rank1(start+left-1); - /* number of 1s before T[r] */ - size_t rank_before_right = bs->rank1(start+right); - /* number of 1s in T[l..r] */ - size_t num_ones = rank_before_right - rank_before_left; - /* number of 0s in T[l..r] */ - size_t num_zeros = (right-left+1) - num_ones; - - /* if there are more than q 0s we go right. left otherwise */ - if(q >= num_zeros) { /* go right */ - freq = num_ones; /* calc freq */ - /* set bit to 1 in sym */ - sym = 1 << (height - level - 1); //set(sym,level); - /* number of 1s before T[l..r] within the current node */ - left = rank_before_left - before; - /* number of 1s in T[l..r] */ - right = rank_before_right - before - 1; - q = q - num_zeros; - /* calc starting pos of right childnode */ - start = end - (bs->rank1(end)-before) + 1; - } /* go left q = q // sym == sym */ - else { - freq = num_zeros;/* calc freq */ - /* number of zeros before T[l..r] within the current node */ - left = left - (rank_before_left - before); - /* number of zeros in T[l..r] + left bound */ - right = right - (rank_before_right - before); - /* calc end pos of left childnode */ - end = end - (bs->rank1(end) - before); - } - level++; - } - - /* unmap symbol */ - return pair(am->unmap(sym),static_cast(freq)); - } - -}; diff --git a/libcds/src/static/sequence/WaveletTreeNoptrsS.cpp b/libcds/src/static/sequence/WaveletTreeNoptrsS.cpp deleted file mode 100644 index 8c41b0cc..00000000 --- a/libcds/src/static/sequence/WaveletTreeNoptrsS.cpp +++ /dev/null @@ -1,393 +0,0 @@ -/* WaveletTreeNoptrsSS.cpp - * Copyright (C) 2012, Francisco Claude, all rights reserved. - * - * WaveletTreeNoptrsS definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - WaveletTreeNoptrsS::WaveletTreeNoptrsS(const Array &symb, BitSequenceBuilder * bmb, Mapper * am) : Sequence(n) { - bmb->use(); - this->n=symb.getLength(); - this->am=am; - bool deleteSymbols = true; - am->use(); - // This is terrible - uint *symbols = new uint[n]; - for(uint i=0;imap(symbols[i]); - max_v=max_value(symbols,n); - height=bits(max_v); - uint *occurrences=new uint[max_v+1]; - for(uint i=0;i<=max_v;i++) occurrences[i]=0; - for(uint i=0;ibuild(oc,new_n+1); - delete [] occurrences; - this->n = new_n; - uint ** _bm=new uint*[height]; - for(uint i=0;ibuild(_bm[i],new_n); - delete [] _bm[i]; - } - delete [] _bm; - - if (!deleteSymbols) - for(uint i=0;iunmap(symbols[i]); - - // delete [] new_symb; // already deleted in build_level()! - delete [] oc; - bmb->unuse(); - } - - WaveletTreeNoptrsS::WaveletTreeNoptrsS(uint * symbols, size_t n, BitSequenceBuilder * bmb, Mapper * am, bool deleteSymbols) : Sequence(n) { - bmb->use(); - this->n=n; - this->am=am; - am->use(); - for(uint i=0;imap(symbols[i]); - max_v=max_value(symbols,n); - height=bits(max_v); - uint *occurrences=new uint[max_v+1]; - for(uint i=0;i<=max_v;i++) occurrences[i]=0; - for(uint i=0;ibuild(oc,new_n+1); - delete [] occurrences; - this->n = new_n; - uint ** _bm=new uint*[height]; - for(uint i=0;ibuild(_bm[i],new_n); - delete [] _bm[i]; - } - delete [] _bm; - - if (!deleteSymbols) - for(uint i=0;iunmap(symbols[i]); - - // delete [] new_symb; // already deleted in build_level()! - delete [] oc; - bmb->unuse(); - } - - - - WaveletTreeNoptrsS::WaveletTreeNoptrsS():Sequence(0) { - bitstring = NULL; - occ = NULL; - am = NULL; - } - - WaveletTreeNoptrsS::~WaveletTreeNoptrsS() { - if(bitstring) { - for(uint i=0;iunuse(); - } - - void WaveletTreeNoptrsS::save(ostream & fp) const - { - uint wr = WVTREE_NOPTRSS_HDR; - saveValue(fp,wr); - saveValue(fp,n); - saveValue(fp,max_v); - saveValue(fp,height); - am->save(fp); - for(uint i=0;isave(fp); - occ->save(fp); - } - - WaveletTreeNoptrsS * WaveletTreeNoptrsS::load(istream & fp) { - uint rd = loadValue(fp); - if(rd!=WVTREE_NOPTRSS_HDR) return NULL; - WaveletTreeNoptrsS * ret = new WaveletTreeNoptrsS(); - ret->n = loadValue(fp); - ret->length = ret->n; - ret->max_v = loadValue(fp); - ret->height = loadValue(fp); - ret->am = Mapper::load(fp); - if(ret->am==NULL) { - delete ret; - return NULL; - } - ret->am->use(); - ret->bitstring = new BitSequence*[ret->height]; - for(uint i=0;iheight;i++) - ret->bitstring[i] = NULL; - for(uint i=0;iheight;i++) { - ret->bitstring[i] = BitSequence::load(fp); - if(ret->bitstring[i]==NULL) { - cout << "damn" << i << " " << ret->height << endl; - delete ret; - return NULL; - } - } - ret->occ = BitSequence::load(fp); - if(ret->occ==NULL) { - delete ret; - return NULL; - } - return ret; - } - - inline uint get_start(uint symbol, uint mask) { - return symbol&mask; - } - - inline uint get_end(uint symbol, uint mask) { - return get_start(symbol,mask)+!mask+1; - } - - bool WaveletTreeNoptrsS::is_set(uint val, uint ind) const - { - assert(indrank0(end); - size_t optR = 0; - if (bitstring[level]->access(pos, optR)) { - pos = C + optR - 1; - ret = (ret << 1) | 1; - } else { - pos = optR - 1; - ret = ret << 1; - } - level++; - } - uint ret2 = 0; - for (uint i = 0; i < height; i++) { - ret2 = (ret2 << 1) | (ret & 1); - ret /= 2; - } - return am->unmap(ret2); - } - - size_t WaveletTreeNoptrsS::rank(uint symbol, size_t pos) const - { - symbol = am->map(symbol); - uint level = 0; - size_t end = n - 1; - // size_t count = 0; - size_t start = 0; - while (level < height) { - size_t C = bitstring[level]->rank0(end); - if(is_set(symbol, height - level - 1)) { - start = C + (start == 0? 0 : bitstring[level]->rank1(start - 1)); - pos = bitstring[level]->rank1(pos) + C - 1; - // count = pos + 1 - start; - } - else { - start = (start == 0? 0 : bitstring[level]->rank0(start - 1)); - pos = bitstring[level]->rank0(pos) - 1; - // count = pos + 1 - start; - } - level++; - // cout << "pos=" << pos << " start=" << start << endl; - // if(count==0) return 0; - } - return pos + 1 - start;; - } - - size_t WaveletTreeNoptrsS::select(uint symbol, size_t j) const - { - size_t end = n - 1; - symbol = am->map(symbol); - size_t pos = (symbol == 0? -1 : occ->select1(symbol)) + j; - for (int level = height - 1; level >= 0; level--) { - size_t C = bitstring[level]->rank0(end); - if (pos < C) { // left - pos = bitstring[level]->select0(pos + 1); - } else { // right - pos = bitstring[level]->select1(pos - C + 1); - } - } - return pos; - } - - size_t WaveletTreeNoptrsS::getSize() const - { - size_t ptrs = sizeof(WaveletTreeNoptrsS)+height*sizeof(Sequence*); - size_t bytesBitstrings = 0; - for(uint i=0;igetSize(); - return bytesBitstrings+occ->getSize()+ptrs; - } - - void WaveletTreeNoptrsS::build_level(uint **bm, uint *symbols, uint length, uint *occs) { - // for (uint i = 0; i < length; i++) - // cout << " " << symbols[i]; - // cout << endl; - uint sigma = max_value(symbols, length); - uint *new_order = new uint[sigma + 1]; - for (uint level = 0; level < height; level++) { - uint zeroes = 0; - for (uint i = 0; i < sigma + 1; i++) - if (!is_set(i, height - level - 1)) { - new_order[i] = 0; - } else { - new_order[i] = 1; - } - for (uint i = 0; i < length; i++) - if (!new_order[symbols[i]]) - zeroes++; - uint *new_symbols = new uint[length]; - uint new_pos0 = 0, new_pos1 = zeroes; - for (uint i = 0; i < length; i++) { - if (!new_order[symbols[i]]) { - //cout << "[" << new_pos0 << "]=" << symbols[i] << endl; - new_symbols[new_pos0++] = symbols[i]; - bitclean(bm[level], i); - } else { - //cout << "[" << new_pos1 << "]=" << symbols[i] << endl; - new_symbols[new_pos1++] = symbols[i]; - cds_utils::bitset(bm[level], i); - } - } - delete [] symbols; - symbols = new_symbols; - // for (uint i = 0; i < length; i++) - // cout << " " << symbols[i]; - // cout << endl; - } - delete [] symbols; - delete [] new_order; - } - - uint WaveletTreeNoptrsS::max_value(uint *symbols, size_t n) { - uint max_v = 0; - for(size_t i=0;i>= 1; - } - return ret; - } - - size_t WaveletTreeNoptrsS::count(uint symbol) const - { - return occ->select1(am->map(symbol))-occ->select1(am->map(symbol)-1)+1; - } - - -}; diff --git a/libcds/src/static/sequence/wt_coder.cpp b/libcds/src/static/sequence/wt_coder.cpp deleted file mode 100644 index f751aa86..00000000 --- a/libcds/src/static/sequence/wt_coder.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* wt_coder.cpp - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * wt_coder definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - wt_coder::wt_coder() { - user_count=0; - } - - void wt_coder::use() { - user_count++; - } - - void wt_coder::unuse() { - user_count--; - if(user_count==0) delete this; - } - - wt_coder * wt_coder::load(istream & fp) { - uint rd = loadValue(fp); - size_t pos = fp.tellg(); - fp.seekg(pos-sizeof(uint)); - switch(rd) { - case WT_CODER_HUFF_HDR: return wt_coder_huff::load(fp); - case WT_CODER_BINARY_HDR: return wt_coder_binary::load(fp); - } - return NULL; - } -}; diff --git a/libcds/src/static/sequence/wt_coder_binary.cpp b/libcds/src/static/sequence/wt_coder_binary.cpp deleted file mode 100644 index 5f55b2f1..00000000 --- a/libcds/src/static/sequence/wt_coder_binary.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* wt_coder_binary.cpp - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * wt_coder_binary definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - wt_coder_binary::wt_coder_binary(const Array & a, Mapper *am) { - //am->use(); - uint maxv = 0; - for(size_t i=0;iunuse(); - } - - wt_coder_binary::wt_coder_binary(uint * seq, size_t n, Mapper * am) { - uint max_v = 0; - for(uint i=0;imap(seq[i]),max_v); - h=bits(max_v); - } - - wt_coder_binary::wt_coder_binary(uchar * seq, size_t n, Mapper * am) { - uint max_v = 0; - for(uint i=0;imap((uint)seq[i]),max_v); - h=bits(max_v); - } - - wt_coder_binary::wt_coder_binary() {} - - wt_coder_binary::~wt_coder_binary() {} - - bool wt_coder_binary::is_set(uint symbol, uint l) const - { - if((1<<(h-l-1))&symbol) return true; - return false; - } - - bool wt_coder_binary::is_set(uint *symbol, uint l) const { - if(bitget(symbol, h - l - 1)) return true; - return false; - } - - uint * wt_coder_binary::get_symbol(uint symbol) const { - uint * ret = new uint[1]; - *ret = symbol; - return ret; - } - - bool wt_coder_binary::done(uint symbol, uint l) const - { - if(l==h) return true; - return false; - } - - size_t wt_coder_binary::getSize() const - { - return sizeof(wt_coder_binary); - } - - void wt_coder_binary::save(ostream & fp) const - { - uint wr = WT_CODER_BINARY_HDR; - saveValue(fp,wr); - saveValue(fp,h); - } - - wt_coder_binary * wt_coder_binary::load(istream & fp) { - uint rd = loadValue(fp); - if(rd!=WT_CODER_BINARY_HDR) return NULL; - wt_coder_binary * ret = new wt_coder_binary(); - ret->h = loadValue(fp); - return ret; - } -}; diff --git a/libcds/src/static/sequence/wt_coder_huff.cpp b/libcds/src/static/sequence/wt_coder_huff.cpp deleted file mode 100644 index a9aabce3..00000000 --- a/libcds/src/static/sequence/wt_coder_huff.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* wt_coder_huff.cpp - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * wt_coder_huff definition - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - wt_coder_huff::wt_coder_huff(const Array & a, Mapper * am) { - am->use(); - size_t n = a.getLength(); - uint * symbs = new uint[n]; - for(uint i=0;imap(a[i]); - hc = new HuffmanCoder(symbs, n); - maxBuffer = hc->maxLength()/W+1; - delete [] symbs; - am->unuse(); - } - - wt_coder_huff::wt_coder_huff(uint * symbs, size_t n, Mapper * am) { - am->use(); - for(uint i=0;imap(symbs[i]); - hc = new HuffmanCoder(symbs, n); - maxBuffer = hc->maxLength()/W+1; - for(uint i=0;iunmap(symbs[i]); - am->unuse(); - } - - wt_coder_huff::wt_coder_huff(uchar * symbs, size_t n, Mapper * am) { - am->use(); - for(uint i=0;imap((uint)symbs[i]); - hc = new HuffmanCoder(symbs, n); - maxBuffer = hc->maxLength()/W+1; - for(uint i=0;iunmap((uint)symbs[i]); - am->unuse(); - } - - wt_coder_huff::wt_coder_huff() {} - - wt_coder_huff::~wt_coder_huff() { - delete hc; - } - - uint * wt_coder_huff::get_symbol(uint symbol) const { - uint * ret = new uint[maxBuffer]; - hc->encode(symbol, ret, (size_t)0); - return ret; - } - - // TODO: it could be implemented in a more efficient (low level) way - bool wt_coder_huff::is_set(uint symbol, uint l) const - { - uint *buffer = new uint[maxBuffer]; - hc->encode(symbol, buffer, (size_t)0); - bool ret = bitget(buffer,l); - delete[] buffer; - return ret; - } - - bool wt_coder_huff::is_set(uint *symbol, uint l) const { - return bitget(symbol,l); - } - - bool wt_coder_huff::done(uint symbol, uint l) const - { - uint *buffer = new uint[maxBuffer]; - uint s_len = (uint)hc->encode(symbol, buffer, (size_t)0); - bool ret = l==s_len; - delete[] buffer; - return ret; - } - - size_t wt_coder_huff::getSize() const - { - return 2*sizeof(uint)+sizeof(wt_coder_huff)+hc->getSize()+(hc->maxLength()/W+1)*sizeof(uint); - } - - void wt_coder_huff::save(ostream & fp) const - { - uint wr = WT_CODER_HUFF_HDR; - saveValue(fp,wr); - hc->save(fp); - } - - wt_coder_huff * wt_coder_huff::load(istream & fp) { - uint rd = loadValue(fp); - if(rd!=WT_CODER_HUFF_HDR) return NULL; - wt_coder_huff * ret = new wt_coder_huff(); - ret->hc = HuffmanCoder::load(fp); - assert(ret->hc!=NULL); - ret->maxBuffer = ret->hc->maxLength()/W+1; - return ret; - } -}; diff --git a/libcds/src/static/sequence/wt_node.cpp b/libcds/src/static/sequence/wt_node.cpp deleted file mode 100644 index 5e09e225..00000000 --- a/libcds/src/static/sequence/wt_node.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* wt_node.cpp - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * wt_node - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - wt_node * wt_node::load(istream & fp) { - uint rd = loadValue(fp); - if(rd==WT_NODE_NULL_HDR) return NULL; - size_t pos = fp.tellg(); - fp.seekg(pos-sizeof(uint)); - switch(rd) { - case WT_NODE_INTERNAL_HDR: return wt_node_internal::load(fp); - case WT_NODE_LEAF_HDR: return wt_node_leaf::load(fp); - } - return NULL; - } -}; diff --git a/libcds/src/static/sequence/wt_node_internal.cpp b/libcds/src/static/sequence/wt_node_internal.cpp deleted file mode 100644 index ef402342..00000000 --- a/libcds/src/static/sequence/wt_node_internal.cpp +++ /dev/null @@ -1,281 +0,0 @@ -/* wt_node_internal.cpp - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * wt_node_internal - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - wt_node_internal::wt_node_internal(uint * symbols, size_t n, uint l, wt_coder * c, BitSequenceBuilder * bmb) { - uint * ibitmap = new uint[n/W+1]; - for(uint i=0;iis_set(symbols[i],l)) - cds_utils::bitset(ibitmap,i); - } - bitmap = bmb->build(ibitmap, n); - delete [] ibitmap; - size_t count_right = bitmap->rank1(n-1); - size_t count_left = n-count_right+1; - uint * left = new uint[count_left+1]; - uint * right = new uint[count_right+1]; - count_right = count_left = 0; - bool match_left = true, match_right = true; - for(uint i=0;iaccess(i)) { - right[count_right++]=symbols[i]; - if(count_right>1) - if(right[count_right-1]!=right[count_right-2]) - match_right = false; - } - else { - left[count_left++]=symbols[i]; - if(count_left>1) - if(left[count_left-1]!=left[count_left-2]) - match_left = false; - } - } - if(count_left>0) { - if(match_left/* && c->done(left[0],l+1)*/) - left_child = new wt_node_leaf(left[0], count_left); - else - left_child = new wt_node_internal(left, count_left, l+1, c, bmb); - } - else { - left_child = NULL; - } - delete [] left; - - if(count_right>0) { - if(match_right/* && c->done(right[0],l+1)*/) - right_child = new wt_node_leaf(right[0], count_right); - else - right_child = new wt_node_internal(right, count_right, l+1, c, bmb); - } - else { - right_child = NULL; - } - delete [] right; - } - - wt_node_internal::wt_node_internal(uchar * symbols, size_t n, uint l, wt_coder * c, BitSequenceBuilder * bmb, size_t left, uint *done) { - uint * ibitmap = new uint[n/W+1]; - for(size_t i=0;iis_set((uint)symbols[i + left],l)) - cds_utils::bitset(ibitmap,i); - bitmap = bmb->build(ibitmap, n); - delete [] ibitmap; - - size_t count_right = bitmap->rank1(n-1); - size_t count_left = n-count_right; - - for (size_t i=0;iis_set(swap,l)) - j = bitmap->rank0(k)-1; - else - j = count_left + bitmap->rank1(k)-1; - uchar temp = symbols[j+left]; - symbols[j+left] = swap; - swap = temp; - set_field(done,1,k+left,1); - } - - while (get_field(done,1,i+left)) - ++i; - } - - bool match_left = true, match_right = true; - for (size_t i=1; i < count_left; i++) - if (symbols[i+left] != symbols[i+left-1]) - match_left = false; - for (size_t i=count_left + 1; i < n; i++) - if (symbols[i+left] != symbols[i+left-1]) - match_right = false; - - if(count_left>0) { - if(match_left/* && c->done(left[0],l+1)*/) - left_child = new wt_node_leaf((uint)symbols[left], count_left); - else - left_child = new wt_node_internal(symbols, count_left, l+1, c, bmb, left, done); - } - else { - left_child = NULL; - } - if(count_right>0) { - if(match_right/* && c->done(right[0],l+1)*/) - right_child = new wt_node_leaf((uint)symbols[left+count_left], count_right); - else - right_child = new wt_node_internal(symbols, count_right, l+1, c, bmb, left+count_left, done); - } - else { - right_child = NULL; - } - } - - wt_node_internal::wt_node_internal() { } - - wt_node_internal::~wt_node_internal() { - delete bitmap; - if(right_child!=NULL) delete right_child; - if(left_child!=NULL) delete left_child; - } - - size_t wt_node_internal::rank(uint * symbol, size_t pos, uint l, wt_coder *c) const - { - bool is_set = c->is_set(symbol,l); - if(!is_set) { - /*if(left_child==NULL) { - cout << "symbol1=" << symbol << endl; - return 0; - }*/ - return left_child->rank(symbol, bitmap->rank0(pos)-1,l+1, c); - } - else { - /*if(right_child==NULL) { - cout << "symbol2=" << symbol << endl; - return 0; - }*/ - return right_child->rank(symbol, bitmap->rank1(pos)-1,l+1, c); - } - } - - size_t wt_node_internal::select(uint * symbol, size_t pos, uint l, wt_coder *c) const - { - bool is_set = c->is_set(symbol,l); //c->is_set(symbol, l); - size_t ret = 0; - if(!is_set) { - /*if(left_child==NULL) - return (size_t)(-1);*/ - size_t new_pos = left_child->select(symbol, pos, l+1, c); - if(new_pos+1==0) return (uint)(-1); - ret = bitmap->select0(new_pos)+1; - } - else { - /*if(right_child==NULL) - return (size_t)(-1);*/ - size_t new_pos = right_child->select(symbol, pos, l+1, c); - if(new_pos+1==0) return (uint)(-1); - ret = bitmap->select1(new_pos)+1; - } - if(ret==0) return (size_t)-1; - return ret; - } - - uint wt_node_internal::access(size_t pos) const - { - size_t rOpt = 0; - bool is_set = bitmap->access(pos,rOpt); - if(!is_set) { - assert(left_child!=NULL); - return left_child->access(rOpt-1); - } - else { - assert(right_child!=NULL); - return right_child->access(rOpt-1); - } - } - - // Returns the value at given position and its rank - uint wt_node_internal::access(size_t pos, size_t &rankp) const - { - size_t rOpt = 0; - bool is_set = bitmap->access(pos,rOpt); - if(!is_set) { - // recurse left - return left_child->access(rOpt-1, rankp); - } - else { - // recurse right - return right_child->access(rOpt-1, rankp); - } - } - - pair wt_node_internal::quantile_freq(size_t left,size_t right,uint q) const - { - /* number of 1s before T[l..r] */ - size_t rank_before_left = bitmap->rank1(left-1); - /* number of 1s before T[r] */ - size_t rank_before_right = bitmap->rank1(right); - /* number of 1s in T[l..r] */ - size_t num_ones = rank_before_right - rank_before_left; - /* number of 0s in T[l..r] */ - size_t num_zeros = (right-left+1) - num_ones; - - if(q >= num_zeros) { - return right_child->quantile_freq(rank_before_left,rank_before_left+num_ones-1,q-num_zeros); - } else { - return left_child->quantile_freq((left-rank_before_left),(left-rank_before_left)+num_zeros-1,q); - } - } - - size_t wt_node_internal::getSize() const - { - uint s = bitmap->getSize()+sizeof(wt_node_internal); - if(left_child!=NULL) - s += left_child->getSize(); - if(right_child!=NULL) - s += right_child->getSize(); - return s; - } - - void wt_node_internal::save(ostream & fp) const - { - uint wr = WT_NODE_INTERNAL_HDR; - saveValue(fp,wr); - bitmap->save(fp); - if(left_child!=NULL) { - left_child->save(fp); - } - else { - wr = WT_NODE_NULL_HDR; - saveValue(fp,wr); - } - if(right_child!=NULL) { - right_child->save(fp); - } - else { - wr = WT_NODE_NULL_HDR; - saveValue(fp,wr); - } - } - - wt_node_internal * wt_node_internal::load(istream & fp) { - uint rd = loadValue(fp); - if(rd!=WT_NODE_INTERNAL_HDR) return NULL; - wt_node_internal * ret = new wt_node_internal(); - ret->bitmap = BitSequence::load(fp); - ret->left_child = wt_node::load(fp); - ret->right_child = wt_node::load(fp); - return ret; - } - -}; diff --git a/libcds/src/static/sequence/wt_node_leaf.cpp b/libcds/src/static/sequence/wt_node_leaf.cpp deleted file mode 100644 index 7c28497e..00000000 --- a/libcds/src/static/sequence/wt_node_leaf.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* wt_node_leaf.cpp - * Copyright (C) 2008, Francisco Claude, all rights reserved. - * - * wt_node_leaf - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - wt_node_leaf::wt_node_leaf(uint symbol, size_t count) { - this->symbol = symbol; - this->count = count; - } - - wt_node_leaf::wt_node_leaf() {} - - wt_node_leaf::~wt_node_leaf() {} - - size_t wt_node_leaf::rank(uint *symbol, size_t pos, uint l, wt_coder *c) const - { - /*if(symbol!=this->symbol) { - return 0; - }*/ - //pos++; - return pos+1; - } - - size_t wt_node_leaf::select(uint *symbol, size_t pos, uint l, wt_coder *c) const - { - //if(symbol!=this->symbol) return (size_t)-1; - if(pos==0 || pos>count) return (size_t)-1; - return pos; - } - - uint wt_node_leaf::access(size_t pos) const - { - return symbol; - } - - uint wt_node_leaf::access(size_t pos, size_t &rank) const - { - rank = pos+1; - return symbol; - } - - pair wt_node_leaf::quantile_freq(size_t left,size_t right,uint q) const - { - return std::make_pair(symbol,right-left+1); - } - - size_t wt_node_leaf::getSize() const - { - return sizeof(wt_node_leaf); - } - - void wt_node_leaf::save(ostream & fp) const - { - uint wr = WT_NODE_LEAF_HDR; - saveValue(fp,wr); - saveValue(fp,count); - saveValue(fp,symbol); - } - - wt_node_leaf * wt_node_leaf::load(istream & fp) { - uint rd = loadValue(fp); - if(rd!=WT_NODE_LEAF_HDR) return NULL; - wt_node_leaf * ret = new wt_node_leaf(); - ret->count = loadValue(fp); - ret->symbol = loadValue(fp); - return ret; - } -}; diff --git a/libcds/src/static/suffixtree/LCP.cpp b/libcds/src/static/suffixtree/LCP.cpp deleted file mode 100644 index 8ea9eb01..00000000 --- a/libcds/src/static/suffixtree/LCP.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - uint * LCP::create_lcp(TextIndex *csa, char *text, uint n, int q) const - { - if(q > (int)n) { - cout << "Specified q (" << q << ") greater than string length (" << n << ")" << endl; - return NULL; - } - int i,h,j,k, m; - int *sa = NULL; - int *plcp = NULL; - /*q==-1 its mean that for any position we just use psi for calculate each LCP*/ - if(q!=-1) { - m = 1+(n-1)/q; - plcp = new int[m]; //space for sampled lcps - if(plcp==NULL) { - cerr << "Failed to allocate memory for plcp." << endl; - return NULL; - } - /*initialize samples to -1*/ - for(i=0; i < m; i++) - plcp[i] = -1; - sa = new int[n]; - /*calculate SA*/ - for(k=0; k < (int)n; k++) - sa[k] = csa->getSA(k); - /*compute the sparse phi array (in plcp)*/ - for(k=1; k < (int)n-1; k++) { - if(sa[k] % q == 0) - plcp[sa[k]/q] = sa[k-1]; - } - /*most of sparse phi computed make a special case of the last one*/ - if(sa[n-1]%q == 0) - plcp[sa[n-1]/q] = n; - /*all of sparse phi computed*/ - - /*compute lcp''*/ - h = 0; - for(i=0; i < m; i++) { - j = plcp[i]; //here plcp[i] = phi'[i] - k = i*q; - while(k+h < (int)n && j+h < (int)n && text[k+h] == text[j+h]) - h++; - plcp[i] = h; //now plcp[i] = h - if(h > 0) - h -= q; - if(h < 0) - h = 0; - } - } - - /*compute lcp*/ - uint *lcp = new uint[n]; - lcp[0]=0; - uint sa_k, sa_ant; - int iq; - sa_k = sa[0]; - for(k=1; k<(int)n;k++) { - sa_ant = sa_k; - sa_k = sa[k]; - if(sa_k % q == 0) - lcp[k] = plcp[sa_k/q]; - else { - //smallest multiple of q less than i - iq = (sa_k/q) * q; - h = plcp[sa_k/q] - (sa_k-iq); - if(h<0) - h=0; - /*the total cost of this loop should be O(qn)*/ - while(sa_k+h < n && sa_ant+h < n && text[sa_k+h]==text[sa_ant+h]) - h++; - lcp[k] = h; - } - } - delete [] plcp; - delete [] sa; - return lcp; - } - - LCP * LCP::load(istream & fp) { - size_t r = loadValue(fp); - size_t pos = fp.tellg(); - fp.seekg(pos-sizeof(size_t)); - cout << "Loading "<< r << endl; - switch(r) { - case NAIVE: return LCP_naive::load(fp); - case SAD_GON_OS: return LCP_Sad::load(fp); - case FMN_RRR_OS: return LCP_FMN::load(fp); - case PT: return LCP_PT::load(fp); - case PHI: return LCP_PhiSpare::load(fp); - case DAC: return LCP_DAC::load(fp); - case DAC_VAR: return LCP_DAC_VAR::load(fp); - } - return NULL; - } -}; diff --git a/libcds/src/static/suffixtree/LCP_DAC.cpp b/libcds/src/static/suffixtree/LCP_DAC.cpp deleted file mode 100644 index 7dabf11f..00000000 --- a/libcds/src/static/suffixtree/LCP_DAC.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - /*global variable for do sequential access*/ - - /*LCP using Directly Addressable Variable-Length Codes */ - LCP_DAC::LCP_DAC() { - lcp_type = DAC; - rep = NULL; - n = 0; - next_p = NULL; - } - - LCP_DAC::LCP_DAC(TextIndex *csa, char *text, size_t length) { - lcp_type = DAC; - n = length; - uint *lcp = create_lcp(csa,text,n,32); - rep = new factorization(lcp, n); - next_p = new size_t[(uint)rep->nLevels -1]; - delete [] lcp; - } - - size_t LCP_DAC::get_LCP(size_t i, TextIndex *csa) const - { - return (size_t)rep->access(i+1); - } - - size_t LCP_DAC::get_seq_LCP(size_t i, TextIndex *csa, size_t **next_pos, size_t *n_next, bool dir) const - { - if(*n_next==0) { - *n_next = (size_t)rep->nLevels -1; - for(size_t j=0; j< *n_next; j++) - next_p[j] =0; - *next_pos = next_p; - } - return (size_t)rep->access_seq(i+1, *next_pos, dir); - } - - size_t LCP_DAC::getSize() const - { - size_t mem = 0; - mem += sizeof(LCP_DAC); - mem += sizeof(size_t)*((uint)rep->nLevels -1); - mem += rep->getSize(); - return mem; - } - - void LCP_DAC::save(ostream & fp) const - { - saveValue(fp, lcp_type); - saveValue(fp, n); - rep->save(fp); - } - - LCP_DAC* LCP_DAC::load(istream & fp) { - LCP_DAC *lcp = new LCP_DAC(); - size_t type = loadValue(fp); - if(type!=DAC) { - abort(); - } - lcp->n = loadValue(fp); - lcp->rep = factorization::load(fp); - lcp->next_p = new size_t[(uint)((lcp->rep)->nLevels) -1]; - return lcp; - } - - LCP_DAC::~LCP_DAC() { - if(rep!=NULL) - delete (factorization *)rep; - if(next_p!=NULL) - delete [] next_p; - } - -}; diff --git a/libcds/src/static/suffixtree/LCP_DAC_VAR.cpp b/libcds/src/static/suffixtree/LCP_DAC_VAR.cpp deleted file mode 100644 index 6b7edf7a..00000000 --- a/libcds/src/static/suffixtree/LCP_DAC_VAR.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - /*LCP using Directly Addressable Variable-Length Codes variable******************************************/ - LCP_DAC_VAR::LCP_DAC_VAR() { - lcp_type = DAC_VAR; - next_p_var = NULL; - rep = NULL; - n = 0; - } - - LCP_DAC_VAR::LCP_DAC_VAR(TextIndex *csa, char *text, size_t length) { - lcp_type = DAC_VAR; - n = length; - uint *lcp; - uint *frec_acu = new uint[n]; - uint max_lcp = 0; - ushort *kvalues; - uint nkvalues; - /*create the LCP array and frec_acu array*/ - lcp = create_lcp(csa,text,n,32); - for(uint i=0; inLevels -1]; - delete [] kvalues; - delete [] frec_acu; - delete [] lcp; - } - - void LCP_DAC_VAR::calc_kvalues(uint max_lcp, uint *frec_acu, ushort **kvalues, uint *nkvalues) const - { - uint list_length=0; - uint nBits; - - /*calculate the kvalues*/ - list_length = frec_acu[max_lcp]; - nBits = bits(max_lcp); - //This table will contain the size of the best option for store the firts x bits - long * tableSize = new long[nBits+1]; - uint * tableNLevels = new uint[nBits+1]; - uint ** tableKvalues = new uint*[nBits+1]; - uint j; - ulong maxSize=0, maxPos=0; - uint posVocInf, posVocSup; - ulong currentSize; - tableSize[0]=0; - tableNLevels[0]=0; - tableKvalues[0]=NULL; - - for(uint i=1;i<=nBits;i++) { - maxSize=-1; - maxPos=0; - for(j=0;j= max_lcp) - posVocSup= max_lcp; - if(j==0) - currentSize = tableSize[j]+ ((ulong)(frec_acu[max_lcp]-frec_acu[posVocInf]))*((i-j)); - else - currentSize = tableSize[j]+ ((ulong)(frec_acu[max_lcp]-frec_acu[posVocInf]))*((i-j)+1)+(frec_acu[max_lcp]-frec_acu[posVocInf])/FACT_RANK; - if(maxSize>currentSize) { - maxSize=currentSize; - maxPos=j; - } - } - tableSize[i]=maxSize; - tableNLevels[i]=tableNLevels[maxPos]+1; - tableKvalues[i]=new uint[tableNLevels[i]]; - for(j=0;j=max_lcp) - posVocSup=max_lcp; - if(j==tableNLevels[nBits]) - sumaTotal += ((ulong)(frec_acu[max_lcp]-frec_acu[posVocInf]))*bitsCount; - else - sumaTotal += ((ulong)(frec_acu[max_lcp]-frec_acu[posVocInf]))*(bitsCount+1)+(frec_acu[max_lcp]-frec_acu[posVocInf])/FACT_RANK; - bitCountInf+=bitsCount; - } - - *nkvalues = tableNLevels[nBits]; - ushort *_kvalues = new ushort[*nkvalues]; - cout << endl; - for(j=0;jaccess(i+1); - } - - size_t LCP_DAC_VAR::get_seq_LCP(size_t i, TextIndex *csa, size_t **next_pos, size_t *n_next, bool dir) const - { - if(*n_next==0) { - *n_next = (uint)rep->nLevels -1; - for(uint j=0; j< *n_next; j++) - next_p_var[j] =0; - *next_pos = next_p_var; - } - return (size_t)rep->access_seq(i+1, *next_pos, dir); - } - - size_t LCP_DAC_VAR::getSize() const - { - size_t mem = 0; - mem += sizeof(LCP_DAC_VAR); - mem += sizeof(size_t)*((uint)rep->nLevels -1); - mem += rep->getSize(); - return mem; - } - - void LCP_DAC_VAR::save(ostream & fp) const - { - saveValue(fp, lcp_type); - saveValue(fp, n); - rep->save(fp); - } - - LCP_DAC_VAR* LCP_DAC_VAR::load(istream & fp) { - LCP_DAC_VAR *lcp = new LCP_DAC_VAR(); - size_t type = loadValue(fp); - if(type!=DAC_VAR) { - abort(); - } - lcp->n = loadValue(fp); - lcp->rep = factorization_var::load(fp); - lcp->next_p_var = new size_t[(size_t)((lcp->rep)->nLevels) -1]; - return lcp; - } - - LCP_DAC_VAR::~LCP_DAC_VAR() { - if(rep != NULL) - delete (factorization_var *)rep; - if(next_p_var != NULL) - delete [] next_p_var; - } - -}; diff --git a/libcds/src/static/suffixtree/LCP_FMN.cpp b/libcds/src/static/suffixtree/LCP_FMN.cpp deleted file mode 100644 index fa01e5e9..00000000 --- a/libcds/src/static/suffixtree/LCP_FMN.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - LCP_FMN::LCP_FMN() { - lcp_type = FMN_RRR_OS; - O = NULL; - Z = NULL; - b_length = OZ_type = 0; - } - - void LCP_FMN::generate_OZ(BitSequence *U, uint **O, uint **Z, uint length) { - uint *o, *z; - bool bit_1 = true; //tell if we are counting 1 bits or 0 bits - uint cont_1 = 0; - uint cont_0 = 0; - long long nb = 1; - nb = (nb*length+W-1)/W; - if(nb > MAXINT) { - cerr << "Memory limit excess (in LCP)" << endl; - exit(1); - } - o = new uint[(uint)nb]; - z = new uint[(uint)nb]; - - for(uint i=0; i< (uint)nb; i++) { - o[i]=0; - z[i]=0; - } - - for(uint i=0; iaccess(i)) { - if(bit_1) - cont_1++; - else { - bit_1 = true; - cont_1++; - cds_utils::bitset(z,cont_0-1); - } - } - else { - if(bit_1) { - bit_1 = false; - cont_0++; - cds_utils::bitset(o,cont_1-1); - } - else - cont_0++; - } - } - if(bit_1) - cds_utils::bitset(o,cont_1-1); - else - cds_utils::bitset(z,cont_0-1); - *O = o; - *Z = z; - } - - LCP_FMN::LCP_FMN(TextIndex *csa, char *text, size_t n, size_t op_rs) { - if(op_rs!=RRR02_HDR && op_rs!=SDARRAY_HDR) { - cerr << "Error: op_rs must be RRR02_HDR or SDARRAY_HDR\n" << endl; - exit(1); - } - lcp_type = FMN_RRR_OS; - OZ_type = op_rs; - LCP_Sad *sa_lcp = new LCP_Sad(csa, text, n); - uint *O_aux, *Z_aux; - b_length = sa_lcp->U_length; - generate_OZ(sa_lcp->U, &O_aux, &Z_aux, b_length); - if(op_rs==RRR02_HDR) { - O = new BitSequenceRRR(O_aux, b_length); - Z = new BitSequenceRRR(Z_aux, b_length); - } - else { - O = new BitSequenceSDArray(O_aux, b_length); - Z = new BitSequenceSDArray(Z_aux, b_length); - } - delete (LCP_Sad *)sa_lcp; - delete [] O_aux; - delete [] Z_aux; - } - - LCP_FMN::LCP_FMN(LCP *lcp, TextIndex *csa, size_t n, size_t op_rs) { - uint *O_aux, *Z_aux; - if(op_rs!=RRR02_HDR && op_rs!=SDARRAY_HDR) { - cerr << "Error: op_rs must be RRR02_HDR or SDARRAY_HDR\n" << endl; - exit(1); - } - lcp_type = FMN_RRR_OS; - OZ_type = op_rs; - LCP_Sad *sa_lcp = new LCP_Sad(lcp, csa, n); - b_length = sa_lcp->U_length; - generate_OZ(sa_lcp->U, &O_aux, &Z_aux, b_length); - if(op_rs==RRR02_HDR) { - O = new BitSequenceRRR(O_aux, b_length); - Z = new BitSequenceRRR(Z_aux, b_length); - } - else { - O = new BitSequenceSDArray(O_aux, b_length); - Z = new BitSequenceSDArray(Z_aux, b_length); - } - delete (LCP_Sad *)sa_lcp; - delete [] O_aux; - delete [] Z_aux; - } - - size_t LCP_FMN::get_LCP(size_t i, TextIndex *csa) const - { - size_t val = csa->getSA(i); - size_t rank_0 = O->rank1(val); - if(rank_0 > 0) { - size_t r = Z->select1(rank_0) - val +1; - return r; - } - else - return 0; - } - - size_t LCP_FMN::get_seq_LCP(size_t i, TextIndex *csa, size_t **next_pos, size_t *n_next, bool dir) const - { - return get_LCP(i,csa); - } - - size_t LCP_FMN::getSize() const - { - return O->getSize() + Z->getSize() + sizeof(LCP_FMN); - } - - void LCP_FMN::save(ostream & fp) const - { - saveValue(fp,lcp_type); - saveValue(fp,b_length); - saveValue(fp,OZ_type); - O->save(fp); - Z->save(fp); - } - - LCP_FMN* LCP_FMN::load(istream & fp) { - LCP_FMN *lcp = new LCP_FMN(); - size_t type = loadValue(fp); - if(type!=FMN_RRR_OS) { - abort(); - } - lcp->b_length = loadValue(fp); - lcp->OZ_type = loadValue(fp); - lcp->O = BitSequence::load(fp); - lcp->Z = BitSequence::load(fp); - return lcp; - } - - LCP_FMN::~LCP_FMN() { - if(O!= NULL) { - if(OZ_type == RRR02_HDR) - delete (BitSequenceRRR *)O; - else - delete (BitSequenceSDArray *)O; - } - if(Z!=NULL) { - if(OZ_type == RRR02_HDR) - delete (BitSequenceRRR *)Z; - else - delete (BitSequenceSDArray *)Z; - } - } - -}; diff --git a/libcds/src/static/suffixtree/LCP_PT.cpp b/libcds/src/static/suffixtree/LCP_PT.cpp deleted file mode 100644 index 329452d9..00000000 --- a/libcds/src/static/suffixtree/LCP_PT.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -const int max_precomputed_cover = 8; -const unsigned cover0[] = {0}; -const unsigned cover1[] = {0,1}; -const unsigned cover2[] = {0,1,2}; -const unsigned cover3[] = {0,1,2,4}; -const unsigned cover4[] = {0,1,2,5,8}; -const unsigned cover5[] = { //{0,7,8,10,14,19,23}; - 0,1,2,3,7,11,19 -}; -const unsigned cover6[] = {0,1,2,5,14,16,34,42,59}; -const unsigned cover7[] = {0,1,3,7,17,40,55,64,75,85,104,109,117}; -const unsigned cover8[] = { - 0,1,3,7,12,20,30,44,65,80,89,96,114,122, - 128,150,196,197,201,219 -}; -const unsigned * _covers[] = { - cover0, cover1, cover2, cover3, cover4, - cover5, cover6, cover7, cover8 -}; - -const int _cover_sizes[] = {1,2,3,4,5,7,9,13,20}; - -namespace cds_static -{ - - LCP_PT::LCP_PT() { - lcp_type = PT; - logv = 0; - length = 0; - mask = v = m = cover_size = 0; - rev_cover = NULL; - delta = NULL; - rev_ess = NULL; - rmq = NULL; - } - - LCP_PT::LCP_PT(TextIndex *csa, char *text, size_t n, int _logv) { - if(_logv > max_precomputed_cover) { - fprintf(stderr,"Specified DC (%d) greater than max (%d)\n",_logv,max_precomputed_cover); - exit(1); - } - lcp_type = PT; - logv = _logv; - v = (1 << _logv); - mask = v - 1; - length = n; - unsigned *_cover = (unsigned *)(_covers[logv]); - cover_size = _cover_sizes[logv]; - int _m = length/v; - _m = _m * cover_size; - //compute rev_cover - rev_cover = new int[v]; - int j = 0; - for(int i = 0; i < v; i++) { - rev_cover[i] = -1; - if((int)_cover[j] == i) { - rev_cover[i] = j; - if(j < (int)(length & mask)) - _m++; - j++; - } - } - - //compute delta - delta = new int[v]; - for (int i = cover_size-1; i >= 0; i--) { - for (j = 0; j < cover_size; j++) - delta[(_cover[j]-_cover[i])%v] = _cover[i]; - } - - m = _m; - //compute arrays _ess, rev_ess - int *_ess = (int *)malloc(sizeof(int) * _m); - rev_ess = new int[_m]; - for(int i=0; i<_m; i++) - rev_ess[i]=0; - j = 0; - for(int i = 0; i < (int)length; i++) { - //_sa[i] - int si = csa->getSA(i); - if(rev_cover[si&mask] != -1) { - //this is a sample suffix - _ess[j] = si; - rev_ess[(cover_size*(si>>logv)) + rev_cover[si&mask]] = j; - j++; - } - } - - //compute _ell using _ess, _rev_ess, _rev_cover - int *ell = new int[_m]; - for(int i=0; i<_m;i++) - ell[i]=0; - ell[0] = 0; - int len = 0; - int computed = 0; - int *lengths = (int *)malloc(sizeof(int) * cover_size); - for(int i = 0; i < cover_size; i++) { - lengths[i] = 0; - } - int compares_saved = 0; - int ihat = 0; - for(int i = 0; i < _m; i++) { - ihat = rev_ess[i]; - len = lengths[i%cover_size]; - if(len < 0) len = 0; - compares_saved += len; - if(ihat > 0) { - int j = _ess[ihat-1]; - while(_ess[ihat]+len < (int)length && j+len < (int)length) { - if(text[_ess[ihat]+len] != text[j+len]) { - break; - } - len++; - } - } - ell[ihat] = len; - int a = rev_cover[(_ess[ihat])&mask]; - lengths[a] = len - v; - computed++; - } - //we no longer need _ess and lengths. - free(_ess); - free(lengths); - //preprocess _ell for RMQs - rmq = new RMQ_succinct(ell,_m); - } - - int LCP_PT::calc_delta(unsigned int i, unsigned int j) const - { - return ((delta[(j-i)%v]-i)%v); - } - - size_t LCP_PT::get_LCP(size_t i, TextIndex *csa) const - { - if(i==0) - return 0; - int p0 = i-1; - int p1 = i; - int j=0; - while( csa->getT(p0) == csa->getT(p1) && j < v && p0!=-1 && p1!=-1) { - j++; - p0 = csa->getPsi(p0); - p1 = csa->getPsi(p1); - } - if(jgetSA(i-1); - //SA[i] - int s1 = (int)csa->getSA(i); - int ds0s1 = calc_delta((unsigned int)s0,(unsigned int)s1); - int a0 = s0 + ds0s1; - int a1 = s1 + ds0s1; - int r0 = rev_ess[(cover_size*(a0>>logv)) + rev_cover[a0&mask]]; - int r1 = rev_ess[(cover_size*(a1>>logv)) + rev_cover[a1&mask]]; - int rmin_auto = rmq->a[(rmq->query(r0+1,r1))]; - return (size_t)(ds0s1 + rmin_auto); - } - } - - size_t LCP_PT::get_seq_LCP(size_t i, TextIndex *csa, size_t **next_pos, size_t *n_next, bool dir) const - { - return get_LCP(i,csa); - } - - size_t LCP_PT::getSize() const - { - size_t mem =0; - mem += sizeof(LCP_PT); - mem += rmq->getSize(); - //rev_cover - mem += sizeof(int) * v; - //delta - mem += sizeof(int) * v; - //rev_ess; - mem += sizeof(int) * m; - return mem; - } - - void LCP_PT::save(ostream & fp) const - { - saveValue(fp, lcp_type); - saveValue(fp, logv); - saveValue(fp, length); - saveValue(fp, m); - saveValue(fp, rev_cover, v); - saveValue(fp, delta, v); - saveValue(fp, rev_ess, m); - rmq->save(fp); - } - - LCP_PT * LCP_PT::load(istream & fp) { - LCP_PT *lcp = new LCP_PT(); - size_t type = loadValue(fp); - if(type!=PT) { - abort(); - } - lcp->logv = loadValue(fp); - lcp->length = loadValue(fp); - lcp->m = loadValue(fp); - lcp->v = (1 << lcp->logv); - lcp->mask = lcp->v - 1; - lcp->cover_size = _cover_sizes[lcp->logv]; - lcp->rev_cover = loadValue(fp, lcp->v); - lcp->delta = loadValue(fp, lcp->v); - lcp->rev_ess = loadValue(fp, lcp->m); - lcp->rmq = lcp->rmq->load(fp); - return lcp; - } - - LCP_PT::~LCP_PT() { - delete[] rev_cover; - delete[] delta; - delete[] rev_ess; - delete (RMQ_succinct *)rmq; - } -}; diff --git a/libcds/src/static/suffixtree/LCP_PhiSpare.cpp b/libcds/src/static/suffixtree/LCP_PhiSpare.cpp deleted file mode 100644 index 6a6aaa3d..00000000 --- a/libcds/src/static/suffixtree/LCP_PhiSpare.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - LCP_PhiSpare::LCP_PhiSpare() { - lcp_type = PHI; - q = n = 0; - plcp = NULL; - } - - LCP_PhiSpare::LCP_PhiSpare(TextIndex *csa, char *text, size_t _n, int _q) { - if(_q > (int)_n) { - cerr << "Specified q (" << _q << ") greater than string length (" << _n << ")" << endl; - exit(1); - } - lcp_type = PHI; - - int i,h,j,k, m; - int *sa; - q = _q; - n = _n; - - /*q==-1 its mean that for any position we just use psi for calculate each LCP*/ - if(q!=-1) { - m = 1+(_n-1)/_q; - plcp = new int[m]; //space for sampled lcps - if(plcp==NULL) { - cerr << "Failed to allocate memory for plcp." << endl; - exit(1); - } - // initialize samples to -1 - for(i=0; i < m; i++) - plcp[i] = -1; - sa = new int[n]; - //calculate SA - for(k=0; k < (int)n; k++) - sa[k] = csa->getSA(k); - //compute the sparse phi array (in plcp) - for(k=1; k < (int)n-1; k++) { - if(sa[k] % q == 0) { - plcp[sa[k]/q] = sa[k-1]; - } - } - //most of sparse phi computed - - //make a special case of the last one - if(sa[n-1]%q == 0) - plcp[sa[n-1]/q] = sa[n-2]; - //all of sparse phi computed - - delete [] sa; - - //compute lcp'' - h = 0; - for(i=0; i < m; i++) { - j = plcp[i]; //here plcp[i] = phi'[i] - k = i*q; - while(k+h < (int)n && j+h < (int)n && text[k+h] == text[j+h]) - h++; - plcp[i] = h; //now plcp[i] = h - if(h > 0) - h -= q; - if(h < 0) - h = 0; - } - } - } - - size_t LCP_PhiSpare::get_LCP(size_t i, TextIndex *csa) const - { - if(i==0) - return 0; - int iq, h, y; - int sa_i = csa->getSA(i);// SA[i] - int p0, p1; - p0 = i-1; - p1 = i; - - if(q==-1) - h = 0; - else { - //if we've already worked this one out - if(sa_i % q == 0) - return plcp[sa_i/q]; - iq = (sa_i/q)*q; //smallest multiple of q less than sa_i - h = plcp[sa_i/q] - (sa_i-iq); - if(h < 0) - h = 0; - if(h != 0) { - //SA[i-1] - y = csa->getSA(i-1); - if(y < sa_i) - h=0; - else { - //this must be p1=SA_inverse[SA[i]+h] y p0=SA_inverse[SA[i-1]+h] - p1 = csa->getISA(sa_i+h); - p0 = csa->getISA(y+h); - } - } - } - //the total cost of this loop should be O(qn) - //while(sa_i+h < n && j+h < n && text[i+h] == text[j+h]) - while(csa->getT(p0) == csa->getT(p1) && p0!=-1 && p1!=-1) { - h++; - p0 = csa->getPsi(p0); - p1 = csa->getPsi(p1); - } - return h; - } - - size_t LCP_PhiSpare::get_seq_LCP(size_t i, TextIndex *csa, size_t **next_pos, size_t *n_next, bool dir) const - { - return get_LCP(i,csa); - } - - size_t LCP_PhiSpare::getSize() const - { - size_t mem =0; - if(q==-1) - return 0; - mem += sizeof(LCP_PhiSpare); - mem += (1+(n-1)/q)*sizeof(int); - return mem; - } - - void LCP_PhiSpare::save(ostream & fp) const - { - saveValue(fp, lcp_type); - saveValue(fp, q); - saveValue(fp, n); - if(q!=-1) - saveValue(fp, plcp, (1+(n-1)/q)); - } - - LCP_PhiSpare * LCP_PhiSpare::load(istream & fp) { - LCP_PhiSpare *lcp = new LCP_PhiSpare(); - size_t type = loadValue(fp); - if(type!=PHI) { - abort(); - } - lcp->q = loadValue(fp); - lcp->n = loadValue(fp); - if(lcp->q!=-1) { - int size = 1+ (lcp->n-1/lcp->q); - lcp->plcp = loadValue(fp, size); - } - return lcp; - } - - LCP_PhiSpare::~LCP_PhiSpare() { - if(q!=-1) - delete [] plcp; - } - -}; diff --git a/libcds/src/static/suffixtree/LCP_Sad.cpp b/libcds/src/static/suffixtree/LCP_Sad.cpp deleted file mode 100644 index fdc2f626..00000000 --- a/libcds/src/static/suffixtree/LCP_Sad.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include "LCP_Sad.h" - -namespace cds_static -{ - - LCP_Sad::LCP_Sad() { - lcp_type = SAD_GON_OS; - U = NULL; - U_length = U_type = 0; - } - - LCP_Sad::LCP_Sad(TextIndex *csa, char *text, size_t n, size_t op_rs) { - if(op_rs!=BRW32_HDR && op_rs!=DARRAY_HDR) { - cout << "Error: op_rs must be BRW32_HDR or DARRAY_HDR\n" << endl; - exit(1); - } - lcp_type = SAD_GON_OS; - U_type = op_rs; - uint *lcp = create_lcp(csa,text,n,32); - uint pos =0; - uint lcp_prev, lcp_act; - long long nb = 1; - nb = (nb*2*n+W-1)/W; - if(nb > MAXINT) { - cout << "Memory limit excess (in LCP)" << endl; - exit(1); - } - uint *S = new uint[(uint)nb]; - for(uint i=0; i < (uint)nb; i++) - S[i]=0; - cds_utils::bitset(S,0); - - lcp_prev = lcp[csa->getISA(0)]; - pos += lcp_prev +1; - //calculate S and create U - for(uint i=1; igetISA(i)]; - pos+= lcp_act - lcp_prev + 2; - lcp_prev = lcp_act; - } - cds_utils::bitset(S,pos); - if(op_rs==BRW32_HDR) - //(bitarray, length, factor) - U = new BitSequenceRG(S, pos+1, 4); - else - U = new BitSequenceDArray(S, pos+1); - U_length = (size_t)(pos+1); - delete [] S; - delete [] lcp; - } - - LCP_Sad::LCP_Sad(LCP *lcp, TextIndex *csa, size_t n, size_t op_rs) { - if(op_rs!= BRW32_HDR && op_rs!= DARRAY_HDR) { - cout << "Error: op_rs must be BRW32_HDR or DARRAY_HDR\n" << endl; - exit(1); - } - lcp_type = SAD_GON_OS; - U_type = op_rs; - uint pos =0; - uint lcp_prev, lcp_act; - long long nb = 1; - nb = (nb*2*n+W-1)/W; - if(nb > MAXINT) { - cout << "Memory limit excess (in LCP)" << endl; - exit(1); - } - uint *S = new uint[(uint)nb]; - for(uint i=0; i < (uint)nb; i++) - S[i]=0; - cds_utils::bitset(S,0); - lcp_prev = lcp->get_LCP(csa->getISA(0), csa); - pos += lcp_prev +1; - //calculate S and create U - for(uint i=1; iget_LCP(csa->getISA(i), csa); - pos+= lcp_act - lcp_prev + 2; - lcp_prev = lcp_act; - } - cds_utils::bitset(S,pos); - if(op_rs==BRW32_HDR) - //(bitarray, length, factor) - U = new BitSequenceRG(S, pos+1, 4); - else - U = new BitSequenceDArray(S, pos+1); - U_length = (size_t)(pos+1); - delete [] S; - } - - size_t LCP_Sad::get_LCP(size_t i, TextIndex *csa) const - { - size_t val = csa->getSA(i); - if(val > 0) - return U->select1(val+2)-2*val-1; - else - return U->select1(2)-1; - } - - size_t LCP_Sad::get_seq_LCP(size_t i, TextIndex *csa, size_t **next_pos, size_t *n_next, bool dir) const - { - return get_LCP(i,csa); - } - - size_t LCP_Sad::getSize() const - { - return U->getSize()+sizeof(LCP_Sad); - } - - void LCP_Sad::save(ostream & fp) const - { - saveValue(fp, lcp_type); - saveValue(fp,U_type); - saveValue(fp,U_length); - U->save(fp); - } - - LCP_Sad* LCP_Sad::load(istream & fp) { - LCP_Sad *lcp = new LCP_Sad(); - size_t type = loadValue(fp); - if(type!=SAD_GON_OS) { - abort(); - } - lcp->U_type = loadValue(fp); - lcp->U_length = loadValue(fp); - lcp->U = BitSequence::load(fp); - return lcp; - } - - LCP_Sad::~LCP_Sad() { - if(U!=NULL) { - if(U_type==BRW32_HDR) - delete (BitSequenceRG *)U; - else - delete (BitSequenceDArray *)U; - } - } -}; diff --git a/libcds/src/static/suffixtree/LCP_naive.cpp b/libcds/src/static/suffixtree/LCP_naive.cpp deleted file mode 100644 index 3e64a421..00000000 --- a/libcds/src/static/suffixtree/LCP_naive.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - LCP_naive::LCP_naive() { - lcp_array = NULL; - length = b = 0; - } - - /*Compute LCP by brute force using nlog(n) bits */ - - LCP_naive::LCP_naive(TextIndex *csa, char *text, size_t n) { - length =n; - size_t prev, act, val; - b = bits(length-1); - long long nb = 1; - nb = (nb*b*n+W-1)/W; - if(nb > MAXINT) { - cerr << "Memory limit excess (in LCP)" << endl; - exit(1); - } - lcp_array = new uint[(size_t)nb]; - for(size_t i=0; i<(size_t)nb; i++) - lcp_array[i]=0; - set_field_64(lcp_array, b, 0, 0); - val = csa->getSA(0); - prev = n - val; - for(size_t i=1; i < length; i++) { - val = csa->getSA(i); - act = n - val; - set_field_64(lcp_array, b, i, lcp_length(text, n-prev, val, min(prev,act))); - prev = act; - } - } - - size_t LCP_naive::get_LCP(size_t i, TextIndex *csa) const - { - return get_field_64(lcp_array, b, i); - } - - size_t LCP_naive::get_seq_LCP(size_t i, TextIndex *csa, size_t **next_pos, size_t *n_next, bool dir) const - { - return get_LCP(i,csa); - } - - size_t LCP_naive::getSize() const - { - size_t result = ((b*length+W-1)/W)*sizeof(size_t); - return result + sizeof(LCP_naive); - } - - void LCP_naive::save(ostream & fp) const - { - size_t wr = NAIVE; - saveValue(fp,wr); - saveValue(fp,length); - saveValue(fp,b); - saveValue(fp, lcp_array, ((b*length+W-1)/W)); - } - - LCP_naive* LCP_naive::load(istream & fp) { - LCP_naive *lcp = new LCP_naive(); - size_t type = loadValue(fp); - if(type!=NAIVE) { - abort(); - } - lcp->length = loadValue(fp); - lcp->b = loadValue(fp); - lcp->lcp_array = loadValue(fp, ((lcp->b*lcp->length+W-1)/W)); - return lcp; - } - - LCP_naive::~LCP_naive() { - if(lcp_array!=NULL) { - delete [] lcp_array; - } - } -}; diff --git a/libcds/src/static/suffixtree/NPR.cpp b/libcds/src/static/suffixtree/NPR.cpp deleted file mode 100644 index a5679a11..00000000 --- a/libcds/src/static/suffixtree/NPR.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - NPR * NPR::load(istream & fp) { - size_t r = loadValue(fp); - size_t pos = fp.tellg(); - fp.seekg(pos-sizeof(size_t)); - cout << "Loading NPR "<< r << endl; - switch(r) { - case FMN_NPR: return NPR_FMN::load(fp); - case CN_NPR: return NPR_CN::load(fp); - } - return NULL; - } - -}; diff --git a/libcds/src/static/suffixtree/NPR_CN.cpp b/libcds/src/static/suffixtree/NPR_CN.cpp deleted file mode 100644 index e59d2014..00000000 --- a/libcds/src/static/suffixtree/NPR_CN.cpp +++ /dev/null @@ -1,471 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - NPR_CN::NPR_CN() { - npr_type = CN_NPR; - n = 0; - b = 0; - bits_b = 0; - l = 0; - min_level = NULL; - level_size = NULL; - min_pos = NULL; - } - - NPR_CN::NPR_CN(LCP *lcp, size_t block_Size, TextIndex *csa) { - npr_type = CN_NPR; - n = csa->index_length(); - b = block_Size; - bits_b = bits(b); - l =(size_t)(log(n)/log(b)); - level_size = new uint[l]; - for(size_t i=0; iget_LCP(ini+j, csa); - if(min_aux < min) { - min = min_aux; - pos = j; - } - } - min_level[0][i] = min; - set_field_64(min_pos[0], bits_b, i, pos); - } - - /*calculate min for the last block*/ - min = n; - pos = 0; - ini = (level_size[0]-1)*b; - for(size_t j=ini; j < n; j++) { - min_aux = lcp->get_LCP(j, csa); - if(min_aux < min) { - min = min_aux; - pos = j - ini; - } - } - min_level[0][level_size[0]-1] = min; - set_field_64(min_pos[0], bits_b, level_size[0]-1, pos); - } - - void NPR_CN::create_next_level(size_t r) { - level_size[r] = (level_size[r-1]+b-1)/b; - min_level[r] = new uint[level_size[r]]; - for(size_t i=0; i< level_size[r]; i++) - min_level[r][i] = 0; - min_pos[r] = new uint[((level_size[r]*bits_b+W-1)/W)]; - for(size_t i=0; i<((level_size[r]*bits_b+W-1)/W); i++) - min_pos[r][i] = 0; - size_t min, min_aux; - size_t ini; - size_t pos; - - /*calculate the min for each block except the last one*/ - for(size_t i=0; iget_LCP(v, csa); - return fwd_NSV(v, csa, lcp, value_v); - } - - size_t NPR_CN::find_NSV_level_r(size_t value_v, size_t next_pos, size_t r) const - { - size_t lim; - size_t end_block = b*((next_pos+b)/b); - if(end_block > level_size[r]) - end_block = level_size[r]; - /*search in the same block*/ - for(size_t i=next_pos+1; i < end_block; i++) { - if(min_level[r][i] < value_v) - return i; - } - if(end_block==level_size[r]) - return level_size[r]; - /*search in the next levels*/ - lim = find_NSV_level_r(value_v, next_pos/b, r+1); - /*search in the same block than lim*/ - if(lim==level_size[r+1]) - return level_size[r]; - /*this must return something*/ - for(size_t i= b*lim; i< b*(lim+1); i++) { - if(min_level[r][i] < value_v) - return i; - } - /*if here not exist a return yet -> error!!*/ - return (size_t)-1; - } - - size_t NPR_CN::fwd_NSV(size_t v, TextIndex *csa, LCP *lcp, size_t d) const - { - size_t aux_nsv; - size_t lim; - if(d == 0) - return n; - size_t *next; - size_t n_next = 0; - /*search in the same block*/ - size_t end_block = b*((v+b)/b); - if(end_block>n) - end_block = n; - for(size_t i=v+1; i < end_block; i++) { - aux_nsv = lcp->get_seq_LCP(i,csa, &next, &n_next, 1); - if(aux_nsv < d) - return i; - } - if(end_block==n) - return n; - /*search in the next levels*/ - lim = find_NSV_level_r(d, v/b, 0); - /*search in the same block than lim*/ - if(lim==level_size[0]) { - return n; - } - /*this must return something*/ - n_next = 0; - for(size_t i= b*lim; i< b*(lim+1); i++) { - aux_nsv = lcp->get_seq_LCP(i,csa, &next, &n_next, 1); - if(aux_nsv < d) { - return i; - } - } - /*this never happen*/ - return (size_t)-1; - } - - size_t NPR_CN::find_PSV(size_t v, TextIndex *csa, LCP *lcp) const - { - size_t value_v = lcp->get_LCP(v, csa); - return bwd_PSV(v, csa, lcp, value_v); - } - - size_t NPR_CN::find_PSV_level_r(size_t value_v, size_t next_pos, size_t r) const - { - size_t lim; - size_t ini_block = b*((next_pos)/b); - if(next_pos == 0) - return 0; - /*search in the same block*/ - for(size_t i=next_pos-1; i > ini_block; i--) { - if(min_level[r][i] < value_v) - return i+1; - } - /*last one is a special case so we do it separate*/ - if(next_pos != ini_block) { - if(value_v > min_level[r][ini_block]) - return ini_block+1; - } - if(ini_block==0) - return 0; - /*search in the next levels*/ - lim = find_PSV_level_r(value_v, next_pos/b, r+1); - /*search in the same block than lim*/ - if(lim==0) - return 0; - /*this must return something*/ - for(size_t i= (b*lim-1); i >= b*(lim-1); i--) { - if(min_level[r][i] < value_v) - return i+1; - } - /*if here not exist a return yet -> error!!*/ - return (size_t)-1; - } - - size_t NPR_CN::bwd_PSV(size_t v, TextIndex *csa, LCP *lcp, size_t d) const - { - size_t aux_psv; - size_t lim; - if(d == 0) - return 0; - size_t *next; - size_t n_next = 0; - /*search in the same block*/ - size_t ini_block = b*(v/b); - for(size_t i=v-1; i > ini_block; i--) { - aux_psv = lcp->get_seq_LCP(i,csa, &next, &n_next, 0); - if(aux_psv < d) - return i+1; - } - /*last one is a special case so we do it separeted*/ - if(ini_block < v) { - if(d > lcp->get_LCP(ini_block,csa)) - return ini_block+1; - } - - if(ini_block==0) - return 0; - - /*search in the next levels*/ - lim = find_PSV_level_r(d, v/b, 0); - /*search in the same block than lim*/ - if(lim==0) - return 0; - - /*this must return something*/ - n_next = 0; - for(size_t i= b*lim-1; i >= b*(lim-1); i--) { - aux_psv = lcp->get_seq_LCP(i,csa, &next, &n_next, 0); - if(aux_psv < d) - return i+1; - } - return (size_t)-1; - } - - size_t NPR_CN::find_RMQ(size_t x, size_t y, TextIndex *csa, LCP *lcp) const - { - if(x>y){ size_t z = y; y = x; x = z;} - size_t ret = x; - size_t next_ret, min_r; - if(x==y) - return ret; - size_t *next; - size_t n_next = 0; - size_t min_val = lcp->get_seq_LCP(x,csa, &next, &n_next, 1); - size_t aux_min; - size_t x_r, y_r; - /*if x and y are in the same block O(b)*/ - if(x/b == y/b) { - for(size_t i=x+1; i<=y; i++) { - aux_min = lcp->get_seq_LCP(i,csa, &next, &n_next, 1); - if(aux_min < min_val) { - min_val = aux_min; - ret = i; - } - } - return ret; - } - /*if x is the begin of the block*/ - if(x%b == 0) - x_r = x/b; - else { - /*view in the same block*/ - for(size_t i=x+1; i < b*((x+b-1)/b) ; i++) { - aux_min = lcp->get_seq_LCP(i,csa, &next, &n_next, 1); - if(aux_min < min_val) { - min_val = aux_min; - ret = i; - } - } - x_r = (x+b-1)/b; - } - /*if y is the end of a block*/ - if(y%b == b-1) - y_r = y/b; - else { - /*view in the same block*/ - n_next = 0; - for(size_t i= b*(y/b); i <= y ; i++) { - aux_min = lcp->get_seq_LCP(i,csa, &next, &n_next, 1); - if(aux_min < min_val) { - min_val = aux_min; - ret = i; - } - } - y_r = (y/b) - 1; - } - if(x_r > y_r) { - return ret; - } - next_ret = find_RMQ(x_r, y_r, 0, &min_r); - if( (min_val < min_r) || (min_val == min_r && ret < b*next_ret)) - return ret; - else - return next_ret*b + get_field_64(min_pos[0], bits_b, next_ret); - - /*this never happen*/ - cerr << "Error" << endl; - return 0; - } - - size_t NPR_CN::find_RMQ(size_t x, size_t y, size_t r, size_t *min_r) const - { - size_t ret = x; - size_t next_ret, next_min; - *min_r = min_level[r][x]; - size_t aux_min; - size_t x_r, y_r; - if(x==y) - return ret; - /*if x and y are in the same block O(b)*/ - if(x/b == y/b) { - for(size_t i=x+1; i<=y; i++) { - aux_min = min_level[r][i]; - if(aux_min < *min_r) { - *min_r = aux_min; - ret = i; - } - } - return ret; - } - /*if x is the begin of the block*/ - if(x%b == 0) - x_r = x/b; - else { - /*view in the same block*/ - for(size_t i=x+1; i < b*((x+b-1)/b) ; i++) { - aux_min = min_level[r][i]; - if(aux_min < *min_r) { - *min_r = aux_min; - ret = i; - } - } - x_r = (x+b-1)/b; - } - /*if y is the end of a block*/ - if(y%b == b-1) - y_r = y/b; - else { - /*view in the same block*/ - for(size_t i=b*(y/b); i <= y ; i++) { - aux_min = min_level[r][i]; - if(aux_min < *min_r) { - *min_r = aux_min; - ret = i; - } - } - y_r = y/b - 1; - } - if(x_r > y_r) - return ret; - next_ret = find_RMQ(x_r, y_r, r+1, &next_min); - if( (*min_r < next_min) || (*min_r == next_min && ret < next_ret*b)) - return ret; - else { - *min_r = next_min; - return next_ret*b + get_field_64(min_pos[r+1], bits_b, next_ret); - } - /*Error if the code reach this return*/ - //cerr << "Error" << endl; - return (size_t)-1; - } - - size_t NPR_CN::getSize() const - { - size_t mem = sizeof(NPR_CN); - mem += sizeof(uint)*l; //level size - for(size_t i=0; i(fp); - if(type!=CN_NPR) { - abort(); - } - npr->n = loadValue(fp); - npr->b = loadValue(fp); - npr->bits_b = loadValue(fp); - npr->l = loadValue(fp); - npr->level_size = loadValue(fp, npr->l); - npr->min_level = new uint*[npr->l]; - for(size_t i=0; il; i++) - npr->min_level[i] = loadValue(fp, npr->level_size[i]); - npr->min_pos = new uint*[npr->l]; - for(size_t i=0; il; i++) - npr->min_pos[i] = loadValue(fp, (npr->level_size[i]*npr->bits_b+W-1)/W); - return npr; - } - -}; diff --git a/libcds/src/static/suffixtree/NPR_FMN.cpp b/libcds/src/static/suffixtree/NPR_FMN.cpp deleted file mode 100644 index b0783ae3..00000000 --- a/libcds/src/static/suffixtree/NPR_FMN.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - NPR_FMN::NPR_FMN() { - npr_type = FMN_NPR; - nsv = NULL; - psv = NULL; - rmq = NULL; - } - - NPR_FMN::NPR_FMN(LCP *lcp, size_t block_Size, TextIndex *csa, size_t levels) { - npr_type = FMN_NPR; - nsv = new NSV(lcp,levels, block_Size, csa); - psv = new PSV(lcp,levels, block_Size, csa); - rmq = new RMQ_succinct_lcp(lcp, csa); - } - - NPR_FMN::~NPR_FMN() { - delete (NSV *)nsv; - delete (PSV *)psv; - delete (RMQ_succinct_lcp *)rmq; - } - - size_t NPR_FMN::find_NSV(size_t i, TextIndex *csa, LCP *lcp) const - { - return nsv->find_NSV(i, csa, lcp); - } - - size_t NPR_FMN::find_PSV(size_t i, TextIndex *csa, LCP *lcp) const - { - return psv->find_PSV(i,csa,lcp); - } - - size_t NPR_FMN::bwd_PSV(size_t i, TextIndex *csa, LCP *lcp, size_t d) const - { - if(d==0) - return 0; - size_t pos = i; - size_t val_lcp; - while(pos!=0) { - val_lcp = lcp->get_LCP(pos, csa); - if(val_lcpindex_length();; - size_t pos = i; - size_t val_lcp; - while(pos!=csa->index_length()) { - val_lcp = lcp->get_LCP(pos, csa); - if(val_lcpquery(x, y, csa, lcp); - } - - size_t NPR_FMN::getSize() const - { - size_t mem = sizeof(NPR_FMN); - mem += nsv->getSize(); - mem += psv->getSize(); - mem += rmq->getSize(); - return mem; - } - - void NPR_FMN::save(ostream & fp) const - { - saveValue(fp, npr_type); - nsv->save(fp); - psv->save(fp); - rmq->save(fp); - } - - NPR_FMN * NPR_FMN::load(istream & fp) { - NPR_FMN *npr = new NPR_FMN(); - size_t type = loadValue(fp); - if(type!=FMN_NPR) { - abort(); - } - npr->nsv = NSV::load(fp); - npr->psv = PSV::load(fp); - npr->rmq = RMQ_succinct_lcp::load(fp); - return npr; - } - -}; diff --git a/libcds/src/static/suffixtree/NSV.cpp b/libcds/src/static/suffixtree/NSV.cpp deleted file mode 100644 index 21223c4b..00000000 --- a/libcds/src/static/suffixtree/NSV.cpp +++ /dev/null @@ -1,332 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - NSV::NSV() { - r=b=n=b_A=0; - P=NULL; - R=NULL; - A=NULL; - } - - void NSV::create_first_level(LCP *lcp, TextIndex *csa) { - uint *P_aux; - uint *R_aux; - uint size = (n+W-1)/W; - uint last_nsv = 0; - uint j; - uint lcp_value, nsv_aux; - P_aux = new uint[size]; - R_aux = new uint[size]; - - for(uint i=0; iget_LCP(i, csa); - nsv_aux = 0; - for(j=i+1; jget_LCP(j, csa); - if(lcp_value > nsv_aux) { - /*if is not near*/ - if( i/b < j/b ) { - if( j/b != last_nsv/b) { - /*mark the pioneer in P*/ - cds_utils::bitset(P_aux,i); - /*mark the pioneer and the NSV of the pioneer in R*/ - cds_utils::bitset(R_aux,i); - cds_utils::bitset(R_aux,j); - } - last_nsv=j; - } - break; - } - } /*close for j*/ - if(j==n) { - if(i/b < j/b) { - if(j/b != last_nsv/b) { - /*mark the pioneer in P*/ - cds_utils::bitset(P_aux,i); - /*mark the pioneer and the NSV of the pioneer in R*/ - cds_utils::bitset(R_aux,i); - cds_utils::bitset(R_aux,j); - } - last_nsv=j; - } - } - } /*close for i*/ - P[0] = new BitSequenceRRR(P_aux, n+1); - R[0] = new BitSequenceRRR(R_aux, n+1); - delete [] P_aux; - delete [] R_aux; - } - - void NSV::create_level_r(LCP *lcp, size_t level, TextIndex *csa) { - uint *P_aux; - uint *R_aux; - uint size = (n+W-1)/W; - uint last_nsv = 0; - uint j, far_aux, lcp_value, nsv_aux; - P_aux = new uint[size]; - R_aux = new uint[size]; - - for(uint i=0; i < size; i++) { - P_aux[i]=0; - R_aux[i]=0; - } - - uint num_elements = R[level-1]->rank1(n-1); - uint *lcp_r = new uint[num_elements]; - for(uint i=0; iget_LCP(R[level-1]->select1(i+1), csa); - } - - /*for each i find his NSV position*/ - for(uint i=0; i nsv_aux) { - /*if is not near*/ - if( i/b < j/b ) { - if( j/b != last_nsv/b) { - /*mark the pioneer in P*/ - far_aux = R[level-1]->select1(i+1); - cds_utils::bitset(P_aux,far_aux); - /*mark the pioneer and the NSV of the pioneer in R*/ - cds_utils::bitset(R_aux, far_aux); - cds_utils::bitset(R_aux, R[level-1]->select1(j+1)); - } - last_nsv=j; - } - break; - } - } /*close for j*/ - - if(j==num_elements) { - if( i/b < j/b ) { - if( j/b != last_nsv/b) { - /*mark the pioneer in P*/ - far_aux = R[level-1]->select1(i+1); - cds_utils::bitset(P_aux,far_aux); - /*mark the pioneer and the NSV of the pioneer in R*/ - cds_utils::bitset(R_aux,far_aux); - cds_utils::bitset(R_aux, n); - } - last_nsv=j; - } - } - } /*close for i*/ - delete [] lcp_r; - P[level] = new BitSequenceRRR(P_aux, n); - R[level] = new BitSequenceRRR(R_aux, n); - delete[] P_aux; - delete[] R_aux; - } - - void NSV::create_last_level(LCP *lcp, TextIndex *csa) { - uint *lcp_r; - uint lcp_value, nsv_aux, j; - - /*store the results for the last level*/ - uint num_elements = R[r-1]->rank1(n-1); - - b_A = bits(num_elements); - A = new uint[(num_elements*b_A + W -1)/W]; - for(size_t i=0; i<((num_elements*b_A + W -1)/W); i++) - A[i]=0; - - lcp_r = new uint[num_elements]; - for(uint i=0; iget_LCP(R[r-1]->select1(i+1), csa); - } - - for(uint i=0; i nsv_aux) { - set_field_64(A, b_A, i, j); - break; - } - } /*close for j*/ - if(j==num_elements) - set_field_64(A, b_A, i, j); - } /*close for i*/ - delete [] lcp_r; - } - - size_t NSV::find_NSV_r(size_t v, size_t level, TextIndex *csa, LCP *lcp) const - { - if(level == r) { - return get_field_64(A, b_A, v); - } - - /*look in the same block*/ - size_t num_elements = R[level-1]->rank1(n-1); - size_t pos_v = R[level-1]->select1(v+1); - size_t value_v = lcp->get_LCP(pos_v, csa); - size_t aux_nsv; - size_t pioneer, nsv_pioneer; - size_t end_block = b*((v+b)/b); - - if(end_block > num_elements) - end_block = num_elements; - - for(size_t i=v+1; i < end_block; i++) { - aux_nsv = lcp->get_LCP(R[level-1]->select1(i+1),csa); - if(aux_nsv < value_v) - return i; - } - - if(end_block==num_elements) { - return num_elements; - } - - /*find the pioneer*/ - pioneer = P[level]->select1(P[level]->rank1(pos_v)); - pioneer = R[level]->rank1(pioneer)-1; - /*resolve the pioneer recursive*/ - nsv_pioneer = find_NSV_r(pioneer, level+1, csa, lcp); - nsv_pioneer = R[level]->select1(nsv_pioneer+1); - if(nsv_pioneer==(size_t)-1) - nsv_pioneer = n; - nsv_pioneer = R[level-1]->rank1(nsv_pioneer)-1; - /*seek the answer in the same block of the nsv(las_pioneer)*/ - for(size_t i=(nsv_pioneer/b)*b ; i<=nsv_pioneer; i++) { - aux_nsv = lcp->get_LCP(R[level-1]->select1(i+1),csa); - if(aux_nsv < value_v) - return i; - } - return num_elements; - } - - NSV::NSV(LCP *lcp, size_t levels, size_t block, TextIndex *csa) { - /*levels>=1*/ - n = csa->index_length(); - r = levels; - b = block; - P = new BitSequence*[r]; - R = new BitSequence*[r]; - create_first_level(lcp, csa); - /*create the rest of the levels */ - for(size_t i=1; i < r; i++) { - create_level_r(lcp, i, csa); - } - /*create the last level*/ - create_last_level(lcp, csa); - } - - size_t NSV::find_NSV(size_t v, TextIndex *csa, LCP *lcp) const - { - /*look in the same block*/ - size_t n_next = 0; - size_t *next; - size_t value_v = lcp->get_seq_LCP(v, csa, &next, &n_next, 1); - size_t aux_nsv; - size_t pioneer, nsv_pioneer; - size_t end_block = b*((v+b)/b); - if(end_block>n) - end_block = n; - - for(size_t i=v+1; i < end_block; i++) { - aux_nsv = lcp->get_seq_LCP(i,csa, &next, &n_next, 1); - if(aux_nsv < value_v) - return i; - } - if(end_block==n) - return n; - /*find the pioneer*/ - pioneer = P[0]->select1(P[0]->rank1(v)); - pioneer = R[0]->rank1(pioneer)-1; - /*resolve the pioneer recursive*/ - nsv_pioneer = find_NSV_r(pioneer, 1, csa, lcp); - nsv_pioneer = R[0]->select1(nsv_pioneer+1); - if(nsv_pioneer==(size_t)-1) - nsv_pioneer = n; - /*seek the answer in the same block of the nsv(las_pioneer)*/ - n_next = 0; - for(uint i=(nsv_pioneer/b)*b ; i<=nsv_pioneer; i++) { - aux_nsv = lcp->get_seq_LCP(i,csa, &next, &n_next, 1); - if(aux_nsv < value_v) - return i; - } - return n; - } - - void NSV::save(ostream & fp) const - { - saveValue(fp, r); - saveValue(fp, b); - saveValue(fp, n); - saveValue(fp, b_A); - - for(size_t i=0; isave(fp); - R[i]->save(fp); - } - size_t num_elements = R[r-1]->rank1(n-1); - saveValue(fp, A, (num_elements*b_A + W -1)/W); - } - - NSV* NSV::load(istream & fp) { - NSV *nsv = new NSV(); - nsv->r = loadValue(fp); - nsv->b = loadValue(fp); - nsv->n = loadValue(fp); - nsv->b_A = loadValue(fp); - nsv->P = new BitSequence*[nsv->r]; - nsv->R = new BitSequence*[nsv->r]; - for(size_t i=0; ir; i++) { - nsv->P[i] = BitSequence::load(fp); - nsv->R[i] = BitSequence::load(fp); - } - size_t tam_A = nsv->R[nsv->r-1]->rank1(nsv->n-1); - tam_A = (tam_A*nsv->b_A + W -1)/W; - nsv->A = loadValue(fp, tam_A); - return nsv; - } - - size_t NSV::getSize() const - { - /*sum of all the levels*/ - size_t size =0; - size += sizeof(NSV); - for(size_t i=0; igetSize() + P[i]->getSize(); - } - size += ((b_A*R[r-1]->rank1(n-1) + W -1)/W)*sizeof(uint); - return size; - } - - NSV::~NSV() { - delete [] A; - for(uint i=0; i - -namespace cds_static -{ - PSV::PSV() { - r=b=n=b_A=0; - P=NULL; - R=NULL; - A=NULL; - } - - void PSV::create_first_level(LCP *lcp, TextIndex *csa) { - uint *P_aux; - uint *R_aux; - /*we move all the result 1 space to de rigth*/ - uint size = (n+W-1)/W; - uint last_psv = n; - uint j, lcp_value, psv_aux; - P_aux = new uint[size]; - R_aux = new uint[size]; - - for(uint i=0; i0; i--) { - lcp_value = lcp->get_LCP(i-1,csa); - psv_aux = 0; - for(j=i-1; j>0; j--) { - psv_aux = lcp->get_LCP(j-1,csa); - if(lcp_value > psv_aux) { - /*if is not near*/ - if( i/b != j/b ) { - if( j/b != last_psv/b) { - /*mark the pioneer in P*/ - cds_utils::bitset(P_aux,i); - /*mark the pioneer and the PSV of the pioneer in R*/ - cds_utils::bitset(R_aux,i); - cds_utils::bitset(R_aux,j); - } - last_psv=j; - } - break; - } - } /*close for j*/ - if(j==0) { - if( i/b != j/b ) { - if( j/b != last_psv/b) { - /*mark the pioneer in P*/ - cds_utils::bitset(P_aux,i); - /*mark the pioneer and the NSV of the pioneer in R*/ - cds_utils::bitset(R_aux,i); - cds_utils::bitset(R_aux,j); - } - last_psv=j; - } - } - } /*close for i*/ - P[0] = new BitSequenceRRR(P_aux, n+1); - R[0] = new BitSequenceRRR(R_aux, n+1); - delete[] P_aux; - delete[] R_aux; - } - - void PSV::create_level_r(LCP *lcp, size_t level, TextIndex *csa) { - uint *P_aux, *R_aux; - uint size = (n+W-1)/W; - uint last_psv=n, ini=0; - uint far_aux, lcp_value, psv_aux; - int j; - P_aux = new uint[size]; - R_aux = new uint[size]; - for(uint i=0; i < size; i++) { - P_aux[i]=0; - R_aux[i]=0; - } - uint num_elements = R[level-1]->rank1(n); - uint *lcp_r = new uint[num_elements]; - if(R[level-1]->access(0)) - ini = 1; - - for(uint i=ini; iget_LCP(R[level-1]->select1(i+1)-1, csa); - } - - /*for each i find his PSV position*/ - for(uint i= num_elements-1; i>0; i--) { - lcp_value = lcp_r[i]; - for(j=i-1; j>0; j--) { - psv_aux = lcp_r[j]; - if(lcp_value > psv_aux) { - /*if is not near*/ - if( i/b != j/b ) { - if( j/b != last_psv/b) { - /*mark the pioneer in P*/ - far_aux = R[level-1]->select1(i+1); - cds_utils::bitset(P_aux,far_aux); - /*mark the pioneer and the PSV of the pioneer in R*/ - cds_utils::bitset(R_aux, far_aux); - cds_utils::bitset(R_aux, R[level-1]->select1(j+1)); - } - last_psv=j; - } - break; - } - } /*close for j*/ - - if(j==0) { - if(ini==1) { - /*if is not near*/ - if( i/b != j/b ) { - if( j/b != last_psv/b) { - /*mark the pioneer in P*/ - far_aux = R[level-1]->select1(i+1); - cds_utils::bitset(P_aux,far_aux); - /*mark the pioneer and the PSV of the pioneer in R*/ - cds_utils::bitset(R_aux, far_aux); - cds_utils::bitset(R_aux, 0); - } - last_psv=j; - } - } - else { - psv_aux = lcp_r[j]; - if(lcp_value > psv_aux) { - /*if is not near*/ - if( i/b != j/b ) { - if( j/b != last_psv/b) { - /*mark the pioneer in P*/ - far_aux = R[level-1]->select1(i+1); - cds_utils::bitset(P_aux,far_aux); - /*mark the pioneer and the PSV of the pioneer in R*/ - cds_utils::bitset(R_aux, far_aux); - cds_utils::bitset(R_aux, R[level-1]->select1(j+1)); - } - last_psv=j; - } - } - } - } - } /*close for i*/ - - delete [] lcp_r; - P[level] = new BitSequenceRRR(P_aux, n); - R[level] = new BitSequenceRRR(R_aux, n); - delete[] P_aux; - delete[] R_aux; - } - - void PSV::create_last_level(LCP *lcp, TextIndex *csa) { - size_t *lcp_r; - uint lcp_value, psv_aux; - int j, ini=0; - - /*store the results for the last level*/ - uint num_elements = R[r-1]->rank1(n); - b_A = bits(num_elements); - A = new uint[(num_elements*b_A + W -1)/W]; - for(size_t i=0; i<((num_elements*b_A + W -1)/W); i++) - A[i]=0; - lcp_r = new size_t[num_elements]; - - if(R[r-1]->access(0)) - ini = 1; - - for(uint i=ini; iget_LCP(R[r-1]->select1(i+1)-1, csa); - } - - for(int i=num_elements-1; i>0; i--) { - lcp_value = lcp_r[i]; - for(j=i-1; j>0; j--) { - psv_aux = lcp_r[j]; - if(lcp_value > psv_aux) { - set_field_64(A, b_A, i, j); - break; - } - } /*close for j*/ - if(j==0) { - if(ini) - set_field_64(A, b_A, i, 0); - else { - psv_aux = lcp_r[j]; - if(lcp_value > psv_aux) - set_field_64(A, b_A, i, j); - else - set_field_64(A, b_A, i, 0); - } - } - } /*close for i*/ - set_field_64(A, b_A, 0, 0); - delete [] lcp_r; - } - - PSV::PSV(LCP *lcp, size_t levels, size_t block, TextIndex *csa) { - /*levels>=1*/ - n = csa->index_length(); - r = levels; - b = block; - P = new BitSequence*[r]; - R = new BitSequence*[r]; - create_first_level(lcp, csa); - /*create the rest of the levels */ - for(size_t i=1; i < r; i++) { - create_level_r(lcp, i, csa); - } - /*create the last level*/ - create_last_level(lcp, csa); - } - - size_t PSV::find_PSV_r(size_t v, size_t level, TextIndex *csa, LCP *lcp) const - { - if(level == r) { - return get_field_64(A, b_A, v); - } - /*look in the same block*/ - size_t pos_v = R[level-1]->select1(v+1); - size_t value_v = lcp->get_LCP(pos_v-1, csa); - size_t aux_psv; - size_t pioneer, psv_pioneer; - size_t ini_block = b*(v/b); - size_t ini_search; - - if(ini_block==0) - ini_block = 1; - - for(size_t i=v; i >= ini_block; i--) { - aux_psv = lcp->get_LCP( R[level-1]->select1(i+1)-1,csa); - if(aux_psv < value_v) - return i; - } - - if(ini_block==1) - return 0; - - /*find the pioneer*/ - if(P[level]->access(pos_v)) - pioneer = pos_v; - else - pioneer = P[level]->select1(P[level]->rank1(pos_v)+1); - - pioneer = R[level]->rank1(pioneer)-1; - /*resolve the pioneer recursive*/ - psv_pioneer = find_PSV_r(pioneer, level+1, csa, lcp); - psv_pioneer = R[level-1]->rank1(R[level]->select1(psv_pioneer+1))-1; - if(psv_pioneer==0) - psv_pioneer = 1; - - ini_search = b*((psv_pioneer+b)/b)-1; - - /*seek the answer in the same block of the nsv(las_pioneer)*/ - for(size_t i= ini_search; i >= psv_pioneer; i--) { - aux_psv = lcp->get_LCP(R[level-1]->select1(i+1)-1,csa); - if(aux_psv < value_v) - return i; - } - return 0; - } - - size_t PSV::find_PSV(size_t v, TextIndex *csa, LCP *lcp) const - { - /*look in the same block*/ - size_t n_next = 0; - size_t *next; - size_t value_v = lcp->get_seq_LCP(v, csa, &next, &n_next, 0); - size_t aux_psv; - size_t pioneer, psv_pioneer; - size_t ini_block = b*((v+1)/b); - size_t ini_search; - if(ini_block==0) - ini_block = 1; - - for(size_t i=v; i >= ini_block; i--) { - aux_psv = lcp->get_seq_LCP(i-1,csa, &next, &n_next, 0); - if(aux_psv < value_v) - return i; - } - - if(ini_block==1) - return 0; - - /*find the pioneer*/ - if(P[0]->access(v+1)) - pioneer = v+1; - else - pioneer = P[0]->select1(P[0]->rank1(v+1)+1); - /*imaginary position in R[0]*/ - pioneer = R[0]->rank1(pioneer)-1; - /*resolve the pioneer recursive*/ - psv_pioneer = find_PSV_r(pioneer, 1, csa, lcp); - psv_pioneer = R[0]->select1(psv_pioneer+1); - if(psv_pioneer==0) - psv_pioneer = 1; - - /*seek the answer in the same block of the psv(las_pioneer)*/ - ini_search = b*((psv_pioneer+b)/b) -1; - n_next = 0; - for(size_t i=ini_search; i>=psv_pioneer; i--) { - aux_psv = lcp->get_seq_LCP(i-1,csa, &next, &n_next, 0); - if(aux_psv < value_v) - return i; - } - return 0; - } - - void PSV::save(ostream & fp) const - { - saveValue(fp, r); - saveValue(fp, b); - saveValue(fp, n); - saveValue(fp, b_A); - - for(size_t i=0; isave(fp); - R[i]->save(fp); - } - size_t num_elements = R[r-1]->rank1(n-1); - saveValue(fp, A, (num_elements*b_A + W -1)/W); - } - - PSV* PSV::load(istream & fp) { - PSV *psv = new PSV(); - psv->r = loadValue(fp); - psv->b = loadValue(fp); - psv->n = loadValue(fp); - psv->b_A = loadValue(fp); - psv->P = new BitSequence*[psv->r]; - psv->R = new BitSequence*[psv->r]; - for(size_t i=0; ir; i++) { - psv->P[i] = BitSequence::load(fp); - psv->R[i] = BitSequence::load(fp); - } - size_t tam_A = psv->R[psv->r-1]->rank1(psv->n-1); - tam_A = (tam_A*psv->b_A + W -1)/W; - psv->A = loadValue(fp, tam_A); - return psv; - } - - size_t PSV::getSize() const - { - size_t size = 0; - size += sizeof(PSV); - for(size_t i=0; igetSize() + P[i]->getSize(); - } - size += ((b_A*R[r-1]->rank1(n-1) + W -1)/W)*sizeof(uint); - return size; - } - - PSV::~PSV() { - delete [] A; - for(uint i=0; i - -namespace cds_static -{ - const unsigned int RMQ_succinct::Catalan[17][17] = { - {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, - {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}, - {0,0,2,5,9,14,20,27,35,44,54,65,77,90,104,119,135}, - {0,0,0,5,14,28,48,75,110,154,208,273,350,440,544,663,798}, - {0,0,0,0,14,42,90,165,275,429,637,910,1260,1700,2244,2907,3705}, - {0,0,0,0,0,42,132,297,572,1001,1638,2548,3808,5508,7752,10659,14364}, - {0,0,0,0,0,0,132,429,1001,2002,3640,6188,9996,15504,23256,33915,48279}, - {0,0,0,0,0,0,0,429,1430,3432,7072,13260,23256,38760,62016,95931,144210}, - {0,0,0,0,0,0,0,0,1430,4862,11934,25194,48450,87210,149226,245157,389367}, - {0,0,0,0,0,0,0,0,0,4862,16796,41990,90440,177650,326876,572033,961400}, - {0,0,0,0,0,0,0,0,0,0,16796,58786,149226,326876,653752,1225785,2187185}, - {0,0,0,0,0,0,0,0,0,0,0,58786,208012,534888,1188640,2414425,4601610}, - {0,0,0,0,0,0,0,0,0,0,0,0,208012,742900,1931540,4345965,8947575}, - {0,0,0,0,0,0,0,0,0,0,0,0,0,742900,2674440,7020405,15967980}, - {0,0,0,0,0,0,0,0,0,0,0,0,0,0,2674440,9694845,25662825}, - {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9694845,35357670}, - {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,35357670} - }; - - const int RMQ_succinct::minus_infinity = INT_MIN; - - const char RMQ_succinct::LSBTable256[256] = { - 0,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0 - }; - - unsigned int RMQ_succinct::lsb(DTsucc v) { - return LSBTable256[v]; - } - - const char RMQ_succinct::LogTable256[256] = { - 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 - }; - - RMQ_succinct::RMQ_succinct() { - a = NULL; - n = 0; - M = NULL; - M_depth = 0; - Mprime = NULL; - Mprime_depth = 0; - type = NULL; - Prec = NULL; - s = 0; - sprime = 0; - sprimeprime = 0; - nb = 0; - nsb = 0; - nmb = 0; - } - - unsigned int RMQ_succinct::log2fast(unsigned int v) { - unsigned int c = 0; // c will be lg(v) - // temporaries - unsigned int t, tt; - - if ((tt = v >> 16)) - c = (t = v >> 24) ? 24 + LogTable256[t] : 16 + LogTable256[tt & 0xFF]; - else - c = (t = v >> 8) ? 8 + LogTable256[t] : LogTable256[v]; - return c; - } - - const DTsucc RMQ_succinct::HighestBitsSet[8] = { - static_cast(~0), static_cast(~1), - static_cast(~3), static_cast(~7), - static_cast(~15), static_cast(~31), - static_cast(~63), static_cast(~127)}; - - DTsucc RMQ_succinct::clearbits(DTsucc n, unsigned int x) { - return n & HighestBitsSet[x]; - } - - unsigned int RMQ_succinct::query(unsigned int i, unsigned int j) { - // i's microblock - unsigned int mb_i = microblock(i); - // j's microblock - unsigned int mb_j = microblock(j); - // min: to be returned - unsigned int min, min_i, min_j; - // start of i's microblock - unsigned int s_mi = mb_i * s; - // pos. of i in its microblock - unsigned int i_pos = i - s_mi; - - if (mb_i == mb_j) { // only one microblock-query - min_i = clearbits(Prec[type[mb_i]][j-s_mi], i_pos); - min = min_i == 0 ? j : s_mi + lsb(min_i); - } - else { - // i's block - unsigned int b_i = block(i); - // j's block - unsigned int b_j = block(j); - // start of j's microblock - unsigned int s_mj = mb_j * s; - // position of j in its microblock - unsigned int j_pos = j - s_mj; - min_i = clearbits(Prec[type[mb_i]][s-1], i_pos); - // left in-microblock-query - min = min_i == 0 ? s_mi + s - 1 : s_mi + lsb(min_i); - min_j = Prec[type[mb_j]][j_pos] == 0 ? - // right in-microblock-query - j : s_mj + lsb(Prec[type[mb_j]][j_pos]); - if (a[min_j] < a[min]) min = min_j; - - // otherwise we're done! - if (mb_j > mb_i + 1) { - // start of block i - unsigned int s_bi = b_i * sprime; - // start of block j - unsigned int s_bj = b_j * sprime; - // do another microblock-query! - if (s_bi+s > i) { - mb_i++; // go one microblock to the right - min_i = Prec[type[mb_i]][s-1] == 0 ? - // right in-block-query - s_bi + sprime - 1 : s_mi + s + lsb(Prec[type[mb_i]][s-1]); - if (a[min_i] < a[min]) min = min_i; - } - // and yet another microblock-query! - if (j >= s_bj+s) { - mb_j--; // go one microblock to the left - min_j = Prec[type[mb_j]][s-1] == 0 ? - // right in-block-query - s_mj - 1 : s_bj + lsb(Prec[type[mb_j]][s-1]); - if (a[min_j] < a[min]) min = min_j; - } - - unsigned int block_difference = b_j - b_i; - // otherwise we're done! - if (block_difference > 1) { - // for index calculations in M and M' - unsigned int k, twotothek, block_tmp; - b_i++; // block where out-of-block-query starts - // just one out-of-block-query - if (s_bj - s_bi - sprime <= sprimeprime) { - k = log2fast(block_difference - 2); - // 2^k - twotothek = 1 << k; - i = m(k, b_i); j = m(k, b_j-twotothek); - min_i = a[i] <= a[j] ? i : j; - } - else { // here we have to answer a superblock-query: - // i's superblock - unsigned int sb_i = superblock(i); - // j's superblock - unsigned int sb_j = superblock(j); - - // end of left out-of-block-query - block_tmp = block((sb_i+1)*sprimeprime); - k = log2fast(block_tmp - b_i); - // 2^k - twotothek = 1 << k; - i = m(k, b_i); j = m(k, block_tmp+1-twotothek); - min_i = a[i] <= a[j] ? i : j; - - // start of right out-of-block-query - block_tmp = block(sb_j*sprimeprime); - k = log2fast(b_j - block_tmp); - // 2^k - twotothek = 1 << k; - // going one block to the left doesn't harm and saves some tests - block_tmp--; - i = m(k, block_tmp); j = m(k, b_j-twotothek); - min_j = a[i] <= a[j] ? i : j; - - if (a[min_j] < a[min_i]) min_i = min_j; - - // finally, the superblock-query: - if (sb_j > sb_i + 1) { - k = log2fast(sb_j - sb_i - 2); - twotothek = 1 << k; - i = Mprime[k][sb_i+1]; j = Mprime[k][sb_j-twotothek]; - min_j = a[i] <= a[j] ? i : j; - // does NOT always return leftmost min!!! - if (a[min_j] < a[min_i]) min_i = min_j; - } - } - // does NOT always return leftmost min!!! - if (a[min_i] < a[min]) min = min_i; - } - } - } - return min; - } - - /** - * Standard Constructor. a is the array to be prepared for RMQ. - * n is the size of the array. - * */ - RMQ_succinct::RMQ_succinct(int* a, unsigned int n) { - this->a = a; - this->n = n; - s = 1 << 3; // microblock-size - sprime = 1 << 4; // block-size - sprimeprime = 1 << 8; // superblock-size - nb = block(n-1)+1; // number of blocks - nsb = superblock(n-1)+1; // number of superblocks - nmb = microblock(n-1)+1; // number of microblocks - - // The following is necessary because we've fixed s, s' and s'' according to the computer's - // word size and NOT according to the input size. This may cause the (super-)block-size - // to be too big, or, in other words, the array too small. If this code is compiled on - // a 32-bit computer, this happens iff n < 113. For such small instances it isn't - // advisable anyway to use this data structure, because simpler methods are faster and - // less space consuming. - if (nb n) end = n;// last block could be smaller than s! - // compute block type as in Fischer/Heun CPM'06: - q = s; // init q - p = s-1; // init p - type[i] = 0; // init type (will be increased!) - rp[1] = a[z]; // init rightmost path - - while (++z < end) { // step through current block: - p--; - while (rp[q-p-1] > a[z]) { - // update type - type[i] += Catalan[p][q]; - q--; - } - rp[q-p] = a[z]; // add last element to rightmost path - } - - // precompute in-block-queries for this microblock (if necessary) - // as in Alstrup et al. SPAA'02: - if (Prec[type[i]][0] == 1) { - Prec[type[i]][0] = 0; - gstacksize = 0; - for (unsigned int j = start; j < end; j++) { - while(gstacksize > 0 && (a[j] < a[gstack[gstacksize-1]])) { - gstacksize--; - } - if(gstacksize > 0) { - g = gstack[gstacksize-1]; - Prec[type[i]][j-start] = Prec[type[i]][g-start] | (1 << (g % s)); - } - else Prec[type[i]][j-start] = 0; - gstack[gstacksize++] = j; - } - } - } - delete[] rp; - delete[] gstack; - - // space for out-of-block- and out-of-superblock-queries: - M_depth = (unsigned int) floor(log2(((double) sprimeprime / (double) sprime))); - M = new DTsucc*[M_depth]; - M[0] = new DTsucc[nb]; - Mprime_depth = (unsigned int) floor(log2(nsb)) + 1; - Mprime = new unsigned int*[Mprime_depth]; - Mprime[0] = new unsigned int[nsb]; - - // fill 0'th rows of M and Mprime: - z = 0; // minimum in current block - q = 0; // pos. of min in current superblock - g = 0; // number of current superblock - // step through blocks - for (unsigned int i = 0; i < nb; i++) { - start = z; // init start - p = start; // init minimum - end = start + sprime;// end of block (not inclusive!) - if (end > n) end = n;// last block could be smaller than sprime! - // update minimum in superblock - if (a[z] < a[q]) q = z; - - while (++z < end) { // step through current block: - // update minimum in block - if (a[z] < a[p]) p = z; - // update minimum in superblock - if (a[z] < a[q]) q = z; - } - M[0][i] = p-start; // store index of block-minimum (offset!) - // reached end of superblock? - if (z % sprimeprime == 0 || z == n) { - // store index of superblock-minimum - Mprime[0][g++] = q; - q = z; - } - } - - // fill M - unsigned int dist = 1; // always 2^(j-1) - for (unsigned int j = 1; j < M_depth; j++) { - M[j] = new DTsucc[nb]; - // be careful: loop may go too far - for (unsigned int i = 0; i < nb - dist; i++) { - M[j][i] = a[m(j-1, i)] <= a[m(j-1,i+dist)] ? - // add 'skipped' elements in a - M[j-1][i] : M[j-1][i+dist] + (dist*sprime); - } - // fill overhang - for (unsigned int i = nb - dist; i < nb; i++) M[j][i] = M[j-1][i]; - dist *= 2; - } - - // fill M': - dist = 1; // always 2^(j-1) - for (unsigned int j = 1; j < Mprime_depth; j++) { - Mprime[j] = new unsigned int[nsb]; - for (unsigned int i = 0; i < nsb - dist; i++) { - Mprime[j][i] = a[Mprime[j-1][i]] <= a[Mprime[j-1][i+dist]] ? - Mprime[j-1][i] : Mprime[j-1][i+dist]; - } - // overhang - for (unsigned int i = nsb - dist; i < nsb; i++) Mprime[j][i] = Mprime[j-1][i]; - dist *= 2; - } - } - - uint RMQ_succinct::getSize() { - uint mem = 0; - mem += sizeof(RMQ_succinct); - mem += sizeof(int)*n; - mem += sizeof(DTsucc2)*nmb; - mem += sizeof(DTsucc)*s; - mem += sizeof(DTsucc)*nb; - mem += sizeof(unsigned int)*nsb; - mem += sizeof(DTsucc)*nb; - mem += sizeof(unsigned int)*nsb; - return mem; - } - - void RMQ_succinct::save(ostream & fp) { - saveValue(fp,n); - saveValue(fp, a, n); - saveValue(fp, type, nmb); - for(uint i=0; i < M_depth; i++) - saveValue(fp, M[i], nb); - for(uint i=0; i < Mprime_depth; i++) - saveValue(fp, Mprime[i], nsb); - for(uint i=0; i < Catalan[s][s]; i++) - saveValue(fp, Prec[i], s); - } - - RMQ_succinct * RMQ_succinct::load(istream & fp) { - RMQ_succinct *rmq = new RMQ_succinct(); - rmq->s = 1<<3; - rmq->sprime = 1<<4; - rmq->sprimeprime = 1<<8; - rmq->n = loadValue(fp); - rmq->nb = rmq->block(rmq->n-1)+1; - rmq->nsb = rmq->superblock(rmq->n-1)+1; - rmq->nmb = rmq->microblock(rmq->n-1)+1; - rmq->M_depth = (uint) floor(log2(((double) rmq->sprimeprime / (double) rmq->sprime))); - rmq->Mprime_depth = (uint) floor(log2(rmq->nsb)) + 1; - rmq->a = loadValue(fp, rmq->n); - rmq->type = loadValue(fp, rmq->nmb); - rmq->M = new DTsucc*[rmq->M_depth]; - for(uint i=0; i < rmq->M_depth; i++) - rmq->M[i] = loadValue(fp, rmq->nb); - rmq->Mprime = new uint*[rmq->Mprime_depth]; - for(uint i=0; i < rmq->Mprime_depth; i++) - rmq->Mprime[i] = loadValue(fp, rmq->nsb); - rmq->Prec = new DTsucc*[Catalan[rmq->s][rmq->s]]; - for(uint i=0; i < Catalan[rmq->s][rmq->s]; i++) - rmq->Prec[i] = loadValue(fp, rmq->s); - return rmq; - } - - /** - * Destructor. Deletes allocated space. - **/ - RMQ_succinct::~RMQ_succinct() { - delete[] type; - for (unsigned int i = 0; i < Catalan[s][s]; i++) - delete[] Prec[i]; - delete[] Prec; - for (unsigned int i = 0; i < M_depth; i++) - delete[] M[i]; - delete[] M; - for (unsigned int i = 0; i < Mprime_depth; i++) - delete[] Mprime[i]; - delete[] Mprime; - delete[] a; - } - -}; diff --git a/libcds/src/static/suffixtree/RMQ_succinct_lcp.cpp b/libcds/src/static/suffixtree/RMQ_succinct_lcp.cpp deleted file mode 100644 index 999a6d40..00000000 --- a/libcds/src/static/suffixtree/RMQ_succinct_lcp.cpp +++ /dev/null @@ -1,434 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include "RMQ_succinct_lcp.h" - -namespace cds_static -{ - - const uint RMQ_succinct_lcp::Catalan[17][17] = { - {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, - {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}, - {0,0,2,5,9,14,20,27,35,44,54,65,77,90,104,119,135}, - {0,0,0,5,14,28,48,75,110,154,208,273,350,440,544,663,798}, - {0,0,0,0,14,42,90,165,275,429,637,910,1260,1700,2244,2907,3705}, - {0,0,0,0,0,42,132,297,572,1001,1638,2548,3808,5508,7752,10659,14364}, - {0,0,0,0,0,0,132,429,1001,2002,3640,6188,9996,15504,23256,33915,48279}, - {0,0,0,0,0,0,0,429,1430,3432,7072,13260,23256,38760,62016,95931,144210}, - {0,0,0,0,0,0,0,0,1430,4862,11934,25194,48450,87210,149226,245157,389367}, - {0,0,0,0,0,0,0,0,0,4862,16796,41990,90440,177650,326876,572033,961400}, - {0,0,0,0,0,0,0,0,0,0,16796,58786,149226,326876,653752,1225785,2187185}, - {0,0,0,0,0,0,0,0,0,0,0,58786,208012,534888,1188640,2414425,4601610}, - {0,0,0,0,0,0,0,0,0,0,0,0,208012,742900,1931540,4345965,8947575}, - {0,0,0,0,0,0,0,0,0,0,0,0,0,742900,2674440,7020405,15967980}, - {0,0,0,0,0,0,0,0,0,0,0,0,0,0,2674440,9694845,25662825}, - {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9694845,35357670}, - {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,35357670} - }; - - const int RMQ_succinct_lcp::minus_infinity = INT_MIN; - - const char RMQ_succinct_lcp::LSBTable256[256] = { - 0,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, - 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0 - }; - - uint RMQ_succinct_lcp::lsb(DTsucc v) { - return LSBTable256[v]; - } - - const char RMQ_succinct_lcp::LogTable256[256] = { - 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 - }; - - RMQ_succinct_lcp::RMQ_succinct_lcp() { - n = 0; - M = NULL; - M_depth = 0; - Mprime = NULL; - Mprime_depth = 0; - type = NULL; - Prec = NULL; - s = 0; - sprime = 0; - sprimeprime = 0; - nb = 0; - nsb = 0; - nmb = 0; - } - - uint RMQ_succinct_lcp::log2fast(uint v) { - uint c = 0; // c will be lg(v) - uint t, tt; // temporaries - - if ((tt = v >> 16)) - c = (t = v >> 24) ? 24 + LogTable256[t] : 16 + LogTable256[tt & 0xFF]; - else - c = (t = v >> 8) ? 8 + LogTable256[t] : LogTable256[v]; - return c; - } - - const DTsucc RMQ_succinct_lcp::HighestBitsSet[8] = { - static_cast(~0), static_cast(~1), - static_cast(~3), static_cast(~7), - static_cast(~15), static_cast(~31), - static_cast(~63), static_cast(~127)}; - - DTsucc RMQ_succinct_lcp::clearbits(DTsucc n, uint x) { - return n & HighestBitsSet[x]; - } - - /* - * Standard Constructor. lcp is the array to be prepared for RMQ. - * n is the size of the array. - */ - RMQ_succinct_lcp::RMQ_succinct_lcp(LCP *lcp, TextIndex *csa) { - this->n = csa->index_length(); - s = 1 << 3; // microblock-size - sprime = 1 << 4; // block-size - sprimeprime = 1 << 8; // superblock-size - nb = block(n-1)+1; // number of blocks - nsb = superblock(n-1)+1; // number of superblocks - nmb = microblock(n-1)+1; // number of microblocks - - // The following is necessary because we've fixed s, s' and s'' according to the computer's - // word size and NOT according to the input size. This may cause the (super-)block-size - // to be too big, or, in other words, the array too small. If this code is compiled on - // a 32-bit computer, this happens iff n < 113. For such small instances it isn't - // advisable anyway to use this data structure, because simpler methods are faster and - // less space consuming. - if (nb n) end = n;// last block could be smaller than s! - - // compute block type as in Fischer/Heun CPM'06: - q = s; // init q - p = s-1; // init p - type[i] = 0; // init type (will be increased!) - // init rightmost path - rp[1] = lcp->get_LCP(z, csa); - while (++z < end) { // step through current block: - p--; - while(rp[q-p-1] > (int)lcp->get_LCP(z, csa)) { - // update type - type[i] += Catalan[p][q]; - q--; - } - // add last element to rightmost path - rp[q-p] = lcp->get_LCP(z, csa); - } - // precompute in-block-queries for this microblock (if necessary) - // as in Alstrup et al. SPAA'02: - if (Prec[type[i]][0] == 1) { - Prec[type[i]][0] = 0; - gstacksize = 0; - for (uint j = start; j < end; j++) { - while(gstacksize > 0 && (lcp->get_LCP(j,csa) < lcp->get_LCP(gstack[gstacksize-1], csa))) { - gstacksize--; - } - if(gstacksize > 0) { - g = gstack[gstacksize-1]; - Prec[type[i]][j-start] = Prec[type[i]][g-start] | (1 << (g % s)); - } - else - Prec[type[i]][j-start] = 0; - gstack[gstacksize++] = j; - } //close for j - } - } - delete[] rp; - delete[] gstack; - - // space for out-of-block- and out-of-superblock-queries: - M_depth = (uint) floor(log2(((double) sprimeprime / (double) sprime))); - M = new DTsucc*[M_depth]; - M[0] = new DTsucc[nb]; - Mprime_depth = (uint) floor(log2(nsb)) + 1; - Mprime = new uint*[Mprime_depth]; - Mprime[0] = new uint[nsb]; - - // fill 0'th rows of M and Mprime: - z = 0; // minimum in current block - q = 0; // pos. of min in current superblock - g = 0; // number of current superblock - // step through blocks - for (uint i = 0; i < nb; i++) { - start = z; // init start - p = start; // init minimum - end = start + sprime;// end of block (not inclusive!) - if (end > n) end = n;// last block could be smaller than sprime! - // update minimum in superblock - if (lcp->get_LCP(z,csa) < lcp->get_LCP(q,csa)) q = z; - - while (++z < end) { // step through current block: - // update minimum in block - if (lcp->get_LCP(z,csa) < lcp->get_LCP(p,csa)) p = z; - // update minimum in superblock - if (lcp->get_LCP(z,csa) < lcp->get_LCP(q,csa)) q = z; - } - M[0][i] = p-start; // store index of block-minimum (offset!) - // reached end of superblock? - if (z % sprimeprime == 0 || z == n) { - // store index of superblock-minimum - Mprime[0][g++] = q; - q = z; - } - } - - // fill M: - uint dist = 1; // always 2^(j-1) - for (uint j = 1; j < M_depth; j++) { - M[j] = new DTsucc[nb]; - // be careful: loop may go too far - for (uint i = 0; i < nb - dist; i++) { - M[j][i] = lcp->get_LCP(m(j-1, i),csa) <= lcp->get_LCP(m(j-1,i+dist),csa) ? - // add 'skipped' elements in a - M[j-1][i] : M[j-1][i+dist] + (dist*sprime); - } - // fill overhang - for (uint i = nb - dist; i < nb; i++) M[j][i] = M[j-1][i]; - dist *= 2; - } - - // fill M': - dist = 1; // always 2^(j-1) - for (uint j = 1; j < Mprime_depth; j++) { - Mprime[j] = new uint[nsb]; - for (uint i = 0; i < nsb - dist; i++) { - Mprime[j][i] = lcp->get_LCP(Mprime[j-1][i],csa) <= lcp->get_LCP(Mprime[j-1][i+dist],csa) ? - Mprime[j-1][i] : Mprime[j-1][i+dist]; - } - // overhang - for (uint i = nsb - dist; i < nsb; i++) Mprime[j][i] = Mprime[j-1][i]; - dist *= 2; - } - } - - RMQ_succinct_lcp::~RMQ_succinct_lcp() { - delete[] type; - for (uint i = 0; i < Catalan[s][s]; i++) delete[] Prec[i]; - delete[] Prec; - for (uint i = 0; i < M_depth; i++) delete[] M[i]; - delete[] M; - for (uint i = 0; i < Mprime_depth; i++) delete[] Mprime[i]; - delete[] Mprime; - } - - uint RMQ_succinct_lcp::query(uint i, uint j, TextIndex *csa, LCP *lcp) { - // i's microblock - uint mb_i = microblock(i); - // j's microblock - uint mb_j = microblock(j); - uint min, min_tmp; // min: to be returned - uint s_mi = mb_i * s; // start of i's microblock - uint i_pos = i - s_mi; // pos. of i in its microblock - - if (mb_i == mb_j) { // only one microblock-query - min_tmp = clearbits(Prec[type[mb_i]][j-s_mi], i_pos); - min = min_tmp == 0 ? j : s_mi + lsb(min_tmp); - } - - else { - uint b_i = block(i); // i's block - uint b_j = block(j); // j's block - uint s_mj = mb_j * s;// start of j's microblock - // position of j in its microblock - uint j_pos = j - s_mj; - min_tmp = clearbits(Prec[type[mb_i]][s-1], i_pos); - // left in-microblock-query - min = min_tmp == 0 ? s_mi + s - 1 : s_mi + lsb(min_tmp); - - // otherwise we're done! - if (mb_j > mb_i + 1) { - // start of block i - uint s_bi = b_i * sprime; - // start of block j - uint s_bj = b_j * sprime; - // do another microblock-query! - if (s_bi+s > i) { - mb_i++; // go one microblock to the right - min_tmp = Prec[type[mb_i]][s-1] == 0 ? - // right in-block-query - s_bi + sprime - 1 : s_mi + s + lsb(Prec[type[mb_i]][s-1]); - if (lcp->get_LCP(min_tmp, csa) < lcp->get_LCP(min, csa)) min = min_tmp; - } - - // otherwise no out-of-block-queries - if (b_j > b_i + 1) { - uint k, t, b;// temporary variables - b_i++; // block where out-of-block-query starts - // just one out-of-block-query - if (s_bj - s_bi - sprime <= sprimeprime) { - k = log2fast(b_j - b_i - 1); - // 2^k - t = 1 << k; - // i can be overwritten! - i = m(k, b_i); b = m(k, b_j-t); - min_tmp = lcp->get_LCP(i,csa) <= lcp->get_LCP(b,csa) ? i : b; - if (lcp->get_LCP(min_tmp,csa) < lcp->get_LCP(min,csa)) min = min_tmp; - } - else { // here we have two out-of-block-queries: - // i's superblock - uint sb_i = superblock(i); - // j's superblock - uint sb_j = superblock(j); - // end of left out-of-block-query - b = block((sb_i+1)*sprimeprime); - k = log2fast(b - b_i); - // 2^k - t = 1 << k; - // i & i_pos can be overwritten! - i = m(k, b_i); i_pos = m(k, b+1-t); - min_tmp = lcp->get_LCP(i,csa) <= lcp->get_LCP(i_pos,csa) ? i : i_pos; - if (lcp->get_LCP(min_tmp,csa) < lcp->get_LCP(min,csa)) min = min_tmp; - // the superblock-query - if (sb_j > sb_i + 1) { - k = log2fast(sb_j - sb_i - 2); - t = 1 << k; - i = Mprime[k][sb_i+1]; i_pos = Mprime[k][sb_j-t]; - min_tmp = lcp->get_LCP(i,csa) <= lcp->get_LCP(i_pos,csa) ? i : i_pos; - if (lcp->get_LCP(min_tmp,csa) < lcp->get_LCP(min,csa)) min = min_tmp; - } - // start of right out-of-block-query - b = block(sb_j*sprimeprime); - k = log2fast(b_j - b); - // 2^k - t = 1 << k; - b--; // going one block to the left doesn't harm and saves some tests - i = m(k, b); i_pos = m(k, b_j-t); - min_tmp = lcp->get_LCP(i,csa) <= lcp->get_LCP(i_pos,csa) ? i : i_pos; - if (lcp->get_LCP(min_tmp,csa) < lcp->get_LCP(min,csa)) min = min_tmp; - } - } - // another microblock-query to compensate for missing block-layer - if (j >= s_bj+s) { - min_tmp = Prec[type[mb_j-1]][s-1] == 0 ? - s_mj - 1 : s_bj + lsb(Prec[type[mb_j-1]][s-1]); - if (lcp->get_LCP(min_tmp,csa) < lcp->get_LCP(min,csa)) min = min_tmp; - } - } - min_tmp = Prec[type[mb_j]][j_pos] == 0 ? - // right in-microblock-query - j : s_mj + lsb(Prec[type[mb_j]][j_pos]); - if (lcp->get_LCP(min_tmp,csa) < lcp->get_LCP(min,csa)) min = min_tmp; - } - return min; - } - - uint RMQ_succinct_lcp::getSize() { - unsigned long mem = sizeof(DTsucc2)*nmb; - mem += sizeof(DTsucc)*s; - mem += sizeof(DTsucc)*nb; - mem += sizeof(uint)*nsb; - mem += sizeof(DTsucc)*nb; - mem += sizeof(uint)*nsb; - return (uint)mem; - } - - void RMQ_succinct_lcp::save(ostream & fp) { - saveValue(fp,n); - saveValue(fp, type, nmb); - for(uint i=0; i < M_depth; i++) - saveValue(fp, M[i], nb); - for(uint i=0; i < Mprime_depth; i++) - saveValue(fp, Mprime[i], nsb); - for(uint i=0; i < Catalan[s][s]; i++) - saveValue(fp, Prec[i], s); - } - - RMQ_succinct_lcp * RMQ_succinct_lcp::load(istream & fp) { - RMQ_succinct_lcp *rmq = new RMQ_succinct_lcp(); - rmq->s = 1<<3; - rmq->sprime = 1<<4; - rmq->sprimeprime = 1<<8; - rmq->n = loadValue(fp); - rmq->nb = rmq->block(rmq->n-1)+1; - rmq->nsb = rmq->superblock(rmq->n-1)+1; - rmq->nmb = rmq->microblock(rmq->n-1)+1; - rmq->M_depth = (uint) floor(log2(((double) rmq->sprimeprime / (double) rmq->sprime))); - rmq->Mprime_depth = (uint) floor(log2(rmq->nsb)) + 1; - rmq->type = loadValue(fp, rmq->nmb); - rmq->M = new DTsucc*[rmq->M_depth]; - for(uint i=0; i < rmq->M_depth; i++) - rmq->M[i] = loadValue(fp, rmq->nb); - rmq->Mprime = new uint*[rmq->Mprime_depth]; - for(uint i=0; i < rmq->Mprime_depth; i++) - rmq->Mprime[i] = loadValue(fp, rmq->nsb); - rmq->Prec = new DTsucc*[Catalan[rmq->s][rmq->s]]; - for(uint i=0; i < Catalan[rmq->s][rmq->s]; i++) - rmq->Prec[i] = loadValue(fp, rmq->s); - return rmq; - } - -}; diff --git a/libcds/src/static/suffixtree/SuffixTree.cpp b/libcds/src/static/suffixtree/SuffixTree.cpp deleted file mode 100644 index 9461225a..00000000 --- a/libcds/src/static/suffixtree/SuffixTree.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - SuffixTree * SuffixTree::load(istream & fp) { - size_t r = loadValue(fp); - size_t pos = fp.tellg(); - fp.seekg(pos-sizeof(size_t)); - cout << "Loading "<< r << endl; - switch(r) { - case CSTY: return SuffixTreeY::load(fp); - } - return NULL; - } - -}; diff --git a/libcds/src/static/suffixtree/SuffixTreeY.cpp b/libcds/src/static/suffixtree/SuffixTreeY.cpp deleted file mode 100644 index bbd41d78..00000000 --- a/libcds/src/static/suffixtree/SuffixTreeY.cpp +++ /dev/null @@ -1,484 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include -#include - -namespace cds_static -{ - - SuffixTreeY::SuffixTreeY() { - length = 0; - csa = NULL; - lcp = NULL; - npr = NULL; - } - - SuffixTreeY::SuffixTreeY(char *text, size_t n, size_t lcp_type, size_t npr_type, size_t b) { - length = n; - cout << "Text length: " << n << endl; - /*create the index*/ - csa = new TextIndexCSA((uchar *)text, (ulong)length, NULL); - cout << "TextIndex bits/c: " << csa->getSize()*8.0/length << endl; - switch(lcp_type) { - case NAIVE: lcp = new LCP_naive(csa, text, length); break; - case SAD_GON_OS: lcp = new LCP_Sad(csa, text, length); break; - case FMN_RRR_OS: lcp = new LCP_FMN(csa, text, length); break; - case PT: lcp = new LCP_PT(csa, text, length); break; - case PHI: lcp = new LCP_PhiSpare(csa,text,length); break; - case DAC: lcp = new LCP_DAC(csa, text, length); break; - case DAC_VAR: lcp = new LCP_DAC_VAR(csa, text,length); break; - default: exit(0); - } - cout << "LCP bits/c: " << lcp->getSize()*8.0/length << endl; - switch(npr_type) { - case FMN_NPR: npr = new NPR_FMN(lcp, b, csa); break; - case CN_NPR: npr = new NPR_CN(lcp, b, csa); break; - default: exit(0); - } - cout << "NPR bits/c: " << npr->getSize()*8.0/length << endl; - /*here you can free the text*/ - } - - SuffixTreeY::SuffixTreeY(LCP *_lcp, NPR *_npr, TextIndex *_csa) { - csa = _csa; - cout << "TextIndex bits/c: " << csa->getSize()*8.0/length << endl; - lcp = _lcp; - cout << "LCP bits/c: " << lcp->getSize()*8.0/length << endl; - npr = _npr; - cout << "NPR bits/c: " << npr->getSize()*8.0/length << endl; - } - - bool SuffixTreeY::isRoot(size_t vl,size_t vr) const - { - if(vl==0 && vr==length-1) - return true; - return false; - } - - void SuffixTreeY::Root(size_t *vl, size_t *vr) const - { - *vl = 0; - *vr = length-1; - } - - size_t SuffixTreeY::Count(size_t vl, size_t vr) const - { - return vr - vl+1; - } - - bool SuffixTreeY::Ancestor(size_t wl, size_t wr, size_t vl, size_t vr) const - { - if((wl<=vl) && (wr >= vr)) - return true; - return false; - } - - size_t SuffixTreeY::SDepth(size_t vl, size_t vr) const - { - size_t h,k, val; - if(vl!=vr) { - k = npr->find_RMQ(vl+1, vr, csa, lcp); - h = lcp->get_LCP(k, csa); - } - else { /*for leaf (->v.left==v.right)*/ - val = csa->getSA(vl); - h = length - val +1; - } - return h; - } - - size_t SuffixTreeY::Locate(size_t vl, size_t vr) const - { - if(vl==vr) { - return csa->getSA(vl); - } - return (size_t)-1; - } - - void SuffixTreeY::Parent(size_t vl, size_t vr, size_t *parent_l, size_t *parent_r) const - { - if(isRoot(vl, vr)) { - *parent_l = (size_t)-1; - *parent_r = (size_t)-1; - return; - } - size_t k; - if(vr == length-1) - k = vl; - else { - if(lcp->get_LCP(vl, csa) > lcp->get_LCP(vr+1,csa)) - k = vl; - else - k = vr+1; - } - size_t p_l = npr->find_PSV(k,csa,lcp); - if(p_l > 0) - p_l--; - size_t p_r = npr->find_NSV(k,csa,lcp)-1; - *parent_l = p_l; - *parent_r = p_r; - } - - void SuffixTreeY::FChild(size_t vl, size_t vr, size_t *fchild_l, size_t *fchild_r) const - { - if(vl==vr) { - *fchild_l = (size_t)-1; - *fchild_r = (size_t)-1; - return; - } - *fchild_l = vl; - *fchild_r = npr->find_RMQ(vl+1,vr,csa,lcp)-1; - } - - void SuffixTreeY::NSibling(size_t vl, size_t vr, size_t *nsibling_l, size_t *nsibling_r) const - { - size_t wl, wr; - Parent(vl, vr, &wl, &wr); - if(wl==(size_t)-1) { /*v is the root*/ - *nsibling_l = (size_t)-1; - *nsibling_r = (size_t)-1; - return; - } - if(wr == vr) { /*v does not have a next sibling*/ - *nsibling_l = (size_t)-1; - *nsibling_r = (size_t)-1; - return; - } - if(vr+1 == wr) { /*v's next sibling is a leaf*/ - *nsibling_l = wr; - *nsibling_r = wr; - return; - } - else { - size_t left = vr+1; - size_t lcp_rm = lcp->get_LCP(vr+1, csa); - size_t rm = npr->fwd_NSV(vr+1, csa, lcp, lcp_rm+1); - *nsibling_l = left; - *nsibling_r = rm-1; - return; - } - } - - void SuffixTreeY::SLink(size_t vl, size_t vr, size_t *slink_l, size_t *slink_r) const - { - size_t x,y,k; - /*v is the root*/ - if(vl==0 && vr == length-1) { - *slink_l = (size_t)-1; - *slink_r = (size_t)-1; - return; - } - x = csa->getPsi(vl); - y = csa->getPsi(vr); - k = npr->find_RMQ(x+1, y, csa, lcp); - size_t p_l = npr->find_PSV(k, csa, lcp); - if(p_l > 0) - p_l--; - size_t p_r = npr->find_NSV(k,csa,lcp)-1; - *slink_l = p_l; - *slink_r = p_r; - } - - void SuffixTreeY::SLink_i(size_t vl, size_t vr, size_t i, size_t *slinki_l, size_t *slinki_r) const - { - size_t x,y,k; - size_t seq = 1; /*set seq = 0 if you dont want to do it sequentialy*/ - /*v is the root*/ - if(vl==0 && vr == length-1) { - *slinki_l = (size_t)-1; - *slinki_r = (size_t)-1; - return; - } - - if(seq) { - while(!isRoot(vl,vr) && i>0) { - SLink(vl, vr, &vl, &vr); - i--; - } - if(i==0) { - *slinki_l = vl; - *slinki_r = vr; - } - else { - *slinki_l = (uint)-1; - *slinki_r = (uint)-1; - } - } - else { - /*psi_i(v->left)*/ - x = csa->getSA(vl); - if(x+i >=length) { //then return the root - Root(slinki_l, slinki_r); - return; - } - x = csa->getISA(x); - /*psi_i(v->right)*/ - y = csa->getSA(vr); - if(y+i >=length) { //then return the root - Root(slinki_l, slinki_r); - return; - } - y = csa->getISA(y); - /*first letter of x and y are diff*/ - if(csa->getT(x)!= csa->getT(y)) { - Root(slinki_l, slinki_r); - return; - } - k = npr->find_RMQ(x+1, y, csa, lcp); - size_t p_l = npr->find_PSV(k, csa, lcp); - if(p_l > 0) - p_l--; - size_t p_r = npr->find_NSV(k,csa,lcp)-1; - *slinki_l = p_l; - *slinki_r = p_r; - } - } - - void SuffixTreeY::LCA(size_t vl, size_t vr, size_t wl, size_t wr, size_t *lca_l, size_t *lca_r) const - { - size_t k; - if(Ancestor(vl, vr, wl, wr)) { - *lca_l = vl; - *lca_r = vr; - return; - } - if(Ancestor(wl, wr, vl, vr)) { - *lca_l = wl; - *lca_r = wr; - return; - } - if(vr < wl) - k = npr->find_RMQ(vr+1, wl, csa, lcp); - else //wr < vl - k = npr->find_RMQ(wr+1, vl, csa, lcp); - /*there are no more possible case for calculate k*/ - uint p_l = npr->find_PSV(k, csa, lcp); - if(p_l > 0) - p_l--; - size_t p_r = npr->find_NSV(k,csa,lcp)-1; - *lca_l = p_l; - *lca_r = p_r; - } - - void SuffixTreeY::Child(size_t vl, size_t vr, uchar a, size_t *child_l, size_t *child_r) const - { - int x,y,m, pos_letter; - uchar first_letter; - size_t aux_l, aux_r; - size_t res_l = (size_t)-1; - size_t res_r = (size_t)-1; - vector children_l; - vector children_r; - if(vl==vr) { //is a leaf - *child_l = (size_t)-1; - *child_r = (size_t)-1; - return; - } - /*calculate the position where the letter must be*/ - pos_letter = SDepth(vl, vr)+1; - /*get all the childs of v*/ - FChild(vl, vr, &aux_l, &aux_r); - children_l.push_back(aux_l); - children_r.push_back(aux_r); - NSibling(aux_l, aux_r, &aux_l, &aux_r); - while(aux_l != (size_t)-1) { - children_l.push_back(aux_l); - children_r.push_back(aux_r); - NSibling(aux_l, aux_r, &aux_l, &aux_r); - } - x=0; - y=children_l.size()-1; - /*Binary search over children*/ - while(x<=y) { - m = (x+y)/2; - aux_l = children_l[m]; - aux_r = children_r[m]; - /*get letter*/ - first_letter = Letter(aux_l, aux_r, pos_letter); - if(first_letter == a) { - res_l = aux_l; - res_r = aux_r; - break; - } - else { - if (first_letter < a) - x=m+1; - else - y=m-1; - } - } - /*free the space used*/ - children_l.clear(); - children_r.clear(); - *child_l = res_l; - *child_r = res_r; - } - - uchar SuffixTreeY::Letter(size_t vl, size_t vr, int i) const - { - uchar l; - if(i==1) { - l = (uchar)csa->getT(vl); - return l; - } - /*else return Letter(psi_{i-1}(vl),1)*/ - size_t p1 = vl; - for(size_t j=0; j<(size_t)(i-1); j++) - p1 = csa->getPsi(p1); - /* - uint v_sa, v_i; - v_sa = csa_lookup(csa, v->left+1)-1; //SA[v->left] - v_i = csa_inverse(csa, v_sa + i)-1; // psi_{i-1} (v_sa); - */ - return Letter(p1, p1,1); //Letter(v_i,v_i, 1); - } - - size_t SuffixTreeY::TDepth(size_t vl, size_t vr) const - { - size_t depth = 0; - size_t aux_l = vl; - size_t aux_r = vr; - while(aux_l !=0 || aux_r != length-1) { - Parent(aux_l, aux_r, &aux_l, &aux_r); - depth++; - } - return depth; - } - - void SuffixTreeY::LAQs(size_t vl, size_t vr, size_t d, size_t *laq_s_l, size_t *laq_s_r) const - { - size_t u_l, u_r=0; - if(d==0) { - *laq_s_l = 0; - *laq_s_r = length-1; - return; - } - u_l = npr->bwd_PSV(vl+1, csa, lcp, d); - if(u_l>0) - u_l--; - if(vr==0) - u_r=0; - else { - u_r = npr->fwd_NSV(vr-1, csa, lcp, d); - if(u_r!=vr) - u_r--; - } - *laq_s_l = u_l; - *laq_s_r = u_r; - } - - void SuffixTreeY::LAQt(size_t vl, size_t vr, size_t d, size_t *laq_t_l, size_t *laq_t_r) const - { - size_t depth = 0; - size_t x; - size_t string_depth = d; - size_t res_l, res_r; - size_t next_l, next_r; - size_t aux_l, aux_r; - size_t acum =1; - if(d==0 || (vl==0 && vr==length-1)) { - *laq_t_l = 0; - *laq_t_r = length-1; - return; - } - LAQs(vl, vr, d, &res_l, &res_r); - depth = TDepth(res_l, res_r); - x = d-depth; - while(x!=0 && !(res_l==vl && res_r==vr) ) { - if(acum==1) - //this can be improve - string_depth = SDepth(res_l,res_r); - LAQs(vl, vr, string_depth+x, &next_l, &next_r); - aux_l = next_l; - aux_r = next_r; - - while(aux_l != res_l || aux_r != res_r) { - Parent(aux_l, aux_r, &aux_l, &aux_r); - depth++; - } - - if(res_l==next_l && res_r==next_r) { - string_depth++; - acum++; - } - else { - acum = 1; - res_l = next_l; - res_r = next_r; - x = d - depth; - } - } - *laq_t_l = res_l; - *laq_t_r = res_r; - } - - size_t SuffixTreeY::getSize() const - { - size_t mem = sizeof(SuffixTreeY); - mem += lcp->getSize(); - mem += npr->getSize(); - mem += csa->getSize(); - return mem; - } - - void SuffixTreeY::save(ostream & fp) const - { - size_t wr = CSTY; - saveValue(fp,wr); - saveValue(fp, length); - lcp->save(fp); - npr->save(fp); - csa->save(fp); - } - - SuffixTreeY * SuffixTreeY::load(istream & fp) { - SuffixTreeY *cst = new SuffixTreeY(); - size_t type = loadValue(fp); - if(type!=CSTY) { - abort(); - } - cst->length = loadValue(fp); - cst->lcp = LCP::load(fp); - cst->npr = NPR::load(fp); - cst->csa = TextIndex::load(fp); - return cst; - } - - SuffixTreeY::~SuffixTreeY() { - delete (TextIndexCSA *)csa; - size_t lcp_type = lcp->lcp_type; - switch(lcp_type) { - case NAIVE: delete (LCP_naive *)lcp; break; - case SAD_GON_OS: delete (LCP_Sad *)lcp; break; - case FMN_RRR_OS: delete (LCP_FMN *)lcp; break; - case PT: delete (LCP_PT *)lcp; break; - case PHI: delete (LCP_PhiSpare *)lcp; break; - case DAC: delete (LCP_DAC *)lcp; break; - case DAC_VAR: delete (LCP_DAC_VAR *)lcp; break; - default: break; - } - size_t npr_type = npr->npr_type; - switch(npr_type) { - case FMN_NPR: delete (NPR_FMN *)npr; break; - case CN_NPR: delete (NPR_CN *)npr; break; - default: break; - } - } - -}; diff --git a/libcds/src/static/suffixtree/factorization.cpp b/libcds/src/static/suffixtree/factorization.cpp deleted file mode 100644 index 37637b8c..00000000 --- a/libcds/src/static/suffixtree/factorization.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -#define BASE 16 -#define BASE_BITS 4 - -const unsigned int TABLEBASE[7] = {0,16,272,4368,69904,1118480,17895696}; - -namespace cds_static -{ - - factorization::factorization() { - listLength =0; - nLevels =0; - levelsIndex = NULL; - levels = NULL; - bS = NULL; - rankLevels = NULL; - } - - factorization::factorization(uint *list,uint l_Length) { - uint levelSizeAux[7]={0,0,0,0,0,0,0}; - uint cont[7]={0,0,0,0,0,0,0}; - listLength = l_Length; - uint i; - int j, k; - uint value, newvalue; - uint bits_BS_len = 0; - - //space needed for all the levels - for (i=0; i=TABLEBASE[j]) - levelSizeAux[j]++; - } - - j=0; - while((j<7)&&(levelSizeAux[j]!=0)) { - //fprintf(stderr,"levelSize[%d]=%d\n",j,levelSizeAux[j]); - if(levelSizeAux[j]%2) - levelSizeAux[j]++; - j++; - } - nLevels = j; - levelsIndex = new uint[nLevels+1]; - for(j=0; j<= nLevels; j++) - levelsIndex[j] = 0; - levelsIndex[0]=0; - for(j=0; j=0) { - if(value >= TABLEBASE[j]) { - newvalue = value - TABLEBASE[j]; - for(k=0; k overhead 50% - // factor=3 => overhead 33% - // factor=4 => overhead 25% - // factor=20=> overhead 5% - delete [] bits_BS; - //Contadores - rankLevels = new uint[nLevels]; - for(j=0; jrank1(levelsIndex[j]-1); - } - - uint factorization::access(uint param) { - uint mult=0; - uint j; - uint partialSum=0; - uint ini=param-1; - uint * bsData = ((BitSequenceRG *)bS)->data; - unsigned char * level; - unsigned char readByte; - uint pos, rankini, cont; - - j=0; - level= levels + (levelsIndex[j]>>1); - cont = ini + (levelsIndex[j]&0x1); - pos= levelsIndex[j]+ini; - mult=0; - readByte = ((*(level+(cont>>1)))>>(BASE_BITS*(cont&0x1)))&0xF; - while((!bitget(bsData,pos))) { - rankini = bS->rank1(levelsIndex[j]+ini-1) - rankLevels[j]; - ini = ini-rankini; - partialSum = partialSum + (readByte<>1); - cont=ini+(levelsIndex[j]&0x1); - pos= levelsIndex[j]+ini; - readByte = ((*(level+(cont>>1)))>>(BASE_BITS*(cont&0x1)))&0xF; - if( (int)j >= nLevels-1) { - break; - } - } - partialSum = partialSum + (readByte<data; - unsigned char * level; - unsigned char readByte; - uint pos, rankini, cont; - - j=0; - level= levels + (levelsIndex[j]>>1); - cont = ini + (levelsIndex[j]&0x1); - pos= levelsIndex[j]+ini; - mult=0; - readByte = ((*(level+(cont>>1)))>>(BASE_BITS*(cont&0x1)))&0xF; - while((!bitget(bsData,pos))) { - partialSum = partialSum + (readByte<rank1(levelsIndex[j]+ini-1) - rankLevels[j]; - ini = ini-rankini; - if(dir) - next_pos[j] = ini+1; - else - next_pos[j] = ini-1; - } - else { - ini = next_pos[j]; - if(dir) - next_pos[j] = next_pos[j]+1; - else - next_pos[j] = next_pos[j]-1; - } - - j++; - mult+=BASE_BITS; - level =levels + (levelsIndex[j]>>1); - cont=ini+(levelsIndex[j]&0x1); - pos= levelsIndex[j]+ini; - readByte = ((*(level+(cont>>1)))>>(BASE_BITS*(cont&0x1)))&0xF; - if( (int)j >= nLevels-1) { - break; - } - } - partialSum = partialSum + (readByte<save(fp); - } - - factorization* factorization::load(istream & fp) { - factorization *rep = new factorization(); - rep->listLength = loadValue(fp); - rep->nLevels = loadValue(fp); - rep->levelsIndex = loadValue(fp, rep->nLevels+1); - rep->rankLevels = loadValue(fp, rep->nLevels); - rep->levels = loadValue(fp, (rep->levelsIndex[rep->nLevels]/2)); - rep->bS = BitSequence::load(fp); - return rep; - } - - uint factorization::getSize() { - uint mem=0; - mem += sizeof(factorization); - mem += (nLevels+1)*sizeof(uint); - mem += sizeof(uint)*nLevels; - mem += sizeof(unsigned char)*(levelsIndex[nLevels]/2); - mem += bS->getSize(); - return mem; - } - - factorization:: ~factorization() { - delete[] levelsIndex; - delete[] levels; - delete[] rankLevels; - delete (BitSequenceRG *)bS; - } - -}; diff --git a/libcds/src/static/suffixtree/factorization_var.cpp b/libcds/src/static/suffixtree/factorization_var.cpp deleted file mode 100644 index 4dc3c0c7..00000000 --- a/libcds/src/static/suffixtree/factorization_var.cpp +++ /dev/null @@ -1,307 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - factorization_var::factorization_var() { - tamCode = 0; - iniLevel = NULL; - base = NULL; - base_bits = NULL; - tablebase = NULL; - tamtablebase = 0; - listLength = 0; - nLevels = 0; - levelsIndex = NULL; - levels = NULL; - bS = NULL; - rankLevels = NULL; - } - - factorization_var::factorization_var(uint *list, uint l_Length, ushort* kvalues, uint nkvalues) { - uint *levelSizeAux; - uint *cont; - uint *contB; - listLength = l_Length; - uint i; - int j, k; - uint value, newvalue; - uint bits_BS_len = 0; - ushort kval; - uint oldval =0; - uint newval =0; - i=0; - uint multval=1; - do { - oldval=newval; - if(i>=nkvalues) - kval = 1<<(kvalues[nkvalues-1]); - else - kval=1<<(kvalues[i]); - multval*=kval; - newval = oldval+multval; - i++; - }while(oldval=nkvalues) - kval = 1<<(kvalues[nkvalues-1]); - else - kval=1<<(kvalues[i]); - multval*=kval; - newval = oldval+multval; - tablebase[i]=oldval; - } - for(i=0;i=tablebase[j]) - levelSizeAux[j]++; - } - j=0; - //Contadores - while((j<(int)tamtablebase)&&(levelSizeAux[j]!=0)) { - j++; - } - nLevels = j; - levelsIndex = new uint[nLevels+1]; - bits_BS_len =0; - base = new ushort[nLevels]; - base_bits = new ushort[nLevels]; - for(i=0;i=nkvalues) { - base[i]=1<<(kvalues[nkvalues-1]); - base_bits[i]=kvalues[nkvalues-1]; - } - else { - base[i]=1<<(kvalues[i]); - base_bits[i]=kvalues[i]; - } - } - uint tamLevels =0; - for(i=0;i=0) { - if(value >= tablebase[j]) { - newvalue = value- tablebase[j]; - for(k=0;krank1(levelsIndex[j]-1); - // for(i=0;idata,pos))) { - rankini = bS->rank1(levelsIndex[j]+ini-1) - rankLevels[j]; - ini = ini-rankini; - partialSum = partialSum+ (readByte<data,pos))) { - partialSum = partialSum+ (readByte<rank1(levelsIndex[j]+ini-1) - rankLevels[j]; - ini = ini-rankini; - if(dir) - next_pos[j] = ini+1; - else - next_pos[j] = ini-1; - } - else { - ini = next_pos[j]; - if(dir) - next_pos[j] = next_pos[j]+1; - else - next_pos[j] = next_pos[j]-1; - } - - mult+=base_bits[j]; - j++; - cont = iniLevel[j]+ini*base_bits[j]; - pos=levelsIndex[j]+ini; - readByte = bitread(levels,cont,base_bits[j]); - if(j==(uint)nLevels-1) - break; - } - partialSum = partialSum + (readByte<getSize(); - // rankLevels - mem += sizeof(uint)*nLevels; - return mem; - } - - void factorization_var::save(ostream & fp) { - saveValue(fp, tamCode); - saveValue(fp, tamtablebase); - saveValue(fp, listLength); - saveValue(fp, nLevels); - saveValue(fp, iniLevel, nLevels); - saveValue(fp, base, nLevels); - saveValue(fp, base_bits, nLevels); - saveValue(fp, tablebase, tamtablebase); - saveValue(fp, levelsIndex, nLevels+1); - saveValue(fp, levels, tamCode/W+1); - saveValue(fp, rankLevels, nLevels); - bS->save(fp); - } - - factorization_var* factorization_var::load(istream & fp) { - factorization_var *rep = new factorization_var(); - rep->tamCode = loadValue(fp); - rep->tamtablebase = loadValue(fp); - rep->listLength = loadValue(fp); - rep->nLevels = loadValue(fp); - rep->iniLevel = loadValue(fp, rep->nLevels); - rep->base = loadValue(fp,rep->nLevels); - rep->base_bits = loadValue(fp, rep->nLevels); - rep->tablebase = loadValue(fp, rep->tamtablebase); - rep->levelsIndex = loadValue(fp, rep->nLevels+1); - rep->levels = loadValue(fp, rep->tamCode/W+1); - rep->rankLevels = loadValue(fp, rep->nLevels); - rep->bS = BitSequence::load(fp); - return rep; - } - - factorization_var::~factorization_var() { - delete [] iniLevel; - delete [] base; - delete [] base_bits; - delete [] tablebase; - delete [] levelsIndex; - delete [] levels; - delete [] rankLevels; - delete (BitSequenceRG *)bS; - } - -}; diff --git a/libcds/src/static/textindex/TextIndex.cpp b/libcds/src/static/textindex/TextIndex.cpp deleted file mode 100644 index cf72c8e9..00000000 --- a/libcds/src/static/textindex/TextIndex.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -/* General interface for using the compressed index libraries */ - -#include - -namespace cds_static -{ - - /** Reads a text index determining the type */ - TextIndex * TextIndex::load(istream & fp) { - uint r = loadValue(fp); - size_t pos = fp.tellg(); - fp.seekg(pos-sizeof(uint)); - switch(r) { - case CSA_HDR: return TextIndexCSA::load(fp); - } - return NULL; - } -}; diff --git a/libcds/src/static/textindex/TextIndexCSA.cpp b/libcds/src/static/textindex/TextIndexCSA.cpp deleted file mode 100644 index 40088aed..00000000 --- a/libcds/src/static/textindex/TextIndexCSA.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cnovas, all rights reserved. - * - *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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_static -{ - - TextIndexCSA::TextIndexCSA() { - csa = NULL; - } - - TextIndexCSA::TextIndexCSA(uchar *text, ulong length, char *build_options) { - void *index; - build_index(text, length, build_options, &index); - csa = (CSA *) index; - } - - TextIndexCSA::~TextIndexCSA() { - csa_free(csa); - /*remove files *.idx and *.psi*/ - /*system("rm -rf *.psi"); - * system("rm .rf *.idx");*/ - } - - size_t TextIndexCSA::count(uchar *pattern, ulong length, ulong *numocc) const - { - return (size_t)cds_static::count(csa, pattern, length, numocc); - } - - size_t TextIndexCSA::locate (uchar *pattern, ulong length, ulong **occ, ulong *numocc) const - { - return (size_t)cds_static::locate (csa, pattern, length, occ, numocc); - } - - size_t TextIndexCSA::extract (ulong from, ulong to, uchar **snippet, ulong *snippet_length) const - { - return (size_t)cds_static::extract (csa, from, to, snippet, snippet_length); - } - - size_t TextIndexCSA::display (uchar *pattern, ulong length, ulong numc, ulong *numocc, uchar **snippet_text, ulong **snippet_lengths) const - { - return (size_t)cds_static::display(csa, pattern, length, numc, numocc, snippet_text, snippet_lengths); - } - - size_t TextIndexCSA::index_length() const - { - return (size_t)(csa->n); - } - - size_t TextIndexCSA::getSA(size_t i) const - { - return csa_lookup(csa,i+1)-1; - } - - size_t TextIndexCSA::getISA(size_t i) const - { - return csa_inverse(csa,i+1)-1; - } - - size_t TextIndexCSA::getPsi(size_t i) const - { - return csa_psi(csa,i+1)-1; - } - - size_t TextIndexCSA::getT(size_t i) const - { - return csa_T(csa,i+1); - } - - size_t TextIndexCSA::getSize() const - { - ulong size; - index_size(csa, &size); - return (size_t)size; - } - - void TextIndexCSA::save(ostream & fp) const - { - uint wr = CSA_HDR; - saveValue(fp,wr); - if(csa!=NULL) - csa_save(csa,fp); - } - - TextIndexCSA * TextIndexCSA::load(istream & fp) { - uint type = loadValue(fp); - if(type!=CSA_HDR) { - abort(); - } - TextIndexCSA *ticsa= new TextIndexCSA(); - ticsa->csa = csa_load(fp); - return ticsa; - } - -}; diff --git a/libcds/src/static/textindex/comparray4.cpp b/libcds/src/static/textindex/comparray4.cpp deleted file mode 100644 index 466c6acd..00000000 --- a/libcds/src/static/textindex/comparray4.cpp +++ /dev/null @@ -1,1106 +0,0 @@ -/* comparray4.c - Copyright (C) 2005, K. Sadakane, all rights reserved. - - This file contains an implementation of CSA. - For more information, see - - K. Sadakane. Compressed text databases with efficient query - algorithms based on the compressed suffix array. - In Proceedings 11th Annual International Symposium on Algorithms - and Computation (ISAAC)}, LNCS v. 1969, pages 410--421, 2000. - - K. Sadakane. Succinct representations of lcp information and - improvements in the compressed suffix arrays. - In Proceedings 13th Annual ACM-SIAM Symposium on Discrete - Algorithms (SODA), 2002. - - K. Sadakane. New text indexing functionalities of the compressed - suffix arrays. Journal of Algorithms, 48(2):294--313, 2003. - - 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. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - 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 - -*/ - -#define USE_MMAP - -#include -#include -#include -#include -#include - -#define inline -#define ENCODENUM encodegamma -#define DECODENUM decodegamma - -#define DD 16 -#define TBLSIZE (1<> 4; - l = i & (DD-1); - x = (B[j]<> (DD-l)) & 0xffff; - } - - int getbit(unsigned short *B, int i) { - int j,l; - i--; - j = i >> 4; - l = i & (DD-1); - return (B[j] >> (DD-1-l)) & 1; - } - - int setbit(unsigned short *B, int i,int x) { - int j,l; - i--; - j = i / DD; - l = i % DD; - if (x==0) B[j] &= (~(1<<(DD-1-l))); - else if (x==1) B[j] |= (1<<(DD-1-l)); - else { - printf("error setbit x=%d\n",x); - exit(1); - } - return x; - } - - int initranktables(void) { - unsigned short B; - int i,j,m,r; - int b; - #if DD!=16 - error - #endif - /* DD==16 O */ - for (i = 0; i < TBLSIZE; i++) { - B = i; - r = 0; - for (m = 0; m < DD; m++) { - b = getbit(&B, m+1); - r += b; - R3[m][i] = r; - } - for (m = 1; m <= DD; m++) { - r = 0; - for (j = 1; j <= DD; j++) { - b = getbit(&B, j); - if (b == 1) { - r += b; - if (r == m) R5[m-1][i] = j-1; - } - } - } - } - for (i = 0; i < DD; i++) { - for (j = (1<0) { - x>>=1; - l++; - } - return l; - } - - /* x 1 */ - int encodegamma(unsigned short *B,int p,int x) { - int j,w; - if (x<=0) { - fprintf(stderr,"encodegamma %d\n",x); exit(1); - } - w = blog(x); - for (j=0;j=0;j--) setbit(B,1+p+(w-1)+(w-1)-j,(x >> j)&1); - return 2*w-1; - } - - #ifndef DEBUG - inline - #endif - int getzerorun(unsigned short *B,int p) { - int w,w2; - #if 0 - w = 0; - while (getbit(B,1+p+w)==0) w++; - #else - w = 0; - while (1) { - w2 = R4[getbitD(B,1+p)]; - w += w2; - if (w2 < DD) break; - p += DD; - } - #endif - return w; - } - - int decodegamma(unsigned short *B,int p,int *ans) { - int w,x; - int w2; - #if 0 - x = getbitD(B,1+p); - b = R6b[x]; - if (b>0) { - *ans = R6x[x]; - return b; - } - #endif - w = getzerorun(B,p); - #if 0 - x = 1; - for (i=0;i DD) { - x <<= DD; - x += getbitD(B,1+p); - p += DD; - w2 -= DD; /* w return value */ - } - x <<= w2; - x += (getbitD(B,1+p)>>(DD-w2)); - #endif - *ans = x; - return 2*w+1; - } - - void mkdecodetable(void) { - unsigned short B[256]; - int i,j,b,b2,d,x; - - for (i=0; i<256; i++) B[i] = 0xffff; - for (i = 0; i < TBLSIZE; i++) { - B[0] = i; - R6b[i] = 0; R6x[i] = 0; - b = 0; j = 0; x = 0; - while (1) { - b2 = DECODENUM(B,b,&d); - if (b+b2 > DD) break; - b += b2; - x += d; - j++; - if (j==1) {R6b[i] = b2; R6x[i] = d;} - } - R5n[i] = j; R5b[i] = b; R5x[i] = x; - } - } - - inline - int psi_list(CSA *SA,int i) { - int j,l,r,m; - #ifdef DEBUG - if (i > SA->n || i < 1) { - printf("error psi_get i=%d n=%d\n",i,SA->n); - exit(1); - } - #endif - l = 1; r = SA->m; - while (l < r) { - m = (l + r) / 2; - if (SA->K[m+1] <= i) { - l = m + 1; - } - else { - r = m; - } - } - j = r; - return j; - } - - void psisort2(int *p,int *I,unsigned char *s,int n) { - int i,sum; - int C[SIGMA]; - int x,c; - for (i = 0; i < SIGMA; i++) C[i] = 0; - for (i = 1; i <= n; i++) { - c = s[i]; - C[c]++; - } - sum = 0; - for (i = 0; i < SIGMA; i++) { - sum = sum + C[i]; - C[i] = sum - C[i]; - } - - for (i = 0; i <= n; i++) { - x = p[i]-1; - if (x==0) continue; - c = s[x]; - I[1+C[c]++] = i; - } - } - - void writeint(int x,FILE *f) { - int tmp; - tmp = x; - fwrite(&tmp,sizeof(int),1,f); - } - - void csa_new(int n, int *p, unsigned char *s, char *fname1, char *fname2, int rankb_w, int rankb_w2) { - int i,v,b,x,b2,d,w,m; - int *I,*J; - int K[SIGMA+2],C[SIGMA+1],C2[SIGMA+1]; - unsigned short Btmp[64]; - FILE *f1,*f2; - int psize,isize; - - f1 = fopen(fname1,"wb"); /* psi */ - f2 = fopen(fname2,"wb"); /* directory */ - if (f1 == NULL || f2 == NULL) { - perror("csa2_new1: "); - exit(1); - } - - for (i=0; i0) { - m++; - C2[m] = i; - K[m] = v; - v += C[i]; - } - } - K[m+1] = v; - - for (v=0,i=0; i */ - } - isize += SIGMA*sizeof(int); - for (i = 1; i <= m+1; i++) { - writeint(K[i],f2); /* px */ - } - isize += (m+1)*sizeof(int); - for (i = 1; i <= m; i++) { - writeint(C2[i],f2); /* ->R[h */ - } - isize += m*sizeof(int); - - I=(int *)malloc((n+2) * sizeof(*I)); - if (I==NULL) { - fprintf(stderr, "psi_new2 malloc I failed\n"); - exit(1); - } - - psisort2(p,I,s-1,n); - - writeint(-1,f2); /* R[0] */ - writeint(0,f2); /* P[0] */ - isize += 2*sizeof(int); - - x = -1; b = b2 = 0; - for (i=1; i<=n; i++) { - if (I[i] < x) { - d = (n+65536) - x; - } - else { - d = I[i] - x; - } - w = ENCODENUM(Btmp,b2,d); - b += w; b2 += w; - if (b2 >= 16) { - fwrite(Btmp,b2 / 16,sizeof(short),f1); - psize += (b2/16)*sizeof(short); - Btmp[0] = Btmp[b2 / 16]; - b2 = b2 % 16; - }; - if (I[i] < x) { - x = -1; - i--; - } - else { - x = I[i]; - if (i % rankb_w2 == 0) { - /* R[i / L] */ - writeint(I[i],f2); - /* P[i / L] */ - writeint(b,f2); - isize += 2*sizeof(int); - } - } - } - if (b2 > 0) { - fwrite(Btmp,(b2+15) / 16,sizeof(short),f1); - psize += ((b2+15)/16)*sizeof(short); - }; - - writeint(n+1,f2); /* SA[0] */ - isize += sizeof(int); - for (i=rankb_w; i<=n; i+=rankb_w) { - writeint(p[i],f2); - isize += sizeof(int); - } - J = (int *)malloc(((n-1)/(rankb_w*16)+1)*sizeof(*J)); - if (J==NULL) { - perror("csa2_new\n"); - exit(1); - } - for (i=1; i<=n; i++) { - if ((p[i]-1) % (rankb_w*16) == 0) { - J[(p[i]-1) / (rankb_w*16)] = i; - } - } - for (i = 0; i <= (n-1)/(rankb_w*16); i++) { - writeint(J[i],f2); - isize += sizeof(int); - } - fclose(f1); - fclose(f2); - - free(I); - free(J); - - } - - int readint(FILE *f) { - int s; - int tmp; - s=fread(&tmp,sizeof(int),1,f); - return tmp; - } - - int csa_read(CSA *SA,char *fname1,char *fname2) { - int i,n,m; - FILE *f; - int psize,isize; - unsigned char *ptr; - - #ifndef USE_MMAP - f = fopen(fname1,"rb"); - if (f == NULL) { - perror("csa2_read1: "); - exit(1); - } - fseek(f,0,SEEK_END); - psize = ftell(f); - fseek(f,0,0); - SA->B = malloc(psize+1); - if (SA->B == NULL) { - perror("csa2_read2: "); - exit(1); - } - fread(SA->B,psize+1,1,f); - fclose(f); - #else - SA->mapp = mymmap(fname1); - if (SA->mapp->addr==NULL) { - perror("mmap1\n"); - exit(1); - } - SA->B = (unsigned short *)SA->mapp->addr; - SA->p_size = SA->mapp->len; - psize = SA->mapp->len; - #endif - - f = fopen(fname2,"rb"); - if (f == NULL) { - perror("csa2_read3: "); - exit(1); - } - fseek(f,0,SEEK_END); - isize = ftell(f); - fseek(f,0,0); - SA->n = n = readint(f); /* eLXg */ - SA->l = readint(f); /* psii[ */ - SA->two = readint(f); /* SAi[ */ - SA->two2 = readint(f); /* ISAi[ */ - - /* At@xbgTCY */ - if ((m=readint(f)) != SIGMA) { - printf("error sigma=%d\n",m); - } - SA->m = m = readint(f); /* */ - isize = 6*sizeof(int); - - for (i = 0; i < SIGMA; i++) { - /* -> */ - SA->C[i] = readint(f); - } - isize += SIGMA*sizeof(int); - for (i = 1; i <= m+1; i++) { - /* px */ - SA->K[i] = readint(f); - } - isize += (m+1)*sizeof(int); - for (i = 1; i <= m; i++) { - /* ->R[h */ - SA->C2[i] = readint(f); - } - isize += m*sizeof(int); - - #ifndef USE_MMAP - SA->R = malloc((n / SA->l + 1)*2*sizeof(int)); - if (SA->R == NULL) { - perror("csa2_read4: "); - exit(1); - } - for (i = 0; i <= n / SA->l; i++) { - /* psil */ - SA->R[i*2] = readint(f); - /* psi|C^ */ - SA->R[i*2+1] = readint(f); - } - - SA->SA = malloc((n / SA->two + 1)*sizeof(int)); - if (SA->SA == NULL) { - perror("csa2_read6: "); - exit(1); - } - for (i = 0; i <= (n / SA->two); i++) { - SA->SA[i] = readint(f); - } - SA->ISA = malloc((n / SA->two2 + 1)*sizeof(int)); - if (SA->ISA == NULL) { - perror("csa2_read7: "); - exit(1); - } - for (i = 0; i <= (n-1) / SA->two2; i++) { - SA->ISA[i] = readint(f); - } - fclose(f); - #else - fclose(f); - - SA->mapi = mymmap(fname2); - if (SA->mapi->addr==NULL) { - perror("mmap2\n"); - exit(1); - } - SA->i_size = SA->mapi->len; - - ptr = (unsigned char *)SA->mapi->addr + isize; - SA->R = (int *)ptr; - isize += (n / SA->l+1)*2*sizeof(int); - SA->r_size = (n / SA->l+1)*2; - - ptr = (unsigned char *)SA->mapi->addr + isize; - SA->SA = (int *)ptr; - SA->sa_size = (n / SA->two+1); - isize += (n / SA->two+1)*sizeof(int); - - ptr = (unsigned char *)SA->mapi->addr + isize; - SA->ISA = (int *)ptr; - SA->isa_size =(n / SA->two2+1); - #endif - return 0; - } - - void csa_init(CSA *SA) { - for(int i=0; i< SIGMA+2; i++) - SA->K[i]=0; - for(int i=0; i< SIGMA+1; i++) { - SA->C[i]=0; - SA->C2[i]=0; - } - } - - void csa_save(CSA *SA, ostream & fp) { - saveValue(fp, SA->m); - saveValue(fp, SA->two); - saveValue(fp, SA->two2); - saveValue(fp, SA->l); - saveValue(fp, SA->n); - saveValue(fp, SA->K, (SIGMA+2)); - saveValue(fp, SA->C, (SIGMA+1)); - saveValue(fp, SA->C2, (SIGMA+1)); - #ifdef USE_MMAP - saveValue(fp, SA->p_size); - saveValue(fp, SA->B, SA->p_size); - saveValue(fp, SA->i_size); - saveValue(fp, SA->r_size); - saveValue(fp, SA->R, SA->r_size); - saveValue(fp, SA->sa_size); - saveValue(fp, SA->SA, SA->sa_size); - saveValue(fp, SA->isa_size); - saveValue(fp, SA->ISA, SA->isa_size); - #endif - } - - CSA *csa_load(istream & fp) { - CSA *SA; - SA = (CSA *) malloc(sizeof(CSA)); - csa_init(SA); - initranktables(); - mkdecodetable(); - SA->m = loadValue(fp); - SA->two = loadValue(fp); - SA->two2 = loadValue(fp); - SA->l = loadValue(fp); - SA->n = loadValue(fp); - for(int i=0; i<(SIGMA+2); i++) - SA->K[i] = loadValue(fp); - for(int i=0; i<(SIGMA+1); i++) - SA->C[i] = loadValue(fp); - for(int i=0; i<(SIGMA+1); i++) - SA->C2[i] = loadValue(fp); - #ifdef USE_MMAP - SA->p_size = loadValue(fp); - SA->B = loadValue(fp, SA->p_size); - SA->i_size = loadValue(fp); - SA->r_size = loadValue(fp); - SA->R = loadValue(fp, SA->r_size); - SA->sa_size = loadValue(fp); - SA->SA = loadValue(fp, SA->sa_size); - SA->isa_size = loadValue(fp); - SA->ISA = loadValue(fp, SA->isa_size); - SA->mapp = NULL; - SA->mapi = NULL; - #endif - return SA; - } - - void csa_free(CSA *csa) { - #ifdef USE_MMAP - if(csa->mapp!=NULL && csa->mapi!=NULL) { - free(csa->mapp); - free(csa->mapi); - } - else { - delete [] csa->B; - delete [] csa->ISA; - delete [] csa->R; - delete [] csa->SA; - } - #endif - free(csa); - } - - inline - int csa_psi(CSA *SA, int i) { - int j,k,b,d,x; - int k2,p,n; - int l; - unsigned short *B; - #ifdef DEBUG - if (i > SA->n || i < 1) { - printf("error csa2_psi i=%d n=%d\n",i,SA->n); - exit(1); - } - #endif - - l = SA->l; - x = SA->R[(i / l)*2]; - b = SA->R[(i / l)*2+1]; - j = i % l; - - n = SA->n; - B = SA->B; - - #if 0 - for (k=0; k n) { - //printf("i %d k %d d %d x %d n %d\n",i,k,d,x,n); - x = -1; - k--; - } - //printf("k %d j %d b %d \n",k,j,b); - } - #else - - k = 0; - while (k < j) { - p = getbitD(B,1+b); - k2 = R5n[p]; - if (k2 == 0) { - b += DECODENUM(B,b,&d); - x += d; - k++; - if (x > n) { - x = -1; - k--; - } - } - else { - if (k+k2 > j) break; - k += k2; - b += R5b[p]; - x += R5x[p]; - } - } - - for (; k n) { - x = -1; - k--; - } - } - #endif - #ifdef DEBUG - if (x < 0 || x > SA->n) { - printf("error csa2_psi(%d) %d\n",i,x); - } - #endif - return x; - } - - inline - int csa_T(CSA *SA,int i) { - int c; - c = psi_list(SA,i); - return SA->C2[c]; - } - - void csa_decode(unsigned char *p,CSA *SA,int suf,int len) { - int pos; - int i; - pos = csa_inverse(SA,suf); - i = 0; - while (i < len) { - *p++ = csa_T(SA,pos); - pos = csa_psi(SA,pos); - i++; - } - } - - void csa_decode2(unsigned char *p,CSA *SA,int pos,int len) { - int i; - i = 0; - while (i < len) { - *p++ = csa_T(SA,pos); - pos = csa_psi(SA,pos); - i++; - } - } - - void csa_decode1line(unsigned char *p,CSA *SA,int suf,int maxlen) { - int i,k,m,pos; - unsigned char *tmp; - - m = maxlen*2; - tmp = (unsigned char *)malloc(m+1); - if (tmp==NULL) {perror("csa_decode1line"); exit(1);} - - k = suf - maxlen; if (k <= 0) k = 1; - pos = csa_inverse(SA,k); - - i = 0; - while (i < m) { - tmp[i] = csa_T(SA,pos); - pos = csa_psi(SA,pos); - i++; - } - for (i = suf-k; i < m; i++) { - if (tmp[i] == 0x0a) {i--; break;} - } - m = i; - for (i = suf-k; i >= 0; i--) { - if (tmp[i] == 0x0a) {i++; break;} - } - if (m-i > maxlen) i = m-maxlen; - while (i < m) *p++ = tmp[i++]; - *p = 0; - free(tmp); - } - - void csa_decodeall(unsigned char *p,CSA *SA) { - int *I; - int i,n,pos; - int x,b,d; - unsigned short *B; - n = SA->n; - I =(int *)malloc((n+1)*sizeof(*I)); - if (I == NULL) {perror("decodeall"); exit(1);} - - B = SA->B; - x = -1; b = 0; - for (i=1; i<=n; i++) { - b += DECODENUM(B,b,&d); - x += d; - if (x > n) { - x = -1; i--; - } - else { - I[i] = x; - } - } - pos = csa_inverse(SA,1); - for (i=1; i<=n; i++) { - if (pos < 1 || pos > n) { - printf("i %d pos %d\n",i,pos); - } - *p++ = csa_T(SA,pos); - pos = I[pos]; - } - } - - int csa_lookup(CSA *SA, int i) { - int v,two; - v = 0; two = SA->two; - while (i % two !=0) { - i = csa_psi(SA,i); - v++; - } - i = i / two; - return SA->SA[i]-v; - } - - int np; - int csa_lookup2(CSA *SA, int i) { - int v,two; - v = 0; two = SA->two; - while (i % two !=0) { - i = csa_psi(SA,i); - np++; - v++; - } - i = i / two; - return SA->SA[i]-v; - } - - int csa_inverse(CSA *SA, int suf) { - int p,pos; - int two2; - - two2 = SA->two2; - - p = ((suf-1)/two2)*two2+1; - pos = SA->ISA[(suf-1)/two2]; - - while (p < suf) { - pos = csa_psi(SA,pos); - p++; - } - return pos; - } - - int intcompare(const void *i, const void *j) { - if (*(int *)i > * (int *)j) - return 1; - if (*(int *)i < *(int *)j) - return -1; - return 0; - } - - int *csa_batchlookup(CSA *SA,int l, int r) { - int *I; - int j; - I = (int *)malloc((r-l+1+1)*sizeof(*I)); - np = 0; - for (j=0; jtwo; - sa = SA->SA; - - I = (unsigned long *)malloc((r-l+1)*sizeof(*I)); - V = (int *)malloc((r-l+1+1)*sizeof(*V)); - J = (int *)malloc((r-l+1+1)*sizeof(*J)); - - for (j=l; j<=r; j++) J[j-l] = -1; - for (j=l; j<=r; j++) I[j-l] = 0; - for (m=0,j=l; j<=r; j++) { - f = 0; - i = j; v = 0; - while (i % two !=0) { - i = csa_psi(SA,i); - v++; - m++; - if (l <= i && i <= r) { - V[j-l] = v; - J[i-l] = j; - f = 1; - break; - } - } - if (f==0) { - i = i / two; - I[j-l] = sa[i]-v; - } - } - for (j=l; j<=r; j++) { - if (I[j-l] != 0) { - q = j; - while (J[q-l] != -1) { - s = I[q-l]; - i = J[q-l]; - v = V[i-l]; - I[i-l] = s - v; - J[q-l] = -1; - q = i; - } - } - } - - for (j=l; j<=r; j++) - I[j-l]--; - - free(V); free(J); - return I; - } - - int *csa_batchlookup3(CSA *SA,int l, int r,int len) { - int *I; /* z */ - int *P; /* r i z */ - int v; /* [ */ - int m; /* SA */ - int q; - int i,j; - int two; - int *sa; - int k,b,d,x,n,w; - unsigned short *B; - - n = SA->n; - B = SA->B; - two = SA->two; - sa = SA->SA; - w = SA->l; - - I =(int *) malloc((r-l+1+1)*sizeof(*I)); - P =(int *) malloc((r-l+1+1)*sizeof(*I)); - #if 1 - x = SA->R[(l / w)*2]; - b = SA->R[(l / w)*2+1]; - j = l % w; - for (k=0; k n) {x = -1; k--;} - } - for (m = 0, q = 0, i = l; i <= r; i++) { - if (i % two == 0) { - I[1+m] = sa[i / two]; - m++; - } - else { - P[q++] = x; - } - b += DECODENUM(B,b,&d); - x += d; - if (x > n) { - x = -1; - b += DECODENUM(B,b,&d); - x += d; - } - } - v = 1; - #else - for (q = 0, i = l; i <= r; i++) { - P[q++] = i; - } - v = 0; - m = 0; - #endif - while (q > 0 && v <= len) { - for (k = 0, j = 0; j < q; j++) { - i = P[j]; - if (i % two == 0) { - I[1+m] = sa[i / two] - v; - m++; - } - else { - P[k++] = csa_psi(SA,i); - } - } - q = k; - v++; - } - for (j = 0; j < q; j++) { - I[1+m] = csa_lookup(SA,P[j])-v; - m++; - } - qsort(I+1, r-l+1, sizeof(int), intcompare); - I[0] = r-l+1; - free(P); - return I; - } - - /* backward search */ - int csa_bsearch(unsigned char *key,int keylen,CSA *SA,int *li,int *ri) { - int c,h,l,r,m,ll,rr,pl,pr; - int x,b,w,d,n,*R; - unsigned short *B; - int len; - - c = key[keylen-1]; - r = SA->C[c]; if (c>0) l = SA->C[c-1]+1; else l = 1; - len = 0; - if (l > r) goto end; - len++; - for (h = keylen-2; h >= 0; h--) { - pl = l; pr = r; - c = key[h]; - r = SA->C[c]; if (c>0) l = SA->C[c-1]+1; else l = 1; - if (l > r) goto end; - #if 0 - while (1) { // find maximum r such that Psi[r] <= pr - j = csa_psi(SA,r); - if (j <= pr) break; - r--; - //if (l > r) goto end; - } - #else - #if 0 - ll = l; rr = r; - while (ll <= rr) { - m = (ll + rr) / 2; - if (csa_psi(SA,m) <= pr) ll = m+1; else rr = m-1; - } - r = ll-1; - #else - R = SA->R; B = SA->B; w = SA->l; n = SA->n; - ll = l / w + 1; - rr = r / w; - while (ll <= rr) { - m = (ll + rr) / 2; - if (R[m*2] <= pr) ll = m+1; else rr = m-1; - } - m = (ll-1)*w; - x = R[(m / w)*2]; - b = R[(m / w)*2+1]; - - #if 1 - while (m < l) { - b += DECODENUM(B,b,&d); - x += d; - //if (x > n) printf("??? \n"); - if (x > n) {x = -1; m--;} - m++; - } - #endif - while (x <= pr && m <= r) { - b += DECODENUM(B,b,&d); - x += d; - //if (x > n) printf("??? \n"); - m++; - } - r = m-1; - #endif - #endif - #if 0 - while (1) { // find minimum l such that Psi[l] >= pl - j = csa_psi(SA,l); - if (j >= pl) break; - l++; - //if (l > r) goto end; - } - #else - #if 0 - ll = l; rr = r; - while (ll <= rr) { - m = (ll + rr) / 2; - if (csa_psi(SA,m) >= pl) rr = m-1; else ll = m+1; - } - l = rr+1; - #else - //ll = l / w + 1; - ll = l / w; - rr = r / w; - while (ll <= rr) { - m = (ll + rr) / 2; - if (R[m*2] >= pl) rr = m-1; else ll = m+1; - } - m = rr*w; - x = R[(m / w)*2]; - b = R[(m / w)*2+1]; - - while (m < l) { - b += DECODENUM(B,b,&d); - x += d; - if (x > n) {x = -1; m--;} - m++; - } - while (x < pl && m <= r) { - b += DECODENUM(B,b,&d); - x += d; - m++; - } - l = m; - #endif - #endif - if (l > r) goto end; - len++; - } - end: - *li = l; *ri = r; - return len; - } - -}; diff --git a/libcds/src/static/textindex/mmap.cpp b/libcds/src/static/textindex/mmap.cpp deleted file mode 100644 index 01c65e58..00000000 --- a/libcds/src/static/textindex/mmap.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* mmap.c - Copyright (C) 2005, K. Sadakane, all rights reserved. - - This file contains an implementation of memory manager - - 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. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - 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 - -*/ - -#ifdef __APPLE__ -#include -#endif - - -#include - -#ifndef WIN32 -#include -#endif - -#include - -namespace cds_static -{ - - #ifdef WIN32 - MMAP * mymmap (char *fname) { - void *base; - HANDLE fd,h; - int len; - MMAP *m; - m = (MMAP*) malloc(sizeof(*m)); - if (m==NULL) {perror("mymmap malloc"); exit(1);} - fd = CreateFile( (WCHAR*) fname,GENERIC_READ,0,NULL,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL); - if (fd==INVALID_HANDLE_VALUE) { - printf("createfile\n"); - exit(1); - } - m->h1 = fd; - len = GetFileSize(fd,0); - m->len = len; - h = CreateFileMapping (fd, NULL, PAGE_READONLY, 0, len, NULL); - if (h==NULL) { - printf("createfilemapping\n"); - exit(1); - } - m->h2 = h; - base = MapViewOfFile (h, FILE_MAP_READ, 0, 0, len); - if (base==NULL) { - printf("mapviewoffile\n"); - return NULL; - } - m->addr = base; - return m; - } - - int mymunmap (MMAP *m) { - UnmapViewOfFile (m->addr); - CloseHandle(m->h2); - CloseHandle(m->h1); - return 0; - } - - #else - - MMAP *mymmap (char *fname) { - int fd; - int len; - MMAP *m; - struct stat statbuf; - caddr_t base; - m =(MMAP *) malloc(sizeof(*m)); - if (m==NULL) {perror("mymmap malloc"); exit(1);} - - stat(fname,&statbuf); - len = statbuf.st_size; - fd = open(fname,O_RDONLY); - base = (caddr_t)mmap(0,len,PROT_READ,MAP_SHARED,fd,0); - if (base==(caddr_t)-1) { - perror("mmap1\n"); - exit(1); - } - m->addr = (void *)base; - m->fd = fd; - m->len = len; - return m; - } - - int mymunmap (MMAP *m) { - if (munmap(m->addr,m->len)==-1) { - perror("munmap 1:"); - } - close(m->fd); - return 0; - } - -#endif - -} diff --git a/libcds/src/static/textindex/qsufsort.cpp b/libcds/src/static/textindex/qsufsort.cpp deleted file mode 100644 index 0a76fc79..00000000 --- a/libcds/src/static/textindex/qsufsort.cpp +++ /dev/null @@ -1,312 +0,0 @@ -/* qsufsort.cpp - Copyright 1999, N. Jesper Larsson, all rights reserved. - - This file contains an implementation of the algorithm presented in "Faster - Suffix Sorting" by N. Jesper Larsson (jesper@cs.lth.se) and Kunihiko - Sadakane (sada@is.s.u-tokyo.ac.jp). - - This software may be used freely for any purpose. However, when distributed, - the original source must be clearly stated, and, when the source code is - distributed, the copiright notice must be retained and any alterations in - the code must be clearly marked. No warranty is given regarding the quality - of this software.*/ - -#include - -static int *I, /* group array, ultimately suffix array.*/ -*V, /* inverse array, ultimately inverse of I.*/ -r, /* number of symbols aggregated by transform.*/ -h; /* length of already-sorted prefixes.*/ - -#define KEY(p) (V[*(p)+(h)]) -#define SWAP(p, q) (tmp=*(p), *(p)=*(q), *(q)=tmp) -#define MED3(a, b, c) (KEY(a)KEY(c) ? (b) : KEY(a)>KEY(c) ? (c) : (a))) - -namespace cds_static -{ - /* Subroutine for select_sort_split and sort_split. Sets group numbers for a - group whose lowest position in I is pl and highest position is pm.*/ - - static void update_group(int *pl, int *pm) { - int g; - - g=pm-I; /* group number.*/ - V[*pl]=g; /* update group number of first position.*/ - if (pl==pm) - *pl=-1; /* one element, sorted group.*/ - else - do /* more than one element, unsorted group.*/ - V[*++pl]=g; /* update group numbers.*/ - while (pl>1); /* small arrays, middle element.*/ - if (n>7) { - pl=p; - pn=p+n-1; - if (n>40) { /* big arrays, pseudomedian of 9.*/ - s=n>>3; - pl=MED3(pl, pl+s, pl+s+s); - pm=MED3(pm-s, pm, pm+s); - pn=MED3(pn-s-s, pn-s, pn); - } - pm=MED3(pl, pm, pn); /* midsize arrays, median of 3.*/ - } - return KEY(pm); - } - - /* Sorting routine called for each unsorted group. Sorts the array of integers - (suffix numbers) of length n starting at p. The algorithm is a ternary-split - quicksort taken from Bentley & McIlroy, "Engineering a Sort Function", - Software -- Practice and Experience 23(11), 1249-1265 (November 1993). This - function is based on Program 7.*/ - - static void sort_split(int *p, int n) { - int *pa, *pb, *pc, *pd, *pl, *pm, *pn; - int f, v, s, t, tmp; - - if (n<7) { /* multi-selection sort smallest arrays.*/ - select_sort_split(p, n); - return; - } - - v=choose_pivot(p, n); - pa=pb=p; - pc=pd=p+n-1; - while (1) { /* split-end partition.*/ - while (pb<=pc && (f=KEY(pb))<=v) { - if (f==v) { - SWAP(pa, pb); - ++pa; - } - ++pb; - } - while (pc>=pb && (f=KEY(pc))>=v) { - if (f==v) { - SWAP(pc, pd); - --pd; - } - --pc; - } - if (pb>pc) - break; - SWAP(pb, pc); - ++pb; - --pc; - } - pn=p+n; - if ((s=pa-p)>(t=pb-pa)) - s=t; - for (pl=p, pm=pb-s; s; --s, ++pl, ++pm) - SWAP(pl, pm); - if ((s=pd-pc)>(t=pn-pd-1)) - s=t; - for (pl=pb, pm=pn-s; s; --s, ++pl, ++pm) - SWAP(pl, pm); - - s=pb-pa; - t=pd-pc; - if (s>0) - sort_split(p, s); - update_group(p+s, p+n-t-1); - if (t>0) - sort_split(p+n-t, t); - } - - /* Bucketsort for first iteration. - - Input: x[0...n-1] holds integers in the range 1...k-1, all of which appear - at least once. x[n] is 0. (This is the corresponding output of transform.) k - must be at most n+1. p is array of size n+1 whose contents are disregarded. - - Output: x is V and p is I after the initial sorting stage of the refined - suffix sorting algorithm.*/ - - static void bucketsort(int *x, int *p, int n, int k) { - int *pi, i, c, d, g; - - for (pi=p; pi=p; --pi) { - d=x[c=*pi]; /* c is position, d is next in list.*/ - x[c]=g=i; /* last position equals group number.*/ - if (d>=0) { /* if more than one element in group.*/ - p[i--]=c; /* p is permutation for the sorted x.*/ - do { - d=x[c=d]; /* next in linked list.*/ - x[c]=g; /* group number in x.*/ - p[i--]=c; /* permutation in p.*/ - } while (d>=0); - } else - p[i--]=-1; /* one element, sorted group.*/ - } - } - - /* Transforms the alphabet of x by attempting to aggregate several symbols into - one, while preserving the suffix order of x. The alphabet may also be - compacted, so that x on output comprises all integers of the new alphabet - with no skipped numbers. - - Input: x is an array of size n+1 whose first n elements are positive - integers in the range l...k-1. p is array of size n+1, used for temporary - storage. q controls aggregation and compaction by defining the maximum value - for any symbol during transformation: q must be at least k-l; if q<=n, - compaction is guaranteed; if k-l>n, compaction is never done; if q is - INT_MAX, the maximum number of symbols are aggregated into one. - - Output: Returns an integer j in the range 1...q representing the size of the - new alphabet. If j<=n+1, the alphabet is compacted. The global variable r is - set to the number of old symbols grouped into one. Only x[n] is 0.*/ - - static int transform(int *x, int *p, int n, int k, int l, int q) { - int b, c, d, e, i, j, m, s; - int *pi, *pj; - - for (s=0, i=k-l; i; i>>=1) - ++s; /* s is number of bits in old symbol.*/ - e=INT_MAX>>s; /* e is for overflow checking.*/ - for (b=d=r=0; r=k-l) { /* if bucketing possible,*/ - j=transform(V, I, n, k, l, n); - /* bucketsort on first r positions.*/ - bucketsort(V, I, n, j); - } - else { - transform(V, I, n, k, l, INT_MAX); - for (i=0; i<=n; ++i) - I[i]=i; /* initialize I with suffix numbers.*/ - h=0; - sort_split(I, n+1); /* quicksort on first r positions.*/ - } - h=r; /* number of symbols aggregated by transform.*/ - - while (*I>=-n) { - pi=I; /* pi is first position of group.*/ - sl=0; /* sl is negated length of sorted groups.*/ - do { - if ((s=*pi)<0) { - pi-=s; /* skip over sorted group.*/ - sl+=s; /* add negated length to sl.*/ - } - else { - if (sl) { - /* combine sorted groups before pi.*/ - *(pi+sl)=sl; - sl=0; - } - pk=I+V[s]+1; /* pk-1 is last position of unsorted group.*/ - sort_split(pi, pk-pi); - pi=pk; /* next group.*/ - } - } while (pi<=I+n); - if (sl) /* if the array ends with a sorted group.*/ - *(pi+sl)=sl; /* combine sorted groups at end of I.*/ - h=2*h; /* double sorted-depth.*/ - } - - for (i=0; i<=n; ++i) /* reconstruct suffix array from inverse.*/ - I[V[i]]=i; - } - -}; diff --git a/libcds/src/static/textindex/suftest3.test.cpp b/libcds/src/static/textindex/suftest3.test.cpp deleted file mode 100644 index aa7e7af8..00000000 --- a/libcds/src/static/textindex/suftest3.test.cpp +++ /dev/null @@ -1,412 +0,0 @@ -/* suftest3.test.c - Copyright (C) 2006, Rodrigo Gonzalez, all rights reserved. - - This file contains an implementation of the interface for CSA. - For more information, see - - K. Sadakane. Compressed text databases with efficient query - algorithms based on the compressed suffix array. - In Proceedings 11th Annual International Symposium on Algorithms - and Computation (ISAAC)}, LNCS v. 1969, pages 410--421, 2000. - - K. Sadakane. Succinct representations of lcp information and - improvements in the compressed suffix arrays. - In Proceedings 13th Annual ACM-SIAM Symposium on Discrete - Algorithms (SODA), 2002. - - K. Sadakane. New text indexing functionalities of the compressed - suffix arrays. Journal of Algorithms, 48(2):294--313, 2003. - - 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. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - 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 - -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef uchar -#define uchar unsigned char -#endif -#ifndef ulong -#define ulong unsigned long -#endif -#ifndef min -#define min(x,y) ((x)<(y)?(x):(y)) -#endif - -namespace cds_static -{ - typedef struct rusage mytimestruct; - void mygettime(mytimestruct *t) { - getrusage(RUSAGE_SELF,t); - } - double mylaptime(mytimestruct *before,mytimestruct *after) { - double t; - t = after->ru_utime.tv_sec - before->ru_utime.tv_sec; - t += (double)(after->ru_utime.tv_usec - - before->ru_utime.tv_usec)/1000000; - return t; - } - - /* Three function to variables to manage parameters */ - static bool is_delimeter(char *delimiters, char c) { - int i=0,len_delimiters=strlen(delimiters); - bool is=false; - for (i=0;imapp!=NULL) - free(SA->mapp); - if(SA->mapi!=NULL) - free(SA->mapi); - #else - free(SA->B) - free(SA->ISA); - free(SA->R); - free(SA->SA); - #endif - free(SA); - return 0; - } - int index_size(void *index, ulong *size) { - CSA *SA=(CSA *) index; - *size=0; - #ifdef USE_MMAP - *size+=sizeof(MMAP)*2; - *size+=(SA->p_size); //Size B - *size+=(SA->i_size); //Size ISA+R+SA - #endif - *size+=sizeof(CSA); - return 0; - } - - int index_size_count(void *index, ulong *size) { - CSA *SA=(CSA *) index; - *size=0; - #ifdef USE_MMAP - *size+=sizeof(MMAP)*2; - *size+=(SA->p_size); //Size B - *size+=(SA->i_size); //Size ISA+R+SA - #endif - *size+=sizeof(CSA); - return 0; - } - int index_size_locate(void *index, ulong *size) { - CSA *SA=(CSA *) index; - *size=0; - #ifdef USE_MMAP - *size+=sizeof(MMAP)*2; - *size+=(SA->p_size); //Size B - *size+=(SA->i_size); //Size ISA+R+SA - #endif - *size+=sizeof(CSA); - return 0; - } - - /*//////////////////// - //Querying the Index// - ////////////////////*/ - int count(void *index, uchar *pattern, ulong length, ulong *numocc) { - int l,r,len; - CSA *SA=(CSA *) index; - len = csa_bsearch(pattern,length,SA,&l,&r); - *numocc = r-l+1; - return 0; - } - - ulong locate_extract(void *index) { - CSA *SA=(CSA *) index; - ulong largo,*occ,lar,n=SA->n,l,r,lll=0; - ulong matches,locate; - ulong random,hh; - for ( hh=1; hh <= 1000000; hh*=10) - for (lar=1;lar<=9;lar++) { - largo=lar*hh; - occ=NULL; - random = (ulong) (((float) rand()/ (float) RAND_MAX)*(n-1)); - matches = largo+1; - locate=0; - occ = (ulong *) malloc(matches*sizeof(ulong)); - l=random; - r=min(random+largo,n-3); - occ = csa_batchlookup2(SA,l,r); - free(occ); - } - return lll; - } - - int locate(void *index, uchar *pattern, ulong length, ulong **occ, ulong *numocc) { - //*numocc=locate_extract(index); - //exit(0); - int l,r,len; - CSA *SA=(CSA *) index; - len = csa_bsearch(pattern,length,SA,&l,&r); - *numocc = r-l+1; - (*occ) = csa_batchlookup2(SA,l,r); - return 0; - } - - /*/////////////////////// - //Accessing the indexed// - ///////////////////////*/ - int display(void *index, uchar *pattern, ulong length, ulong numc, ulong *numocc, uchar **snippet_text, ulong **snippet_lengths) { - int l,r; - int pos; - ulong *occ, i, j, from, to, len, x; - uchar *text_aux; - CSA *SA=(CSA *) index; - csa_bsearch(pattern,length,SA,&l,&r); - *numocc = r-l+1; - occ = csa_batchlookup2(SA,l,r); - *snippet_lengths = (ulong *) malloc((*numocc)*sizeof(ulong)); - if (!(*snippet_lengths)) return 1; - *snippet_text = (uchar *) malloc((*numocc)*(length+2*numc)*sizeof(uchar)); - if (!(*snippet_text)) return 1; - text_aux=*snippet_text; - - for (i=0;i<(*numocc);i++) { - x=occ[i]; - if (x>numc) from = x-numc; - else from=0; - to= ((int)(x+length+numc-1)<(int)(SA->n-1)?(x+length+numc-1):(SA->n-1)); - len =to-from+1; - pos = csa_inverse(SA,from+1); - for (j=0; (int)j<(int)len;j++) { - text_aux[j] = csa_T(SA,pos); - pos= csa_psi(SA,pos); - } - text_aux+=length+2*numc; - (*snippet_lengths)[i] = len; - } - free(occ); - return 0; - } - - int extract(void *index, ulong from, ulong to, uchar **snippet, ulong *snippet_length) { - CSA *SA=(CSA *) index; - ulong n = SA->n; - int pos; - if (to >= n) to=n-1; - if (from > to) { - *snippet = NULL; - *snippet_length=0; - } - else { - ulong j; - ulong len =to-from+1; - *snippet = (uchar *) malloc((len)*sizeof(uchar)); - if (!(*snippet)) return 1; - pos = csa_inverse(SA,from+1); - for (j=0; jn; - return 0; - } - - /*//////////////// - //Error handling// - ////////////////*/ - char * error_index(int e) { - char *error = new char[50]; - switch(e) { - case 0: - printf(error, "No error"); - break; - case 1: - printf(error, "Out of memory"); - break; - case 2: - printf(error, "The text must end with a \\0"); - break; - case 5: - printf(error, "You can't free the text if you don't copy it"); - break; - case 20: - printf(error, "Cannot create files"); - break; - case 21: - printf(error, "Error writing the index"); - break; - case 22: - printf(error, "Error writing the index"); - break; - case 23: - printf(error, "Cannot open index"); - break; - case 24: - printf(error, "Cannot open text"); - break; - case 25: - printf(error, "Error reading the index"); - break; - case 26: - printf(error, "Error reading the index"); - break; - case 27: - printf(error, "Error reading the text"); - break; - case 28: - printf(error, "Error reading the text"); - break; - case 99: - printf(error, "Not implemented"); - break; - default: - printf(error, "Unknown error"); - } - return error; - } - -}; diff --git a/libcds/src/utils/Array.cpp b/libcds/src/utils/Array.cpp deleted file mode 100644 index bbe81088..00000000 --- a/libcds/src/utils/Array.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* Array.cpp - * Copyright (C) 2009, Francisco Claude, all rights reserved. - * - * Array interface - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -namespace cds_utils -{ - - Array::Array(istream & input) { - length = loadValue(input); - maxValue = loadValue(input); - bitsPerItem = loadValue(input); - uintLength = loadValue(input); - data = loadValue(input,uintLength); - } - - Array::Array(const vector & A, uint bpe) { - size_t n = A.size(); - maxValue = 0; - if(bpe==0) { - for(size_t k=0;k::iterator & ini, const set::iterator & fin, uint bpe) { - size_t n = 0; - maxValue = 0; - for(set::iterator it = ini; it!=fin ;++it) { - maxValue = max(maxValue,*it); - n++; - } - if(bpe!=0) { - maxValue = (1<<(bpe))-1; - } - length = n; - initData(); - assert(bpe==0 || bitsPerItem==bpe); - n = 0; - for(set::iterator it=ini;it!=fin;++it) { - assert(*it <= maxValue); - setField(n, *it); - n++; - } - } - - Array::Array(const vector::iterator & ini, const vector::iterator & fin, uint bpe) { - size_t n = 0; - maxValue = 0; - for(vector::iterator it = ini; it!=fin ;++it) { - maxValue = max(maxValue,*it); - n++; - } - if(bpe!=0) { - maxValue = (1<<(bpe))-1; - } - length = n; - initData(); - assert(bpe==0 || bitsPerItem==bpe); - n = 0; - for(vector::iterator it=ini;it!=fin;++it) { - assert(*it <= maxValue); - setField(n, *it); - n++; - } - } - - Array::Array(size_t n, uint _maxValue) { - length = n; - maxValue = _maxValue; - initData(); - } - - Array::Array(uint * A, size_t n, uint bpe) { - maxValue = 0; - if(bpe==0) { - for(size_t k=0;k -#include - -namespace cds_utils -{ - - BitString::BitString(istream & input) { - assert(input.good()); - input.read((char*)&length,sizeof(size_t)); - input.read((char*)&uintLength,sizeof(size_t)); - data = new uint[uintLength]; - input.read((char*)data,uintLength*sizeof(uint)); - } - - void BitString::initData(const size_t len) { - length = len; - uintLength = length/W+1; - data = new uint[uintLength]; - for(uint i=0;i fields, const size_t len) { - initData(len); - for(size_t i=0; i -#include - -namespace cds_utils -{ - - uint transform(const string & s) { - stringstream ss; - ss << s; - uint ret; - ss >> ret; - return ret; - } - - void tokenize(string str, vector &tokens, char delim) { - string::size_type last_pos = 0; - string::size_type pos = str.find_first_of(delim); - while(pos!=string::npos) { - tokens.push_back(str.substr(last_pos,pos-last_pos)); - last_pos = pos+1; - if(last_pos >= str.length()) break; - pos = str.find_first_of(delim,pos+1); - } - if(last_pos - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -namespace cds_utils -{ -#ifndef WIN32 - clock_t init; - void start_timing() { - init = clock(); - } - - double get_timing() { - clock_t fin = clock(); - return (1000.*(fin-init)/CLOCKS_PER_SEC); - } -#else - void start_timing() { - } - - double get_timing() { - return 0.0; - } -#endif -} diff --git a/libcds/tests/Makefile.am b/libcds/tests/Makefile.am deleted file mode 100644 index 62a86682..00000000 --- a/libcds/tests/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -check_PROGRAMS = \ -testArray \ -testBitSequence \ -testHuffman \ -testLCP \ -testNPR \ -testSequence \ -testSuffixTree \ -testTextIndex \ -timeSequence \ -toArray2 \ -toArray -#testQuantile - -AM_DEFAULT_SOURCE_EXT = .cpp -AM_CPPFLAGS = -I@top_srcdir@/libcds/include $(WARN_CFLAGS) -LDADD = ../libcds.la - -TESTS = $(check_PROGRAMS) diff --git a/libcds/tests/testArray.cpp b/libcds/tests/testArray.cpp deleted file mode 100644 index 720b3f83..00000000 --- a/libcds/tests/testArray.cpp +++ /dev/null @@ -1,126 +0,0 @@ - -#include -#include -#include - -#include -#include -#include - -using namespace std; -using namespace cds_utils; - -bool compare(Array * a1, Array * a2) { - if(a1==NULL || a2==NULL) - return a1==a2; - if(a1->getMax() != a2->getMax()) - return false; - if(a1->getLength() != a2->getLength()) - return false; - if(a1->getSize() != a2->getSize()) - return false; - for(size_t i=0;igetLength();i++) - if(a1->getField(i)!=(*a2)[i]) - return false; - return true; -} - -void test(const string & function, Array *a1, Array *a2) { - if(!compare(a1,a2)) { - cout << "Error in ()" << function << endl; - abort(); - } -} - -void testSaveLoad(Array * a) { - string dir = "/tmp/"; - string pfx = "lcds"; - char * fname = tempnam(dir.c_str(),pfx.c_str()); //tmpnam(NULL); - ofstream outfs(fname); - a->save(outfs); - outfs.close(); - ifstream infs(fname); - Array * a_copy = new Array(infs); - infs.close(); - remove(fname); - //delete [] fname; // C function uses malloc - free(fname); - test("testSaveLoad",a,a_copy); - delete a_copy; -} - -void testConstructors(Array * a) { - vector vals_vector; - uint * vals_array = new uint[a->getLength()]; - for(size_t i=0;igetLength();i++) { - vals_vector.push_back(a->getField(i)); - vals_array[i] = a->getField(i); - } - Array * a2 = new Array(vals_vector); - test("testConstructor",a,a2); - delete a2; - a2 = new Array(vals_vector.begin(),vals_vector.end()); - test("testConstructor",a,a2); - delete a2; - a2 = new Array(vals_array,a->getLength()); - test("testConstructor",a,a2); - delete a2; - if(a->getLength()>0) { - a2 = new Array(vals_array,(size_t)0,(size_t)a->getLength()-1,0); - test("testConstructor",a,a2); - delete a2; - } - a2 = new Array(a->getLength(),a->getMax()); - for(size_t i=0;igetLength();i++) - a2->setField(i,a->getField(i)); - test("testConstructor",a,a2); - delete a2; - delete [] vals_array; -} - -Array * buildArray(uint seed, size_t len, uint maxv) { - Array * a = new Array(len,maxv); - srand(seed); - for(size_t i=0;isetField(i,val); - } - return a; -} - -int main(int argc, char ** argv) { - - Array * a; - - // Test 1: empty array - cout << "Testing empty array" << endl; - a = buildArray(57921, 0, 0); - testSaveLoad(a); - testConstructors(a); - delete a; - - // Test 2: binary array - cout << "Testing binary array" << endl; - a = buildArray(57921, 100000, 1); - testSaveLoad(a); - testConstructors(a); - delete a; - - // Test 1: 7 bits array - cout << "Testing 7 bits array" << endl; - a = buildArray(8647, 100000, 126); - testSaveLoad(a); - testConstructors(a); - delete a; - - // Test 1: big array - cout << "Testing big array" << endl; - a = buildArray(8647, 10000000, (1<<23)); - testSaveLoad(a); - testConstructors(a); - delete a; - - cout << endl << "Tests passed!" << endl; - return 0; -} - diff --git a/libcds/tests/testBitSequence.cpp b/libcds/tests/testBitSequence.cpp deleted file mode 100644 index bff54f2d..00000000 --- a/libcds/tests/testBitSequence.cpp +++ /dev/null @@ -1,120 +0,0 @@ - -#include - -#include -#include -#include -#include -#include -#include - -using namespace std; -using namespace cds_utils; -using namespace cds_static; - -BitSequence * saveLoad(BitSequence * bs) { - ofstream ofs("bitsequence.tmp"); - bs->save(ofs); - ofs.close(); - ifstream ifs("bitsequence.tmp"); - BitSequence * ret = BitSequence::load(ifs); - ifs.close(); - return ret; -} - -bool testBitSequence(BitString & a, BitSequence * bs) { - size_t rank0SoFar = 0; - size_t rank1SoFar = 0; - for(size_t i=0; iselect1(rank1SoFar)!=i) { - cerr << "SELECT1 ERROR " << i << endl; - return false; - } - if(i>0 && bs->selectNext1(i)!=i) { - cout << "i=" << i << "sn=" << bs->selectNext1(i) << endl; - cerr << "SELECTNEXT1 ERROR" << endl; - return false; - } - } else { - rank0SoFar++; - if(bs->select0(rank0SoFar)!=i) { - cerr << "SELECT0 ERROR" << endl; - return false; - } - if(i>0 && bs->selectNext0(i)!=i) { - cerr << "SELECTNEXT0 ERROR" << endl; - return false; - } - } - if(bs->rank1(i)!=rank1SoFar) - return false; - if(bs->rank0(i)!=rank0SoFar) - return false; - if(bs->access(i)!=a[i]) - return false; - } - return true; -} - -int main(int argc, char ** argv) { - - if(argc!=4) { - cout << "Checks the bitsequence classes generating bitmaps with density using as seed for the numbers generation" << endl << endl; - cout << "usage: " << argv[0] << " " << endl; - return 0; - } - - srand(transform(string(argv[1]))); - uint len = transform(string(argv[2])); - uint dens = transform(string(argv[3])); - - uint act_dens = 0; - BitString a(len); - while(act_dens < dens) { - size_t pos = rand()%len; - if(!a[pos]) { - act_dens++; - a.setBit(pos,true); - } - } - - BitSequenceRG bsRG(a,20); - BitSequence * s = saveLoad(&bsRG); - if(!testBitSequence(a,s)) { - cerr << "ERROR TESTING BitSequenceRG" << endl; - return -1; - } - cout << "RG OK\n" << endl; - delete (BitSequenceRG *)s; - - BitSequenceDArray bsDArray(a); - s = saveLoad(&bsDArray); - if(!testBitSequence(a,s)) { - cerr << "ERROR TESTING BitSequenceDArray" << endl; - return -1; - } - cout << "DArray OK\n" << endl; - delete (BitSequenceDArray *)s; - - BitSequenceSDArray bsSDArray(a); - s = saveLoad(&bsSDArray); - if(!testBitSequence(a,s)) { - cerr << "ERROR TESTING BitSequenceSDArray" << endl; - return -1; - } - cout << "SDArray OK\n" << endl; - delete (BitSequenceSDArray *)s; - - BitSequenceRRR bsRRR(a,33); - s = saveLoad(&bsRRR); - if(!testBitSequence(a,s)) { - cerr << "ERROR TESTING BitSequenceRRR" << endl; - return -1; - } - cout << "RRR OK\n" << endl; - delete (BitSequenceRRR *)s; - return 0; -} - diff --git a/libcds/tests/testHuffman.cpp b/libcds/tests/testHuffman.cpp deleted file mode 100644 index 9a734e1b..00000000 --- a/libcds/tests/testHuffman.cpp +++ /dev/null @@ -1,47 +0,0 @@ - -#include - -#include -#include - -using namespace std; -using namespace cds_utils; -using namespace cds_static; - - -int main(int argc, char ** argv) { - - if(argc!=4) { - cout << "Checks the array class generating elements between 0 and using as seed for the numbers generation" << endl << endl; - cout << "usage: " << argv[0] << " " << endl; - return 0; - } - - srand(transform(string(argv[1]))); - uint len = transform(string(argv[2])); - uint maxv = transform(string(argv[3])); - - //cout << "maxv = " << maxv << endl; - //cout << "len = " << len << endl; - - Array a(len,maxv); - for(uint i=0;imaxLength() << endl; - - for(size_t i=0;iencode(a[i],stream,ptr); - for(size_t k=0;k -#include -#include - -using namespace std; -using namespace cds_utils; -using namespace cds_static; - -LCP * saveLoad(LCP * bs) { - ofstream ofs("lcp.tmp"); - bs->save(ofs); - ofs.close(); - ifstream ifs("lcp.tmp"); - LCP * ret = LCP::load(ifs); - ifs.close(); - return ret; -} - -bool testLCP(LCP *s1, LCP *s2, TextIndex *csa){ - for(size_t i=0; iindex_length(); i++){ - if(s1->get_LCP(i,csa)!=s2->get_LCP(i,csa)) - return false; - } - size_t *next; - size_t n_next = 0; - for(size_t i=0; iindex_length(); i++){ - if((i%100)==0) - n_next = 0; - if(s1->get_seq_LCP(i,csa, &next, &n_next, 1)!=s2->get_seq_LCP(i,csa, &next, &n_next, 1)) - return false; - } - - return true; -} - - -int main(int argc, char *argv[]){ - char *text; - size_t length; - LCP *lcp_naive=NULL; - LCP *lcp=NULL; - - if(argc!=2) { - cout << "Checks if the LCP of the file is save/load correctly" << endl << endl; - cout << "usage: " << argv[0] << " " << endl; - return 0; - } - - TextIndex *csa; - - if(loadText(argv[1], &text, &length)) - return 1; - - cout << "length: " << length << endl; - - /*create index*/ - csa = new TextIndexCSA((uchar *)text, (ulong)length, NULL); - - lcp_naive = new LCP_naive(csa,text,length); - - lcp = saveLoad(lcp_naive); - if(!testLCP(lcp_naive, lcp, csa)) { - cerr << "ERROR TESTING LCP_naive" << endl; - return -1; - } - delete (LCP_naive *)lcp; - cout << "LCP_naive OK\n" << endl; - - LCP_Sad lcpSad(csa, text, length); - lcp = saveLoad(&lcpSad); - if(!testLCP(lcp_naive, lcp, csa)) { - cerr << "ERROR TESTING LCP_Sad" << endl; - return -1; - } - delete (LCP_Sad *)lcp; - cout << "LCP_Sad OK\n" << endl; - - LCP_FMN lcpFMN(csa, text, length); - lcp = saveLoad(&lcpFMN); - if(!testLCP(lcp_naive, lcp, csa)) { - cerr << "ERROR TESTING LCP_FMN" << endl; - return -1; - } - delete (LCP_FMN *)lcp; - cout << "LCP_FMN OK\n" << endl; - - LCP_PT lcpPT(csa, text, length, 6); //the last parameter can be 1,2,3,4,5,6,7,8 - lcp = saveLoad(&lcpPT); - if(!testLCP(lcp_naive, lcp, csa)) { - cerr << "ERROR TESTING LCP_PT" << endl; - return -1; - } - delete (LCP_PT *)lcp; - cout << "LCP_PT OK\n" << endl; - - LCP_PhiSpare lcpPhi(csa, text, length, 8); //the last parameter can be -1, 0, ..., length-1 - lcp = saveLoad(&lcpPhi); - if(!testLCP(lcp_naive, lcp, csa)) { - cerr << "ERROR TESTING LCP_PhiSpare" << endl; - return -1; - } - delete (LCP_PhiSpare *)lcp; - cout << "LCP_PhiSpare OK\n" << endl; - - - LCP_DAC lcpDAC(csa, text, length); - lcp = saveLoad(&lcpDAC); - if(!testLCP(lcp_naive, lcp, csa)) { - cerr << "ERROR TESTING LCP_DAC" << endl; - return -1; - } - delete (LCP_DAC *)lcp; - cout << "LCP_DAC OK\n" << endl; - - LCP_DAC_VAR lcpDACVAR(csa, text, length); - lcp = saveLoad(&lcpDACVAR); - if(!testLCP(lcp_naive, lcp, csa)) { - cerr << "ERROR TESTING LCP_DAC_VAR" << endl; - return -1; - } - delete (LCP_DAC_VAR *)lcp; - cout << "LCP_DAC_VAR OK\n" << endl; - - delete (LCP_naive *)lcp_naive; - delete (TextIndexCSA *)csa; - delete [] text; - return 0; -} - diff --git a/libcds/tests/testNPR.cpp b/libcds/tests/testNPR.cpp deleted file mode 100644 index 8a4d9e01..00000000 --- a/libcds/tests/testNPR.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cánovas, all rights reserved. - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include -#include - -using namespace std; -using namespace cds_utils; -using namespace cds_static; - -NPR * saveLoad(NPR * bs) { - ofstream ofs("npr.tmp"); - bs->save(ofs); - ofs.close(); - ifstream ifs("npr.tmp"); - NPR * ret = NPR::load(ifs); - ifs.close(); - return ret; -} - -bool testNPR(NPR *npr, LCP *lcp, TextIndex *csa, size_t *naive_nsv, size_t *naive_psv, size_t l){ - - for(size_t i=0; ifind_NSV(i, csa,lcp) != naive_nsv[i]){ - cout << "Error in NSV" << endl; - return false; - }*/ - if(npr->find_PSV(csa->index_length()-l+i, csa, lcp) != naive_psv[i]){ - cout << "Error in PSV" << endl; - return false; - } - } - - int x,y,z, j, rmq_naive; - size_t rmq_pos; - for(size_t i=0; iindex_length(); - y=(int)rand()%csa->index_length(); - if(yget_LCP(x,csa); - rmq_pos = x; - for(j=x+1; j<=y; j++){ - z = lcp->get_LCP(j,csa); - if(zfind_RMQ(x,y,csa,lcp)){ - cout << "Error in RMQ" << endl; - return false; - } - } - return true; -} - - -int main(int argc, char *argv[]){ - char *text; - size_t length; - LCP *lcp = NULL; - NPR *npr = NULL; - - size_t *naive_nsv=NULL; - size_t *naive_psv=NULL; - - if(argc!=2) { - cout << "Checks if the NPR of the file is save/load correctly" << endl << endl; - cout << "usage: " << argv[0] << " " << endl; - return 0; - } - - TextIndex *csa; - - if(loadText(argv[1], &text, &length)) - return 1; - - cout << "length: " << length << endl; - - /*create index*/ - csa = new TextIndexCSA((uchar *)text, (ulong)length, NULL); - - lcp = new LCP_DAC(csa,text,length); - - size_t l = 1000; - size_t aux_naive; - int j; - naive_nsv = new size_t[l]; - naive_psv = new size_t[l]; - - cout << "Creating first " << l << " NSV_naive" << endl; - for(size_t i=0; iget_LCP(i,csa); - for(j=i+1; (size_t)j < length; j++){ - if(aux_naive > lcp->get_LCP(j,csa)) - break; - } - naive_nsv[i] = j; - } - - cout << "Creating last " << l << " PSV_naive" << endl; - for(size_t i = (length -l); i < length; i++){ - aux_naive = lcp->get_LCP(i,csa); - for(j=i-1; j>=0; j--){ - if(aux_naive > lcp->get_LCP(j,csa)) - break; - } - naive_psv[i-(length-l)] = j+1; - } - - - NPR_FMN nprFMN(lcp, 32, csa, 2); //(LCP, block_size, TextIndex, levels of recursion levels of recursion (try 1,2,3 or 4)) - npr = saveLoad(&nprFMN); - if(!testNPR(npr, lcp, csa, naive_nsv, naive_psv, l)){ - cerr << "ERROR TESTING NPR_FMN" << endl; - return -1; - } - delete (NPR_FMN *)npr; - cout << "NPR_FMN OK\n" << endl; - - NPR_CN nprCN(lcp, 32, csa); //(LCP, block_size, TextIndex) - npr = saveLoad(&nprCN); - if(!testNPR(npr, lcp, csa, naive_nsv, naive_psv, l)){ - cerr << "ERROR TESTING NPR_CN" << endl; - return -1; - } - delete (NPR_CN *)npr; - cout << "NPR_CN OK\n" << endl; - - delete [] naive_nsv; - delete [] naive_psv; - delete (LCP_DAC *)lcp; - delete (TextIndexCSA *)csa; - delete [] text; - return 0; -} - diff --git a/libcds/tests/testQuantile.cpp b/libcds/tests/testQuantile.cpp deleted file mode 100644 index bd09e028..00000000 --- a/libcds/tests/testQuantile.cpp +++ /dev/null @@ -1,124 +0,0 @@ - -#include - -#include -#include -#include -#include - -using namespace std; -using namespace cds_static; - - -int uintcmp(const void* a,const void* b) -{ - return (*(const uint32_t*)a - *(const uint32_t*)b); -} - -void testQuantileWT(Array& a,WaveletTree& wt) -{ - size_t N = 500; - /* select 500 rand ranges and perform quantile queries */ - while(N) { - size_t start = rand() % a.getLength(); - size_t len = (rand() % (a.getLength() - start)) % 10; - - /* copy and sort the array */ - uint32_t* A = new uint32_t[len+1]; - for(size_t i=0;i<=len;i++) { - A[i] = a[start+i]; - }; - qsort(A,len+1,sizeof(uint32_t),uintcmp); - - /* test */ - size_t accum = 0; - size_t quantile = 1; - while(accum <= len) { - pair qf = wt.quantile_freq(start,start+len,quantile); - for(size_t i=0;i qf = wt.quantile_freq(start,start+len,quantile); - for(size_t i=0;iuse(); - mapper2->use(); - cout << "Test 1 : Wavelet tree with pointers" << endl; - /*WaveletTree wt1(a,new wt_coder_huff(a, mapper),new BitSequenceBuilderDArray(), mapper);*/ - WaveletTree wt1(a,new wt_coder_binary(a, mapper),new BitSequenceBuilderRG(20), mapper); - cout << "bs.size() = " << wt1.getSize() << endl; - - testQuantileWT(a, wt1); - - cout << "Test 2 : Wavelet tree without pointers" << endl; - WaveletTreeNoptrs wt3(a, new BitSequenceBuilderRRR(32), mapper); - cout << "bs.size() = " << wt3.getSize() << endl; - testQuantileWTNPTR(a, wt3); - mapper->unuse(); - mapper2->unuse(); - - fprintf(stdout,"ALL OK\n"); - - return 0; -} - diff --git a/libcds/tests/testSequence.cpp b/libcds/tests/testSequence.cpp deleted file mode 100644 index f727b440..00000000 --- a/libcds/tests/testSequence.cpp +++ /dev/null @@ -1,96 +0,0 @@ - -#include - -#include -#include -#include -#include - -using namespace std; -using namespace cds_static; - - -void testSequence(Array & a, Sequence & bs) { - ofstream outfs("sequence.tmp"); - bs.save(outfs); - outfs.close(); - ifstream infs("sequence.tmp"); - Sequence * seq = Sequence::load(infs); - infs.close(); - uint maxv = a.getMax(); - size_t count[maxv+1]; - for(size_t i=0;i<=maxv;i++) - count[i] = 0; - for(size_t i=0;iaccess(i)) { - cerr << "ERROR ACCESS" << endl; - cerr << "Got:" << seq->access(i) << " Expected:" << a[i] << endl; - exit(-3); - } - for(uint j=a[i];j<=a[i];j++) { - if(seq->rank(j,i)!=count[j]) { - cerr << "ERROR RANK " << endl; - cerr << " Rank result: " << bs.rank(j,i) << " count=" << count[j] << endl; - cerr << " symbol=" << j << " position=" << i << endl; - exit(-1); - } - } - if(seq->select(a[i],count[a[i]])!=i) { - cerr << "ERROR SELECT " << endl; - cerr << "a[i]=" << a[i] << " maxv=" << maxv << endl; - cerr << "bs.select=" << bs.select(a[i],count[a[i]]) << " i=" << i << endl; - exit(-2); - } - - } - delete seq; -} - -int main(int argc, char ** argv) { - - if(argc!=4) { - cout << "Checks the array class generating elements between 0 and using as seed for the numbers generation" << endl << endl; - cout << "usage: " << argv[0] << " " << endl; - return 0; - } - - srand(transform(string(argv[1]))); - uint len = transform(string(argv[2])); - uint maxv = transform(string(argv[3])); - - //cout << "maxv = " << maxv << endl; - //cout << "len = " << len << endl; - - Array a(len,maxv); - for(uint i=0;iuse(); - mapper2->use(); - cout << "Test 1 : Wavelet tree with pointers" << endl; - // WaveletTree wt1(a,new wt_coder_binary(a, mapper),new BitSequenceBuilderRRR(32), mapper); - WaveletTreeNoptrs wt1(a, new BitSequenceBuilderRRR(32), mapper); - cout << "bs.size() = " << wt1.getSize() << endl; - testSequence(a, wt1); - - cout << "Test 2 : Wavelet tree without pointers" << endl; - // uint *tmp = new uint[a.getLength()]; - // for (uint i=0; i < a.getLength(); i++) - // tmp[i] = a.getField(i); - // WaveletMatrix wt3(tmp, a.getLength(), new BitSequenceBuilderRRR(32), mapper); - WaveletMatrix wt3(a, new BitSequenceBuilderRRR(32), mapper); - // WaveletTreeNoptrs wt3(tmp, a.getLength(), new BitSequenceBuilderRRR(32), mapper); - cout << "bs.size() = " << wt3.getSize() << endl; - testSequence(a, wt3); - mapper->unuse(); - mapper2->unuse(); - return 0; -} - diff --git a/libcds/tests/testSuffixTree.cpp b/libcds/tests/testSuffixTree.cpp deleted file mode 100644 index 934b83bd..00000000 --- a/libcds/tests/testSuffixTree.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright (C) 2010, Rodrigo Cánovas, all rights reserved. - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - */ - -#include - -using namespace std; -using namespace cds_utils; -using namespace cds_static; - -SuffixTree * saveLoad(SuffixTree * bs) { - ofstream ofs("cst.tmp"); - bs->save(ofs); - ofs.close(); - ifstream ifs("cst.tmp"); - SuffixTree * ret = SuffixTree::load(ifs); - ifs.close(); - return ret; -} - -bool testSuffixTree(SuffixTree *s1){ - /*add any test you want*/ - return true; -} - - -int main(int argc, char *argv[]){ - char *text; - size_t length; - - if(argc!=2) { - cout << "Checks if the SuffixTree of the file is save/load correctly" << endl << endl; - cout << "usage: " << argv[0] << " " << endl; - return 0; - } - - if(loadText(argv[1], &text, &length)) - return 1; - - /*create index*/ - - SuffixTree *cst; - - SuffixTreeY csty(text, length, DAC, CN_NPR, 32); - cst = saveLoad(&csty); - if(!testSuffixTree(cst)) { - cerr << "ERROR TESTING SuffixTreeY" << endl; - return -1; - } - delete (SuffixTreeY *)cst; - cout << "SuffixTree_Y OK\n" << endl; - - delete [] text; - return 0; -} - diff --git a/libcds/tests/testTextIndex.cpp b/libcds/tests/testTextIndex.cpp deleted file mode 100644 index 6e40351f..00000000 --- a/libcds/tests/testTextIndex.cpp +++ /dev/null @@ -1,63 +0,0 @@ - -#include - -#include -#include - -using namespace std; -using namespace cds_utils; -using namespace cds_static; - -TextIndex * saveLoad(TextIndex * bs) { - ofstream ofs("textindex.tmp"); - bs->save(ofs); - ofs.close(); - ifstream ifs("textindex.tmp"); - TextIndex * ret = TextIndex::load(ifs); - ifs.close(); - return ret; -} - -bool testTextIndex(TextIndex *s1, TextIndex *s2){ - for(size_t i=0; iindex_length(); i++){ - if(s1->getSA(i)!=s2->getSA(i)) - return false; - if(s1->getISA(i)!=s2->getISA(i)) - return false; - if(s1->getPsi(i)!=s2->getPsi(i)) - return false; - } - return true; -} - -int main(int argc, char ** argv) { - - if(argc!=2) { - cout << "Checks if the TextIndex of the file is save/load correctly" << endl << endl; - cout << "usage: " << argv[0] << " " << endl; - return 0; - } - char *text=NULL; - size_t length; - TextIndex *ticsa, *load_ticsa; - - if(loadText(argv[1], &text, &length)) - return 1; - cout << "length: " << length << endl; - - ticsa = new TextIndexCSA((uchar *)text, (ulong)length, NULL); - - load_ticsa = saveLoad(ticsa); - - if(!testTextIndex(ticsa, load_ticsa)) { - cerr << "ERROR TESTING TextIndexCSA" << endl; - return -1; - } - - cout << "CSA OK\n" << endl; - delete (TextIndexCSA *)ticsa; - delete (TextIndexCSA *)load_ticsa; - if(text!=NULL) - delete text; -} - diff --git a/libcds/tests/timeSequence.cpp b/libcds/tests/timeSequence.cpp deleted file mode 100644 index 0da4f2c0..00000000 --- a/libcds/tests/timeSequence.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* timeSequence.cpp - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -using namespace std; -using namespace cds_static; -using namespace cds_utils; - -uint numqueries = 100000; -uint seed = 8647; - -Array extract_alphabet(const Array & values) { - set sigma; - for(size_t i=0;i *queries = new pair[numqueries]; - for(uint i=0;irank(queries[i].first,seq->getLength()-2); - } - size_t acc = 0; - start_timing(); - for(uint i=0;iselect(queries[i].first,queries[i].second+1); - } - double time = get_timing(); - cout << "*************************" << endl; - cout << " SELECT QUERIES" << endl; - cout << " time: " << time << "ms" << endl; - cout << " acc: " << acc << endl; -} - -void measure_access(const Array & sigma, Sequence * seq) { - size_t *queries = new size_t[numqueries]; - for(uint i=0;igetLength(); - } - size_t acc = 0; - start_timing(); - for(uint i=0;iaccess(queries[i]); - } - double time = get_timing(); - cout << "*************************" << endl; - cout << " ACCESS QUERIES" << endl; - cout << " time: " << time << "ms" << endl; - cout << " acc: " << acc << endl; -} - - -void measure_rank(const Array & sigma, Sequence * seq) { - pair *queries = new pair[numqueries]; - for(uint i=0;igetLength(); - } - size_t acc = 0; - start_timing(); - for(uint i=0;irank(queries[i].first,queries[i].second); - } - double time = get_timing(); - cout << "*************************" << endl; - cout << " RANK QUERIES" << endl; - cout << " time: " << time << "ms" << endl; - cout << " acc: " << acc << endl; -} - -int main(int argc, char **argv) { - int c; - char *fname=NULL, *builderopt=NULL; - SequenceBuilder * sb = NULL; - while((c=getopt(argc,argv,"f:b:q:"))!=-1) { - switch(c) { - case 'f': fname = optarg; break; - case 'b': builderopt = optarg; break; - case 'q': numqueries = atoi(optarg); break; - } - } - if(fname==NULL || builderopt==NULL) { - cout << "usage: " << argv[0] << " -f fname -b buildstr [-q numqueries]" << endl; - return 0; - } - ifstream input(fname); - if(!input.good()) { - cerr << "Error opening file: " << fname << endl; - } - Array values(input); - sb = new SequenceBuilderStr(builderopt); - Sequence * seq = sb->build(values); - cout << "builderopt=" << builderopt << endl; - cout << "size=" << seq->getSize() << endl; - cout << "plain size=" << values.getSize() << endl; - cout << "sigma=" << values.getMax() << endl; - Array sigma = extract_alphabet(values); - measure_access(sigma,seq); - measure_rank(sigma,seq); - measure_select(sigma,seq); - return 0; -} - diff --git a/libcds/tests/toArray.cpp b/libcds/tests/toArray.cpp deleted file mode 100644 index 4b482785..00000000 --- a/libcds/tests/toArray.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* toArray.cpp - * Copyright (C) 2010, Francisco Claude, all rights reserved. - * - * Francisco Claude - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -#include -#include - -using namespace cds_utils; - -int main(int argc, char ** argv) { - if(argc!=3) { - cout << "usage: " << argv[0] << " " << endl; - return 0; - } - - size_t len = 0; - uchar * content = loadValue(argv[1],len); - uint * content2 = new uint[len]; - for(size_t i=0;i - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -#include -#include - -using namespace cds_utils; - -int main(int argc, char ** argv) { - if(argc!=3) { - cout << "usage: " << argv[0] << " " << endl; - return 0; - } - - size_t len = 0; - int * content = loadValue(argv[1],len); - uint * content2 = new uint[len]; - size_t pos = 0; - for(size_t i=3;i0) content2[pos++]=content[i]; - - Array a(content2,pos); - ofstream out(argv[2]); - a.save(out); - out.close(); - - delete [] content; - delete [] content2; - return 0; -} - - - diff --git a/libcds/tutorial/src/ArrayExample.cpp b/libcds/tutorial/src/ArrayExample.cpp deleted file mode 100755 index 0df24290..00000000 --- a/libcds/tutorial/src/ArrayExample.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/** - * ArrayExample.cpp - * Copyright (C) 2011 Francisco Claude F. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -#include -#include -#include - -using namespace std; -using namespace cds_utils; - -int main(int argc, char **argv) { - size_t N=0; - cout << "Enter array length: "; - cin >> N; - uint * A = new uint[N]; - for(size_t i=0;i> A[i]; - } - - Array * a = new Array(A,N); - delete [] A; - - cout << "Size: " << a->getSize() << " bytes" << endl; - for(uint i=0;i> N; - cout << "Enter the maximum value to be stored: "; - cin >> M; - Array *a = new Array(N,M); - for(size_t i=0;i> tmp; - a->setField(i,tmp); - } - - cout << "Size: " << a->getSize() << " bytes" << endl; - for(uint i=0;i> N; - uint * bs = new uint[uint_len(N,1)]; - for(uint i=0;i> b; - if(b==0) bitclean(bs,i); - else bitset(bs,i); - } - BitSequenceRG * bsrg = new BitSequenceRG(bs,N,20); - cout << "rank(" << N/2 << ")=" << bsrg->rank1(N/2) << endl; - cout << "select(1) = " << bsrg->select1(1) << endl; - cout << "size = " << bsrg->getSize() << endl; - delete bsrg; - delete [] bs; - return 0; -} diff --git a/libcds/tutorial/src/BitSequenceRRRExample.cpp b/libcds/tutorial/src/BitSequenceRRRExample.cpp deleted file mode 100755 index 06eefa25..00000000 --- a/libcds/tutorial/src/BitSequenceRRRExample.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/** - * BitSequenceRRRExample.cpp - * Copyright (C) 2011 Francisco Claude F. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include - -using namespace std; -using namespace cds_utils; -using namespace cds_static; - -int main(int argc, char **argv) { - size_t N; - cout << "Length of the bitmap: "; - cin >> N; - uint * bs = new uint[uint_len(N,1)]; - for(uint i=0;i> b; - if(b==0) bitclean(bs,i); - else bitset(bs,i); - } - BitSequenceRRR * bsrrr = new BitSequenceRRR(bs,N,16); - cout << "rank(" << N/2 << ")=" << bsrrr->rank1(N/2) << endl; - cout << "select(1) = " << bsrrr->select1(1) << endl; - cout << "size = " << bsrrr->getSize() << endl; - delete bsrrr; - delete [] bs; - return 0; -} diff --git a/libcds/tutorial/src/BitSequenceSDArrayExample.cpp b/libcds/tutorial/src/BitSequenceSDArrayExample.cpp deleted file mode 100755 index 5636faf1..00000000 --- a/libcds/tutorial/src/BitSequenceSDArrayExample.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/** - * BitSequenceSDArrayExample.cpp - * Copyright (C) 2011 Francisco Claude F. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include -#include - -using namespace std; -using namespace cds_utils; -using namespace cds_static; - -int main(int argc, char **argv) { - size_t N; - cout << "Length of the bitmap: "; - cin >> N; - uint * bs = new uint[uint_len(N,1)]; - for(uint i=0;i> b; - if(b==0) bitclean(bs,i); - else bitset(bs,i); - } - BitSequenceSDArray * bss = new BitSequenceSDArray(bs,N); - cout << "rank(" << N/2 << ")=" << bss->rank1(N/2) << endl; - cout << "select(1) = " << bss->select1(1) << endl; - cout << "size = " << bss->getSize() << endl; - delete bss; - delete [] bs; - return 0; -} diff --git a/libcds/tutorial/src/Makefile b/libcds/tutorial/src/Makefile deleted file mode 100755 index 334c8a08..00000000 --- a/libcds/tutorial/src/Makefile +++ /dev/null @@ -1,54 +0,0 @@ - -CPP=g++ - -CPPFLAGS=-g3 -O0 -I../includes/ -#CPPFLAGS=-O3 -Wall -DNDEBUG -I../includes/ -INCS=-I../../includes/ -LIB=../../lib/libcds.a - -OBJECTS= ArrayExample.o ArrayExample2.o BitSequenceRGExample.o BitSequenceRRRExample.o BitSequenceSDArrayExample.o SequenceWaveletTreeExample.o SequenceGMRExample.o SequenceAlphPartExample.o -BIN= ArrayExample ArrayExample2 BitSequenceRGExample BitSequenceRRRExample BitSequenceSDArrayExample SequenceWaveletTreeExample SequenceGMRExample SequenceAlphPartExample - -%.o: %.cpp - @echo " [C++] Compiling $<" - @$(CPP) $(CPPFLAGS) $(INCS) -c $< -o $@ - -all: clean $(OBJECTS) $(BIN) - @echo " [MSG] Done compiling tests" - @echo " [FLG] $(CPPFLAGS)" - -ArrayExample: - @echo " [LNK] Building ArrayExample" - @$(CPP) $(CPPFLAGS) -o ArrayExample ArrayExample.o $(LIB) - -ArrayExample2: - @echo " [LNK] Building ArrayExample2" - @$(CPP) $(CPPFLAGS) -o ArrayExample2 ArrayExample2.o $(LIB) - -BitSequenceRGExample: - @echo " [LNK] Building BitSequenceRGExample" - @$(CPP) $(CPPFLAGS) -o BitSequenceRGExample BitSequenceRGExample.o $(LIB) - -BitSequenceRRRExample: - @echo " [LNK] Building BitSequenceRRRExample" - @$(CPP) $(CPPFLAGS) -o BitSequenceRRRExample BitSequenceRRRExample.o $(LIB) - -BitSequenceSDArrayExample: - @echo " [LNK] Building BitSequenceSDArrayExample" - @$(CPP) $(CPPFLAGS) -o BitSequenceSDArrayExample BitSequenceSDArrayExample.o $(LIB) - -SequenceWaveletTreeExample: - @echo " [LNK] Building SequenceWaveletTreeExample" - @$(CPP) $(CPPFLAGS) -o SequenceWaveletTreeExample SequenceWaveletTreeExample.o $(LIB) - -SequenceGMRExample: - @echo " [LNK] Building SequenceGMRExample" - @$(CPP) $(CPPFLAGS) -o SequenceGMRExample SequenceGMRExample.o $(LIB) - -SequenceAlphPartExample: - @echo " [LNK] Building SequenceAlphPartExample" - @$(CPP) $(CPPFLAGS) -o SequenceAlphPartExample SequenceAlphPartExample.o $(LIB) - -clean: - @echo " [CLN] Cleaning object and binary files" - @rm -f $(OBJECTS) $(BIN) diff --git a/libcds/tutorial/src/SequenceAlphPartExample.cpp b/libcds/tutorial/src/SequenceAlphPartExample.cpp deleted file mode 100755 index cae1bc4a..00000000 --- a/libcds/tutorial/src/SequenceAlphPartExample.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/** - * SequenceAlphPartExample.cpp - * Copyright (C) 2011 Francisco Claude F. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -#include -#include -#include -#include - -using namespace std; -using namespace cds_static; - -int main(int argc, char **argv) { - - size_t N; - uint s; - cout << "Length: "; - cin >> N; - uint * seq = new uint[N]; - for(size_t i=0;i> seq[i]; - } - - SequenceBuilder * sb1 = new SequenceBuilderWaveletTree( - new BitSequenceBuilderRG(20), - new MapperNone()); - SequenceBuilder * sb2 = new SequenceBuilderGMRChunk( - new BitSequenceBuilderRG(20), - new PermutationBuilderMRRR( - 20, new BitSequenceBuilderRG(20))); - SequenceBuilder * sb3 = new SequenceBuilderGMR( - new BitSequenceBuilderRG(20), - sb2); - - SequenceAlphPart * ap = new SequenceAlphPart(seq, N, 0u, - sb1, sb3); - cout << "size = " << ap->getSize() << " bytes" << endl; - - delete ap; - delete []seq; - return 0; -} - diff --git a/libcds/tutorial/src/SequenceGMRExample.cpp b/libcds/tutorial/src/SequenceGMRExample.cpp deleted file mode 100755 index e06bb114..00000000 --- a/libcds/tutorial/src/SequenceGMRExample.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/** - * SequenceGMRExample.cpp - * Copyright (C) 2011 Francisco Claude F. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -#include -#include -#include -#include - -using namespace std; -using namespace cds_static; - -int main(int argc, char **argv) { - - size_t N; - uint s; - cout << "Length: "; - cin >> N; - uint * seq = new uint[N]; - for(size_t i=0;i> seq[i]; - } - SequenceGMR * gmr = new SequenceGMR(seq, N, 5u, - new BitSequenceBuilderRG(20), - new SequenceBuilderGMRChunk( - new BitSequenceBuilderRG(20), - new PermutationBuilderMRRR( - 20, - new BitSequenceBuilderRG(20)))); - cout << "size = " << gmr->getSize() << " bytes" << endl; - - delete gmr; - delete []seq; - return 0; -} - diff --git a/libcds/tutorial/src/SequenceWaveletTreeExample.cpp b/libcds/tutorial/src/SequenceWaveletTreeExample.cpp deleted file mode 100755 index 9d1ee567..00000000 --- a/libcds/tutorial/src/SequenceWaveletTreeExample.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/** - * SequenceWaveletTreeExample.cpp - * Copyright (C) 2011 Francisco Claude F. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -#include -#include -#include -#include - -using namespace std; -using namespace cds_static; - -int main(int argc, char **argv) { - - size_t N; - uint s; - cout << "Length: "; - cin >> N; - uint * seq = new uint[N]; - for(size_t i=0;i> seq[i]; - } - WaveletTree * wt1 = new WaveletTree(seq, N, - new wt_coder_huff(seq, N, - new MapperNone()), - new BitSequenceBuilderRG(20), - new MapperNone()); - cout << "size = " << wt1->getSize() << " bytes" << endl; - - delete wt1; - delete []seq; - return 0; -} - diff --git a/libcds/tutorial/ssa/Makefile b/libcds/tutorial/ssa/Makefile deleted file mode 100755 index 6f707341..00000000 --- a/libcds/tutorial/ssa/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -CPP=g++ - - -#CPPFLAGS=-g3 -Wall -DVERBOSE -#CPPFLAGS=-O9 -Wall -DNDEBUG -CPPFLAGS=-O9 -Wall -DVERBOSE - -INCLUDES=-I../../includes/ -I. -LIB=../../lib/libcds.a -OBJECTS=ssa.o -BINS=test_count build_index dump_bwt - -%.o: %.cpp - @echo " [C++] Compiling $<" - @$(CPP) $(CPPFLAGS) $(INCLUDES) -c $< -o $@ - -all: clean stats $(OBJECTS) $(BINS) - -stats: - @echo - @echo " COMPILING SSA" - @echo " ###################" - @echo " * Compiler flags: $(CPPFLAGS)" - @echo " * Include dirs: $(INCLUDES)" - @echo - @echo - -clean: - @echo " [CLN] Removing object files" - @rm -f $(OBJECTS) $(BINS) - -test_count: - @echo " [BLD] Building test_count" - @$(CPP) $(CPPFLAGS) $(INCLUDES) -o test_count test_count.cpp $(OBJECTS) $(LIB) - -dump_bwt: - @echo " [BLD] Building dump_bwt" - @$(CPP) $(CPPFLAGS) $(INCLUDES) -o dump_bwt dump_bwt.cpp $(OBJECTS) $(LIB) - -build_index: - @echo " [BLD] Building build_index" - @$(CPP) $(CPPFLAGS) $(INCLUDES) -o build_index build_index.cpp $(OBJECTS) $(LIB) - diff --git a/libcds/tutorial/ssa/build_index.cpp b/libcds/tutorial/ssa/build_index.cpp deleted file mode 100755 index ef98b131..00000000 --- a/libcds/tutorial/ssa/build_index.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/** - * build_index.cpp - * Copyright (C) 2011 Francisco Claude F. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -#include "ssa.h" -#include -#include -#include - -using namespace std; - -int main(int argc, char ** argv) { - if(argc!=3) { - cout << "usage: " << argv[0] << " " << endl; - return 0; - } - - fstream input(argv[1],ios::in | ios::binary); - if(!input.is_open()) { - cerr << "Error opening file: " << argv[1] << endl; - return -1; - } - - input.seekg(0,ios::end); - uint n=input.tellg(); - uchar * text = new uchar[n+1]; - - input.seekg(0,ios::beg); - input.read((char*)text,sizeof(uchar)*n); - input.close(); - //for(uint i=0;iset_samplepos(32); - _ssa->set_samplesuff(32); - _ssa->build_index(); - _ssa->print_stats(); - - cerr << "Index size: " << _ssa->size() << endl; - - ofstream fp(argv[2]); - _ssa->save(fp); - fp.close(); - - //delete sbb; - delete _ssa; - delete [] text; - - return 0; -} diff --git a/libcds/tutorial/ssa/dump_bwt.cpp b/libcds/tutorial/ssa/dump_bwt.cpp deleted file mode 100755 index b5a434c5..00000000 --- a/libcds/tutorial/ssa/dump_bwt.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/** - * dump_bwt.cpp - * Copyright (C) 2011 Francisco Claude F. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -#include "ssa.h" -#include -#include -#include - -using namespace std; - -int main(int argc, char ** argv) { - if(argc!=2) { - cout << "usage: " << argv[0] << " " << endl; - return 0; - } - - ifstream ssainput(argv[1]); - ssa * _ssa = new ssa(ssainput); - ssainput.close(); - _ssa->print_bwt(); - delete _ssa; - - return 0; -} diff --git a/libcds/tutorial/ssa/ssa.cpp b/libcds/tutorial/ssa/ssa.cpp deleted file mode 100755 index 1e547740..00000000 --- a/libcds/tutorial/ssa/ssa.cpp +++ /dev/null @@ -1,430 +0,0 @@ -/** - * ssa.cpp - * Copyright (C) 2011 Francisco Claude F. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -#include "ssa.h" - -ssa::ssa(uchar *text, uint n, bool free_text) { - assert(n>0); - - // Initial values and default constructors - this->n=n; - this->n1=n+1; - this->_seq = text; - this->built = false; - this->free_text=free_text; - - // Default sampling values - samplepos = 64; - samplesuff = 64; - - #ifdef VERBOSE - cout << "ssa" << endl; - cout << " n=" << n << endl; - cout << " free_text=" << free_text << endl; - #endif - - // Structures that will be built after calling build_index() - _sa = NULL; - bwt = NULL; - _bwt = NULL; - sampled = NULL; - pos_sample = NULL; - suff_sample = NULL; -} - - -ssa::~ssa() { - if(_seq!=NULL && free_text) - delete [] _seq; - if(_bwt!=NULL) - delete [] _bwt; - if(bwt!=NULL) - delete bwt; - if(_sa!=NULL) - delete [] _sa; - if(pos_sample!=NULL) - delete [] pos_sample; - if(suff_sample!=NULL) - delete [] suff_sample; - if(sampled!=NULL) - delete sampled; - delete [] sbuff; -} - -#include -using namespace cds_utils; - -void ssa::save(ofstream & fp) { - saveValue(fp,n); - saveValue(fp,sigma); - saveValue(fp,maxV); - saveValue(fp,samplepos); - saveValue(fp,samplesuff); - bwt->save(fp); - sampled->save(fp); - saveValue(fp,pos_sample,2+n/samplepos); - saveValue(fp,suff_sample,1+n/samplesuff); - saveValue(fp,occ,maxV+1); -} - -void ssa::print_bwt() { - for(size_t i=0;i<=n;i++) { - uint symbol = bwt->access(i); - if(symbol>0) - cout << (uchar)symbol; - } -} - -uint ssa::length() { - return n; -} - - -ssa::ssa(ifstream & fp) { - built = true; - _sa = NULL; - bwt = NULL; - _bwt = NULL; - sampled = NULL; - pos_sample = NULL; - suff_sample = NULL; - - _seq=NULL; - - n = loadValue(fp); - sigma = loadValue(fp); - maxV = loadValue(fp); - samplepos = loadValue(fp); - samplesuff = loadValue(fp); - bwt = Sequence::load(fp); - sampled = BitSequence::load(fp); - pos_sample = loadValue(fp,2+n/samplepos); - suff_sample = loadValue(fp,1+n/samplesuff); - occ = loadValue(fp,maxV+1); - sbuff = new uchar[samplepos+1]; - spos = (uchar)-(samplepos+1); -} - - -uint ssa::size() { - uint size = bwt->getSize(); - size += sizeof(uint)*(2+n/samplepos); - size += sizeof(uint)*(1+n/samplesuff); - size += sizeof(ssa); - size += sizeof(uchar)*(1+samplepos); - size += (1+maxV)*sizeof(uint); - size += sampled->getSize(); - return size; -} - - -void ssa::print_stats() { - cout << "ssa stats:" << endl; - cout << "****************" << endl; - cout << "Total space : " << size() << endl; - cout << endl; - cout << " bwt : " << bwt->getSize() << endl; - cout << " pos sample : " << sizeof(uint)*(2+n/samplepos) << endl; - cout << " suff sample : " << sizeof(uint)*(1+n/samplesuff) << endl; - cout << " occ : " << (maxV+1)*sizeof(uint) << endl; - cout << endl; -} - - - -bool ssa::set_samplepos(uint sample) { - if(built) return false; - samplepos = sample; - return true; -} - - -bool ssa::set_samplesuff(uint sample) { - if(built) return false; - samplesuff = sample; - return true; -} - - -bool ssa::build_index(Array * v, BitSequence * b) { - built = true; - assert(_seq!=NULL); - if(bwt!=NULL) { - delete bwt; - bwt = NULL; - } - #ifdef VERBOSE - cout << "Building the SA" << endl; - #endif - build_sa(); - #ifdef VERBOSE - cout << "Done with the SA" << endl; - #endif - if(v!=NULL) - for(uint i=0;i<=n;i++) - v->setField(i,b->rank1(_sa[i])); - #ifdef VERBOSE - cout << "Building the BWT" << endl; - #endif - build_bwt(); - #ifdef VERBOSE - cout << "Done with the BWT" << endl; - #endif - if(free_text) { - delete [] _seq; - _seq = NULL; - } - #ifdef VERBOSE - cout << "Building the WT of the BWT" << endl; - #endif - bwt = new WaveletTree(_bwt, n+1, - new wt_coder_huff(_bwt, n+1, - new MapperNone()), - new BitSequenceBuilderRRR(32), - new MapperNone()); - - maxV = 0; - for(uint i=0;i0); - assert(pattern!=NULL); - assert(bwt!=NULL); - ulong i=m-1; - uint c = pattern[i]; - uint sp = occ[c]; - uint ep = occ[c+1]-1; - while (sp<=ep && i>=1) { - c = pattern[--i]; - //cout << "sp=" << sp << " ep=" << ep << endl; - sp = occ[c]+bwt->rank(c,sp-1); - ep = occ[c]+bwt->rank(c,ep)-1; - } - //cout << "*sp=" << sp << " *ep=" << ep << endl; - if(sp<=ep) { - uint matches = ep-sp+1; - *occs = new uint[matches]; - uint i = sp; - uint j,dist; - size_t rank_tmp; - while(i<=ep) { - j = i; - dist = 0; - while(!sampled->access(j)) { - c = bwt->access(j,rank_tmp); - rank_tmp--; - j = occ[c]+rank_tmp; - dist++; - } - (*occs)[i-sp] = suff_sample[sampled->rank1(j)-1]+dist; - i++; - } - return ep-sp+1; - } - else { - *occs = NULL; - return 0; - } -} - - -uint ssa::count(uchar * pattern, uint m) { - assert(m>0); - assert(pattern!=NULL); - assert(bwt!=NULL); - ulong i=m-1; - uint c = pattern[i]; - uint sp = occ[c]; - uint ep = occ[c+1]-1; - while (sp<=ep && i>=1) { - c = pattern[--i]; - //cout << "sp=" << sp << " ep=" << ep << endl; - sp = occ[c]+bwt->rank(c,sp-1); - ep = occ[c]+bwt->rank(c,ep)-1; - } - //cout << "*sp=" << sp << " *ep=" << ep << endl; - if (sp<=ep) { - return ep-sp+1; - } - else { - return 0; - } -} - - -uchar * ssa::rebuild() { - uchar * text = new uchar[n]; - for(uint i=0;i=i); - assert(jaccess(p,rank_tmp); - p = occ[c]+rank_tmp; - sbuff[len-dist-1] = (uchar)(c-1); - } -} - - -uchar ssa::extract_pos(uint k) { - uint block = k/samplepos; - if(block!=spos) - fill_buffer(samplepos*block,min(samplepos*block+(samplepos-1),n)); - spos = block; - return sbuff[samplepos-(samplepos*(block+1)-k)]; -} - - -uchar * ssa::extract(uint i, uint j) { - assert(j>=i); - assert(j=i;k--) - buff[k-i] = extract_pos(k); - return buff; -} - - -void ssa::sort_sa(uint ini, uint fin) { - if(ini>=fin || ini>=(fin+1)) return; - uint piv = ini; - piv = pivot(ini,fin,piv); - sort_sa(ini,piv-1); - sort_sa(piv+1,fin); -} - - -int ssa::cmp(uint i, uint j) { - while(i. - */ - - -#ifndef SSA_WORDS_H -#define SSA_WORDS_H - -#include -#include -#include -#include - -#include -#include - -using namespace std; -using namespace cds_static; - -#define SSA_HDR 29 - -class ssa -{ - public: - ssa(uchar * seq, uint n, bool free_text=false); - ssa(ifstream & fp); - ~ssa(); - - bool set_samplepos(uint sample); - bool set_samplesuff(uint sample); - - bool build_index(Array * a=NULL, BitSequence * b=NULL); - - uint size(); - void print_stats(); - uint length(); - - uint locate(uchar * pattern, uint m, uint ** occ); - uint count(uchar * pattern, uint m); - uchar * extract(uint i, uint j); - uchar extract_pos(uint i); - - void print_bwt(); - - uchar * rebuild(); - void save(ofstream & fp); - - - protected: - uint n,n1; - uint sigma; - Sequence * bwt; - BitSequence * sampled; - uint samplepos; - uint samplesuff; - uint * pos_sample; - uint * suff_sample; - uchar * sbuff; - uint spos; - uint * occ; - uint maxV; - - bool built; - bool free_text; - uchar * _seq; - uint * _bwt; - uint * _sa; - - void build_bwt(); - void build_sa(); - void sort_sa(uint ini, uint fin); - int cmp(uint i, uint j); - void swap(uint i, uint j); - uint pivot(uint ini, uint fin, uint piv); - void fill_buffer(uint i, uint j); - -}; -#endif diff --git a/libcds/tutorial/ssa/test_count.cpp b/libcds/tutorial/ssa/test_count.cpp deleted file mode 100755 index 203aa4ac..00000000 --- a/libcds/tutorial/ssa/test_count.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/** - * test_count.cpp - * Copyright (C) 2011 Francisco Claude F. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -#include "ssa.h" -#include -#include -#include - -using namespace std; - -uint brute_check(uchar * text, uint n, uchar * pattern, uint m) { - uint ret = 0; - for(uint i=0;i " << endl; - return 0; - } - - fstream input(argv[1],ios::in | ios::binary); - if(!input.is_open()) { - cerr << "Error opening file: " << argv[1] << endl; - return -1; - } - - input.seekg(0,ios::end); - uint n=input.tellg(); - uchar * text = new uchar[n+1]; - - input.seekg(0,ios::beg); - input.read((char*)text,sizeof(uchar)*n); - input.close(); - //for(uint i=0;iprint_stats(); - - uint m; - { - stringstream ss; - ss << argv[3]; - ss >> m; - } - - uint rep; - { - stringstream ss; - ss << argv[4]; - ss >> rep; - } - - uint total_occ = 0; - uchar * pattern = new uchar[m+1]; - for(uint i=0;icount(pattern,m); - uint real_occ = brute_check(text,n,pattern,m); - if(occ!=real_occ) { - cerr << "Error for pattern " << i+1 << endl; - cerr << "ssa->count() returned " << occ << endl; - cerr << "expected value is " << real_occ << endl; - break; - } - total_occ += occ; - } - - cerr << "Total occ: " << total_occ << endl; - - delete [] pattern; - delete _ssa; - delete [] text; - - return 0; -} diff --git a/libcds/tutorial/tutorial.pdf b/libcds/tutorial/tutorial.pdf deleted file mode 100755 index cfd1d80c..00000000 Binary files a/libcds/tutorial/tutorial.pdf and /dev/null differ diff --git a/libhdt/Makefile.am b/libhdt/Makefile.am index 410c1c11..853452d5 100644 --- a/libhdt/Makefile.am +++ b/libhdt/Makefile.am @@ -162,10 +162,5 @@ $(KYOTO_CFLAGS) $(SERD_CFLAGS) $(ZLIB_CFLAGS) $(EXTRAFLAGS) libhdt_la_LDFLAGS = $(SERD_LIBS) $(ZLIB_LIBS) $(KYOTO_LIBS) libhdt_la_LIBADD = -if WANTS_LIBCDS -libhdt_la_CPPFLAGS += -DHAVE_CDS -I$(top_builddir)/libcds/include -libhdt_la_LIBADD += $(top_builddir)/libcds/libcds.la -endif - pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = hdt.pc diff --git a/libhdt/include/HDTManager.hpp b/libhdt/include/HDTManager.hpp index 57911a75..346b37e8 100644 --- a/libhdt/include/HDTManager.hpp +++ b/libhdt/include/HDTManager.hpp @@ -1,9 +1,10 @@ /* * File: HDTManager.hpp - * Last modified: $Date: 2012-08-21 21:15:01 +0100 (mar, 21 ago 2012) $ + * Last modified: $Date$ * Revision: $Revision: 250 $ - * Last modified by: $Author: mario.arias $ + * Last modified by: $Author$ * + * Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) * Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto * All rights reserved. * @@ -37,6 +38,7 @@ #include "HDTListener.hpp" #include +#include namespace hdt { @@ -49,7 +51,7 @@ class HDTManager { /** * Reads an HDT file into main memory. */ - static HDT *loadHDT(const char *file, ProgressListener *listener=NULL); + static std::unique_ptr loadHDT(const char *file, ProgressListener *listener=NULL); /** * Load an HDT File, and load/create additional indexes to support all kind of queries efficiently. @@ -58,17 +60,46 @@ class HDTManager { * @return * @throws IOException */ - static HDT *loadIndexedHDT(const char *hdtFileName, ProgressListener *listener=NULL); + static std::unique_ptr loadIndexedHDT(const char *hdtFileName, ProgressListener *listener=NULL); + + /** + * Load an HDT File from memory, and load/create additional indexes to support all kind of queries efficiently. + * @param hdtBuffer + * @param hdtBufferLen + * @param hdtIndexBuffer + * @param hdtIndexBufferLen + * @param listener Listener to get notified of loading progress. Can be null if no notifications needed. + * @return + * @throws IOException + */ + static std::unique_ptr loadIndexedHDTFromMemory( + const char *hdtBuffer, + size_t hdtBufferLen, + const char* hdtIndexBuffer, + size_t hdtIndexBufferLen, + ProgressListener *listener=NULL); + + /** + * Load multiple HDT Files stored in memory buffers, and load/create additional indexes to support all kind of queries efficiently. + * @param buffer_list List of pairs + * @param baseUri + * @param listener + * @return + * @throws IOException + */ + static std::unique_ptr loadFromSeveralHDTInMemory( + const std::vector>& buffer_list, + string baseUri, ProgressListener * listener=NULL); /** * Maps an HDT file. Faster to load, uses less memory, but may result in delays at access time. */ - static HDT *mapHDT(const char *file, ProgressListener *listener=NULL); + static std::unique_ptr mapHDT(const char *file, ProgressListener *listener=NULL); /** * Maps an HDT file and load/generate additional indexes to solve efficiently all queries. */ - static HDT *mapIndexedHDT(const char *file, ProgressListener *listener=NULL); + static std::unique_ptr mapIndexedHDT(const char *file, ProgressListener *listener=NULL); /** * Return an indexed HDT that is efficient for all kind of queries, given a (possibly) not indexed HDT. @@ -76,7 +107,7 @@ class HDTManager { * @param listener Listener to get notified of loading progress. Can be null if no notifications needed. * @return */ - static HDT *indexedHDT(HDT *hdt, ProgressListener *listener=NULL); + static void indexedHDT(HDT *hdt, ProgressListener *listener=NULL); /** * Create an HDT file from an RDF file. @@ -89,7 +120,7 @@ class HDTManager { * @throws IOException * @throws ParserException */ - static HDT *generateHDT(const char *rdfFileName, const char *baseURI, RDFNotation rdfNotation, HDTSpecification &hdtFormat, ProgressListener *listener=NULL); + static std::unique_ptr generateHDT(const char *rdfFileName, const char *baseURI, RDFNotation rdfNotation, HDTSpecification &hdtFormat, ProgressListener *listener=NULL); }; } diff --git a/libhdt/include/RDFParser.hpp b/libhdt/include/RDFParser.hpp index fe220680..21f3bb66 100644 --- a/libhdt/include/RDFParser.hpp +++ b/libhdt/include/RDFParser.hpp @@ -4,6 +4,7 @@ * Revision: $Revision$ * Last modified by: $Author$ * + * Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) * Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto * All rights reserved. * @@ -55,7 +56,7 @@ class RDFParserCallback { virtual void doParse(const char *fileName, const char *baseUri, RDFNotation notation, bool ignoreErrors, RDFCallback *callback)=0; - static RDFParserCallback *getParserCallback(RDFNotation notation); + static RDFParserCallback *getParserCallback(RDFNotation notation, const std::string& bnode_prefix); }; class RDFParserPull: public IteratorTripleString { diff --git a/libhdt/src/bitsequence/BitSequence375.cpp b/libhdt/src/bitsequence/BitSequence375.cpp index 92b25cd3..1ad6730c 100644 --- a/libhdt/src/bitsequence/BitSequence375.cpp +++ b/libhdt/src/bitsequence/BitSequence375.cpp @@ -1,4 +1,5 @@ /* BitSequence375.cpp + Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) Copyright (C) 2005, Rodrigo Gonzalez, all rights reserved. New RANK, SELECT, SELECT-NEXT and SPARSE RANK implementations. @@ -95,6 +96,7 @@ void BitSequence375::buildIndex() //cout << "Blocks: " << numwords << " Super: "<< superblocks.size() << " Size: " << superblocks.size()*8 << endl; // Fill them + uint64_t x{}; while(blockIndex < numwords) { if(!(blockIndex%BLOCKS_PER_SUPER)) @@ -107,7 +109,8 @@ void BitSequence375::buildIndex() } blocks[blockIndex] = blockPop; - blockPop += popcount64(array[blockIndex]); + memcpy(&x, &array[blockIndex], sizeof(size_t)); + blockPop += popcount64(x); blockIndex++; } @@ -405,7 +408,9 @@ size_t BitSequence375::select1(const size_t x) const countdown -= blocks[blockIdx]; // Search bit inside block - size_t bitpos = wordSelect1(array[blockIdx], countdown); + size_t value{}; + memcpy(&value, &array[blockIdx], sizeof(value)); + size_t bitpos = wordSelect1(value, countdown); return blockIdx * WORDSIZE + bitpos - 1; } diff --git a/libhdt/src/hdt/BasicHDT.cpp b/libhdt/src/hdt/BasicHDT.cpp index c1225918..09b3f187 100644 --- a/libhdt/src/hdt/BasicHDT.cpp +++ b/libhdt/src/hdt/BasicHDT.cpp @@ -4,6 +4,10 @@ * Revision: $Revision$ * Last modified by: $Author$ * + * Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto + * All rights reserved. + * * 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 @@ -217,7 +221,7 @@ void BasicHDT::loadDictionary(const char* fileName, const char* baseUri, RDFNota // Load data DictionaryLoader dictLoader(dict, &iListener); - RDFParserCallback *parser = RDFParserCallback::getParserCallback(notation); + RDFParserCallback *parser = RDFParserCallback::getParserCallback(notation, spec.getOrEmpty("bnode.prefix")); parser->doParse(fileName, baseUri, notation, true, &dictLoader); delete parser; @@ -285,7 +289,7 @@ void BasicHDT::loadTriples(const char* fileName, const char* baseUri, RDFNotatio TriplesLoader tripLoader(dictionary, triplesList, &iListener); RDFParserCallback *pars = RDFParserCallback::getParserCallback( - notation); + notation, spec.getOrEmpty("bnode.prefix")); pars->doParse(fileName, baseUri, notation, true, &tripLoader); delete pars; header->insert("_:statistics", HDTVocabulary::ORIGINAL_SIZE, tripLoader.getSize()); @@ -449,6 +453,38 @@ void BasicHDT::addDictionaryFromHDT(const char *fileName, ModifiableDictionary * } } +void BasicHDT::addDictionaryFromHDT(const char * buffer, size_t bufferLen, ModifiableDictionary * dict, ProgressListener * listener) +{ + BasicHDT hdt; + hdt.mapHDT(buffer, bufferLen, listener); + + Dictionary *otherDict = hdt.getDictionary(); + + char str[100]; + + for(long long int i=0;igetNsubjects();i++) { + dict->insert(otherDict->idToString(i+1, SUBJECT), SUBJECT); + + if ((listener != NULL) && (i % 100000) == 0) { + sprintf(str, "%lld subjects added.", i); + listener->notifyProgress((i*100)/otherDict->getNsubjects(), str); + } + } + + for(long long int i=0;igetNpredicates();i++) { + dict->insert(otherDict->idToString(i+1, PREDICATE), PREDICATE); + } + + for(long long int i=0;igetNobjects();i++) { + dict->insert(otherDict->idToString(i+1, OBJECT), OBJECT); + + if ((listener != NULL) && (i % 100000) == 0) { + sprintf(str, "%lld objects added.", i); + listener->notifyProgress((i*100)/otherDict->getNobjects(), str); + } + } +} + void BasicHDT::loadDictionaryFromHDTs(const char** fileName, size_t numFiles, const char* baseUri, ProgressListener* listener) { @@ -486,6 +522,42 @@ void BasicHDT::loadDictionaryFromHDTs(const char** fileName, size_t numFiles, co } } +void BasicHDT::loadDictionaryFromHDTs(const std::vector>& hdt_list, const char * baseUri, ProgressListener * listener) +{ + StopWatch st; + IntermediateListener iListener(listener); + + // Create temporary dictionary + ModifiableDictionary *dict = getLoadDictionary(); + dict->startProcessing(); + try { + NOTIFY(listener, "Loading Dictionary", 0, 100); + iListener.setRange(0, 80); + + for (auto& hdt_file : hdt_list) { + addDictionaryFromHDT(hdt_file.first, hdt_file.second, dict, &iListener); + } + + iListener.setRange(80, 90); + dict->stopProcessing(&iListener); + + // Convert to final format + dictionary->import(dict); + + delete dict; + } catch (std::exception& e) { + cerr << "Catch exception dictionary: " << e.what() << endl; + delete dict; + throw; +#ifndef WIN32 + } catch (char *e) { + cout << "Catch exception dictionary: " << e << endl; + delete dict; + throw e; +#endif + } +} + void BasicHDT::loadTriplesFromHDTs(const char** fileNames, size_t numFiles, const char* baseUri, ProgressListener* listener) { // Generate Triples ModifiableTriples* triplesList = new TriplesList(spec); @@ -616,6 +688,135 @@ void BasicHDT::loadTriplesFromHDTs(const char** fileNames, size_t numFiles, cons } +void BasicHDT::loadTriplesFromHDTs(const std::vector>& hdt_list, const char * baseUri, ProgressListener * listener) +{ + // Generate Triples + ModifiableTriples* triplesList = new TriplesList(spec); + //ModifiableTriples *triplesList = new TriplesKyoto(spec); + //ModifiableTriples *triplesList = new TripleListDisk(); + StopWatch st; + IntermediateListener iListener(listener); + try { + NOTIFY(listener, "Loading Triples", 0, 100); + iListener.setRange(0, 60); + + triplesList->startProcessing(&iListener); + + TriplesLoader tripLoader(dictionary, triplesList, &iListener); + + // FIXME: Import from files + + uint64_t totalOriginalSize=0; + BasicHDT hdt; + + for (auto& hdt_file : hdt_list) { + hdt.mapHDT(hdt_file.first, hdt_file.second); + Dictionary *dict = hdt.getDictionary(); + + // Create mapping arrays + size_t nsubjects = dict->getNsubjects(); + LogSequence2 subjectMap(bits(dictionary->getNsubjects()), nsubjects); + subjectMap.resize(nsubjects); + for(size_t i=0;iidToString(i+1, SUBJECT); + size_t newid = dictionary->stringToId(str, SUBJECT); + subjectMap.set(i, newid); + } + + size_t npredicates = dict->getNpredicates(); + LogSequence2 predicateMap(bits(dictionary->getNpredicates()), npredicates); + predicateMap.resize(npredicates); + for(size_t i=0;iidToString(i+1, PREDICATE); + size_t newid = dictionary->stringToId(str, PREDICATE); + predicateMap.set(i, newid); + } + + size_t nobjects = dict->getNobjects(); + LogSequence2 objectMap(bits(dictionary->getNobjects()), nobjects); + objectMap.resize(nobjects); + for(size_t i=0;iidToString(i+1, OBJECT); + size_t newid = dictionary->stringToId(str, OBJECT); + objectMap.set(i, newid); + } + + totalOriginalSize += hdt.getHeader()->getPropertyLong("_:statistics", HDTVocabulary::ORIGINAL_SIZE.c_str()); + + size_t numtriples = hdt.getTriples()->getNumberOfElements(); + IteratorTripleID *it = hdt.getTriples()->searchAll(); + + TripleID newTid; + char str[100]; + long long int j = 0; + while(it->hasNext()) { + TripleID *tid = it->next(); + + newTid.setAll( + subjectMap.get(tid->getSubject()-1), + predicateMap.get(tid->getPredicate()-1), + objectMap.get(tid->getObject()-1) + ); + + triplesList->insert(newTid); + + if ((listener != NULL) && (j % 100000) == 0) { + sprintf(str, "%lld triples added.", j); + listener->notifyProgress((j*100)/numtriples, str); + } + j++; + } + delete it; + } + + triplesList->stopProcessing(&iListener); + + // SORT & Duplicates + string ord = spec.getOrEmpty("triplesOrder"); + + TripleComponentOrder order = parseOrder(ord.c_str()); + if (order == Unknown) { + order = SPO; + } + + iListener.setRange(80, 85); + triplesList->sort(order, &iListener); + + iListener.setRange(85, 90); + triplesList->removeDuplicates(&iListener); + + header->insert("_:statistics", HDTVocabulary::ORIGINAL_SIZE, totalOriginalSize); + +#ifndef WIN32 + } catch (char *e) { + cout << "Catch exception triples" << e << endl; + delete triplesList; + throw; +#else + } catch (std::exception& e) { + // cerr << "Catch exception triples" << e << endl; + delete triplesList; + throw; +#endif + } + if (triples->getType() == triplesList->getType()) { + delete triples; + triples = triplesList; + } else { + iListener.setRange(90, 100); + try { + triples->load(*triplesList, &iListener); + } catch (std::exception& e) { + delete triplesList; + throw; + } + delete triplesList; + } + + //cerr << triples->getNumberOfElements() << " triples added in " << st << endl << endl; + +} + void BasicHDT::loadFromSeveralHDT(const char **fileNames, size_t numFiles, string baseUri, ProgressListener *listener) { try { @@ -650,6 +851,41 @@ void BasicHDT::loadFromSeveralHDT(const char **fileNames, size_t numFiles, strin } } +void BasicHDT::loadFromSeveralHDT( + const std::vector>& buffer_list, + string baseUri, ProgressListener * listener) +{ + try { + // Make sure that URI starts and ends with <> + if(baseUri.at(0)!='<') + baseUri = '<'+baseUri; + if(baseUri.at(baseUri.length()-1)!='>') + baseUri.append(">"); + + IntermediateListener iListener(listener); + + iListener.setRange(0,50); + loadDictionaryFromHDTs(buffer_list, baseUri.c_str(), &iListener); + + iListener.setRange(50,99); + loadTriplesFromHDTs(buffer_list, baseUri.c_str(), &iListener); + + fillHeader(baseUri); + + }catch (std::exception& e) { + // cerr << "Catch exception load: " << e << endl; + deleteComponents(); + createComponents(); + throw; +#ifndef WIN32 + } catch (char *e) { + cout << "Catch exception load: " << e << endl; + deleteComponents(); + createComponents(); + throw e; +#endif + } +} void BasicHDT::saveToRDF(RDFSerializer &serializer, ProgressListener *listener) @@ -671,6 +907,19 @@ void BasicHDT::loadFromHDT(const char *fileName, ProgressListener *listener) { stream.close(); } +void BasicHDT::loadFromHDT(const char *buffer, size_t bufferLen, ProgressListener *listener) +{ + this->fileName = "memory_stream.tmp"; + + DecompressStream stream(buffer, bufferLen); + istream *in = stream.getStream(); + if(!in->good()){ + throw std::runtime_error("Error opening buffer to load HDT."); + } + this->loadFromHDT(*in, listener); + stream.close(); +} + void BasicHDT::loadHeader(const char *fileName, ProgressListener *listener) { this->fileName = fileName; @@ -800,6 +1049,22 @@ void BasicHDT::mapHDT(const char *fileNameChar, ProgressListener *listener) { this->loadMMap(ptr, ptr+mappedSize, &iListener); } +void BasicHDT::mapHDT(const char * buffer, size_t bufferLen, ProgressListener * listener) +{ + IntermediateListener iListener(listener); + + // Clean previous + if(mappedHDT!=NULL) { + delete mappedHDT; + mappedHDT = nullptr; + } + + unsigned char* ptr = reinterpret_cast(const_cast(buffer)); + + // Load + this->loadMMap(ptr, ptr+bufferLen, &iListener); +} + size_t BasicHDT::loadMMap(unsigned char *ptr, unsigned char *ptrMax, ProgressListener *listener) { size_t count=0; ControlInformation controlInformation; @@ -930,6 +1195,21 @@ void BasicHDT::loadOrCreateIndex(ProgressListener *listener) { } } +void BasicHDT::loadOrCreateIndex(const char* indexBuffer, size_t indexBufferLen, ProgressListener *listener) +{ + memstream in(indexBuffer, indexBufferLen); + + if (in.good()) { + ControlInformation ci; + ci.load(in); + triples->loadIndex(in, ci, listener); + } else { + IntermediateListener iListener(listener); + iListener.setRange(0,100); + triples->generateIndex(&iListener); + } +} + void BasicHDT::saveIndex(ProgressListener *listener) { if(this->fileName.size()==0) { cerr << "Cannot save Index if the HDT is not saved" << endl; diff --git a/libhdt/src/hdt/BasicHDT.hpp b/libhdt/src/hdt/BasicHDT.hpp index 23145ade..15383a5b 100644 --- a/libhdt/src/hdt/BasicHDT.hpp +++ b/libhdt/src/hdt/BasicHDT.hpp @@ -4,6 +4,10 @@ * Revision: $Revision$ * Last modified by: $Author$ * + * Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto + * All rights reserved. + * * 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 @@ -56,8 +60,11 @@ class BasicHDT : public HDT { void loadTriples(const char *fileName, const char *baseUri, RDFNotation notation, ProgressListener *listener); void addDictionaryFromHDT(const char *fileName, ModifiableDictionary *dict, ProgressListener *listener=NULL); + void addDictionaryFromHDT(const char* buffer, size_t bufferLen, ModifiableDictionary *dict, ProgressListener *listener=NULL); void loadDictionaryFromHDTs(const char** fileName, size_t numFiles, const char* baseUri, ProgressListener* listener=NULL); + void loadDictionaryFromHDTs(const std::vector>& hdt_list, const char* baseUri, ProgressListener* listener=NULL); void loadTriplesFromHDTs(const char** fileNames, size_t numFiles, const char* baseUri, ProgressListener* listener=NULL); + void loadTriplesFromHDTs(const std::vector>& hdt_list, const char* baseUri, ProgressListener* listener=NULL); void fillHeader(const string &baseUri); @@ -97,16 +104,21 @@ class BasicHDT : public HDT { * @param input */ void loadFromHDT(const char *fileName, ProgressListener *listener = NULL); + void loadFromHDT(const char *buffer, size_t bufferLen, ProgressListener *listener = NULL); void loadHeader(const char *fileName, ProgressListener *listener); void loadFromSeveralHDT(const char **fileNames, size_t numFiles, string baseUri, ProgressListener *listener=NULL); + void loadFromSeveralHDT( + const std::vector>& buffer_list, + string baseUri, ProgressListener *listener=NULL); /** * Load an HDT from a file, using memory mapping * @param input */ void mapHDT(const char *fileName, ProgressListener *listener = NULL); + void mapHDT(const char *buffer, size_t bufferLen, ProgressListener *listener = NULL); /** * @param output @@ -125,6 +137,7 @@ class BasicHDT : public HDT { void saveToHDT(const char *fileName, ProgressListener *listener = NULL); void loadOrCreateIndex(ProgressListener *listener = NULL); + void loadOrCreateIndex(const char* indexBuffer, size_t indexBufferLen, ProgressListener *listener = NULL); void saveIndex(ProgressListener *listener = NULL); diff --git a/libhdt/src/hdt/ControlInformation.cpp b/libhdt/src/hdt/ControlInformation.cpp index 3aeb299f..3227df01 100644 --- a/libhdt/src/hdt/ControlInformation.cpp +++ b/libhdt/src/hdt/ControlInformation.cpp @@ -4,6 +4,10 @@ * Revision: $Revision$ * Last modified by: $Author$ * + * Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto + * All rights reserved. + * * 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 @@ -178,7 +182,10 @@ size_t ControlInformation::load(const unsigned char *ptr, const unsigned char *m CRC16 crc; crc.update(&ptr[0], count); CHECKPTR(ptr,maxPtr, sizeof(crc16_t)); - const crc16_t filecrc = *((crc16_t *)&ptr[count]); + + crc16_t filecrc{}; + memcpy(&filecrc, &ptr[count], sizeof(filecrc)); + if(filecrc!=crc.getValue()) { throw std::runtime_error("CRC of control information does not match."); } diff --git a/libhdt/src/hdt/HDTManager.cpp b/libhdt/src/hdt/HDTManager.cpp index df942ae0..dc381508 100644 --- a/libhdt/src/hdt/HDTManager.cpp +++ b/libhdt/src/hdt/HDTManager.cpp @@ -1,8 +1,12 @@ /* * File: HDTFactory.cpp - * Last modified: $Date: 2012-08-21 21:15:01 +0100 (mar, 21 ago 2012) $ + * Last modified: $Date$ * Revision: $Revision: 250 $ - * Last modified by: $Author: mario.arias $ + * Last modified by: $Author$ + * + * Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto + * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -29,26 +33,36 @@ #include #include #include "BasicHDT.hpp" +#include using namespace hdt; namespace hdt { -HDT *HDTManager::loadHDT(const char *file, ProgressListener *listener){ - BasicHDT *h = new BasicHDT(); +std::unique_ptr HDTManager::loadHDT(const char *file, ProgressListener *listener){ + auto h{std::make_unique()}; h->loadFromHDT(file, listener); return h; } -HDT *HDTManager::mapHDT(const char *file, ProgressListener *listener){ - BasicHDT *h = new BasicHDT(); +std::unique_ptr HDTManager::loadFromSeveralHDTInMemory( + const std::vector>& buffer_list, + string baseUri, ProgressListener * listener) +{ + auto h{std::make_unique()}; + h->loadFromSeveralHDT(buffer_list, baseUri, listener); + return h; +} + +std::unique_ptr HDTManager::mapHDT(const char *file, ProgressListener *listener){ + auto h{std::make_unique()}; h->mapHDT(file, listener); return h; } -HDT *HDTManager::mapIndexedHDT(const char *file, ProgressListener *listener){ - BasicHDT *h = new BasicHDT(); +std::unique_ptr HDTManager::mapIndexedHDT(const char *file, ProgressListener *listener){ + auto h{std::make_unique()}; IntermediateListener iListener(listener); iListener.setRange(0,10); h->mapHDT(file, &iListener); @@ -58,8 +72,8 @@ HDT *HDTManager::mapIndexedHDT(const char *file, ProgressListener *listener){ return h; } -HDT *HDTManager::loadIndexedHDT(const char *file, ProgressListener *listener){ - BasicHDT *h = new BasicHDT(); +std::unique_ptr HDTManager::loadIndexedHDT(const char *file, ProgressListener *listener){ + auto h{std::make_unique()}; IntermediateListener iListener(listener); iListener.setRange(0,50); h->loadFromHDT(file, listener); @@ -69,14 +83,25 @@ HDT *HDTManager::loadIndexedHDT(const char *file, ProgressListener *listener){ return h; } -HDT *HDTManager::indexedHDT(HDT *hdt, ProgressListener *listener){ +std::unique_ptr HDTManager::loadIndexedHDTFromMemory(const char *hdtBuffer, size_t hdtBufferLen, const char* hdtIndexBuffer, size_t hdtIndexBufferLen, ProgressListener *listener) +{ + auto h{std::make_unique()}; + IntermediateListener iListener(listener); + iListener.setRange(0,50); + h->loadFromHDT(hdtBuffer, hdtBufferLen, listener); + + iListener.setRange(50,100); + h->loadOrCreateIndex(hdtIndexBuffer, hdtIndexBufferLen, listener); + return h; +} + +void HDTManager::indexedHDT(HDT* hdt, ProgressListener *listener){ BasicHDT *bhdt = dynamic_cast(hdt); bhdt->loadOrCreateIndex(listener); - return bhdt; } -HDT *HDTManager::generateHDT(const char *rdfFileName, const char *baseURI, RDFNotation rdfNotation, HDTSpecification &hdtFormat, ProgressListener *listener){ - BasicHDT *hdt = new BasicHDT(hdtFormat); +std::unique_ptr HDTManager::generateHDT(const char *rdfFileName, const char *baseURI, RDFNotation rdfNotation, HDTSpecification &hdtFormat, ProgressListener *listener){ + auto hdt{std::make_unique(hdtFormat)}; hdt->loadFromRDF(rdfFileName, baseURI, rdfNotation, listener); return hdt; } diff --git a/libhdt/src/hdt/HDTSpecification.cpp b/libhdt/src/hdt/HDTSpecification.cpp index dbf6d2b1..08722365 100644 --- a/libhdt/src/hdt/HDTSpecification.cpp +++ b/libhdt/src/hdt/HDTSpecification.cpp @@ -4,6 +4,10 @@ * Revision: $Revision$ * Last modified by: $Author$ * + * Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto + * All rights reserved. + * * 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 @@ -59,31 +63,21 @@ void HDTSpecification::setOptions(const std::string& options) { } } -const std::string& HDTSpecification::get(const std::string& key) { - return map.at(key); -} - const std::string emptyString = ""; -const std::string& HDTSpecification::getOrEmpty(const std::string& key) { - - /* Webassembly does not play nice with C++ - - https://emscripten.org/docs/porting/exceptions.html - https://stackoverflow.com/questions/69608789/c-exception-to-exception-less - - */ - #ifdef __EMSCRIPTEN__ +const std::string& HDTSpecification::get(const std::string& key) { auto it = map.find(key); - return it == map.end() ? emptyString : it->second; - #else - try { - return map.at(key); - }catch (std::exception& e) { + if (it == map.end()) { return emptyString; } - #endif + + return it->second; +} + +const std::string& HDTSpecification::getOrEmpty(const std::string& key) { + auto it = map.find(key); + return it == map.end() ? emptyString : it->second; } void HDTSpecification::set(const std::string& key, const std::string& value) { diff --git a/libhdt/src/rdf/RDFParser.cpp b/libhdt/src/rdf/RDFParser.cpp index fadd9004..36568cbb 100644 --- a/libhdt/src/rdf/RDFParser.cpp +++ b/libhdt/src/rdf/RDFParser.cpp @@ -1,8 +1,32 @@ /* - * RDFParser.cpp + * File: RDFParser.cpp + * Last modified: $Date$ + * Revision: $Revision$ + * Last modified by: $Author$ + * + * Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto + * All rights reserved. + * + * 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. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * 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 + * + * Contacting the authors: + * Mario Arias: mario.arias@gmail.com + * Javier D. Fernandez: jfergar@infor.uva.es + * Miguel A. Martinez-Prieto: migumar2@infor.uva.es * - * Created on: 11/07/2011 - * Author: mck */ #include "RDFParser.hpp" @@ -12,14 +36,14 @@ namespace hdt { -RDFParserCallback *RDFParserCallback::getParserCallback(RDFNotation notation) { +RDFParserCallback *RDFParserCallback::getParserCallback(RDFNotation notation, const std::string& bnode_prefix) { #ifdef HAVE_SERD if(notation==NQUAD || // Deprecated: use `NQUADS' instead. notation==NQUADS || notation==NTRIPLES || notation==TRIG || notation==TURTLE) { - return new RDFParserSerd(); + return new RDFParserSerd(bnode_prefix); } #else throw ParseException("No Parser available for input RDF Format"); diff --git a/libhdt/src/rdf/RDFParserSerd.cpp b/libhdt/src/rdf/RDFParserSerd.cpp index a2463cc8..17fff156 100644 --- a/libhdt/src/rdf/RDFParserSerd.cpp +++ b/libhdt/src/rdf/RDFParserSerd.cpp @@ -1,3 +1,34 @@ +/* + * File: RDFParserSerd.cpp + * Last modified: $Date$ + * Revision: $Revision$ + * Last modified by: $Author$ + * + * Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto + * All rights reserved. + * + * 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. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * 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 + * + * Contacting the authors: + * Mario Arias: mario.arias@gmail.com + * Javier D. Fernandez: jfergar@infor.uva.es + * Miguel A. Martinez-Prieto: migumar2@infor.uva.es + * + */ + #ifdef HAVE_SERD #ifdef HAVE_LIBZ @@ -143,7 +174,8 @@ struct LibzSerdStream { #endif -RDFParserSerd::RDFParserSerd() : numByte(0) +RDFParserSerd::RDFParserSerd(const std::string& bnode_prefix) + : numByte(0), bnode_prefix(bnode_prefix) { } @@ -184,6 +216,7 @@ void RDFParserSerd::doParse(const char *fileName, const char *baseUri, RDFNotati NULL); serd_reader_set_error_sink(reader, hdtserd_on_error, NULL); + serd_reader_add_blank_prefix(reader, (const uint8_t*)bnode_prefix.c_str()); const uint8_t* input=serd_uri_to_path((const uint8_t *)fileName); diff --git a/libhdt/src/rdf/RDFParserSerd.hpp b/libhdt/src/rdf/RDFParserSerd.hpp index d5d8613d..4a15935d 100644 --- a/libhdt/src/rdf/RDFParserSerd.hpp +++ b/libhdt/src/rdf/RDFParserSerd.hpp @@ -1,3 +1,33 @@ +/* + * File: RDFParserSerd.hpp + * Last modified: $Date$ + * Revision: $Revision$ + * Last modified by: $Author$ + * + * Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto + * All rights reserved. + * + * 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. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * 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 + * + * Contacting the authors: + * Mario Arias: mario.arias@gmail.com + * Javier D. Fernandez: jfergar@infor.uva.es + * Miguel A. Martinez-Prieto: migumar2@infor.uva.es + * + */ #ifndef RDFPARSERSERD_HPP #define RDFPARSERSERD_HPP @@ -20,13 +50,14 @@ class RDFParserSerd : public RDFParserCallback { RDFCallback *callback; string error; uint64_t numByte; + std::string bnode_prefix; string getString(const SerdNode *term); string getStringObject(const SerdNode *term, const SerdNode *dataType, const SerdNode *lang); SerdSyntax getParserType(RDFNotation notation); public: - RDFParserSerd(); + RDFParserSerd(const std::string& bnode_prefix); virtual ~RDFParserSerd(); void doParse(const char *fileName, const char *baseUri, RDFNotation notation, bool ignoreErrors, RDFCallback *callback); diff --git a/libhdt/src/sequence/AdjacencyList.cpp b/libhdt/src/sequence/AdjacencyList.cpp index 262df925..d9aee03d 100644 --- a/libhdt/src/sequence/AdjacencyList.cpp +++ b/libhdt/src/sequence/AdjacencyList.cpp @@ -150,7 +150,7 @@ size_t AdjacencyList::binSearch(size_t element, size_t begin, size_t end) { else return mid; } - throw std::runtime_error("Not found"); + return static_cast(-1); } size_t AdjacencyList::linSearch(size_t element, size_t begin, size_t end) { diff --git a/libhdt/src/sequence/LogSequence.cpp b/libhdt/src/sequence/LogSequence.cpp index 54a2efa9..bfb77508 100644 --- a/libhdt/src/sequence/LogSequence.cpp +++ b/libhdt/src/sequence/LogSequence.cpp @@ -1,9 +1,10 @@ /* * File: LogSequence.cpp - * Last modified: $Date: 2011-08-21 05:35:30 +0100 (dom, 21 ago 2011) $ + * Last modified: $Date$ * Revision: $Revision: 180 $ - * Last modified by: $Author: mario.arias $ + * Last modified by: $Author$ * + * Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) * Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto * All rights reserved. * @@ -29,7 +30,7 @@ * */ -#ifdef HAVE_CSD +#ifdef HAVE_CDS #include #include @@ -61,7 +62,7 @@ size_t LogSequence::get(size_t position) void LogSequence::add(IteratorUInt &elements) { - std::vector vector; + std::vector vector; size_t max = 0; while(elements.hasNext()) { @@ -69,7 +70,7 @@ void LogSequence::add(IteratorUInt &elements) if(element>((size_t)-1)) { throw std::out_of_range("Error, saving a value out of range"); } - vector.push_back(element); + vector.push_back(static_cast(element)); max = element > max ? element : max; } diff --git a/libhdt/src/sequence/LogSequence2.hpp b/libhdt/src/sequence/LogSequence2.hpp index be9d15c8..958c1105 100644 --- a/libhdt/src/sequence/LogSequence2.hpp +++ b/libhdt/src/sequence/LogSequence2.hpp @@ -1,9 +1,10 @@ /* * File: LogSequence2.hpp - * Last modified: $Date: 2011-08-21 05:35:30 +0100 (dom, 21 ago 2011) $ + * Last modified: $Date$ * Revision: $Revision: 180 $ - * Last modified by: $Author: mario.arias $ + * Last modified by: $Author$ * + * Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) * Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto * All rights reserved. * @@ -75,11 +76,14 @@ class LogSequence2 : public IntSequence { size_t i=bitPos/W; size_t j=bitPos%W; size_t result; + size_t value{}; + memcpy(&value, &data[i], sizeof(value)); if (j+bitsField <= W) { - result = (data[i] << (W-j-bitsField)) >> (W-bitsField); + result = (value << (W-j-bitsField)) >> (W-bitsField); } else { - result = data[i] >> j; - result = result | (data[i+1] << ( (W<<1) -j-bitsField)) >> (W-bitsField); + result = value >> j; + memcpy(&value, &data[i+1], sizeof(value)); + result = result | (value << ( (W<<1) -j-bitsField)) >> (W-bitsField); } return result; } diff --git a/libhdt/src/triples/BitmapTriplesIterators.cpp b/libhdt/src/triples/BitmapTriplesIterators.cpp index 92c0be6e..e9309967 100644 --- a/libhdt/src/triples/BitmapTriplesIterators.cpp +++ b/libhdt/src/triples/BitmapTriplesIterators.cpp @@ -93,20 +93,42 @@ void BitmapTriplesSearchIterator::findRange() // S X X if(patY!=0) { // S P X - try { - minY = adjY.find(patX-1, patY); + minY = adjY.find(patX-1, patY); + if (minY < static_cast(-1)) + { maxY = minY+1; - if(patZ!=0) { + if(patZ!=0) + { // S P O minZ = adjZ.find(minY,patZ); - maxZ = minZ+1; - } else { + if (minZ < static_cast(-1)) + { + maxZ = minZ+1; + } + else + { + // Item not found in list, no results. + minY = minZ = maxY = maxZ = 0; + } + } + else + { // S P ? minZ = adjZ.find(minY); - maxZ = adjZ.last(minY)+1; - //maxZ = adjZ.findNext(minZ); + if (minZ < static_cast(-1)) + { + maxZ = adjZ.last(minY)+1; + //maxZ = adjZ.findNext(minZ); + } + else + { + // Item not found in list, no results. + minY = minZ = maxY = maxZ = 0; + } } - } catch (std::exception& e) { + } + else + { // Item not found in list, no results. minY = minZ = maxY = maxZ = 0; } diff --git a/libhdt/src/util/fileUtil.cpp b/libhdt/src/util/fileUtil.cpp index d3decef3..3ee1115e 100644 --- a/libhdt/src/util/fileUtil.cpp +++ b/libhdt/src/util/fileUtil.cpp @@ -1,9 +1,10 @@ /* * File: StopWatch.hpp - * Last modified: $Date: 2011-08-21 05:35:30 +0100 (dom, 21 ago 2011) $ + * Last modified: $Date$ * Revision: $Revision: 180 $ - * Last modified by: $Author: mario.arias $ + * Last modified by: $Author$ * + * Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) * Copyright (C) 2012, Mario Arias * All rights reserved. * @@ -187,6 +188,7 @@ DecompressStream::DecompressStream(const char *fileName) : in(NULL), filePipe(NU #ifdef HAVE_LIBZ in = gzStream = new igzstream(fileName); #else + close(); throw std::runtime_error("Support for GZIP was not compiled in this version. Please Decompress the file before importing it."); #endif } @@ -206,6 +208,7 @@ DecompressStream::DecompressStream(const char *fileName) : in(NULL), filePipe(NU if(pipeCommand.length()>0) { pipeCommand.append(fileName); if ((filePipe=popen(pipeCommand.c_str(),"r")) == NULL) { + close(); cerr << "Error creating pipe for command " << pipeCommand << endl; throw std::runtime_error("popen() failed to create pipe"); } @@ -217,20 +220,52 @@ DecompressStream::DecompressStream(const char *fileName) : in(NULL), filePipe(NU if (!in->good()) { + close(); cerr << "Error opening file " << fileName << " for parsing " << endl; throw std::runtime_error("Error opening file for parsing"); } #endif } +DecompressStream::DecompressStream(const char *buffer, size_t len) : in(NULL), filePipe(NULL), fileStream(NULL) +{ +#ifdef HAVE_LIBZ + gzStream = NULL; +#endif + + in = new memstream(buffer, len); + + if (!in->good()) + { + close(); + cerr << "Error creating memory stream for parsing " << endl; + throw std::runtime_error("Error creating memory stream for parsing"); + } +} + +DecompressStream::~DecompressStream() { + close(); +} + void DecompressStream::close() { - if(fileStream) fileStream->close(); + if(fileStream) { + fileStream->close(); + fileStream = nullptr; + } #ifndef WIN32 - if(filePipe) pclose(filePipe); + if(filePipe) { + pclose(filePipe); + filePipe = nullptr; + } #endif #ifdef HAVE_LIBZ - if(gzStream) gzStream->close(); + if(gzStream) { + gzStream->close(); + gzStream = nullptr; + } #endif - delete in; - in=NULL; + if (in) { + delete in; + in=NULL; + } } diff --git a/libhdt/src/util/fileUtil.hpp b/libhdt/src/util/fileUtil.hpp index c3e7a5cd..023255cd 100644 --- a/libhdt/src/util/fileUtil.hpp +++ b/libhdt/src/util/fileUtil.hpp @@ -1,9 +1,9 @@ /* * File: StopWatch.hpp - * Last modified: $Date: 2011-08-21 05:35:30 +0100 (dom, 21 ago 2011) $ + * Last modified: $Date$ * Revision: $Revision: 180 $ - * Last modified by: $Author: mario.arias $ * + * Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) * Copyright (C) 2012, Mario Arias * All rights reserved. * @@ -36,6 +36,7 @@ #include "../third/gzstream.h" #include "../third/fdstream.hpp" +#include "../third/memstream.hpp" #include @@ -61,6 +62,8 @@ class DecompressStream { public: DecompressStream(const char *fileName); + DecompressStream(const char *buffer, size_t len); + ~DecompressStream(); std::istream *getStream() { return in; } diff --git a/libhdt/src/util/filemap.cpp b/libhdt/src/util/filemap.cpp index 7d6ca131..ee623d56 100644 --- a/libhdt/src/util/filemap.cpp +++ b/libhdt/src/util/filemap.cpp @@ -1,9 +1,10 @@ /* * File: mmap.cpp - * Last modified: $Date: 2012-09-19 12:02:39 +0100 (mié, 19 sep 2012) $ + * Last modified: $Date$ * Revision: $Revision: 278 $ - * Last modified by: $Author: mario.arias $ + * Last modified by: $Author$ * + * Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) * Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto * All rights reserved. * @@ -117,7 +118,7 @@ FileMap::FileMap(const char *fileName) : fd(0), ptr(NULL) { } // Mark as needed so the OS keeps as much as possible in memory - madvise((void*)ptr, mappedSize, MADV_WILLNEED); + posix_madvise((void*)ptr, mappedSize, POSIX_MADV_WILLNEED); #endif } diff --git a/libhdt/tests/Makefile.am b/libhdt/tests/Makefile.am index 01280b76..5932643d 100644 --- a/libhdt/tests/Makefile.am +++ b/libhdt/tests/Makefile.am @@ -44,9 +44,4 @@ AM_CPPFLAGS = -I@top_srcdir@/libhdt/include $(WARN_CFLAGS) $(EXTRAFLAGS) AM_LDFLAGS = $(SERD_LIBS) $(ZLIB_LIBS) $(KYOTO_LIBS) LDADD = ../libhdt.la -if WANTS_LIBCDS -AM_CPPFLAGS += -DHAVE_CDS -I$(top_builddir)/libcds/include -LDADD += $(top_builddir)/libcds/libcds.la -endif - TESTS = $(check_PROGRAMS) diff --git a/libhdt/third/memstream.hpp b/libhdt/third/memstream.hpp new file mode 100644 index 00000000..6af0fcd4 --- /dev/null +++ b/libhdt/third/memstream.hpp @@ -0,0 +1,78 @@ +/* + * File: HDTManager.hpp + * Last modified: $Date$ + * Revision: $Revision: 1 $ + * Last modified by: $Author$ + * + * Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * All rights reserved. + * + * 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. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General License for more details. + * + * 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 + * + */ + +#ifndef LIBHDT_THIRD_MEMSTREAM_H +#define LIBHDT_THIRD_MEMSTREAM_H + +#include +#include +#include +// for EOF: +#include +// for memmove(): +#include + + +// low-level read and write functions +#ifdef _MSC_VER +# include +#else +# include +#endif + +class memstream : public std::istream { +public: + memstream(const char* buffer, size_t size) + : std::istream(&_buffer), _buffer(buffer, size) { + rdbuf(&_buffer); + } + +private: + class Buffer : public std::streambuf { + public: + Buffer(const char* buffer, size_t size) { + setg(const_cast(buffer), const_cast(buffer), const_cast(buffer + size)); + } + + std::streampos seekoff(std::streamoff off, std::ios_base::seekdir way, std::ios_base::openmode which) override { + if (way == std::ios_base::cur) { + gbump(static_cast(off)); + } else if (way == std::ios_base::end) { + setg(eback(), egptr() + off, egptr()); + } else if (way == std::ios_base::beg) { + setg(eback(), eback() + off, egptr()); + } + return gptr() - eback(); + } + + std::streampos seekpos(std::streampos sp, std::ios_base::openmode which) override { + return seekoff(sp, std::ios_base::beg, which); + } + }; + + Buffer _buffer; +}; + +#endif // LIBHDT_THIRD_MEMSTREAM_H diff --git a/libhdt/tools/Makefile.am b/libhdt/tools/Makefile.am index 5c909bc2..1b8a7ffe 100644 --- a/libhdt/tools/Makefile.am +++ b/libhdt/tools/Makefile.am @@ -5,8 +5,3 @@ AM_DEFAULT_SOURCE_EXT = .cpp AM_CPPFLAGS = -I@top_srcdir@/libhdt/include $(WARN_CFLAGS) $(EXTRAFLAGS) AM_LDFLAGS = $(SERD_LIBS) $(ZLIB_LIBS) $(KYOTO_LIBS) LDADD = ../libhdt.la - -if WANTS_LIBCDS -AM_CPPFLAGS += -DHAVE_CDS -I$(top_builddir)/libcds/include -LDADD += $(top_builddir)/libcds/libcds.la -endif diff --git a/libhdt/tools/hdt2rdf.cpp b/libhdt/tools/hdt2rdf.cpp index c394ad66..69e1863a 100644 --- a/libhdt/tools/hdt2rdf.cpp +++ b/libhdt/tools/hdt2rdf.cpp @@ -1,9 +1,10 @@ /* - * File: HDTEnums.cpp - * Last modified: $Date: 2012-08-13 23:00:07 +0100 (lun, 13 ago 2012) $ + * File: hdt2rdf.cpp + * Last modified: $Date$ * Revision: $Revision: 222 $ - * Last modified by: $Author: mario.arias $ + * Last modified by: $Author$ * + * Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) * Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto * All rights reserved. * @@ -118,7 +119,7 @@ int main(int argc, char **argv) { try { ProgressListener* progress = showProgress ? new StdoutProgressListener() : NULL; - HDT *hdt = HDTManager::mapHDT(inputFile.c_str(), progress); + auto hdt = HDTManager::mapHDT(inputFile.c_str(), progress); if(outputFile!="-") { RDFSerializer *serializer = RDFSerializer::getSerializer(outputFile.c_str(), notation); @@ -129,7 +130,6 @@ int main(int argc, char **argv) { hdt->saveToRDF(*serializer); delete serializer; } - delete hdt; delete progress; } catch (std::exception& e) { cerr << "ERROR: " << e.what() << endl; diff --git a/libhdt/tools/hdtSearch.cpp b/libhdt/tools/hdtSearch.cpp index 0c4a283e..4627e065 100644 --- a/libhdt/tools/hdtSearch.cpp +++ b/libhdt/tools/hdtSearch.cpp @@ -1,9 +1,9 @@ /* - * File: HDTEnums.cpp - * Last modified: $Date: 2012-08-13 23:00:07 +0100 (lun, 13 ago 2012) $ + * File: hdtSearch.cpp + * Last modified: $Date$ * Revision: $Revision: 222 $ - * Last modified by: $Author: mario.arias $ * + * Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) * Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto * All rights reserved. * @@ -174,7 +174,7 @@ int main(int argc, char **argv) { try { StdoutProgressListener prog; - HDT *hdt = HDTManager::mapIndexedHDT(inputFile.c_str(), &prog); + auto hdt = HDTManager::mapIndexedHDT(inputFile.c_str(), &prog); ostream *out; ofstream outF; @@ -188,7 +188,7 @@ int main(int argc, char **argv) { if(query!="") { // Supplied query, search and exit. - iterate(hdt, (char*)query.c_str(), *out, measure, offset); + iterate(hdt.get(), (char*)query.c_str(), *out, measure, offset); } else { // No supplied query, show terminal. char line[1024*10]; @@ -207,7 +207,7 @@ int main(int argc, char **argv) { continue; } - iterate(hdt, line, *out, measure, offset); + iterate(hdt.get(), line, *out, measure, offset); cerr << ">> "; } @@ -216,8 +216,6 @@ int main(int argc, char **argv) { if(outputFile!="") { outF.close(); } - - delete hdt; } catch (std::exception& e) { cerr << "ERROR: " << e.what() << endl; return 1; diff --git a/libhdt/tools/modifyHeader.cpp b/libhdt/tools/modifyHeader.cpp index c3b88a1a..1280c04e 100644 --- a/libhdt/tools/modifyHeader.cpp +++ b/libhdt/tools/modifyHeader.cpp @@ -1,3 +1,33 @@ +/* + * File: modifyHeader.cpp + * Last modified: $Date$ + * Revision: $Revision: 222 $ + * + * Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto + * All rights reserved. + * + * 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. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * 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 + * + * + * Contacting the authors: + * Mario Arias: mario.arias@gmail.com + * Javier D. Fernandez: jfergar@infor.uva.es + * Miguel A. Martinez-Prieto: migumar2@infor.uva.es + * + */ #include #include #include @@ -94,7 +124,7 @@ int main(int argc, char **argv) { try { // LOAD - HDT *hdt = HDTManager::mapHDT(inputFile); + auto hdt = HDTManager::mapHDT(inputFile); // Replace header Header *head = hdt->getHeader(); @@ -127,8 +157,6 @@ int main(int argc, char **argv) { } // SAVE hdt->saveToHDT(outputFile); - - delete hdt; } catch (std::exception& e) { cerr << "ERROR: " << e.what() << endl; return 1; diff --git a/libhdt/tools/rdf2hdt.cpp b/libhdt/tools/rdf2hdt.cpp index 2f60776c..3bb79503 100644 --- a/libhdt/tools/rdf2hdt.cpp +++ b/libhdt/tools/rdf2hdt.cpp @@ -1,9 +1,9 @@ /* * File: rdf2hdt.cpp - * Last modified: $Date: 2012-08-13 23:00:07 +0100 (lun, 13 ago 2012) $ + * Last modified: $Date$ * Revision: $Revision: 222 $ - * Last modified by: $Author: mario.arias $ * + * Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) * Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto * All rights reserved. * @@ -214,7 +214,7 @@ int main(int argc, char **argv) { StopWatch globalTimer; ProgressListener* progress = showProgress ? new StdoutProgressListener() : NULL; - HDT *hdt = HDTManager::generateHDT(inputFile.c_str(), baseUri.c_str(), notation, spec, progress); + auto hdt = HDTManager::generateHDT(inputFile.c_str(), baseUri.c_str(), notation, spec, progress); ofstream out; @@ -229,10 +229,9 @@ int main(int argc, char **argv) { vout << ") System(" << globalTimer.getSystemStr() << ")" << endl; if(generateIndex) { - hdt = HDTManager::indexedHDT(hdt, progress); + HDTManager::indexedHDT(hdt.get(), progress); } - delete hdt; delete progress; } catch (std::exception& e) { cerr << "ERROR: " << e.what() << endl; diff --git a/libhdt/tools/replaceHeader.cpp b/libhdt/tools/replaceHeader.cpp index 868762fe..dac18acf 100644 --- a/libhdt/tools/replaceHeader.cpp +++ b/libhdt/tools/replaceHeader.cpp @@ -1,10 +1,34 @@ /* - * Tutorial01.cpp + * File: replaceHeader.cpp + * Last modified: $Date: 2012-11-29 15:51:00 +0100 (thu, 29 nov 2012) $ + * Revision: $Revision: 222 $ + * Last modified by: $Author: mario.arias $ + * + * Copyright (C) 2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto + * All rights reserved. + * + * 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. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * 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 + * + * + * Contacting the authors: + * Mario Arias: mario.arias@gmail.com + * Javier D. Fernandez: jfergar@infor.uva.es + * Miguel A. Martinez-Prieto: migumar2@infor.uva.es * - * Created on: 02/03/2011 - * Author: mck */ - #include #include #include @@ -42,7 +66,7 @@ int main(int argc, char **argv) { try { // LOAD - HDT *hdt = HDTManager::mapHDT(inputFile); + auto hdt = HDTManager::mapHDT(inputFile); // Replace header Header *head= hdt->getHeader(); @@ -59,7 +83,6 @@ int main(int argc, char **argv) { // SAVE hdt->saveToHDT(outputFile); - delete hdt; } catch (std::exception& e) { cerr << "ERROR: " << e.what() << endl; return 1; diff --git a/m4/ax_cxx_compile_stdcxx.m4 b/m4/ax_cxx_compile_stdcxx.m4 index 5032bba8..9e9eaeda 100644 --- a/m4/ax_cxx_compile_stdcxx.m4 +++ b/m4/ax_cxx_compile_stdcxx.m4 @@ -33,19 +33,18 @@ # Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov # Copyright (c) 2015 Paul Norman # Copyright (c) 2015 Moritz Klammler -# Copyright (c) 2016 Krzesimir Nowak +# Copyright (c) 2016, 2018 Krzesimir Nowak # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 7 +#serial 10 dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro dnl (serial version number 13). -AX_REQUIRE_DEFINED([AC_MSG_WARN]) AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"], [$1], [14], [ax_cxx_compile_alternatives="14 1y"], @@ -61,14 +60,6 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) AC_LANG_PUSH([C++])dnl ac_success=no - AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, - ax_cv_cxx_compile_cxx$1, - [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], - [ax_cv_cxx_compile_cxx$1=yes], - [ax_cv_cxx_compile_cxx$1=no])]) - if test x$ax_cv_cxx_compile_cxx$1 = xyes; then - ac_success=yes - fi m4_if([$2], [noext], [], [dnl if test x$ac_success = xno; then @@ -139,7 +130,6 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl [define if the compiler supports basic C++$1 syntax]) fi AC_SUBST(HAVE_CXX$1) - m4_if([$1], [17], [AC_MSG_WARN([C++17 is not yet standardized, so the checks may change in incompatible ways anytime])]) ]) @@ -587,20 +577,12 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ #error "This is not a C++ compiler" -#elif __cplusplus <= 201402L +#elif __cplusplus < 201703L #error "This is not a C++17 compiler" #else -#if defined(__clang__) - #define REALLY_CLANG -#else - #if defined(__GNUC__) - #define REALLY_GCC - #endif -#endif - #include #include #include @@ -608,16 +590,12 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ namespace cxx17 { -#if !defined(REALLY_CLANG) namespace test_constexpr_lambdas { - // TODO: test it with clang++ from git - constexpr int foo = [](){return 42;}(); } -#endif // !defined(REALLY_CLANG) namespace test::nested_namespace::definitions { @@ -852,12 +830,9 @@ namespace cxx17 } -#if !defined(REALLY_CLANG) namespace test_template_argument_deduction_for_class_templates { - // TODO: test it with clang++ from git - template struct pair { @@ -876,7 +851,6 @@ namespace cxx17 } } -#endif // !defined(REALLY_CLANG) namespace test_non_type_auto_template_parameters { @@ -890,12 +864,9 @@ namespace cxx17 } -#if !defined(REALLY_CLANG) namespace test_structured_bindings { - // TODO: test it with clang++ from git - int arr[2] = { 1, 2 }; std::pair pr = { 1, 2 }; @@ -927,14 +898,10 @@ namespace cxx17 const auto [ x3, y3 ] = f3(); } -#endif // !defined(REALLY_CLANG) -#if !defined(REALLY_CLANG) namespace test_exception_spec_type_system { - // TODO: test it with clang++ from git - struct Good {}; struct Bad {}; @@ -952,7 +919,6 @@ namespace cxx17 static_assert (std::is_same_v); } -#endif // !defined(REALLY_CLANG) namespace test_inline_variables { @@ -977,6 +943,6 @@ namespace cxx17 } // namespace cxx17 -#endif // __cplusplus <= 201402L +#endif // __cplusplus < 201703L ]]) diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4 deleted file mode 100644 index 6826620f..00000000 --- a/m4/gnulib-cache.m4 +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (C) 2002-2014 Free Software Foundation, Inc. -# -# This file is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This file is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this file. If not, see . -# -# As a special exception to the GNU General Public License, -# this file may be distributed as part of a program that -# contains a configuration script generated by Autoconf, under -# the same distribution terms as the rest of that program. -# -# Generated by gnulib-tool. -# -# This file represents the specification of how gnulib-tool is used. -# It acts as a cache: It is written and read by gnulib-tool. -# In projects that use version control, this file is meant to be put under -# version control, like the configure.ac and various Makefile.am files. - - -# Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build --no-conditional-dependencies --no-libtool --macro-prefix=gl warnings - -# Specification in the form of a few gnulib-tool.m4 macro invocations: -gl_LOCAL_DIR([]) -gl_MODULES([ - warnings -]) -gl_AVOID([]) -gl_SOURCE_BASE([lib]) -gl_M4_BASE([m4]) -gl_PO_BASE([]) -gl_DOC_BASE([doc]) -gl_TESTS_BASE([tests]) -gl_LIB([libgnu]) -gl_MAKEFILE_NAME([]) -gl_MACRO_PREFIX([gl]) -gl_PO_DOMAIN([]) -gl_WITNESS_C_MACRO([]) diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 deleted file mode 100644 index 646b818f..00000000 --- a/m4/gnulib-comp.m4 +++ /dev/null @@ -1,205 +0,0 @@ -# DO NOT EDIT! GENERATED AUTOMATICALLY! -# Copyright (C) 2002-2014 Free Software Foundation, Inc. -# -# This file is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This file is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this file. If not, see . -# -# As a special exception to the GNU General Public License, -# this file may be distributed as part of a program that -# contains a configuration script generated by Autoconf, under -# the same distribution terms as the rest of that program. -# -# Generated by gnulib-tool. -# -# This file represents the compiled summary of the specification in -# gnulib-cache.m4. It lists the computed macro invocations that need -# to be invoked from configure.ac. -# In projects that use version control, this file can be treated like -# other built files. - - -# This macro should be invoked from ./configure.ac, in the section -# "Checks for programs", right after AC_PROG_CC, and certainly before -# any checks for libraries, header files, types and library functions. -AC_DEFUN([gl_EARLY], -[ - m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace - m4_pattern_allow([^gl_ES$])dnl a valid locale name - m4_pattern_allow([^gl_LIBOBJS$])dnl a variable - m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable - AC_REQUIRE([gl_PROG_AR_RANLIB]) - # Code from module warnings: -]) - -# This macro should be invoked from ./configure.ac, in the section -# "Check for header files, types and library functions". -AC_DEFUN([gl_INIT], -[ - AM_CONDITIONAL([GL_COND_LIBTOOL], [false]) - gl_cond_libtool=false - gl_libdeps= - gl_ltlibdeps= - gl_m4_base='m4' - m4_pushdef([AC_LIBOBJ], m4_defn([gl_LIBOBJ])) - m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gl_REPLACE_FUNCS])) - m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES])) - m4_pushdef([gl_LIBSOURCES_LIST], []) - m4_pushdef([gl_LIBSOURCES_DIR], []) - gl_COMMON - gl_source_base='lib' - # End of code from modules - m4_ifval(gl_LIBSOURCES_LIST, [ - m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ || - for gl_file in ]gl_LIBSOURCES_LIST[ ; do - if test ! -r ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file ; then - echo "missing file ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file" >&2 - exit 1 - fi - done])dnl - m4_if(m4_sysval, [0], [], - [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) - ]) - m4_popdef([gl_LIBSOURCES_DIR]) - m4_popdef([gl_LIBSOURCES_LIST]) - m4_popdef([AC_LIBSOURCES]) - m4_popdef([AC_REPLACE_FUNCS]) - m4_popdef([AC_LIBOBJ]) - AC_CONFIG_COMMANDS_PRE([ - gl_libobjs= - gl_ltlibobjs= - if test -n "$gl_LIBOBJS"; then - # Remove the extension. - sed_drop_objext='s/\.o$//;s/\.obj$//' - for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do - gl_libobjs="$gl_libobjs $i.$ac_objext" - gl_ltlibobjs="$gl_ltlibobjs $i.lo" - done - fi - AC_SUBST([gl_LIBOBJS], [$gl_libobjs]) - AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs]) - ]) - gltests_libdeps= - gltests_ltlibdeps= - m4_pushdef([AC_LIBOBJ], m4_defn([gltests_LIBOBJ])) - m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gltests_REPLACE_FUNCS])) - m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES])) - m4_pushdef([gltests_LIBSOURCES_LIST], []) - m4_pushdef([gltests_LIBSOURCES_DIR], []) - gl_COMMON - gl_source_base='tests' -changequote(,)dnl - gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS -changequote([, ])dnl - AC_SUBST([gltests_WITNESS]) - gl_module_indicator_condition=$gltests_WITNESS - m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$gl_module_indicator_condition]) - m4_popdef([gl_MODULE_INDICATOR_CONDITION]) - m4_ifval(gltests_LIBSOURCES_LIST, [ - m4_syscmd([test ! -d ]m4_defn([gltests_LIBSOURCES_DIR])[ || - for gl_file in ]gltests_LIBSOURCES_LIST[ ; do - if test ! -r ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file ; then - echo "missing file ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file" >&2 - exit 1 - fi - done])dnl - m4_if(m4_sysval, [0], [], - [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) - ]) - m4_popdef([gltests_LIBSOURCES_DIR]) - m4_popdef([gltests_LIBSOURCES_LIST]) - m4_popdef([AC_LIBSOURCES]) - m4_popdef([AC_REPLACE_FUNCS]) - m4_popdef([AC_LIBOBJ]) - AC_CONFIG_COMMANDS_PRE([ - gltests_libobjs= - gltests_ltlibobjs= - if test -n "$gltests_LIBOBJS"; then - # Remove the extension. - sed_drop_objext='s/\.o$//;s/\.obj$//' - for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do - gltests_libobjs="$gltests_libobjs $i.$ac_objext" - gltests_ltlibobjs="$gltests_ltlibobjs $i.lo" - done - fi - AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs]) - AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs]) - ]) - LIBGNU_LIBDEPS="$gl_libdeps" - AC_SUBST([LIBGNU_LIBDEPS]) - LIBGNU_LTLIBDEPS="$gl_ltlibdeps" - AC_SUBST([LIBGNU_LTLIBDEPS]) -]) - -# Like AC_LIBOBJ, except that the module name goes -# into gl_LIBOBJS instead of into LIBOBJS. -AC_DEFUN([gl_LIBOBJ], [ - AS_LITERAL_IF([$1], [gl_LIBSOURCES([$1.c])])dnl - gl_LIBOBJS="$gl_LIBOBJS $1.$ac_objext" -]) - -# Like AC_REPLACE_FUNCS, except that the module name goes -# into gl_LIBOBJS instead of into LIBOBJS. -AC_DEFUN([gl_REPLACE_FUNCS], [ - m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl - AC_CHECK_FUNCS([$1], , [gl_LIBOBJ($ac_func)]) -]) - -# Like AC_LIBSOURCES, except the directory where the source file is -# expected is derived from the gnulib-tool parameterization, -# and alloca is special cased (for the alloca-opt module). -# We could also entirely rely on EXTRA_lib..._SOURCES. -AC_DEFUN([gl_LIBSOURCES], [ - m4_foreach([_gl_NAME], [$1], [ - m4_if(_gl_NAME, [alloca.c], [], [ - m4_define([gl_LIBSOURCES_DIR], [lib]) - m4_append([gl_LIBSOURCES_LIST], _gl_NAME, [ ]) - ]) - ]) -]) - -# Like AC_LIBOBJ, except that the module name goes -# into gltests_LIBOBJS instead of into LIBOBJS. -AC_DEFUN([gltests_LIBOBJ], [ - AS_LITERAL_IF([$1], [gltests_LIBSOURCES([$1.c])])dnl - gltests_LIBOBJS="$gltests_LIBOBJS $1.$ac_objext" -]) - -# Like AC_REPLACE_FUNCS, except that the module name goes -# into gltests_LIBOBJS instead of into LIBOBJS. -AC_DEFUN([gltests_REPLACE_FUNCS], [ - m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl - AC_CHECK_FUNCS([$1], , [gltests_LIBOBJ($ac_func)]) -]) - -# Like AC_LIBSOURCES, except the directory where the source file is -# expected is derived from the gnulib-tool parameterization, -# and alloca is special cased (for the alloca-opt module). -# We could also entirely rely on EXTRA_lib..._SOURCES. -AC_DEFUN([gltests_LIBSOURCES], [ - m4_foreach([_gl_NAME], [$1], [ - m4_if(_gl_NAME, [alloca.c], [], [ - m4_define([gltests_LIBSOURCES_DIR], [tests]) - m4_append([gltests_LIBSOURCES_LIST], _gl_NAME, [ ]) - ]) - ]) -]) - -# This macro records the list of files which have been installed by -# gnulib-tool and may be removed by future gnulib-tool invocations. -AC_DEFUN([gl_FILE_LIST], [ - lib/dummy.c - m4/00gnulib.m4 - m4/gnulib-common.m4 - m4/onceonly.m4 - m4/warnings.m4 -]) diff --git a/m4/onceonly.m4 b/m4/onceonly.m4 deleted file mode 100644 index 15f94cef..00000000 --- a/m4/onceonly.m4 +++ /dev/null @@ -1,104 +0,0 @@ -# onceonly.m4 serial 9 -dnl Copyright (C) 2002-2003, 2005-2006, 2008-2014 Free Software Foundation, -dnl Inc. -dnl -dnl This file is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 3 of the License, or -dnl (at your option) any later version. -dnl -dnl This file is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with this file. If not, see . -dnl -dnl As a special exception to the GNU General Public License, -dnl this file may be distributed as part of a program -dnl that contains a configuration script generated by Autoconf, under -dnl the same distribution terms as the rest of that program. - -dnl This file defines some "once only" variants of standard autoconf macros. -dnl AC_CHECK_HEADERS_ONCE like AC_CHECK_HEADERS -dnl AC_CHECK_FUNCS_ONCE like AC_CHECK_FUNCS -dnl AC_CHECK_DECLS_ONCE like AC_CHECK_DECLS -dnl AC_REQUIRE([AC_FUNC_STRCOLL]) like AC_FUNC_STRCOLL -dnl The advantage is that the check for each of the headers/functions/decls -dnl will be put only once into the 'configure' file. It keeps the size of -dnl the 'configure' file down, and avoids redundant output when 'configure' -dnl is run. -dnl The drawback is that the checks cannot be conditionalized. If you write -dnl if some_condition; then gl_CHECK_HEADERS(stdlib.h); fi -dnl inside an AC_DEFUNed function, the gl_CHECK_HEADERS macro call expands to -dnl empty, and the check will be inserted before the body of the AC_DEFUNed -dnl function. - -dnl The original code implemented AC_CHECK_HEADERS_ONCE and AC_CHECK_FUNCS_ONCE -dnl in terms of AC_DEFUN and AC_REQUIRE. This implementation uses diversions to -dnl named sections DEFAULTS and INIT_PREPARE in order to check all requested -dnl headers at once, thus reducing the size of 'configure'. It is known to work -dnl with autoconf 2.57..2.62 at least . The size reduction is ca. 9%. - -dnl Autoconf version 2.59 plus gnulib is required; this file is not needed -dnl with Autoconf 2.60 or greater. But note that autoconf's implementation of -dnl AC_CHECK_DECLS_ONCE expects a comma-separated list of symbols as first -dnl argument! -AC_PREREQ([2.59]) - -# AC_CHECK_HEADERS_ONCE(HEADER1 HEADER2 ...) is a once-only variant of -# AC_CHECK_HEADERS(HEADER1 HEADER2 ...). -AC_DEFUN([AC_CHECK_HEADERS_ONCE], [ - : - m4_foreach_w([gl_HEADER_NAME], [$1], [ - AC_DEFUN([gl_CHECK_HEADER_]m4_quote(m4_translit(gl_HEADER_NAME, - [./-], [___])), [ - m4_divert_text([INIT_PREPARE], - [gl_header_list="$gl_header_list gl_HEADER_NAME"]) - gl_HEADERS_EXPANSION - AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_HEADER_NAME])), - [Define to 1 if you have the <]m4_defn([gl_HEADER_NAME])[> header file.]) - ]) - AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(m4_translit(gl_HEADER_NAME, - [./-], [___]))) - ]) -]) -m4_define([gl_HEADERS_EXPANSION], [ - m4_divert_text([DEFAULTS], [gl_header_list=]) - AC_CHECK_HEADERS([$gl_header_list]) - m4_define([gl_HEADERS_EXPANSION], []) -]) - -# AC_CHECK_FUNCS_ONCE(FUNC1 FUNC2 ...) is a once-only variant of -# AC_CHECK_FUNCS(FUNC1 FUNC2 ...). -AC_DEFUN([AC_CHECK_FUNCS_ONCE], [ - : - m4_foreach_w([gl_FUNC_NAME], [$1], [ - AC_DEFUN([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]), [ - m4_divert_text([INIT_PREPARE], - [gl_func_list="$gl_func_list gl_FUNC_NAME"]) - gl_FUNCS_EXPANSION - AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_FUNC_NAME])), - [Define to 1 if you have the ']m4_defn([gl_FUNC_NAME])[' function.]) - ]) - AC_REQUIRE([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME])) - ]) -]) -m4_define([gl_FUNCS_EXPANSION], [ - m4_divert_text([DEFAULTS], [gl_func_list=]) - AC_CHECK_FUNCS([$gl_func_list]) - m4_define([gl_FUNCS_EXPANSION], []) -]) - -# AC_CHECK_DECLS_ONCE(DECL1 DECL2 ...) is a once-only variant of -# AC_CHECK_DECLS(DECL1, DECL2, ...). -AC_DEFUN([AC_CHECK_DECLS_ONCE], [ - : - m4_foreach_w([gl_DECL_NAME], [$1], [ - AC_DEFUN([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]), [ - AC_CHECK_DECLS(m4_defn([gl_DECL_NAME])) - ]) - AC_REQUIRE([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME])) - ]) -]) diff --git a/rdf2hdt/.gitignore b/rdf2hdt/.gitignore deleted file mode 100755 index fab7372d..00000000 --- a/rdf2hdt/.gitignore +++ /dev/null @@ -1,73 +0,0 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc -*.o -*.obj -*.orig -*.rej -*.so -*.so.* -*_pch.h.cpp -*_resource.rc -*.qm -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res -*.rc -/.qmake.cache -/.qmake.stash - -# qtcreator generated files -*.pro.user* - -# xemacs temporary files -*.flc - -# Vim temporary files -.*.swp - -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* - -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe - diff --git a/rdf2hdt/rdf2hdt.cpp b/rdf2hdt/rdf2hdt.cpp deleted file mode 100755 index 55d3cef4..00000000 --- a/rdf2hdt/rdf2hdt.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - * File: rdf2hdt.cpp - * Last modified: $Date: 2012-08-13 23:00:07 +0100 (lun, 13 ago 2012) $ - * Revision: $Revision: 222 $ - * Last modified by: $Author: mario.arias $ - * - * Copyright (C) 2012, Mario Arias, Javier D. Fernandez, Miguel A. Martinez-Prieto - * All rights reserved. - * - * 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. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * 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 - * - * - * Contacting the authors: - * Mario Arias: mario.arias@gmail.com - * Javier D. Fernandez: jfergar@infor.uva.es - * Miguel A. Martinez-Prieto: migumar2@infor.uva.es - * - */ - -#include -#include -#include -#include -#include -#include -#include - -//#include - -#include "../src/triples/PlainTriples.hpp" -#include "../src/util/StopWatch.hpp" - -using namespace hdt; -using namespace std; - -void help() { - cout << "$ rdf2hdt [options] " << endl; - cout << "\t-h\t\t\tThis help" << endl; - cout << "\t-i\t\tAlso generate index to solve all triple patterns." << endl; - cout << "\t-c\t\tHDT Config options file" << endl; - cout << "\t-o\t\tHDT Additional options (option1=value1;option2=value2;...)" << endl; - cout << "\t-f\t\tFormat of the RDF input (nquads,nq,ntriples,nt,trig,turtle,ttl)" << endl; - cout << "\t-B\t\"\"\tBase URI of the dataset." << endl; - cout << "\t-V\tPrints the HDT version number." << endl; - //cout << "\t-v\tVerbose output" << endl; -} - -int main(int argc, char **argv) { - string inputFile; - string outputFile; - bool verbose=false; // NOTE: generates -Wunused-but-set-variable warning. - bool generateIndex=false; - string configFile; - string options; - string rdfFormat; - string baseUri; - - RDFNotation notation = NTRIPLES; - -// int c; -// while( (c = getopt(argc,argv,"c:o:vf:B:i:V"))!=-1) { -// switch(c) { -// case 'c': -// configFile = optarg; -// cout << "Configfile: " << configFile << endl; -// break; -// case 'o': -// options = optarg; -// cout << "Options: " << options << endl; -// break; -// case 'v': -// verbose = true; -// break; -// case 'f': -// rdfFormat = optarg; -// cout << "RDF format: " << rdfFormat << endl; -// break; -// case 'B': -// baseUri = optarg; -// break; -// case 'i': -// generateIndex=true; -// break; -// case 'V': -// cout << HDTVersion::get_version_string(".") << endl; -// return 0; -// default: -// cout << "ERROR: Unknown option" << endl; -// help(); -// return 1; -// } -// } - -// if(argc-optind<2) { -// cout << "ERROR: You must supply an input and output" << endl << endl; -// help(); -// return 1; -// } - - inputFile = argv[1]; - outputFile = argv[2]; - - if(inputFile=="") { - cout << "ERROR: You must supply an RDF input file" << endl << endl; - help(); - return 1; - } - - if(outputFile=="") { - cout << "ERROR: You must supply an HDT output file" << endl << endl; - help(); - return 1; - } - - if(baseUri=="") { - baseUri=""; - } - - if(rdfFormat!="") { - if(rdfFormat=="nquads" || rdfFormat=="nq") { - notation = NQUADS; - } else if(rdfFormat=="ntriples" || rdfFormat=="nt") { - notation = NTRIPLES; - } else if(rdfFormat=="trig") { - notation = TRIG; - } else if(rdfFormat=="turtle" || rdfFormat=="ttl") { - notation = TURTLE; - } else { - cerr << "ERROR: Input format `" << rdfFormat << "' is not supported.\n" - << "Use either of the following:\n" - << "\t- `ntriples' or `nt' for N-Triples\n" - << "\t- `nquads' or `nq' for N-Quads\n" - << "\t- `turtle' or `ttl' for Turtle\n" - << "\t- `trig' for TriG" << endl; - help(); - return 1; - } - } - - // Process - StdoutProgressListener progress; - HDTSpecification spec(configFile); - - spec.setOptions(options); - - try { - // Read RDF - StopWatch globalTimer; - - cout << "HERE: " << endl; - - const char * a = inputFile.c_str(); - const char * b = baseUri.c_str(); - - HDT *hdt = HDTManager::generateHDT(inputFile.c_str(), baseUri.c_str(), notation, spec, NULL); - //HDT *hdt = HDTManager::generateHDT(inputFile.c_str(), baseUri.c_str(), notation, spec, &progress); - - ofstream out; - - // Save HDT - out.open(outputFile.c_str(), ios::out | ios::binary | ios::trunc); - if(!out.good()){ - throw std::runtime_error("Could not open output file."); - } - hdt->saveToHDT(out, &progress); - out.close(); - - globalTimer.stop(); - cout << "HDT Successfully generated. " << endl; - cout << "Total processing time: "; - cout << "Clock(" << globalTimer.getRealStr(); - cout << ") User(" << globalTimer.getUserStr(); - cout << ") System(" << globalTimer.getSystemStr() << ")" << endl; - - if(generateIndex) { - hdt = HDTManager::indexedHDT(hdt, &progress); - } - - delete hdt; - } catch (std::exception& e) { - cerr << "ERROR: " << e.what() << endl; - return 1; - } - -} diff --git a/rdf2hdt/rdf2hdt.pro b/rdf2hdt/rdf2hdt.pro deleted file mode 100755 index f9e63cc3..00000000 --- a/rdf2hdt/rdf2hdt.pro +++ /dev/null @@ -1,15 +0,0 @@ -TEMPLATE = app -CONFIG += console c++11 - -SOURCES += \ - rdf2hdt.cpp - -LIBCDS = ../libcds-v1.0.12 - -# Using Hard-coded Makefile -INCLUDEPATH += $${LIBCDS}/includes ../hdt-lib/include/ . -#LIBS += $${LIBCDS}/lib/libcds.a ../hdt-lib/libhdt.a - - 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" - -PRE_TARGETDEPS += $$LIBS