├── make.bat ├── javacli ├── docs │ ├── package-list │ ├── resources │ │ └── inherit.gif │ ├── index.html │ ├── allclasses-noframe.html │ ├── stylesheet.css │ ├── allclasses-frame.html │ └── javacli │ │ └── package-frame.html ├── jnilocalsock.dll ├── buildlocalsock.bat ├── CliError.java ├── Reference.java ├── ConnectionPool.java └── LocalSocket.java ├── jnicli ├── docs │ ├── package-list │ ├── resources │ │ └── inherit.gif │ ├── packages.html │ ├── index.html │ ├── stylesheet.css │ ├── allclasses-noframe.html │ ├── allclasses-frame.html │ └── jnicli │ │ └── package-frame.html ├── jnicli.dll ├── jnicli.jar ├── compile.bat ├── CliException.java ├── IncrementalCursorForUpdate.java ├── IncrementalCursor.java ├── PrefetchedCursor.java ├── DatabaseSessionClient.java ├── DatabaseSessionServer.java └── Cursor.java ├── Makefile.am ├── javacli.jar ├── jnicli.jar ├── genauto.sh ├── GiST ├── doc │ ├── gist.gif │ ├── contrib.html │ ├── readme.html │ └── index.html ├── HISTORY ├── CONTENTS ├── genparse.bat ├── libGiST │ ├── Makefile │ ├── GiSTpredicate.cpp │ ├── GiSTfile.h │ ├── GiSTcursor.h │ ├── GiSTdb.h │ ├── GiSTstore.h │ ├── GiSTcursor.cpp │ ├── GiSTlist.h │ ├── GiSTdefs.h │ ├── GiSTdb.cpp │ ├── GiSTpath.h │ └── GiST.h ├── tests │ └── runtests.sh ├── BTree │ ├── gram.tab.h │ ├── BT.h │ ├── Makefile │ ├── BTnode.h │ ├── BTpredicate.cpp │ ├── BTree.help │ ├── BTpredicate.h │ ├── command.h │ ├── scan.l │ ├── BTentry.cpp │ └── BTnode.cpp ├── RSTree │ ├── gram.tab.h │ ├── RTnode.h │ ├── RT.h │ ├── Makefile │ ├── GiST.help │ ├── RTpredicate.h │ ├── command.h │ ├── RTpredicate.cpp │ ├── scan.l │ ├── RTree.help │ ├── RTentry.cpp │ └── RT.cpp ├── RTree │ ├── gram.tab.h │ ├── RTentry.cpp │ ├── RT.h │ ├── RTnode.h │ ├── Makefile │ ├── command.h │ ├── RTpredicate.h │ ├── RTpredicate.cpp │ ├── scan.l │ ├── RTree.help │ └── RTnode.cpp ├── README └── Makefile ├── AUTHORS ├── inc ├── wince.h ├── fastdb.h ├── exception.h ├── symtab.h ├── hashtab.h ├── repsock.h ├── unisock.h ├── fastdbShim.h └── wince_time.h ├── ruby ├── clitest.sql └── benchmark.rb ├── clitest.sql ├── runtests.bat ├── COPYING ├── runtests.sh ├── CSharpRemoteCLI ├── AutoincrementAttribute.cs ├── CliError.cs ├── csharpcli.sln ├── ReferencesAttribute.cs ├── Reference.cs ├── ConnectionPool.cs ├── csharpcli.csproj.user └── AssemblyInfo.cs ├── CSharp ├── Makefile ├── FastDbNet.csproj.user ├── CLI-CSharp.sln ├── Test1.csproj.user ├── Test2.csproj.user └── AssemblyInfo.cs ├── clilogin.htm ├── buglogin.htm ├── testddl.sql ├── fastdb4ce └── fastdb4ce.vcw ├── fastdb.dsw ├── src ├── stdtp.cpp ├── forcerecovery.cpp ├── Makefile.am ├── symtab.cpp └── fastdbShim.cpp ├── subsql4ce └── subsql4ce.vcl ├── FastDB.bpg ├── examples ├── testfrag.cpp ├── JniTestIndex.java ├── Makefile.am ├── testidx.cpp ├── JniTestRelations.java ├── testpar.cpp ├── testharr.cpp ├── TestIndex.java ├── testfuzzy.cpp └── testleak.cpp ├── fastdb.spec └── README /make.bat: -------------------------------------------------------------------------------- 1 | nmake -f makefile.mvc %* -------------------------------------------------------------------------------- /javacli/docs/package-list: -------------------------------------------------------------------------------- 1 | javacli 2 | -------------------------------------------------------------------------------- /jnicli/docs/package-list: -------------------------------------------------------------------------------- 1 | jnicli 2 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = src examples 2 | 3 | -------------------------------------------------------------------------------- /javacli.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gavioto/fastdb/HEAD/javacli.jar -------------------------------------------------------------------------------- /jnicli.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gavioto/fastdb/HEAD/jnicli.jar -------------------------------------------------------------------------------- /genauto.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | autoreconf --force --install -I config -I m4 3 | 4 | -------------------------------------------------------------------------------- /GiST/doc/gist.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gavioto/fastdb/HEAD/GiST/doc/gist.gif -------------------------------------------------------------------------------- /jnicli/jnicli.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gavioto/fastdb/HEAD/jnicli/jnicli.dll -------------------------------------------------------------------------------- /jnicli/jnicli.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gavioto/fastdb/HEAD/jnicli/jnicli.jar -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Konstantin Knizhnik 2 | e-mail: knizhnik@garret.ru 3 | Web site: www.garret.ru 4 | -------------------------------------------------------------------------------- /javacli/jnilocalsock.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gavioto/fastdb/HEAD/javacli/jnilocalsock.dll -------------------------------------------------------------------------------- /javacli/docs/resources/inherit.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gavioto/fastdb/HEAD/javacli/docs/resources/inherit.gif -------------------------------------------------------------------------------- /jnicli/docs/resources/inherit.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gavioto/fastdb/HEAD/jnicli/docs/resources/inherit.gif -------------------------------------------------------------------------------- /GiST/HISTORY: -------------------------------------------------------------------------------- 1 | v0.9b1: 2 | First version. 3 | no support for FindMin/GetNext-style traversal 4 | shipped with BTree, RTree, and RSTree demos 5 | -------------------------------------------------------------------------------- /inc/wince.h: -------------------------------------------------------------------------------- 1 | #ifndef __WINCE_H__ 2 | #define __WINCE_H__ 3 | 4 | #include 5 | 6 | #include "wince_time.h" 7 | 8 | #define assert(x) 9 | #define stricmp _stricmp 10 | #define getenv(x) 0 11 | 12 | int abort(); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /jnicli/compile.bat: -------------------------------------------------------------------------------- 1 | if not defined JAVA_HOME set JAVA_HOME=\jdk1.3 2 | 3 | javac -g *.java 4 | jar cvf jnicli.jar *.class 5 | 6 | cl -LD -Zi -W3 -EHsc -MTd -I../inc -I"%JAVA_HOME%\include" -I"%JAVA_HOME%\include\win32" jnicli.cpp ..\fastdb.lib "%JAVA_HOME%\lib\jvm.lib" 7 | -------------------------------------------------------------------------------- /javacli/buildlocalsock.bat: -------------------------------------------------------------------------------- 1 | if not defined JAVA_HOME set JAVA_HOME=\jdk1.3 2 | if not defined PACKAGE_NAME set PACKAGE_NAME=javacli 3 | 4 | cl -LD -Zi -W3 -MTd -I.. -DPACKAGE_NAME="\"%PACKAGE_NAME%\"" -I%JAVA_HOME%\include -I%JAVA_HOME%\include\win32 jnilocalsock.cpp ..\gigabase.lib wsock32.lib %JAVA_HOME%\lib\jvm.lib 5 | 6 | -------------------------------------------------------------------------------- /ruby/clitest.sql: -------------------------------------------------------------------------------- 1 | open 'clitest'; 2 | create table Person(name string, 3 | salary int8, 4 | address string, 5 | rating real8, 6 | pets array of string, 7 | subordinates array of reference to Person); 8 | create index on Person.salary; 9 | create hash on Person.name; 10 | start server 'localhost:6100' 4 11 | -------------------------------------------------------------------------------- /clitest.sql: -------------------------------------------------------------------------------- 1 | open 'clitest'; 2 | create table persons (name string, 3 | salary int8, 4 | address string, 5 | weight real8, 6 | subordinates array of reference to persons, 7 | blob array of int1); 8 | create index on persons.salary; 9 | create hash on persons.name; 10 | start server 'localhost:6100' 8 11 | -------------------------------------------------------------------------------- /runtests.bat: -------------------------------------------------------------------------------- 1 | del *.fdb 2 | localclitest 3 | testalter 4 | testconcur 5 | testddl 6 | subsql testddl.sql 7 | testddl 8 | testfuzzy 9 | testidx 10 | testiref 11 | testleak 12 | testfrag 13 | testperf 14 | testindex 15 | testraw 16 | testsync 17 | testspat 18 | testarridx 19 | testudt 20 | testwcs 21 | testtimseseries 22 | testpar 23 | start testconc update 24 | start testconc inspect 2 25 | 26 | 27 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 2 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 3 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 4 | AUTHOR OF THIS SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 5 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 6 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 7 | -------------------------------------------------------------------------------- /runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | rm -f *.odb 4 | ./localclitest 5 | ./testalter 6 | ./testconcur 7 | ./testddl 8 | ./subsql testddl.sql 9 | ./testddl 10 | ./testfuzzy 11 | ./testidx 12 | ./testiref 13 | ./testleak 14 | ./testfrag 15 | ./testperf 16 | ./testindex 17 | ./testraw 18 | ./testsync 19 | ./testspat 20 | ./testarridx 21 | ./testudt 22 | ./testwcs 23 | ./testtimeseries 24 | ./testpar 25 | ./testconc update & ./testconc inspect 2 26 | 27 | 28 | -------------------------------------------------------------------------------- /CSharpRemoteCLI/AutoincrementAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace CSharpCLI 4 | { 5 | 6 | /// 7 | /// Class representing autoincrement attribute 8 | /// 9 | [AttributeUsage(AttributeTargets.Field)] 10 | public class AutoincrementAttribute : Attribute 11 | { 12 | /// 13 | /// Default constructor 14 | /// 15 | public AutoincrementAttribute() {} 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /javacli/CliError.java: -------------------------------------------------------------------------------- 1 | package javacli; 2 | 3 | /** 4 | * Exception thrown by Gigabase CLI implementation. 5 | * It is derived from RuntimeException class so programmer should not delare 6 | * this exception in throws part. 7 | */ 8 | public class CliError extends RuntimeException { 9 | /** 10 | * Constructor of the exception object. 11 | * @param msg message describing the reason of the fault 12 | */ 13 | public CliError(String msg) { 14 | super(msg); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /jnicli/CliException.java: -------------------------------------------------------------------------------- 1 | package jnicli; 2 | 3 | /** 4 | * Exception thrown by Gigabase CLI implementation. 5 | * It is derived from RuntimeException class so programmer should not delare 6 | * this exception in throws part. 7 | */ 8 | public class CliException extends RuntimeException { 9 | /** 10 | * Constructor of the exception object. 11 | * @param msg message describing the reason of the fault 12 | */ 13 | public CliException(String msg) { 14 | super(msg); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /GiST/CONTENTS: -------------------------------------------------------------------------------- 1 | BTree/ -- source code for the BTree example application 2 | CONTENTS -- this file 3 | Makefile -- Makefile used for building under UN*X 4 | README -- licensing information 5 | RSTree/ -- source code for the RSTree example application 6 | RTree/ -- source code for the RTree example application 7 | doc/ -- documentation in HTML format 8 | genparse.bat* -- batch file used for building under MS Windows 9 | libGiST/ -- the libGiST source 10 | tests/ -- regression test suite 11 | -------------------------------------------------------------------------------- /CSharpRemoteCLI/CliError.cs: -------------------------------------------------------------------------------- 1 | namespace CSharpCLI { 2 | 3 | using System; 4 | 5 | /// 6 | /// Exception thrown by Gigabase CLI implementation. 7 | /// It is derived from RuntimeException class so programmer should not delare 8 | /// this exception in throws part. 9 | /// 10 | public class CliError : Exception { 11 | /// 12 | /// Constructor of the exception object. 13 | /// 14 | /// message describing the reason of the fault 15 | /// 16 | public CliError(string msg) : base(msg) {} 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /GiST/genparse.bat: -------------------------------------------------------------------------------- 1 | SET BISON_SIMPLE=\bin\bison.simple 2 | SET BISON_HAIRY=\bin\bison.hairy 3 | 4 | cd RTree 5 | del gram.tab.cpp 6 | bison -dv gram.y 7 | ren gram_tab.c gram.tab.cpp 8 | ren gram_tab.h gram.tab.h 9 | flex -It scan.l > scan.cpp 10 | 11 | cd ..\RSTree 12 | del gram.tab.cpp 13 | bison -dv gram.y 14 | ren gram_tab.c gram.tab.cpp 15 | ren gram_tab.h gram.tab.h 16 | flex -It scan.l > scan.cpp 17 | 18 | cd ..\BTree 19 | del gram.tab.cpp 20 | bison -dv gram.y 21 | ren gram_tab.c gram.tab.cpp 22 | ren gram_tab.h gram.tab.h 23 | flex -It scan.l > scan.cpp 24 | 25 | cd .. 26 | 27 | -------------------------------------------------------------------------------- /jnicli/IncrementalCursorForUpdate.java: -------------------------------------------------------------------------------- 1 | package jnicli; 2 | import java.util.*; 3 | 4 | class IncrementalCursorForUpdate extends IncrementalCursor { 5 | IncrementalCursorForUpdate(DatabaseJNI db, long cursor, ClassDescriptor desc) { 6 | super(db, cursor, desc); 7 | } 8 | 9 | public Object nextElement() { 10 | return currObj = super.nextElement(); 11 | } 12 | 13 | public void update() { 14 | if (currOid == 0) { 15 | throw new NoSuchElementException(); 16 | } 17 | db.update(currOid, currObj); 18 | } 19 | 20 | Object currObj; 21 | } 22 | -------------------------------------------------------------------------------- /CSharp/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | CC=mcs 3 | # 4 | CFLAGS= -unsafe 5 | DEBUG= -g 6 | # 7 | LIB_TARGET=FastDbNet 8 | LIB_FILES=FastDbCli.cs FastDbFields.cs FastDbCommand.cs FastDbConnection.cs AssemblyInfo.cs 9 | LIB_DEFS= -define:LINUX 10 | # 11 | all: $(LIB_TARGET) test 12 | 13 | clean: 14 | rm $(LIB_TARGET).dll *.fdb 15 | 16 | $(LIB_TARGET): $(LIB_FILES) 17 | $(CC) $(CFLAGS) $(DEBUG) -target:library -out:$(LIB_TARGET).dll $(LIB_DEFS) $(LIB_FILES) 18 | 19 | test: $(LIB_TARGET).dll TestIndex.cs 20 | $(CC) $(DEBUG) -target:exe -out:TestIndex.exe -lib:./ -reference:$(LIB_TARGET).dll TestIndex.cs 21 | 22 | # 23 | .SUFFIXES : .cs 24 | -------------------------------------------------------------------------------- /GiST/libGiST/Makefile: -------------------------------------------------------------------------------- 1 | LIBRARY = libGiST.a 2 | 3 | SRCS = GiSTnode.cpp GiST.cpp GiSTfile.cpp GiSTpredicate.cpp GiSTcursor.cpp GiSTdb.cpp 4 | 5 | OBJS = $(SRCS:.cpp=.o) 6 | 7 | DEST = /usr/local/lib 8 | 9 | %.o: %.cpp 10 | $(CC) -c $(CFLAGS) $(INCS) $*.cpp 11 | 12 | $(LIBRARY): .depend $(OBJS) 13 | rm -f $(LIBRARY) 14 | ar rs $(LIBRARY) $(OBJS) 15 | 16 | clean: 17 | rm -f $(OBJS) $(LIBRARY) *~ #*# *pure* 18 | 19 | depend: 20 | makedepend $(DEFINES) $(INCS) $(SRCS) 21 | 22 | .depend: 23 | $(MAKE) depend 24 | touch .depend 25 | 26 | install: $(PROGRAM) 27 | echo Installing $(PROGRAM) in $(DEST) 28 | install -s $(PROGRAM) $(DEST) 29 | 30 | -------------------------------------------------------------------------------- /GiST/tests/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/csh 2 | echo "These tests may take a while. Be patient." 3 | if (-e BTree.out) rm BTree.out 4 | echo "Running BTree test..." 5 | ../BTree/BTree < words.sql > BTree.out 6 | diff BTree.out BTree.std 7 | rm BTree.out 8 | rm wordtmp 9 | if (-e RTree.out) rm RTree.out 10 | echo "Running RTree test..." 11 | ../RTree/RTree < boxes.sql > RTree.out 12 | diff RTree.out RTree.std 13 | rm RTree.out 14 | rm boxtmp 15 | if (-e RSTree.out) rm RSTree.out 16 | echo "Running RSTree test..." 17 | ../RSTree/RSTree < boxes.sql > RSTree.out 18 | sed s/RST/RT/g RSTree.out | sed "s/R.-Tree/R-Tree/g" | diff - RTree.std 19 | rm RSTree.out 20 | rm boxtmp 21 | -------------------------------------------------------------------------------- /GiST/libGiST/GiSTpredicate.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // GiSTpredicate.cpp 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/libGiST/GiSTpredicate.cpp,v 1.1 2007/07/18 20:45:50 knizhnik Exp $ 7 | 8 | #include "GiST.h" 9 | 10 | int PtrPredicate::Consistent(const GiSTentry& entry) const 11 | { 12 | return !entry.IsLeaf() || entry.Ptr() == page; 13 | } 14 | 15 | GiSTobject* PtrPredicate::Copy() const 16 | { 17 | return new PtrPredicate(page); 18 | } 19 | 20 | #ifdef PRINTING_OBJECTS 21 | void PtrPredicate::Print(ostream& os) const 22 | { 23 | os << "ptr = " << page; 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /clilogin.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Client Database 5 | 6 | 7 |

Client Database

8 |
9 | 10 | 11 | 12 | 13 | 15 | 16 | 17 | 19 | 20 |
User: 14 |
Password: 18 |

21 | 22 |

23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /buglogin.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Bug Tracking Database 5 | 6 | 7 |

Bug Tracking Database

8 |
9 | 10 | 11 | 12 | 13 | 15 | 16 | 17 | 19 | 20 |
User: 14 |
Password: 18 |

21 | 22 |

23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /GiST/BTree/gram.tab.h: -------------------------------------------------------------------------------- 1 | typedef union { 2 | BTkey *key; 3 | char *string; 4 | BToper oper; 5 | GiSTpredicate *pred; 6 | int number; 7 | } YYSTYPE; 8 | #define ID 258 9 | #define STRCONST 259 10 | #define INTCONST 260 11 | #define CREATE 261 12 | #define INSERT 262 13 | #define DROP 263 14 | #define OPEN 264 15 | #define CLOSE 265 16 | #define QUIT 266 17 | #define SELECT 267 18 | #define DELETE 268 19 | #define WHERE 269 20 | #define FROM 270 21 | #define NL 271 22 | #define ERROR 272 23 | #define AND 273 24 | #define OR 274 25 | #define DEBUG 275 26 | #define HELP 276 27 | #define DUMP 277 28 | #define opLE 278 29 | #define opGE 279 30 | #define opNE 280 31 | #define NOT 281 32 | 33 | 34 | extern YYSTYPE yylval; 35 | -------------------------------------------------------------------------------- /GiST/RSTree/gram.tab.h: -------------------------------------------------------------------------------- 1 | typedef union { 2 | RTkey *key; 3 | char *string; 4 | RToper oper; 5 | GiSTpredicate *pred; 6 | int number; 7 | double dbl; 8 | } YYSTYPE; 9 | #define ID 258 10 | #define INTCONST 259 11 | #define DBLCONST 260 12 | #define CREATE 261 13 | #define INSERT 262 14 | #define DROP 263 15 | #define OPEN 264 16 | #define CLOSE 265 17 | #define QUIT 266 18 | #define SELECT 267 19 | #define DELETE 268 20 | #define WHERE 269 21 | #define FROM 270 22 | #define NL 271 23 | #define ERROR 272 24 | #define AND 273 25 | #define OR 274 26 | #define DEBUG 275 27 | #define HELP 276 28 | #define DUMP 277 29 | #define opLE 278 30 | #define opGE 279 31 | #define opNE 280 32 | #define NOT 281 33 | 34 | 35 | extern YYSTYPE yylval; 36 | -------------------------------------------------------------------------------- /GiST/RTree/gram.tab.h: -------------------------------------------------------------------------------- 1 | typedef union { 2 | RTkey *key; 3 | char *string; 4 | RToper oper; 5 | GiSTpredicate *pred; 6 | int number; 7 | double dbl; 8 | } YYSTYPE; 9 | #define ID 258 10 | #define INTCONST 259 11 | #define DBLCONST 260 12 | #define CREATE 261 13 | #define INSERT 262 14 | #define DROP 263 15 | #define OPEN 264 16 | #define CLOSE 265 17 | #define QUIT 266 18 | #define SELECT 267 19 | #define DELETE 268 20 | #define WHERE 269 21 | #define FROM 270 22 | #define NL 271 23 | #define ERROR 272 24 | #define AND 273 25 | #define OR 274 26 | #define DEBUG 275 27 | #define HELP 276 28 | #define DUMP 277 29 | #define opLE 278 30 | #define opGE 279 31 | #define opNE 280 32 | #define NOT 281 33 | 34 | 35 | extern YYSTYPE yylval; 36 | -------------------------------------------------------------------------------- /GiST/RTree/RTentry.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // RTentry.cpp 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/RTree/RTentry.cpp,v 1.1 2007/07/18 20:45:47 knizhnik Exp $ 7 | // 8 | // R-Tree Entry Class 9 | 10 | #include "RT.h" 11 | 12 | GiSTpenalty * 13 | RTentry::Penalty(const GiSTentry &newEntry) const 14 | { 15 | GiSTpenalty *retval = new GiSTpenalty; 16 | assert(newEntry.IsA() == RTENTRY_CLASS); 17 | 18 | const RTentry& e = (const RTentry &) newEntry; 19 | RTkey *tmpkey = Key().expand(e.Key()); 20 | 21 | // return area enlargement 22 | *retval = (MAX(tmpkey->area() - e.Key().area(), 0)); 23 | delete tmpkey; 24 | return((GiSTpenalty *)retval); 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /GiST/RTree/RT.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // RT.h 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/RTree/RT.h,v 1.1 2007/07/18 20:45:47 knizhnik Exp $ 7 | 8 | #define RT_H 9 | 10 | #include "GiST.h" 11 | #include "GiSTdb.h" 12 | #include "RTentry.h" 13 | #include "RTnode.h" 14 | #include "RTpredicate.h" 15 | 16 | class RT : public GiST 17 | { 18 | public: 19 | // optional, for debugging support 20 | GiSTobjid IsA() { return RT_CLASS; } 21 | RT(dbDatabase& aDb) : db(aDb) {} 22 | 23 | protected: 24 | // Required members 25 | GiSTnode *CreateNode() const { return new RTnode; } 26 | GiSTstore *CreateStore() const { return new GiSTdb(db); } 27 | 28 | dbDatabase& db; 29 | }; 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /jnicli/docs/packages.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |
21 | 22 |
23 |
24 | The front page has been relocated.Please see: 25 |
26 |           Frame version 27 |
28 |           Non-frame version.
29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /GiST/RTree/RTnode.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // RTnode.h 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/RTree/RTnode.h,v 1.1 2007/07/18 20:45:47 knizhnik Exp $ 7 | 8 | #ifndef RTNODE_H 9 | #define RTNODE_H 10 | 11 | #include "RTentry.h" 12 | 13 | class RTnode : public GiSTnode { 14 | public: 15 | // constructors, destructors, etc. 16 | GiSTobjid IsA() const { return RTNODE_CLASS; } 17 | GiSTobject *Copy() const { return new RTnode(*this); } 18 | 19 | // two of the basic GiST methods 20 | GiSTnode *PickSplit(); 21 | GiSTentry* Union() const; 22 | 23 | // required support methods 24 | GiSTentry *CreateEntry() const { return new RTentry; } 25 | int FixedLength() const { return sizeof(RTkey); } 26 | }; 27 | 28 | #endif 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /GiST/RSTree/RTnode.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // RTnode.h 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/RSTree/RTnode.h,v 1.1 2007/07/18 20:45:47 knizhnik Exp $ 7 | 8 | #ifndef RTNODE_H 9 | #define RTNODE_H 10 | 11 | #include "RTentry.h" 12 | 13 | class RTnode : public GiSTnode { 14 | public: 15 | 16 | GiSTobjid IsA() const { return RTNODE_CLASS; } 17 | GiSTentry *CreateEntry() const { return new RTentry; } 18 | int FixedLength() const { return sizeof(RTkey); } 19 | GiSTobject *Copy() const { return new RTnode(*this); } 20 | // A support routine for PickSplit 21 | RTentry *RTUnionEntries(const int entryvec[], const int min, 22 | const int max); 23 | 24 | // two of the basic GiST methods 25 | GiSTnode *PickSplit(); 26 | GiSTentry* Union() const; 27 | }; 28 | 29 | #endif 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /GiST/libGiST/GiSTfile.h: -------------------------------------------------------------------------------- 1 | // Mode: -*- C++ -*- 2 | 3 | // GiSTfile.h 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/libGiST/GiSTfile.h,v 1.1 2007/07/18 20:45:49 knizhnik Exp $ 7 | 8 | #ifndef GISTFILE_H 9 | #define GISTFILE_H 10 | 11 | #include "GiSTstore.h" 12 | 13 | 14 | // GiSTfile is a simple storage class for GiSTs to work over 15 | // UNIX/NT files. 16 | 17 | class GiSTfile : public GiSTstore { 18 | public: 19 | GiSTfile() : GiSTstore() {} 20 | 21 | void Create(const char *filename); 22 | void Open(const char *filename); 23 | void Close(); 24 | 25 | void Read(GiSTpage page, char *buf); 26 | void Write(GiSTpage page, const char *buf); 27 | GiSTpage Allocate(); 28 | void Deallocate(GiSTpage page); 29 | void Sync() {} 30 | int PageSize() const { return 8192; } 31 | 32 | private: 33 | int fileHandle; 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /GiST/BTree/BT.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // BT.h 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/BTree/BT.h,v 1.1 2007/07/18 20:45:45 knizhnik Exp $ 7 | 8 | #ifndef BT_H 9 | #define BT_H 10 | 11 | #include "GiST.h" 12 | #include "GiSTdb.h" 13 | #include "BTentry.h" 14 | #include "BTnode.h" 15 | #include "BTpredicate.h" 16 | 17 | class BT : public GiST 18 | { 19 | public: 20 | // optional, for debugging support 21 | GiSTobjid IsA() { return BT_CLASS; } 22 | BT(dbDatabase& aDb) : db(aDb) {} 23 | 24 | protected: 25 | // Required members 26 | GiSTnode *CreateNode() const { return new BTnode; } 27 | GiSTstore *CreateStore() const { return new GiSTdb(db); } 28 | 29 | // set special property 30 | int IsOrdered() const { return 1; } 31 | 32 | dbDatabase& db; 33 | }; 34 | 35 | #endif 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /GiST/RSTree/RT.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // RT.h 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/RSTree/RT.h,v 1.1 2007/07/18 20:45:46 knizhnik Exp $ 7 | 8 | #ifndef RT_H 9 | #define RT_H 10 | 11 | #include "GiST.h" 12 | #include "GiSTdb.h" 13 | #include "RTentry.h" 14 | #include "RTnode.h" 15 | #include "RTpredicate.h" 16 | 17 | class RT : public GiST 18 | { 19 | public: 20 | GiSTobjid IsA() { return RT_CLASS; } 21 | RT(dbDatabase& aDb) : db(aDb) {} 22 | 23 | protected: 24 | GiSTnode *CreateNode() const { return new RTnode; } 25 | GiSTstore *CreateStore() const { return new GiSTdb(db); } 26 | 27 | // R*-trees use forced reinsert, and the top nodes to remove are chosen 28 | // specially. 29 | int ForcedReinsert() const { return 1; } 30 | GiSTlist RemoveTop(GiSTnode *node); 31 | 32 | dbDatabase& db; 33 | }; 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /CSharpRemoteCLI/csharpcli.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 9.00 2 | # Visual Studio 2005 3 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csharpcli", "csharpcli.csproj", "{E301BB9A-87C3-400D-8D39-5436A14DEFCB}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Debug|Any CPU = Debug|Any CPU 8 | Release|Any CPU = Release|Any CPU 9 | EndGlobalSection 10 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 11 | {E301BB9A-87C3-400D-8D39-5436A14DEFCB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 12 | {E301BB9A-87C3-400D-8D39-5436A14DEFCB}.Debug|Any CPU.Build.0 = Debug|Any CPU 13 | {E301BB9A-87C3-400D-8D39-5436A14DEFCB}.Release|Any CPU.ActiveCfg = Release|Any CPU 14 | {E301BB9A-87C3-400D-8D39-5436A14DEFCB}.Release|Any CPU.Build.0 = Release|Any CPU 15 | EndGlobalSection 16 | GlobalSection(SolutionProperties) = preSolution 17 | HideSolutionNode = FALSE 18 | EndGlobalSection 19 | EndGlobal 20 | -------------------------------------------------------------------------------- /GiST/libGiST/GiSTcursor.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // GiSTcursor.h 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/libGiST/GiSTcursor.h,v 1.1 2007/07/18 20:45:49 knizhnik Exp $ 7 | 8 | #ifndef GISTCURSOR_H 9 | #define GISTCURSOR_H 10 | 11 | #include "GiSTdefs.h" 12 | #include "GiSTentry.h" 13 | #include "GiSTpredicate.h" 14 | #include "GiSTlist.h" 15 | #include "GiSTpath.h" 16 | 17 | class GiST; 18 | 19 | class GiSTcursor : public GiSTobject 20 | { 21 | public: 22 | GiSTcursor(const GiST& gist, const GiSTpredicate& query); 23 | GiSTentry *Next(); 24 | GiSTobjid IsA() const { return GISTCURSOR_CLASS; } 25 | ~GiSTcursor(); 26 | const GiSTpath& Path() const; 27 | private: 28 | const GiST& gist; 29 | GiSTpath path; 30 | GiSTlist stack; 31 | int first; 32 | GiSTpredicate *query; 33 | int lastlevel; 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /GiST/RSTree/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for GiST test program 2 | # 3 | # Generalized Search Tree 4 | 5 | PROGRAM = RSTree 6 | 7 | SRCS = command.cpp gram.y scan.l RTentry.cpp RTnode.cpp RTpredicate.cpp RT.cpp 8 | 9 | OBJS = command.o gram.tab.o scan.o RTentry.o RTnode.o RTpredicate.o RT.o 10 | 11 | DEST = . 12 | 13 | $(PROGRAM): $(OBJS) .depend 14 | $(LINKER) -o $(PROGRAM) $(LDFLAGS) $(OBJS) $(LIBS) 15 | 16 | .depend: 17 | $(MAKE) depend 18 | touch .depend 19 | 20 | gram.tab.cpp: gram.y 21 | $(YACC) $(YACCFLAGS) gram.y 22 | mv gram.tab.c gram.tab.cpp 23 | 24 | scan.cpp: scan.l 25 | $(LEX) $(LEXFLAGS) scan.l >scan.cpp 26 | 27 | %.o: %.cpp 28 | $(CC) -c $(CFLAGS) $(INCS) $*.cpp 29 | 30 | clean: 31 | rm -f $(OBJS) $(PROGRAM) gram.tab.cpp scan.cpp gram.tab.h gram.output *~ #*# *pure* TAGS 32 | 33 | depend: 34 | makedepend $(DEFINES) $(INCS) $(SRCS) 35 | 36 | install: $(PROGRAM) 37 | echo Installing $(PROGRAM) in $(DEST) 38 | install -s $(PROGRAM) $(DEST) 39 | 40 | -------------------------------------------------------------------------------- /GiST/RTree/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for GiST test program 2 | # 3 | # Generalized Search Tree 4 | 5 | PROGRAM = RTree 6 | 7 | SRCS = command.cpp gram.y scan.l RTentry.cpp RTnode.cpp RTpredicate.cpp 8 | 9 | OBJS = command.o gram.tab.o scan.o RTentry.o RTnode.o RTpredicate.o 10 | 11 | DEST = . 12 | 13 | $(PROGRAM): $(OBJS) ../libGiST .depend 14 | $(LINKER) -o $(PROGRAM) $(LDFLAGS) $(OBJS) $(LIBS) 15 | 16 | .depend: 17 | $(MAKE) depend 18 | touch .depend 19 | 20 | gram.tab.cpp: gram.y 21 | $(YACC) $(YACCFLAGS) gram.y 22 | mv gram.tab.c gram.tab.cpp 23 | 24 | scan.cpp: scan.l 25 | $(LEX) $(LEXFLAGS) scan.l >scan.cpp 26 | 27 | %.o: %.cpp 28 | $(CC) -c $(CFLAGS) $(INCS) $*.cpp 29 | 30 | clean: 31 | rm -f $(OBJS) $(PROGRAM) gram.tab.cpp scan.cpp gram.tab.h gram.output *~ #*# *pure* TAGS 32 | 33 | depend: 34 | makedepend $(DEFINES) $(INCS) $(SRCS) 35 | 36 | install: $(PROGRAM) 37 | echo Installing $(PROGRAM) in $(DEST) 38 | install -s $(PROGRAM) $(DEST) 39 | 40 | -------------------------------------------------------------------------------- /GiST/BTree/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for GiST test program 2 | # 3 | # Generalized Search Tree 4 | 5 | PROGRAM = BTree 6 | 7 | SRCS = command.cpp gram.y scan.l BTentry.cpp BTnode.cpp BTpredicate.cpp 8 | 9 | OBJS = command.o gram.tab.o scan.o BTentry.o BTnode.o BTpredicate.o 10 | 11 | DEST = . 12 | 13 | $(PROGRAM): ../libGiST/libGiST.a $(OBJS) .depend 14 | $(LINKER) -o $(PROGRAM) $(LDFLAGS) $(OBJS) $(LIBS) 15 | 16 | .depend: 17 | $(MAKE) depend 18 | touch .depend 19 | 20 | gram.tab.cpp: gram.y 21 | $(YACC) $(YACCFLAGS) gram.y 22 | mv gram.tab.c gram.tab.cpp 23 | 24 | scan.cpp: scan.l 25 | $(LEX) $(LEXFLAGS) scan.l >scan.cpp 26 | 27 | %.o: %.cpp 28 | $(CC) -c $(CFLAGS) $(INCS) $*.cpp 29 | 30 | clean: 31 | rm -f $(OBJS) $(PROGRAM) gram.tab.cpp scan.cpp gram.tab.h gram.output *~ #*# *pure* TAGS 32 | 33 | depend: 34 | makedepend $(DEFINES) $(INCS) $(SRCS) 35 | 36 | install: $(PROGRAM) 37 | echo Installing $(PROGRAM) in $(DEST) 38 | install -s $(PROGRAM) $(DEST) 39 | 40 | -------------------------------------------------------------------------------- /testddl.sql: -------------------------------------------------------------------------------- 1 | open 'testddl'; -- database should be initialized by "testddl" program 2 | 3 | delete from Record; 4 | 5 | insert into Record values ((('year 1998', 1998), ('year 1999', 1999), 6 | ('year 2000', 2000)), ('Merry Christmas', 'Happy New Year'), (1, 2, 3), 7 | ((1, 2, 3), (4, 5), (6, 7, 8, 9)), 8 | 1, 2, 0.5, true, 3, 1.5, 0, ('hello world', -1), (65, 66, 67, 68, 69, 70)); 9 | 10 | insert into Record values ((('Old Year 1998', 1998), ('New Year 1999', 1999), 11 | ('Last Year 2000', 2000)), ('Best wishes', 'Happy birthday to you', 'Regards'), 12 | (), (), 4, 5, 0.05, false, 6, 0.005, 0, ('hi', +1), (52, 51, 50, 49)), 13 | 14 | ((('3', 3), ('2', 2), ('1', 1)), ('Start'), (-1, -2, -3), 15 | ((), (1), (2, 3)), 16 | 7, 8, 0.01, true, 9, 0.001, 0, ('hello', 0), ()), 17 | 18 | (((':-)', 1), (':-|', 0), (':-(', -1)), ('good', 'normal', 'bad'), (0), 19 | ((1), (), (2)), 20 | 10, 11, -1.2, false, 12, 1.0e5, 0, ('ok', 100), (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ,14, 15)); 21 | 22 | select * from Record; 23 | exit 24 | -------------------------------------------------------------------------------- /fastdb4ce/fastdb4ce.vcw: -------------------------------------------------------------------------------- 1 | Microsoft eMbedded Visual Tools Workspace File, Format Version 4.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "fastdb4ce"=.\fastdb4ce.vcp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | Begin Project Dependency 15 | Project_Dep_Name subsql4ce 16 | End Project Dependency 17 | }}} 18 | 19 | ############################################################################### 20 | 21 | Project: "subsql4ce"=..\subsql4ce\subsql4ce.vcp - Package Owner=<4> 22 | 23 | Package=<5> 24 | {{{ 25 | }}} 26 | 27 | Package=<4> 28 | {{{ 29 | }}} 30 | 31 | ############################################################################### 32 | 33 | Global: 34 | 35 | Package=<5> 36 | {{{ 37 | }}} 38 | 39 | Package=<3> 40 | {{{ 41 | }}} 42 | 43 | ############################################################################### 44 | 45 | -------------------------------------------------------------------------------- /GiST/doc/contrib.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | libGiST, v.0.9b1 5 | 6 | 7 | 8 | 9 |

libGiST v.0.9b1

10 | 11 |

12 |


13 | 14 |
    15 |
  • The Generalized Search Tree was originally described in a 16 | paper by Hellerstein, Naughton and Pfeffer which appeared in the Proceedings 17 | of the VLDB '95 conference.
  • 18 | 19 |
  • The code in libGiST v.0.9b1 was developed by Isaac 20 | Cheng, Gary Grossman, 21 | and Joe Hellerstein.
  • 22 |
23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /GiST/BTree/BTnode.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // BTnode.h 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/BTree/BTnode.h,v 1.1 2007/07/18 20:45:45 knizhnik Exp $ 7 | 8 | 9 | #ifndef BTNODE_H 10 | #define BTNODE_H 11 | 12 | #include "BTentry.h" 13 | 14 | class BTnode : public GiSTnode { 15 | public: 16 | // constructors, destructors, etc. 17 | GiSTobjid IsA() const { return BTNODE_CLASS; } 18 | GiSTobject *Copy() const { return new BTnode(*this); } 19 | 20 | // two of the basic GiST methods 21 | GiSTentry* Union() const; 22 | 23 | // required support methods 24 | GiSTentry *CreateEntry() const { return new BTentry; } 25 | 26 | // members we are overriding for special cases 27 | void Insert(const GiSTentry &entry); 28 | void InsertBefore(const GiSTentry &entry, int index); 29 | void Coalesce(const GiSTnode& node, const GiSTentry& entry); 30 | 31 | }; 32 | 33 | #endif 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /GiST/libGiST/GiSTdb.h: -------------------------------------------------------------------------------- 1 | // Mode: -*- C++ -*- 2 | 3 | // GiSdb.h 4 | // 5 | // This provides interface beween GiST and GigaBASE storage 6 | 7 | #ifndef GISTDB_H 8 | #define GISTDB_H 9 | 10 | #include "GiSTstore.h" 11 | #include "fastdb.h" 12 | 13 | struct GiSTtable { 14 | char const* name; 15 | oid_t rootPageId; 16 | 17 | TYPE_DESCRIPTOR((KEY(name, INDEXED), FIELD(rootPageId))); 18 | }; 19 | 20 | class GiSTdb : public GiSTstore { 21 | public: 22 | GiSTdb(dbDatabase& aDB); 23 | 24 | void Create(const char *filename); 25 | void Open(const char *filename); 26 | void Close(); 27 | 28 | void Read(GiSTpage page, char *buf); 29 | void Write(GiSTpage page, const char *buf); 30 | GiSTpage Allocate(); 31 | void Deallocate(GiSTpage page); 32 | void Sync() {} 33 | int PageSize() const { return dbPageSize; } 34 | 35 | private: 36 | dbDatabase& db; 37 | oid_t rootPageId; 38 | dbQuery query; 39 | char const* tableName; 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /javacli/Reference.java: -------------------------------------------------------------------------------- 1 | package javacli; 2 | 3 | /** 4 | * Class representing references between persistent objects 5 | */ 6 | public class Reference { 7 | int oid; 8 | 9 | /** 10 | * Get object identifier 11 | */ 12 | public int getOid() { 13 | return oid; 14 | } 15 | 16 | /** 17 | * Comparison method for references 18 | */ 19 | public boolean equals(Object obj) { 20 | return obj instanceof Reference && ((Reference)obj).oid == oid; 21 | } 22 | 23 | /** 24 | * Hash code method for references 25 | */ 26 | public int hashCode() { 27 | return oid; 28 | } 29 | 30 | static Class TYPE; 31 | 32 | static { 33 | try { 34 | TYPE = Class.forName("javacli.Reference"); 35 | } catch (ClassNotFoundException x) { 36 | } 37 | } 38 | 39 | public String toString() { 40 | return "$" + oid; 41 | } 42 | 43 | public Reference(int oid) { 44 | this.oid = oid; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /fastdb.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "fastdb"=fastdb.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Project: "subsql"=subsqlprj\subsql.dsp - Package Owner=<4> 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<4> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | Project: "cli"=cli\cli.dsp - Package Owner=<4> 31 | 32 | Package=<5> 33 | {{{ 34 | }}} 35 | 36 | Package=<4> 37 | {{{ 38 | }}} 39 | 40 | ############################################################################### 41 | 42 | Global: 43 | 44 | Package=<5> 45 | {{{ 46 | }}} 47 | 48 | Package=<3> 49 | {{{ 50 | }}} 51 | 52 | ############################################################################### 53 | 54 | -------------------------------------------------------------------------------- /GiST/libGiST/GiSTstore.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // GiSTstore.h 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/libGiST/GiSTstore.h,v 1.1 2007/07/18 20:45:50 knizhnik Exp $ 7 | 8 | #ifndef GISTSTORE_H 9 | #define GISTSTORE_H 10 | 11 | #include "GiSTdefs.h" 12 | 13 | // GiSTstore is the parent class for storage of GiST pages. GiSTfile is 14 | // provided as an example descendant of GiSTstore. 15 | 16 | class GiSTstore { 17 | public: 18 | GiSTstore() : isOpen(0) {} 19 | virtual void Create(const char *filename) = 0; 20 | virtual void Open(const char *filename) = 0; 21 | virtual void Close() = 0; 22 | virtual void Read(GiSTpage page, char *buf) = 0; 23 | virtual void Write(GiSTpage page, const char *buf) = 0; 24 | virtual GiSTpage Allocate() = 0; 25 | virtual void Deallocate(GiSTpage page) = 0; 26 | virtual void Sync() = 0; 27 | virtual int IsOpen() { return isOpen; } 28 | virtual int PageSize() const = 0; 29 | virtual ~GiSTstore() { } 30 | protected: 31 | void SetOpen(int o) { isOpen = o; } 32 | private: 33 | int isOpen; 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /inc/fastdb.h: -------------------------------------------------------------------------------- 1 | //-< FASTDB.H >------------------------------------------------------*--------* 2 | // FastDB Version 1.0 (c) 1999 GARRET * ? * 3 | // (Main Memory Database Management System) * /\| * 4 | // * / \ * 5 | // Created: 20-Nov-98 K.A. Knizhnik * / [] \ * 6 | // Last update: 10-Dec-98 K.A. Knizhnik * GARRET * 7 | //-------------------------------------------------------------------*--------* 8 | // Main header file 9 | 10 | //-------------------------------------------------------------------*--------* 11 | 12 | #ifndef __FASTDB_H__ 13 | #define __FASTDB_H__ 14 | 15 | #define FASTDB_MAJOR_VERSION 3 16 | #define FASTDB_MINOR_VERSION 75 17 | #define FASTDB_VERSION (FASTDB_MAJOR_VERSION*100 + FASTDB_MINOR_VERSION) 18 | 19 | #include "database.h" 20 | #include "array.h" 21 | #include "query.h" 22 | #include "cursor.h" 23 | #include "datetime.h" 24 | #include "container.h" 25 | 26 | #ifdef THROW_EXCEPTION_ON_ERROR 27 | #include "exception.h" 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/stdtp.cpp: -------------------------------------------------------------------------------- 1 | #define INSIDE_FASTDB 2 | 3 | #include "stdtp.h" 4 | #include 5 | 6 | BEGIN_FASTDB_NAMESPACE 7 | 8 | static void CLI_CALLBACK_CC stderrTrace(char* msg) 9 | { 10 | fputs(msg, stderr); 11 | fflush(stderr); 12 | } 13 | 14 | dbTraceFunctionPtr dbTraceFunction = stderrTrace; 15 | bool dbTraceEnable = true; 16 | 17 | FASTDB_DLL_ENTRY void dbTrace(char* message, ...) 18 | { 19 | if (dbTraceEnable) { 20 | va_list args; 21 | va_start (args, message); 22 | char buffer[1024]; 23 | vsprintf(buffer, message, args); 24 | (*dbTraceFunction)(buffer); 25 | va_end(args); 26 | } 27 | } 28 | 29 | #ifdef USE_DLMALLOC 30 | extern "C" { 31 | void* dlmalloc(size_t); 32 | void dlfree(void*); 33 | } 34 | #endif 35 | 36 | FASTDB_DLL_ENTRY byte* dbMalloc(size_t size) 37 | { 38 | #ifdef USE_DLMALLOC 39 | return (byte*)dlmalloc(size); 40 | #else 41 | return (byte*)malloc(size); 42 | #endif 43 | } 44 | 45 | FASTDB_DLL_ENTRY void dbFree(void* p) 46 | { 47 | #ifdef USE_DLMALLOC 48 | dlfree(p); 49 | #else 50 | free(p); 51 | #endif 52 | } 53 | 54 | END_FASTDB_NAMESPACE 55 | -------------------------------------------------------------------------------- /GiST/RTree/command.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- ---------------------------------------- 2 | // 3 | // GiST: Generalized Search Trees 4 | // Isaac Cheng, Gary Grossman 5 | // 6 | // command.h 7 | // Test Program: Command Parser .h 8 | // 9 | // ---------------------------------------------------------- 10 | 11 | #ifndef COMMAND_H 12 | #define COMMAND_H 13 | 14 | #include "GiSTdb.h" 15 | 16 | class Record { 17 | public: 18 | int value; 19 | 20 | TYPE_DESCRIPTOR((FIELD(value))); 21 | }; 22 | 23 | void CommandCreate(const char *method, 24 | const char *table); 25 | 26 | void CommandDrop(const char *table); 27 | 28 | void CommandOpen(const char *method, const char *table); 29 | 30 | void CommandClose(const char *table); 31 | 32 | void CommandSelect(const char *table, 33 | const GiSTpredicate& pred); 34 | 35 | void CommandDelete(const char *table, 36 | const GiSTpredicate& pred); 37 | 38 | void CommandInsert(const char *table, 39 | const RTkey& key, 40 | int ptr); 41 | 42 | void CommandDump(const char *table, GiSTpage page); 43 | 44 | void CommandQuit(); 45 | 46 | void CommandDebug(); 47 | 48 | void CommandHelp(); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /GiST/RSTree/GiST.help: -------------------------------------------------------------------------------- 1 | This is a test program for the Generalized Search Tree (GiST), as 2 | described by Hellerstein, Naughton & Pfeffer in Proceedings of the 3 | 21st International Conference on Very Large Database Systems. 4 | 5 | The following commands are understood: 6 | 7 | create [br]tree foo Creates and opens a new b/r-tree named foo 8 | 9 | open [br]tree foo Opens an existing b/r table foo 10 | 11 | close foo Closes the table foo 12 | 13 | drop x Drops (deletes) the table foo 14 | 15 | select from foo Selects (displays) all entries in foo 16 | 17 | select from foo where key < 9 and key > 4 18 | Selects and entres in foo that are 19 | between 4 and 9 exclusively 20 | 21 | insert foo ("gary", 4) Inserts a new entry with key "gary", pointer 4 22 | into table foo 23 | 24 | delete foo ("gary", 4) deletes an entry with key "gary", pointer 4 25 | from table foo 26 | 27 | debug Activate debugging output 28 | 29 | help Display this screen 30 | 31 | quit Quit the program 32 | 33 | -------------------------------------------------------------------------------- /GiST/BTree/BTpredicate.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // BTpredicate.cpp 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/BTree/BTpredicate.cpp,v 1.1 2007/07/18 20:45:45 knizhnik Exp $ 7 | 8 | #include "BT.h" 9 | 10 | int 11 | BTpredicate::Consistent(const GiSTentry& entry) const 12 | { 13 | BTentry &btentry = (BTentry &)entry; 14 | const BTkey& l = btentry.LowerBound(); 15 | const BTkey& u = btentry.UpperBound(); 16 | 17 | switch (oper) { 18 | case BTEqual: 19 | return (value >= l) && (value <= u); 20 | break; 21 | case BTLessThan: 22 | return l < value; 23 | break; 24 | case BTGreaterThan: 25 | return value < u; // Assume that the keys are integers. 26 | break; 27 | case BTLessEqual: 28 | return value >= l; 29 | break; 30 | case BTGreaterEqual: 31 | return value <= u; 32 | break; 33 | case BTNotEqual: 34 | // Assume that the keys are integers. 35 | return !((value == l) && (value == u)); 36 | // return !((value == l) && (u - l == 1)); 37 | break; 38 | default: 39 | assert(0); 40 | return (0); 41 | break; 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /GiST/RSTree/RTpredicate.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // RTpredicate.h 3 | // 4 | // Copyright (c) 1996, Regents of the University of California 5 | // $Header: /cvsroot/fastdb/fastdb/GiST/RSTree/RTpredicate.h,v 1.1 2007/07/18 20:45:47 knizhnik Exp $ 6 | 7 | #ifndef RTPREDICATE_H 8 | #define RTPREDICATE_H 9 | 10 | #include "GiSTpredicate.h" 11 | 12 | enum RToper { 13 | RToverlap, 14 | RTcontains, 15 | RTcontained, 16 | RTEqual 17 | }; 18 | 19 | class RTpredicate : public GiSTpredicate { 20 | public: 21 | RTpredicate(RToper oper, const RTkey& value) : oper(oper), value(value) {} 22 | RTpredicate(const RTpredicate& p) : oper(p.oper), value(p.value) {} 23 | GiSTobject *Copy() const { return new RTpredicate(*this); } 24 | GiSTobjid IsA() { return RTPREDICATE_CLASS; } 25 | int Consistent(const GiSTentry& entry) const; 26 | void SetOper(RToper op) { oper = op; } 27 | void SetValue(const RTkey& v) { value = v; } 28 | #ifdef PRINTING_OBJECTS 29 | void Print(ostream& os) const { 30 | const char *operstrs[] = { "&&", "^", "||", "=" }; 31 | os << "key " << operstrs[oper] << " " << value; 32 | } 33 | #endif 34 | private: 35 | RToper oper; 36 | RTkey value; 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /GiST/BTree/BTree.help: -------------------------------------------------------------------------------- 1 | This is a test program for the Generalized Search Tree (GiST), as 2 | described by Hellerstein, Naughton & Pfeffer in Proceedings of the 3 | 21st International Conference on Very Large Database Systems. 4 | 5 | The following commands are understood: 6 | 7 | create btree foo Creates and opens a new b-tree named foo 8 | 9 | open btree foo Opens an existing btree foo 10 | 11 | close foo Closes the btree foo 12 | 13 | drop x Drops (deletes) the table foo 14 | 15 | select from foo Selects (displays) all entries in foo 16 | 17 | select from foo where key < 9 and key > 4 18 | Selects and entres in foo that are 19 | between 4 and 9 exclusively 20 | 21 | insert foo ("gary", 4) Inserts a new entry with key "gary", pointer 4 22 | into table foo 23 | 24 | delete foo ("gary", 4) deletes an entry with key "gary", pointer 4 25 | from table foo 26 | 27 | debug Activate debugging output 28 | 29 | help Display this screen 30 | 31 | dump foo Dump tree foo to the screen. 32 | 33 | quit Quit the program 34 | 35 | -------------------------------------------------------------------------------- /GiST/RSTree/command.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- ---------------------------------------- 2 | // 3 | // Copyright (c) 1996, Regents of the University of California 4 | // $Header: /cvsroot/fastdb/fastdb/GiST/RSTree/command.h,v 1.1 2007/07/18 20:45:47 knizhnik Exp $ 5 | // 6 | // command.h 7 | // Test Program: Command Parser .h 8 | // 9 | // ---------------------------------------------------------- 10 | 11 | #ifndef COMMAND_H 12 | #define COMMAND_H 13 | 14 | 15 | class Record { 16 | public: 17 | int value; 18 | 19 | TYPE_DESCRIPTOR((FIELD(value))); 20 | }; 21 | 22 | void CommandCreate(const char *method, 23 | const char *table); 24 | 25 | void CommandDrop(const char *table); 26 | 27 | void CommandOpen(const char *method, const char *table); 28 | 29 | void CommandClose(const char *table); 30 | 31 | void CommandSelect(const char *table, 32 | const GiSTpredicate& pred); 33 | 34 | void CommandDelete(const char *table, 35 | const GiSTpredicate& pred); 36 | 37 | void CommandInsert(const char *table, 38 | const RTkey& key, 39 | int ptr); 40 | 41 | void CommandDump(const char *table, GiSTpage page); 42 | 43 | void CommandQuit(); 44 | 45 | void CommandDebug(); 46 | 47 | void CommandHelp(); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /GiST/BTree/BTpredicate.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // BTpredicate.h 3 | // 4 | // Copyright (c) 1996, Regents of the University of California 5 | // $Header: /cvsroot/fastdb/fastdb/GiST/BTree/BTpredicate.h,v 1.1 2007/07/18 20:45:46 knizhnik Exp $ 6 | 7 | #ifndef BTPREDICATE_H 8 | #define BTPREDICATE_H 9 | 10 | #include "GiSTpredicate.h" 11 | 12 | enum BToper { 13 | BTLessThan, 14 | BTLessEqual, 15 | BTEqual, 16 | BTNotEqual, 17 | BTGreaterEqual, 18 | BTGreaterThan 19 | }; 20 | 21 | class BTpredicate : public GiSTpredicate { 22 | public: 23 | BTpredicate(BToper oper, const BTkey& value) : oper(oper), value(value) {} 24 | BTpredicate(const BTpredicate& p) : oper(p.oper), value(p.value) {} 25 | GiSTobject *Copy() const { return new BTpredicate(*this); } 26 | GiSTobjid IsA() { return BTPREDICATE_CLASS; } 27 | int Consistent(const GiSTentry& entry) const; 28 | void SetOper(BToper op) { oper = op; } 29 | void SetValue(const BTkey& v) { value = v; } 30 | #ifdef PRINTING_OBJECTS 31 | void Print(ostream& os) const { 32 | const char *operstrs[] = { "<", "<=", "=", "<>", ">=", ">" }; 33 | os << "key " << operstrs[oper] << " " << value; 34 | } 35 | #endif 36 | private: 37 | BToper oper; 38 | BTkey value; 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /GiST/BTree/command.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- ---------------------------------------- 2 | // 3 | // Copyright (c) 1996, Regents of the University of California 4 | // $Header: /cvsroot/fastdb/fastdb/GiST/BTree/command.h,v 1.1 2007/07/18 20:45:46 knizhnik Exp $ 5 | // 6 | // command.h 7 | // Test Program: Command Parser .h 8 | // 9 | // ---------------------------------------------------------- 10 | 11 | #ifndef COMMAND_H 12 | #define COMMAND_H 13 | 14 | #include "GiSTdb.h" 15 | 16 | class Record { 17 | public: 18 | int value; 19 | 20 | TYPE_DESCRIPTOR((FIELD(value))); 21 | }; 22 | 23 | void CommandCreate(const char *method, 24 | const char *table); 25 | 26 | void CommandDrop(const char *table); 27 | 28 | void CommandOpen(const char *method, const char *table); 29 | 30 | void CommandClose(const char *table); 31 | 32 | void CommandSelect(const char *table, 33 | const GiSTpredicate& pred); 34 | 35 | void CommandDelete(const char *table, 36 | const GiSTpredicate& pred); 37 | 38 | void CommandInsert(const char *table, 39 | const BTkey& key, 40 | int ptr); 41 | 42 | void CommandDump(const char *table, GiSTpage page); 43 | 44 | void CommandQuit(); 45 | 46 | void CommandDebug(); 47 | 48 | void CommandHelp(); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /GiST/RTree/RTpredicate.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // Copyright (c) 1996, Regents of the University of California 3 | // $Header: /cvsroot/fastdb/fastdb/GiST/RTree/RTpredicate.h,v 1.1 2007/07/18 20:45:47 knizhnik Exp $ 4 | 5 | #ifndef RTPREDICATE_H 6 | #define RTPREDICATE_H 7 | 8 | #include "GiSTpredicate.h" 9 | 10 | enum RToper { 11 | RToverlap, 12 | RTcontains, 13 | RTcontained, 14 | RTEqual 15 | }; 16 | 17 | class RTpredicate : public GiSTpredicate { 18 | public: 19 | // constructors, destructors, etc. 20 | RTpredicate(RToper oper, const RTkey& value) : oper(oper), value(value) {} 21 | RTpredicate(const RTpredicate& p) : oper(p.oper), value(p.value) {} 22 | GiSTobject *Copy() const { return new RTpredicate(*this); } 23 | GiSTobjid IsA() { return RTPREDICATE_CLASS; } 24 | 25 | // basic GiST methods 26 | int Consistent(const GiSTentry& entry) const; 27 | 28 | // access to private members 29 | void SetOper(RToper op) { oper = op; } 30 | void SetValue(const RTkey& v) { value = v; } 31 | 32 | // I/O routines 33 | #ifdef PRINTING_OBJECTS 34 | void Print(ostream& os) const { 35 | const char *operstrs[] = { "&&", "^", "||", "=" }; 36 | os << "key " << operstrs[oper] << " " << value; 37 | } 38 | #endif 39 | private: 40 | RToper oper; 41 | RTkey value; 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /CSharpRemoteCLI/ReferencesAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace CSharpCLI 4 | { 5 | 6 | /// 7 | /// Class representing references attribute. This attribute should be used to 8 | /// to specify name of the referenced table for reference or array of reference fields 9 | /// 10 | [AttributeUsage(AttributeTargets.Field)] 11 | public class ReferencesAttribute : Attribute 12 | { 13 | /// 14 | /// Specify referenced table and inverse reference field 15 | /// 16 | /// name of referenced table 17 | /// name of inverse reference field in referenced table 18 | /// 19 | public ReferencesAttribute(String tableName, String fieldName) { 20 | refTableName = tableName; 21 | inverseRefName = fieldName; 22 | } 23 | /// 24 | /// Specify referenced table 25 | /// 26 | /// name of referenced table 27 | /// 28 | public ReferencesAttribute(String tableName) { 29 | refTableName = tableName; 30 | } 31 | 32 | internal string refTableName; 33 | internal string inverseRefName; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /GiST/RSTree/RTpredicate.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // RTpredicate.cpp 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/RSTree/RTpredicate.cpp,v 1.1 2007/07/18 20:45:47 knizhnik Exp $ 7 | 8 | #include "RT.h" 9 | 10 | int 11 | RTpredicate::Consistent(const GiSTentry& entry) const 12 | { 13 | RTentry &rtentry = (RTentry &)entry; 14 | 15 | if (entry.IsLeaf()) { 16 | switch (oper) { 17 | case RToverlap: 18 | return(rtentry.Key().overlap((RTkey)value)); 19 | break; 20 | case RTcontains: 21 | return(rtentry.Key().contain((RTkey)value)); 22 | break; 23 | case RTcontained: 24 | return(rtentry.Key().contained((RTkey)value)); 25 | break; 26 | case RTEqual: 27 | return(rtentry.Key() == ((RTkey)value)); 28 | break; 29 | default: 30 | assert(0); 31 | return (0); 32 | break; 33 | } 34 | } 35 | else { 36 | switch (oper) { 37 | case RToverlap: 38 | case RTcontained: 39 | return(rtentry.Key().overlap((RTkey)value)); 40 | break; 41 | case RTcontains: 42 | case RTEqual: 43 | return(rtentry.Key().contain(((RTkey)value))); 44 | break; 45 | default: 46 | assert(0); 47 | return (0); 48 | break; 49 | } 50 | } 51 | } 52 | 53 | -------------------------------------------------------------------------------- /GiST/RTree/RTpredicate.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // RTpredicate.cpp 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/RTree/RTpredicate.cpp,v 1.1 2007/07/18 20:45:47 knizhnik Exp $ 7 | 8 | #include "RT.h" 9 | 10 | int 11 | RTpredicate::Consistent(const GiSTentry& entry) const 12 | { 13 | RTentry &rtentry = (RTentry &)entry; 14 | 15 | if (entry.IsLeaf()) { 16 | switch (oper) { 17 | case RToverlap: 18 | return(rtentry.Key().overlap((RTkey)value)); 19 | break; 20 | case RTcontains: 21 | return(rtentry.Key().contain((RTkey)value)); 22 | break; 23 | case RTcontained: 24 | return(rtentry.Key().contained((RTkey)value)); 25 | break; 26 | case RTEqual: 27 | return(rtentry.Key() == ((RTkey)value)); 28 | break; 29 | default: 30 | assert(0); 31 | return (0); 32 | break; 33 | } 34 | } 35 | else { 36 | switch (oper) { 37 | case RToverlap: 38 | case RTcontained: 39 | return(rtentry.Key().overlap((RTkey)value)); 40 | break; 41 | case RTcontains: 42 | case RTEqual: 43 | return(rtentry.Key().contain(((RTkey)value))); 44 | break; 45 | default: 46 | assert(0); 47 | return (0); 48 | break; 49 | } 50 | } 51 | } 52 | 53 | -------------------------------------------------------------------------------- /javacli/ConnectionPool.java: -------------------------------------------------------------------------------- 1 | package javacli; 2 | 3 | /** 4 | * Perform connection pooling 5 | */ 6 | public class ConnectionPool { 7 | /** 8 | * Make new pooled connection. If there is unused connection to this host 9 | * with the same user name and password 10 | * @param hostAddress string with server host name 11 | * @param hostPort integer number with server port 12 | */ 13 | public synchronized Connection newConnection(String hostAddress, int hostPort) 14 | { 15 | Connection con = new Connection(this); 16 | con.open(hostAddress, hostPort); 17 | return con; 18 | } 19 | 20 | /** 21 | * Return conection to the pool 22 | * @param conxn released connection 23 | */ 24 | public synchronized void releaseConnection(Connection conxn) { 25 | conxn.next = connectionChain; 26 | connectionChain = conxn; 27 | conxn.commit(); 28 | } 29 | 30 | /** 31 | * Physically close all opened connections 32 | */ 33 | public synchronized void close() { 34 | for (Connection conxn = connectionChain; conxn != null; conxn = conxn.next) { 35 | conxn.pool = null; 36 | conxn.close(); 37 | } 38 | connectionChain = null; 39 | } 40 | 41 | protected Connection connectionChain; 42 | } 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /CSharpRemoteCLI/Reference.cs: -------------------------------------------------------------------------------- 1 | namespace CSharpCLI { 2 | 3 | using System; 4 | using System.Reflection; 5 | 6 | 7 | /// 8 | /// Class representing references between persistent objects 9 | /// 10 | /// 11 | public class Reference { 12 | internal int oid; 13 | 14 | /// 15 | /// Get object identifier 16 | /// 17 | /// 18 | public int getOid() { 19 | return oid; 20 | } 21 | 22 | /// 23 | /// Comparison method for references 24 | /// 25 | /// 26 | public bool equals(Object obj) { 27 | return obj is Reference && ((Reference)obj).oid == oid; 28 | } 29 | 30 | /// 31 | /// Hash code method for references 32 | /// 33 | /// 34 | public override int GetHashCode() { 35 | return oid; 36 | } 37 | 38 | /// 39 | /// String representation of reference 40 | /// 41 | /// 42 | public override string ToString() { 43 | return "$" + oid; 44 | } 45 | 46 | /// 47 | /// 48 | /// Constructor of reference from integer 49 | /// 50 | /// referenced object identifier 51 | /// 52 | public Reference(int oid) { 53 | this.oid = oid; 54 | } 55 | } 56 | 57 | } -------------------------------------------------------------------------------- /jnicli/IncrementalCursor.java: -------------------------------------------------------------------------------- 1 | package jnicli; 2 | import java.util.*; 3 | 4 | class IncrementalCursor implements Cursor { 5 | IncrementalCursor(DatabaseJNI db, long cursor, ClassDescriptor desc) { 6 | this.db = db; 7 | this.desc = desc; 8 | this.cursor = cursor; 9 | nextOid = db.jniNext(cursor); 10 | } 11 | 12 | public int size() { 13 | return db.jniGetNumberOfSelectedRecords(cursor); 14 | } 15 | 16 | public boolean hasMoreElements() { 17 | return nextOid != 0; 18 | } 19 | 20 | public Object nextElement() { 21 | if (nextOid == 0) { 22 | throw new NoSuchElementException(); 23 | } 24 | Object obj = db.unswizzleObject(cursor, desc); 25 | currOid = nextOid; 26 | nextOid = db.jniNext(cursor); 27 | return obj; 28 | } 29 | 30 | public long getOid() { 31 | return currOid; 32 | } 33 | 34 | public void update() { 35 | throw new CliException("Cursor not in update mode"); 36 | } 37 | 38 | protected void finalize() { 39 | if (nextOid != 0) { 40 | db.jniCloseCursor(cursor); 41 | } 42 | } 43 | 44 | DatabaseJNI db; 45 | long nextOid; 46 | long currOid; 47 | long cursor; 48 | ClassDescriptor desc; 49 | } 50 | -------------------------------------------------------------------------------- /javacli/docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Generated Documentation (Untitled) 8 | 9 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | <H2> 28 | Frame Alert</H2> 29 | 30 | <P> 31 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. 32 | <BR> 33 | Link to<A HREF="javacli/package-summary.html">Non-frame version.</A> 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /jnicli/docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Generated Documentation (Untitled) 8 | 9 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | <H2> 28 | Frame Alert</H2> 29 | 30 | <P> 31 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. 32 | <BR> 33 | Link to<A HREF="jnicli/package-summary.html">Non-frame version.</A> 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /javacli/docs/allclasses-noframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | All Classes 20 |
21 | 22 | 23 | 24 | 41 | 42 |
CliError 25 |
26 | Connection 27 |
28 | ConnectionPool 29 |
30 | LocalSocket 31 |
32 | ObjectSet 33 |
34 | Rectangle 35 |
36 | Reference 37 |
38 | Statement 39 |
40 |
43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /javacli/docs/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* Javadoc style sheet */ 2 | 3 | /* Define colors, fonts and other style attributes here to override the defaults */ 4 | 5 | /* Page background color */ 6 | body { background-color: #FFFFFF; color:#000000 } 7 | 8 | /* Headings */ 9 | h1 { font-size: 145% } 10 | 11 | /* Table colors */ 12 | .TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */ 13 | .TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */ 14 | .TableRowColor { background: #FFFFFF; color:#000000 } /* White */ 15 | 16 | /* Font used in left-hand frame lists */ 17 | .FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 } 18 | .FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } 19 | .FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } 20 | 21 | /* Navigation bar fonts and colors */ 22 | .NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */ 23 | .NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */ 24 | .NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;} 25 | .NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;} 26 | 27 | .NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} 28 | .NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} 29 | 30 | -------------------------------------------------------------------------------- /jnicli/docs/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* Javadoc style sheet */ 2 | 3 | /* Define colors, fonts and other style attributes here to override the defaults */ 4 | 5 | /* Page background color */ 6 | body { background-color: #FFFFFF; color:#000000 } 7 | 8 | /* Headings */ 9 | h1 { font-size: 145% } 10 | 11 | /* Table colors */ 12 | .TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */ 13 | .TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */ 14 | .TableRowColor { background: #FFFFFF; color:#000000 } /* White */ 15 | 16 | /* Font used in left-hand frame lists */ 17 | .FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 } 18 | .FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } 19 | .FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } 20 | 21 | /* Navigation bar fonts and colors */ 22 | .NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */ 23 | .NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */ 24 | .NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;} 25 | .NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;} 26 | 27 | .NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} 28 | .NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} 29 | 30 | -------------------------------------------------------------------------------- /ruby/benchmark.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'fastdb' 4 | require 'benchmark' 5 | 6 | def returning(a) 7 | yield a 8 | a 9 | end 10 | 11 | N_NAMES=1000 12 | NAMES=Array.new(N_NAMES) 13 | for i in 0...N_NAMES 14 | NAMES[i] = rand(1000000007) 15 | end 16 | 17 | class Person < Struct.new(:name, :salary, :rating, :address) 18 | @fname_num = 0 19 | @lname_num = NAMES.size/2 20 | @sal = 10000 21 | @rating = 1 22 | def self.makeup_something 23 | returning(new("#{NAMES[@fname_num]} #{NAMES[@lname_num]}", @sal % 53323, @rating % 10)) do 24 | @fname_num += 3 25 | @lname_num += 6 26 | @fname_num -= NAMES.size if @fname_num >= NAMES.size 27 | @lname_num -= NAMES.size if @lname_num >= NAMES.size 28 | @sal += 4242 29 | @rating += 13 30 | end 31 | end 32 | end 33 | 34 | con = FastDB::Connection.new 35 | Benchmark.bm do |x| 36 | x.report("connecting") { con.open("localhost", 6100) } 37 | x.report("inserting") do 38 | 7.times { con.insert(Person.makeup_something) } 39 | con.commit() 40 | end 41 | x.report("scanning by rating") do 42 | stmt = con.createStatement("select * from Person where rating > %rating order by name") 43 | stmt["rating"] = 5 44 | cursor = stmt.fetch() 45 | end 46 | 47 | x.report("loading anything?") do 48 | stmt = con.createStatement("select * from Person") 49 | cursor = stmt.fetch(true) 50 | cursor.removeAll() 51 | stmt.close() 52 | end 53 | end 54 | 55 | con.close() 56 | -------------------------------------------------------------------------------- /GiST/RSTree/scan.l: -------------------------------------------------------------------------------- 1 | %{ 2 | #include 3 | #include "RT.h" 4 | #include "gram.tab.h" 5 | %} 6 | 7 | ws [ \t]+ 8 | comment #[^\n]* 9 | id [a-zA-Z][a-zA-Z0-9]* 10 | nl [\r\n] 11 | int "-"?[0-9]+ 12 | dubl "-"?[0-9]+"."[0-9]+ 13 | 14 | %% 15 | 16 | {ws} ; 17 | {comment} ; 18 | {dubl} { yylval.dbl = strtod((const char *)yytext, NULL); 19 | return DBLCONST; 20 | } 21 | 22 | {int} { yylval.number = atoi((const char *)yytext); 23 | return INTCONST; 24 | } 25 | "(" | 26 | ")" | 27 | "," | 28 | "<" | 29 | ">" | 30 | "&" | 31 | "~" | 32 | "=" { return yytext[0]; } 33 | "<>" { return opNE; } 34 | "<=" { return opLE; } 35 | ">=" { return opGE; } 36 | 37 | create { return CREATE; } 38 | open { return OPEN; } 39 | close { return CLOSE; } 40 | drop { return DROP; } 41 | insert { return INSERT; } 42 | delete { return DELETE; } 43 | select { return SELECT; } 44 | debug { return DEBUG; } 45 | dump { return DUMP; } 46 | help { return HELP; } 47 | from { return FROM; } 48 | and { return AND; } 49 | or { return OR; } 50 | not { return NOT; } 51 | where { return WHERE; } 52 | quit { return QUIT; } 53 | {id} { yylval.string = strdup((const char *)yytext); return ID; } 54 | {nl} { return NL; } 55 | <> { yyterminate(); } 56 | . { cerr << "Lexical error in input string: invalid character\n"; 57 | return ERROR; } 58 | 59 | %% 60 | -------------------------------------------------------------------------------- /GiST/RTree/scan.l: -------------------------------------------------------------------------------- 1 | %{ 2 | #include 3 | #include "RT.h" 4 | #include "gram.tab.h" 5 | %} 6 | 7 | ws [ \t]+ 8 | comment #[^\n]* 9 | id [a-zA-Z][a-zA-Z0-9]* 10 | nl [\r\n] 11 | int "-"?[0-9]+ 12 | dubl "-"?[0-9]+"."[0-9]+ 13 | 14 | %% 15 | 16 | {ws} ; 17 | {comment} ; 18 | {dubl} { yylval.dbl = strtod((const char *)yytext, NULL); 19 | return DBLCONST; 20 | } 21 | 22 | {int} { yylval.number = atoi((const char *)yytext); 23 | return INTCONST; 24 | } 25 | "(" | 26 | ")" | 27 | "," | 28 | "<" | 29 | ">" | 30 | "&" | 31 | "~" | 32 | "=" { return yytext[0]; } 33 | "<>" { return opNE; } 34 | "<=" { return opLE; } 35 | ">=" { return opGE; } 36 | 37 | create { return CREATE; } 38 | open { return OPEN; } 39 | close { return CLOSE; } 40 | drop { return DROP; } 41 | insert { return INSERT; } 42 | delete { return DELETE; } 43 | select { return SELECT; } 44 | debug { return DEBUG; } 45 | dump { return DUMP; } 46 | help { return HELP; } 47 | from { return FROM; } 48 | and { return AND; } 49 | or { return OR; } 50 | not { return NOT; } 51 | where { return WHERE; } 52 | quit { return QUIT; } 53 | {id} { yylval.string = strdup((const char *)yytext); return ID; } 54 | {nl} { return NL; } 55 | <> { yyterminate(); } 56 | . { cerr << "Lexical error in input string: invalid character\n"; 57 | return ERROR; } 58 | 59 | %% 60 | -------------------------------------------------------------------------------- /jnicli/docs/allclasses-noframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | All Classes 20 |
21 | 22 | 23 | 24 | 41 | 42 |
CliException 25 |
26 | Cursor 27 |
28 | Database 29 |
30 | DatabaseJNI 31 |
32 | DatabaseSession 33 |
34 | DatabaseSessionClient 35 |
36 | DatabaseSessionServer 37 |
38 | PrefetchedCursor 39 |
40 |
43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /inc/exception.h: -------------------------------------------------------------------------------- 1 | //-< EXCEPTION.H >---------------------------------------------------*--------* 2 | // FastDB Version 1.0 (c) 1999 GARRET * ? * 3 | // (Main Memory Database Management System) * /\| * 4 | // * / \ * 5 | // Created: 3-Oct-99 Sebastiano Suraci * / [] \ * 6 | // Last update: 5-Oct-99 K.A. Knizhnik * GARRET * 7 | //-------------------------------------------------------------------*--------* 8 | // Database exception 9 | //-------------------------------------------------------------------*--------* 10 | 11 | #ifndef __EXCEPTION_H__ 12 | #define __EXCEPTION_H__ 13 | 14 | #include 15 | 16 | BEGIN_FASTDB_NAMESPACE 17 | 18 | #ifdef FASTDB_DLL 19 | class __declspec(dllexport) std::exception; 20 | #endif 21 | 22 | class FASTDB_DLL_ENTRY dbException : public std::exception 23 | { 24 | protected: 25 | int err_code; 26 | char* msg; 27 | int arg; 28 | 29 | public: 30 | dbException(int p_err_code, char const* p_msg = NULL, int p_arg = 0); 31 | dbException(dbException const& ex); 32 | 33 | virtual~dbException() throw (); 34 | 35 | virtual const char *what() const throw(); 36 | 37 | int getErrCode() const { return err_code; } 38 | char* getMsg() const { return msg; } 39 | long getArg() const { return arg; } 40 | }; 41 | 42 | END_FASTDB_NAMESPACE 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /javacli/docs/allclasses-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | All Classes 20 |
21 | 22 | 23 | 24 | 41 | 42 |
CliError 25 |
26 | Connection 27 |
28 | ConnectionPool 29 |
30 | LocalSocket 31 |
32 | ObjectSet 33 |
34 | Rectangle 35 |
36 | Reference 37 |
38 | Statement 39 |
40 |
43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /jnicli/PrefetchedCursor.java: -------------------------------------------------------------------------------- 1 | package jnicli; 2 | 3 | import java.util.*; 4 | import java.io.Serializable; 5 | 6 | public class PrefetchedCursor implements Cursor, Serializable { 7 | // Public constructor to allow instantiation of this class 8 | public PrefetchedCursor() {} 9 | 10 | PrefetchedCursor(DatabaseJNI db, long cursor, ClassDescriptor desc) { 11 | long oid; 12 | int size = db.jniGetNumberOfSelectedRecords(cursor); 13 | objects = new Object[size]; 14 | oids = new long[size]; 15 | for (int i = 0; i < size; i++) { 16 | oids[i] = db.jniNext(cursor); 17 | objects[i] = db.unswizzleObject(cursor, desc); 18 | } 19 | db.jniCloseCursor(cursor); 20 | } 21 | 22 | public boolean hasMoreElements() { 23 | return i < objects.length; 24 | } 25 | 26 | public Object nextElement() { 27 | if (i >= objects.length) { 28 | throw new NoSuchElementException(); 29 | } 30 | return objects[i++]; 31 | } 32 | 33 | public long getOid() { 34 | if (i == 0) { 35 | throw new NoSuchElementException(); 36 | } 37 | return oids[i-1]; 38 | } 39 | 40 | public void update() { 41 | throw new CliException("Cursor not in update mode"); 42 | } 43 | 44 | public int size() { 45 | return objects.length; 46 | } 47 | 48 | // make this fields public in order to be accessible in JDK1.1 environment 49 | public Object[] objects; 50 | public long[] oids; 51 | transient int i; 52 | } 53 | -------------------------------------------------------------------------------- /GiST/README: -------------------------------------------------------------------------------- 1 | libGiST: Generalized Search Tree C++ Library 2 | 3 | This directory contains the 0.9beta1 release of the GiST C++ Library. 4 | 5 | We have a WWW home page located at: 6 | http://s2k-ftp.cs.berkeley.edu:8000/gist 7 | Please refer to it for updates on source code, documentation, etc. 8 | 9 | libGiST is not public domain software. It is copyrighted by the 10 | University of California but may be used according to the licensing 11 | terms of the the copyright below: 12 | 13 | ------------------------------------------------------------------------ 14 | 15 | Copyright (c) 1996 Regents of the University of California 16 | 17 | Permission to use, copy, modify, and distribute this software and its 18 | documentation for any purpose, without fee, and without a written agreement 19 | is hereby granted, provided that the above copyright notice and this 20 | paragraph and the following two paragraphs appear in all copies. 21 | 22 | IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR 23 | DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING 24 | LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS 25 | DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE 26 | POSSIBILITY OF SUCH DAMAGE. 27 | 28 | THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 29 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 30 | AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 31 | ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO 32 | PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 33 | 34 | -------------------------------------------------------------------------------- /inc/symtab.h: -------------------------------------------------------------------------------- 1 | //-< SYMTAB.H >----------------------------------------------------*--------* 2 | // FastDB Version 1.0 (c) 1999 GARRET * ? * 3 | // (Main Memory Database Management System) * /\| * 4 | // * / \ * 5 | // Created: 20-Nov-98 K.A. Knizhnik * / [] \ * 6 | // Last update: 10-Dec-98 K.A. Knizhnik * GARRET * 7 | //-------------------------------------------------------------------*--------* 8 | // Symbol table interface 9 | //-------------------------------------------------------------------*--------* 10 | 11 | #ifndef __SYMTAB_H__ 12 | #define __SYMTAB_H__ 13 | 14 | BEGIN_FASTDB_NAMESPACE 15 | 16 | #if defined(CLONE_IDENTIFIERS) || defined(FASTDB_DLL) 17 | #define FASTDB_CLONE_ANY_IDENTIFIER true 18 | #else 19 | #define FASTDB_CLONE_ANY_IDENTIFIER false 20 | #endif 21 | 22 | class FASTDB_DLL_ENTRY dbSymbolTable { 23 | struct HashTableItem { 24 | HashTableItem* next; 25 | char* str; 26 | unsigned hash; 27 | int tag; 28 | byte allocated; 29 | 30 | ~HashTableItem() { 31 | if (allocated) { 32 | delete[] str; 33 | } 34 | } 35 | }; 36 | static HashTableItem* hashTable[]; 37 | 38 | public: 39 | ~dbSymbolTable(); 40 | static dbSymbolTable instance; 41 | 42 | static int add(char* &str, int tag, bool allocate = true); 43 | }; 44 | 45 | END_FASTDB_NAMESPACE 46 | 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /GiST/RSTree/RTree.help: -------------------------------------------------------------------------------- 1 | This is a test program for the Generalized Search Tree (GiST), as 2 | described by Hellerstein, Naughton & Pfeffer in Proceedings of the 3 | 21st International Conference on Very Large Database Systems. 4 | 5 | The following commands are understood: 6 | 7 | create rtree foo Creates and opens a new r-tree named foo 8 | 9 | open rtree foo Opens an existing r-tree foo 10 | 11 | close foo Closes the rtree foo 12 | 13 | drop x Drops (deletes) the table foo 14 | 15 | select from foo Selects (displays) all entries in foo 16 | 17 | select from foo where key (, , , ) 18 | Selects entries in foo based on comparison with 19 | a bounding box. The comparison operators 20 | that can be used in place of are = 21 | (equals), & (overlaps), < (contained-in), and 22 | > (contains). The four coordinates of 23 | the key are (xlow, xhigh, ylow, yhigh) of the 24 | query box, which are all of type double. 25 | 26 | insert foo ((0,1.2,0,1), 4) Inserts a new entry with key (0,1.2,0,1), 27 | pointer 4 into table foo. 28 | 29 | delete foo ((0,0,0,0), 4) deletes an entry with key (0,0,0,0), pointer 4 30 | from table foo 31 | 32 | debug Activate debugging output 33 | 34 | help Display this screen 35 | 36 | dump foo Dump tree foo to the screen. 37 | 38 | quit Quit the program 39 | 40 | -------------------------------------------------------------------------------- /GiST/RTree/RTree.help: -------------------------------------------------------------------------------- 1 | This is a test program for the Generalized Search Tree (GiST), as 2 | described by Hellerstein, Naughton & Pfeffer in Proceedings of the 3 | 21st International Conference on Very Large Database Systems. 4 | 5 | The following commands are understood: 6 | 7 | create rtree foo Creates and opens a new r-tree named foo 8 | 9 | open rtree foo Opens an existing r-tree foo 10 | 11 | close foo Closes the rtree foo 12 | 13 | drop x Drops (deletes) the table foo 14 | 15 | select from foo Selects (displays) all entries in foo 16 | 17 | select from foo where key (, , , ) 18 | Selects entries in foo based on comparison with 19 | a bounding box. The comparison operators 20 | that can be used in place of are = 21 | (equals), & (overlaps), < (contained-in), and 22 | > (contains). The four coordinates of 23 | the key are (xlow, xhigh, ylow, yhigh) of the 24 | query box, which are all of type double. 25 | 26 | insert foo ((0,1.2,0,1), 4) Inserts a new entry with key (0,1.2,0,1), 27 | pointer 4 into table foo. 28 | 29 | delete foo ((0,0,0,0), 4) deletes an entry with key (0,0,0,0), pointer 4 30 | from table foo 31 | 32 | debug Activate debugging output 33 | 34 | help Display this screen 35 | 36 | dump foo Dump tree foo to the screen. 37 | 38 | quit Quit the program 39 | 40 | -------------------------------------------------------------------------------- /GiST/BTree/scan.l: -------------------------------------------------------------------------------- 1 | %{ 2 | #include 3 | #include "BT.h" 4 | #include "gram.tab.h" 5 | %} 6 | 7 | ws [ \t]+ 8 | comment #[^\n]* 9 | qstring \"[^\"\n]*[\"\n] 10 | id [a-zA-Z][a-zA-Z0-9]* 11 | nl [\r\n] 12 | int "-"?[0-9]+ 13 | 14 | %% 15 | 16 | {ws} ; 17 | {comment} ; 18 | {qstring} { yylval.key = new BTkey((char *)(yytext+1), strlen(yytext+1)); 19 | if(yylval.key->key[yyleng-2] != '\"') { 20 | cerr << "Scanner - Unterminated character string.\n"; 21 | return ERROR; 22 | } else { 23 | yylval.key->len--; 24 | return STRCONST; 25 | } 26 | } 27 | {int} { yylval.number = atoi((const char *)yytext); 28 | return INTCONST; 29 | } 30 | "(" | 31 | ")" | 32 | "," | 33 | "<" | 34 | ">" | 35 | "=" { return yytext[0]; } 36 | "<>" { return opNE; } 37 | "<=" { return opLE; } 38 | ">=" { return opGE; } 39 | 40 | create { return CREATE; } 41 | open { return OPEN; } 42 | close { return CLOSE; } 43 | drop { return DROP; } 44 | insert { return INSERT; } 45 | delete { return DELETE; } 46 | select { return SELECT; } 47 | debug { return DEBUG; } 48 | dump { return DUMP; } 49 | help { return HELP; } 50 | from { return FROM; } 51 | and { return AND; } 52 | or { return OR; } 53 | not { return NOT; } 54 | where { return WHERE; } 55 | quit { return QUIT; } 56 | {id} { yylval.string = strdup((const char *)yytext); return ID; } 57 | {nl} { return NL; } 58 | <> { yyterminate(); } 59 | . { cerr << "Lexical error in input string: invalid character\n"; 60 | return ERROR; } 61 | 62 | %% 63 | -------------------------------------------------------------------------------- /jnicli/docs/allclasses-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | All Classes 20 |
21 | 22 | 23 | 24 | 41 | 42 |
CliException 25 |
26 | Cursor 27 |
28 | Database 29 |
30 | DatabaseJNI 31 |
32 | DatabaseSession 33 |
34 | DatabaseSessionClient 35 |
36 | DatabaseSessionServer 37 |
38 | PrefetchedCursor 39 |
40 |
43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /CSharpRemoteCLI/ConnectionPool.cs: -------------------------------------------------------------------------------- 1 | namespace CSharpCLI { 2 | 3 | /// 4 | /// Perform connection pooling 5 | /// 6 | public class ConnectionPool { 7 | /// 8 | /// Make new pooled connection. If there is unused connection to this host 9 | /// with the same user name and password 10 | /// 11 | /// string with server host name 12 | /// integer number with server port 13 | /// 14 | public Connection newConnection(string hostAddress, int hostPort) 15 | { 16 | Connection con = new Connection(this); 17 | con.open(hostAddress, hostPort); 18 | return con; 19 | } 20 | 21 | /// 22 | /// Return conection to the pool 23 | /// 24 | /// released connection 25 | /// 26 | public void releaseConnection(Connection conxn) { 27 | lock (this) 28 | { 29 | conxn.next = connectionChain; 30 | connectionChain = conxn; 31 | conxn.commit(); 32 | } 33 | } 34 | 35 | /// 36 | /// Physically close all opened connections 37 | /// 38 | /// 39 | public void close() { 40 | lock (this) 41 | { 42 | for (Connection conxn = connectionChain; conxn != null; conxn = conxn.next) 43 | { 44 | conxn.pool = null; 45 | conxn.close(); 46 | } 47 | connectionChain = null; 48 | } 49 | } 50 | 51 | internal Connection connectionChain; 52 | } 53 | 54 | 55 | } 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /src/forcerecovery.cpp: -------------------------------------------------------------------------------- 1 | #include "fastdb.h" 2 | #include 3 | #include 4 | 5 | USE_FASTDB_NAMESPACE 6 | 7 | int main(int argc, char* argv[]) 8 | { 9 | if (argc < 2) { 10 | fprintf(stderr, "Usage: forcerecovery [-shadow] [-norecovery] DATABASE-FILE-NAME\n"); 11 | return 1; 12 | } 13 | bool swapCurr = false; 14 | int dirty = 1; 15 | FILE* f = NULL; 16 | for (int i = 1; i < argc; i++) { 17 | if (strcmp(argv[i], "-shadow") == 0) { 18 | swapCurr = true; 19 | } else if (strcmp(argv[i], "-norecovery") == 0) { 20 | dirty = 0; 21 | } else if (*argv[i] == '-') { 22 | fprintf(stderr, "No such option '%s'\n", argv[i]); 23 | return 1; 24 | } else if (f != NULL) { 25 | fprintf(stderr, "File was already specified\n"); 26 | return 1; 27 | } else { 28 | f = fopen(argv[i], "r+b"); 29 | if (f == NULL) { 30 | fprintf(stderr, "Failed to open database file '%s'\n", argv[i]); 31 | return 1; 32 | } 33 | } 34 | } 35 | if (f == NULL) { 36 | fprintf(stderr, "File was not specified\n"); 37 | return 1; 38 | } 39 | dbHeader rec; 40 | if (fread(&rec, sizeof(dbHeader), 1, f) != 1) { 41 | fprintf(stderr, "Failed to read database header\n"); 42 | return 1; 43 | } 44 | if (swapCurr) { 45 | rec.curr = 1 - rec.curr; 46 | } 47 | rec.dirty = dirty; 48 | fseek(f, 0, 0); 49 | if (fwrite(&rec, sizeof(dbHeader), 1, f) != 1) { 50 | fprintf(stderr, "Failed to write database header\n"); 51 | return 1; 52 | } 53 | fclose(f); 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /GiST/libGiST/GiSTcursor.cpp: -------------------------------------------------------------------------------- 1 | // Mode: -*- C++ -*- 2 | 3 | // GiSTcursor.cpp 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/libGiST/GiSTcursor.cpp,v 1.1 2007/07/18 20:45:49 knizhnik Exp $ 7 | 8 | #include "GiST.h" 9 | 10 | GiSTcursor::GiSTcursor(const GiST& gist, 11 | const GiSTpredicate& query) : gist(gist) 12 | { 13 | this->query = (GiSTpredicate*) query.Copy(); 14 | first = 1; 15 | lastlevel = -1; 16 | } 17 | 18 | GiSTentry* 19 | GiSTcursor::Next() 20 | { 21 | GiSTpage page; 22 | 23 | while (first || !stack.IsEmpty()) { 24 | if (first) { 25 | page = GiSTRootPage; 26 | first = 0; 27 | } else { 28 | assert(lastlevel >= 0); 29 | GiSTentry *entry = stack.RemoveFront(); 30 | if (entry->IsLeaf()) 31 | return entry; 32 | 33 | // Pop off the stack 34 | for (int i=0; i < entry->Level() - lastlevel; i++) 35 | path.MakeParent(); 36 | 37 | page = entry->Ptr(); 38 | 39 | delete entry; 40 | } 41 | 42 | // Entry was a pointer to another node 43 | path.MakeChild(page); 44 | 45 | GiSTnode *node = gist.ReadNode(path); 46 | lastlevel = node->Level(); 47 | 48 | GiSTlist list = node->Search(*query); 49 | 50 | while (!list.IsEmpty()) { 51 | GiSTentry *entry = list.RemoveRear(); 52 | stack.Prepend(entry); 53 | } 54 | 55 | delete node; 56 | } 57 | 58 | // The search is over... 59 | return NULL; 60 | } 61 | 62 | GiSTcursor::~GiSTcursor() 63 | { 64 | if (query != NULL) 65 | delete query; 66 | while (!stack.IsEmpty()) 67 | delete stack.RemoveFront(); 68 | } 69 | 70 | const GiSTpath& 71 | GiSTcursor::Path() const 72 | { 73 | return path; 74 | } 75 | -------------------------------------------------------------------------------- /inc/hashtab.h: -------------------------------------------------------------------------------- 1 | //-< HASHTAB.CPP >---------------------------------------------------*--------* 2 | // FastDB Version 1.0 (c) 1999 GARRET * ? * 3 | // (Main Memory Database Management System) * /\| * 4 | // * / \ * 5 | // Created: 20-Nov-98 K.A. Knizhnik * / [] \ * 6 | // Last update: 10-Dec-98 K.A. Knizhnik * GARRET * 7 | //-------------------------------------------------------------------*--------* 8 | // Extensible hash table interface 9 | //-------------------------------------------------------------------*--------* 10 | 11 | #ifndef __HASHTAB_H__ 12 | #define __HASHTAB_H__ 13 | 14 | BEGIN_FASTDB_NAMESPACE 15 | 16 | class FASTDB_DLL_ENTRY dbHashTableItem { 17 | public: 18 | oid_t next; 19 | oid_t record; 20 | nat4 hash; 21 | }; 22 | 23 | const size_t dbInitHashTableSize = 16*1024-1; 24 | 25 | class dbFieldDescriptor; 26 | 27 | class FASTDB_DLL_ENTRY dbHashTable { 28 | nat4 size; 29 | nat4 used; 30 | oid_t page; 31 | 32 | public: 33 | static dbUDTHashFunction getHashFunction(int version, dbFieldDescriptor* fd); 34 | 35 | static oid_t allocate(dbDatabase* db, size_t nRows = 0); 36 | 37 | static void insert(dbDatabase* db, dbFieldDescriptor* fd, oid_t rowId, size_t nRows); 38 | 39 | static void remove(dbDatabase* db, dbFieldDescriptor* fd, oid_t rowId); 40 | 41 | static void find(dbDatabase* db, oid_t hashId, dbSearchContext& sc); 42 | 43 | static void drop(dbDatabase* db, oid_t hashId); 44 | 45 | static void purge(dbDatabase* db, oid_t hashId); 46 | }; 47 | 48 | END_FASTDB_NAMESPACE 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /GiST/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for libGiST, GiST test programs 2 | # 3 | # Generalized Search Tree 4 | 5 | # LINKER = purify -collector=/usr/sww/lib/gcc-lib/hppa1.1-hp-hpux9.03/2.7.2/ld -cache-dir=/tmp/jmh 6 | LINKER = g++ 7 | # LINKER = c++ 8 | export LINKER 9 | 10 | INCS = -I/usr/sww/lib/g++-include -I/usr/include/g++-3 -I../libGiST -I../../inc 11 | # INCS = -I../libGiST 12 | export INCS 13 | 14 | LDFLAGS = -L../libGiST 15 | export LDFLAGS 16 | 17 | LIBS = -lGiST ../../libfastdb_r.a -lpthread 18 | # LIBS = -lGiST 19 | export LIBS 20 | 21 | CC = g++ 22 | # CC = CC 23 | export CC 24 | 25 | DEFINES = -DUNIX 26 | export DEFINES 27 | 28 | CFLAGS = -g -Wall -Wno-unused $(DEFINES) 29 | # CFLAGS = -g $(DEFINES) 30 | export CFLAGS 31 | 32 | # we recommend bison and flex for this code. 33 | # if you want to use yacc and lex, you'll need to muck with the 34 | # Makefiles a bit. 35 | LEX = flex 36 | export LEX 37 | 38 | LEXFLAGS = -It 39 | export LEXFLAGS 40 | 41 | YACC = bison 42 | export YACC 43 | 44 | YACCFLAGS = -dv 45 | export YACCFLAGS 46 | 47 | all: LIBGIST RTREE BTREE RSTREE 48 | 49 | LIBGIST: 50 | cd libGiST ; $(MAKE) 51 | 52 | RTREE: libGiST/libGiST.a 53 | cd RTree; $(MAKE) 54 | 55 | BTREE: libGiST/libGiST.a 56 | cd BTree; $(MAKE) 57 | 58 | RSTREE: libGiST/libGiST.a 59 | cd RSTree; $(MAKE) 60 | 61 | archive: 62 | $(MAKE) clean 63 | cd .. ; tar cf GiST.tar GiST ; gzip -f GiST.tar ; rm GiST.zip ; zip -pr GiST GiST/* ; cd GiST 64 | 65 | clean: 66 | cd libGiST ; $(MAKE) clean 67 | cd BTree; $(MAKE) clean 68 | cd RSTree; $(MAKE) clean 69 | cd RTree; $(MAKE) clean 70 | 71 | depend: 72 | cd libGiST ; $(MAKE) depend 73 | cd BTree; $(MAKE) depend 74 | cd RSTree; $(MAKE) depend 75 | cd RTree; $(MAKE) depend 76 | tags: 77 | etags */*.{cpp,y,l,h} 78 | 79 | -------------------------------------------------------------------------------- /jnicli/DatabaseSessionClient.java: -------------------------------------------------------------------------------- 1 | package jnicli; 2 | 3 | /** 4 | * Database session client implementation. This class implements Database interface using 5 | * proxy object to access remote database server. The role of this class is to keep session context. 6 | */ 7 | public class DatabaseSessionClient implements Database { 8 | public void open(int accessType, String databaseName, String databasePath, long initSize, int transactionCommitDelay) { 9 | session = proxy.open(accessType, databaseName, databasePath, initSize, transactionCommitDelay); 10 | } 11 | 12 | public void close() { 13 | proxy.close(session); 14 | } 15 | 16 | public Cursor select(Class table, String condition, int flags) { 17 | return proxy.select(session, table, condition, flags); 18 | } 19 | 20 | public void update(long oid, Object obj) { 21 | proxy.update(session, oid, obj); 22 | } 23 | 24 | public long insert(Object obj) { 25 | return proxy.insert(session, obj); 26 | } 27 | 28 | public int delete(Class table, String condition) { 29 | return proxy.delete(session, table, condition); 30 | } 31 | 32 | public void commit() { 33 | proxy.commit(session); 34 | } 35 | 36 | public void rollback() { 37 | proxy.rollback(session); 38 | } 39 | 40 | public void lock() { 41 | proxy.lock(session); 42 | } 43 | 44 | public void attach() { 45 | session = proxy.attach(); 46 | } 47 | 48 | public void detach(int flags) { 49 | proxy.detach(session, flags); 50 | } 51 | 52 | public DatabaseSessionClient(DatabaseSession proxy) { 53 | this.proxy = proxy; 54 | } 55 | 56 | private long session; 57 | private DatabaseSession proxy; 58 | } 59 | 60 | -------------------------------------------------------------------------------- /javacli/docs/javacli/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | javacli 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | javacli 20 | 21 | 22 | 39 | 40 |
23 | Classes  24 | 25 |
26 | Connection 27 |
28 | ConnectionPool 29 |
30 | LocalSocket 31 |
32 | ObjectSet 33 |
34 | Rectangle 35 |
36 | Reference 37 |
38 | Statement
41 | 42 | 43 | 44 | 45 | 50 | 51 |
46 | Exceptions  47 | 48 |
49 | CliError
52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /GiST/libGiST/GiSTlist.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // GiSTlist.h 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/libGiST/GiSTlist.h,v 1.1 2007/07/18 20:45:49 knizhnik Exp $ 7 | 8 | #ifndef GISTLIST_H 9 | #define GISTLIST_H 10 | 11 | // A template list package, which is handy. 12 | 13 | 14 | template 15 | struct GiSTlistnode 16 | { 17 | T entry; 18 | GiSTlistnode *prev, *next; 19 | }; 20 | 21 | template 22 | class GiSTlist 23 | { 24 | public: 25 | GiSTlist() { front = rear = NULL; } 26 | // GiSTlist(const GiSTlist& l) { front = l.front; rear = l.rear; } 27 | int IsEmpty() { return front == NULL; } 28 | T RemoveFront() { 29 | assert(front != NULL); 30 | GiSTlistnode *temp = front; 31 | T e = front->entry; 32 | front = front->next; 33 | if (front) 34 | front->prev = NULL; 35 | else 36 | rear = NULL; 37 | delete temp; 38 | return e; 39 | } 40 | T RemoveRear() { 41 | assert(rear != NULL); 42 | GiSTlistnode *temp = rear; 43 | T e = rear->entry; 44 | rear = rear->prev; 45 | if (rear) rear->next = NULL; else front = NULL; 46 | delete temp; 47 | return e; 48 | } 49 | void Prepend(T entry) { 50 | GiSTlistnode *temp = new GiSTlistnode; 51 | 52 | temp->entry = entry; 53 | temp->next = front; 54 | temp->prev = NULL; 55 | 56 | if (rear == NULL) 57 | rear = temp; 58 | else 59 | front->prev = temp; 60 | front = temp; 61 | } 62 | void Append(T entry) { 63 | GiSTlistnode *temp = new GiSTlistnode; 64 | 65 | temp->entry = entry; 66 | temp->prev = rear; 67 | temp->next = NULL; 68 | 69 | if (front == NULL) 70 | front = temp; 71 | else 72 | rear->next = temp; 73 | rear = temp; 74 | } 75 | private: 76 | GiSTlistnode *front, *rear; 77 | }; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /GiST/doc/readme.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | libGiST, v.0.9b1 5 | 6 | 7 | 8 | 9 |

libGiST v.0.9b1

10 | 11 |

12 |


13 | 14 |

libGiST: Generalized Search Tree C++ Library

15 | 16 |

libGiST is not public domain software. It is copyrighted by the University 17 | of California but may be used according to the licensing terms of the the 18 | copyright below:

19 | 20 |

21 |


22 | 23 |

Copyright (c) 1996 Regents of the University of California

24 | 25 |

Permission to use, copy, modify, and distribute this software and its 26 | documentation for any purpose, without fee, and without a written agreement 27 | is hereby granted, provided that the above copyright notice and this paragraph 28 | and the following two paragraphs appear in all copies.

29 | 30 |

IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 31 | FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING 32 | LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, 33 | EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY 34 | OF SUCH DAMAGE.

35 | 36 |

THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 37 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 38 | AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 39 | ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO 40 | OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR 41 | MODIFICATIONS.

42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /CSharp/FastDbNet.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 21 | 37 | 38 | 39 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /GiST/RSTree/RTentry.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // RTentry.cpp 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/RSTree/RTentry.cpp,v 1.1 2007/07/18 20:45:46 knizhnik Exp $ 7 | // 8 | // R-Tree Entry Class 9 | 10 | #include "RT.h" 11 | 12 | // R*-tree penalty metric returns a triplet: 13 | // The first entry is the "Overlap Enlargement", which is used only 14 | // at the level above the leaves. The second entry is the area enlargement, 15 | // which is used everywhere else, and to break ties in the first entry. 16 | // The third entry is just area, which is used to break ties in the second 17 | // entry. 18 | GiSTpenalty * 19 | RTentry::Penalty(const GiSTentry &newEntry) const 20 | { 21 | RTpenalty *retval = new RTpenalty; 22 | assert(newEntry.IsA() == RTENTRY_CLASS); 23 | 24 | const RTentry& e = (const RTentry &) newEntry; 25 | RTkey *tmpkey = Key().expand(e.Key()); 26 | 27 | // If we're one level up from the leaves, return overlap enlargement 28 | if (Level() == 1) { 29 | double curoverlap = OverlapArea(Key()); 30 | double newoverlap = OverlapArea(*tmpkey); 31 | *retval = MAX(newoverlap - curoverlap, 0); 32 | } 33 | else *retval = 0; 34 | retval->amount2 = (MAX(tmpkey->area() - e.Key().area(), 0)); 35 | retval->amount3 = e.Key().area(); 36 | 37 | delete tmpkey; 38 | return((GiSTpenalty *)retval); 39 | } 40 | 41 | double 42 | RTentry::OverlapArea(const RTkey &k) const 43 | { 44 | int i; 45 | GiSTnode *n = Node(); 46 | RTkey *okey, *tmpkey; 47 | double retval; 48 | 49 | okey = new RTkey(k); 50 | 51 | for (i = 0; i < n->NumEntries(); i++) 52 | if (i != Position()) { 53 | tmpkey = okey; 54 | okey = tmpkey->intersect(((RTentry *)((*n)[i].Ptr()))->bbox()); 55 | delete tmpkey; 56 | if (okey == NULL) 57 | return(0); 58 | } 59 | retval = okey->area(); 60 | delete okey; 61 | return(retval); 62 | } 63 | -------------------------------------------------------------------------------- /GiST/libGiST/GiSTdefs.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // GiSTdefs.h 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/libGiST/GiSTdefs.h,v 1.1 2007/07/18 20:45:49 knizhnik Exp $ 7 | 8 | #ifndef GISTDEFS_H 9 | #define GISTDEFS_H 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #ifdef PRINTING_OBJECTS 16 | #include 17 | #endif 18 | 19 | // A GiSTpage is a disk page number (a "pointer" to a disk page) 20 | typedef unsigned long GiSTpage; 21 | 22 | // GiSTobjid's are used to identify objects 23 | // You can add new ones as you define new objects, or simply 24 | // make things be GISTOBJECT_CLASS if you don't want to bother. 25 | typedef enum { 26 | GISTOBJECT_CLASS, 27 | GIST_CLASS, 28 | BT_CLASS, 29 | RT_CLASS, 30 | GISTENTRY_CLASS, 31 | GISTNODE_CLASS, 32 | BTNODE_CLASS, 33 | BTENTRY_CLASS, 34 | BTKEY_CLASS, 35 | RTNODE_CLASS, 36 | RTENTRY_CLASS, 37 | RTKEY_CLASS, 38 | GISTPREDICATE_CLASS, 39 | BTPREDICATE_CLASS, 40 | RTPREDICATE_CLASS, 41 | GISTCURSOR_CLASS 42 | } GiSTobjid; 43 | 44 | // GiSTobject is the base class for all GiST classes 45 | // It provides identity, equality tests and display of objects 46 | 47 | class GiSTobject 48 | { 49 | public: 50 | virtual GiSTobjid IsA() const { return GISTOBJECT_CLASS; } 51 | virtual GiSTobject *Copy() const { return NULL; } 52 | virtual int IsEqual(const GiSTobject& obj) const { return 0; } 53 | #ifdef PRINTING_OBJECTS 54 | virtual void Print(ostream& os) const { os << "No print method\n"; } 55 | #endif 56 | virtual ~GiSTobject() {} 57 | }; 58 | 59 | #ifdef PRINTING_OBJECTS 60 | inline ostream& operator<< (ostream& os, const GiSTobject& obj) { 61 | obj.Print(os); 62 | return os; 63 | } 64 | 65 | inline ostream& operator<< (ostream& os, const GiSTobject *obj) { 66 | obj->Print(os); 67 | return os; 68 | } 69 | #endif 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /CSharp/CLI-CSharp.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastDbNet", "FastDbNet.csproj", "{69D6077F-07F8-4CA5-B99B-3432CE9AFC67}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | EndProjectSection 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test1", "Test1.csproj", "{AB5AE174-68C9-4678-84D8-9B5643B49D84}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | EndProjectSection 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test2", "Test2.csproj", "{AB5AE174-68C9-4678-84D8-9B5643B49D84}" 11 | ProjectSection(ProjectDependencies) = postProject 12 | EndProjectSection 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfiguration) = preSolution 16 | Debug = Debug 17 | Release = Release 18 | EndGlobalSection 19 | GlobalSection(ProjectConfiguration) = postSolution 20 | {69D6077F-07F8-4CA5-B99B-3432CE9AFC67}.Debug.ActiveCfg = Debug|.NET 21 | {69D6077F-07F8-4CA5-B99B-3432CE9AFC67}.Debug.Build.0 = Debug|.NET 22 | {69D6077F-07F8-4CA5-B99B-3432CE9AFC67}.Release.ActiveCfg = Release|.NET 23 | {69D6077F-07F8-4CA5-B99B-3432CE9AFC67}.Release.Build.0 = Release|.NET 24 | {AB5AE174-68C9-4678-84D8-9B5643B49D84}.Debug.ActiveCfg = Debug|.NET 25 | {AB5AE174-68C9-4678-84D8-9B5643B49D84}.Debug.Build.0 = Debug|.NET 26 | {AB5AE174-68C9-4678-84D8-9B5643B49D84}.Release.ActiveCfg = Release|.NET 27 | {AB5AE174-68C9-4678-84D8-9B5643B49D84}.Release.Build.0 = Release|.NET 28 | {AB5AE174-68C9-4678-84D8-9B5643B49D84}.Debug.ActiveCfg = Debug|.NET 29 | {AB5AE174-68C9-4678-84D8-9B5643B49D84}.Debug.Build.0 = Debug|.NET 30 | {AB5AE174-68C9-4678-84D8-9B5643B49D84}.Release.ActiveCfg = Release|.NET 31 | {AB5AE174-68C9-4678-84D8-9B5643B49D84}.Release.Build.0 = Release|.NET 32 | EndGlobalSection 33 | GlobalSection(ExtensibilityGlobals) = postSolution 34 | EndGlobalSection 35 | GlobalSection(ExtensibilityAddIns) = postSolution 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /CSharp/Test1.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 21 | 37 | 38 | 39 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /CSharp/Test2.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 21 | 37 | 38 | 39 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /GiST/RSTree/RT.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // RT.cpp 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/RSTree/RT.cpp,v 1.1 2007/07/18 20:45:46 knizhnik Exp $ 7 | 8 | #include 9 | 10 | #include "GiST.h" 11 | #include "RT.h" 12 | 13 | typedef struct { 14 | double dist; 15 | int ix; 16 | } distix; 17 | 18 | extern "C" int 19 | GiSTdistixcmp(const void *x, const void *y) 20 | { 21 | distix a = *(distix *)x; 22 | distix b = *(distix *)y; 23 | 24 | if (a.dist > b.dist) 25 | return(-1); 26 | else if (a.dist == b.dist) 27 | return(0); 28 | else return(1); 29 | } 30 | 31 | extern "C" int GiSTintcmp(const void *x, const void *y); 32 | GiSTlist 33 | RT::RemoveTop(GiSTnode *node) 34 | { 35 | GiSTlist deleted; 36 | int count = node->NumEntries(); 37 | int num_rem = (int)((count + 1)*RemoveRatio() + 0.5); 38 | distix *dvec = new distix[node->NumEntries()]; 39 | int *ivec = new int[num_rem]; 40 | RTentry *uentry = (RTentry *)(node->Union()); 41 | RTkey tmpbox; 42 | int i; 43 | 44 | // compute distance of each node to center of bounding box, 45 | // and sort by decreasing distance 46 | for (i = 0; i < node->NumEntries(); i++) { 47 | dvec[i].ix = i; 48 | tmpbox = ((RTentry *)((*node)[i].Ptr()))->bbox(); 49 | dvec[i].dist = tmpbox.dist(uentry->bbox()); 50 | } 51 | delete uentry; 52 | 53 | qsort(dvec, node->NumEntries(), sizeof(distix), GiSTdistixcmp); 54 | 55 | for (i = 0; i < num_rem; i++) 56 | ivec[i] = dvec[i].ix; 57 | 58 | delete dvec; 59 | 60 | // sort the first num_rem by index number to make removal easier 61 | qsort(ivec, num_rem, sizeof(int), GiSTintcmp); 62 | 63 | for (i = num_rem - 1; i >=0 ; i--) { 64 | RTentry *tmpentry = new RTentry(*(RTentry *)((*node)[ivec[i]].Ptr())); 65 | deleted.Append(tmpentry); 66 | node->DeleteEntry(ivec[i]); 67 | } 68 | 69 | delete ivec; 70 | 71 | return(deleted); 72 | } 73 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | INCLUDES = -I${top_srcdir}/inc 2 | 3 | pkginclude_HEADERS = \ 4 | ${top_srcdir}/inc/fastdb.h \ 5 | ${top_srcdir}/inc/stdtp.h \ 6 | ${top_srcdir}/inc/config.h \ 7 | ${top_srcdir}/inc/class.h \ 8 | ${top_srcdir}/inc/database.h \ 9 | ${top_srcdir}/inc/cursor.h \ 10 | ${top_srcdir}/inc/reference.h \ 11 | ${top_srcdir}/inc/wwwapi.h \ 12 | ${top_srcdir}/inc/cli.h \ 13 | ${top_srcdir}/inc/array.h \ 14 | ${top_srcdir}/inc/file.h \ 15 | ${top_srcdir}/inc/hashtab.h \ 16 | ${top_srcdir}/inc/ttree.h \ 17 | ${top_srcdir}/inc/rtree.h \ 18 | ${top_srcdir}/inc/container.h \ 19 | ${top_srcdir}/inc/sync.h \ 20 | ${top_srcdir}/inc/sync_unix.h \ 21 | ${top_srcdir}/inc/query.h \ 22 | ${top_srcdir}/inc/datetime.h \ 23 | ${top_srcdir}/inc/harray.h \ 24 | ${top_srcdir}/inc/rectangle.h \ 25 | ${top_srcdir}/inc/timeseries.h \ 26 | ${top_srcdir}/inc/exception.h 27 | 28 | lib_LTLIBRARIES = libfastdb.la libcli.la 29 | bin_PROGRAMS = subsql forcerecovery cleanupsem 30 | noinst_PROGRAMS = cgistub 31 | 32 | LIBSRC = \ 33 | class.cpp \ 34 | compiler.cpp \ 35 | database.cpp \ 36 | xml.cpp \ 37 | hashtab.cpp \ 38 | file.cpp \ 39 | symtab.cpp \ 40 | ttree.cpp \ 41 | rtree.cpp \ 42 | container.cpp \ 43 | cursor.cpp \ 44 | query.cpp \ 45 | wwwapi.cpp \ 46 | unisock.cpp \ 47 | sync.cpp \ 48 | localcli.cpp \ 49 | stdtp.cpp 50 | 51 | if NO_PTHREADS 52 | else 53 | LIBSRC += server.cpp 54 | endif 55 | 56 | 57 | libfastdb_la_SOURCES = $(LIBSRC) 58 | libfastdb_la_LDFLAGS = -version-info 2:0:0 59 | 60 | libcli_la_SOURCES = cli.cpp unisock.cpp repsock.cpp stdtp.cpp 61 | libcli_la_LDFLAGS = -version-info 2:0:0 62 | 63 | subsql_SOURCES = subsql.cpp 64 | subsql_LDADD = ${builddir}/libfastdb.la 65 | 66 | forcerecovery_SOURCES = forcerecovery.cpp 67 | cleanupsem_SOURCES = cleanupsem.cpp 68 | 69 | cgistub_SOURCES = cgistub.cpp 70 | cgistub_LDADD = ${builddir}/libfastdb.la 71 | 72 | 73 | # work around for libtool issue when compiling the same sources both 74 | # with libtool and without 75 | #libfastdb_la_CFLAGS = $(AM_CFLAGS) 76 | #libfastdb_la_CXXFLAGS = $(AM_CXXFLAGS) 77 | -------------------------------------------------------------------------------- /GiST/libGiST/GiSTdb.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // GiSTdb.cpp 4 | 5 | #include "GiSTdb.h" 6 | #include "GiSTpath.h" 7 | 8 | REGISTER(GiSTtable); 9 | 10 | GiSTdb::GiSTdb(dbDatabase& aDB) : GiSTstore(), db(aDB) 11 | { 12 | query = "name=",&tableName; 13 | rootPageId = 0; 14 | } 15 | 16 | 17 | void 18 | GiSTdb::Create(const char *tableName) 19 | { 20 | if (IsOpen()) { 21 | return; 22 | } 23 | dbCursor cursor; 24 | this->tableName = tableName; 25 | SetOpen(1); 26 | if (cursor.select(query) == 0) { 27 | GiSTtable table; 28 | table.name = tableName; 29 | rootPageId = Allocate(); 30 | table.rootPageId = rootPageId; 31 | insert(table); 32 | } else { 33 | rootPageId = cursor->rootPageId; 34 | } 35 | } 36 | 37 | 38 | void 39 | GiSTdb::Open(const char *tableName) 40 | { 41 | dbCursor cursor; 42 | this->tableName = tableName; 43 | if (cursor.select(query) != 0) { 44 | rootPageId = cursor->rootPageId; 45 | SetOpen(1); 46 | } 47 | } 48 | 49 | void 50 | GiSTdb::Close() 51 | { 52 | if (!IsOpen()) { 53 | return; 54 | } 55 | SetOpen(0); 56 | } 57 | 58 | void 59 | GiSTdb::Read(GiSTpage page, char *buf) 60 | { 61 | if (IsOpen()) { 62 | if (page == GiSTRootPage) { 63 | page = rootPageId; 64 | } 65 | memcpy(buf, db.get(page), dbPageSize); 66 | } 67 | } 68 | 69 | void 70 | GiSTdb::Write(GiSTpage page, const char *buf) 71 | { 72 | if (IsOpen()) { 73 | if (page == GiSTRootPage) { 74 | page = rootPageId; 75 | } 76 | memcpy(db.put(page), buf, dbPageSize); 77 | } 78 | } 79 | 80 | GiSTpage 81 | GiSTdb::Allocate() 82 | { 83 | if (!IsOpen()) { 84 | return 0; 85 | } 86 | oid_t page = db.allocateObject(dbPageObjectMarker); 87 | byte* pg = db.get(page); 88 | memset(pg, 0, dbPageSize); 89 | return page; 90 | } 91 | 92 | void 93 | GiSTdb::Deallocate(GiSTpage page) 94 | { 95 | db.freeObject(page); 96 | } 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /jnicli/docs/jnicli/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | jnicli 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | jnicli 20 | 21 | 22 | 31 | 32 |
23 | Interfaces  24 | 25 |
26 | Cursor 27 |
28 | Database 29 |
30 | DatabaseSession
33 | 34 | 35 | 36 | 37 | 48 | 49 |
38 | Classes  39 | 40 |
41 | DatabaseJNI 42 |
43 | DatabaseSessionClient 44 |
45 | DatabaseSessionServer 46 |
47 | PrefetchedCursor
50 | 51 | 52 | 53 | 54 | 59 | 60 |
55 | Exceptions  56 | 57 |
58 | CliException
61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /jnicli/DatabaseSessionServer.java: -------------------------------------------------------------------------------- 1 | package jnicli; 2 | 3 | /** 4 | * Database session client implementation. Server side implementation of DatabaseSession interface. 5 | * It redirect methods to DatabaseJNI class. 6 | */ 7 | public class DatabaseSessionServer implements DatabaseSession { 8 | public long open(int accessType, String databaseName, String databasePath, long initSize, int transactionCommitDelay) { 9 | jni.open(accessType, databaseName, databasePath, initSize, transactionCommitDelay); 10 | return jni.getThreadContext(); 11 | } 12 | 13 | public void close(long session) { 14 | jni.setThreadContext(session); 15 | jni.close(); 16 | } 17 | 18 | public Cursor select(long session, Class table, String condition, int flags) { 19 | jni.setThreadContext(session); 20 | return jni.select(table, condition, flags); 21 | } 22 | 23 | public void update(long session, long oid, Object obj) { 24 | jni.setThreadContext(session); 25 | jni.update(oid, obj); 26 | } 27 | 28 | public long insert(long session, Object obj) { 29 | jni.setThreadContext(session); 30 | return jni.insert(obj); 31 | } 32 | 33 | public int delete(long session, Class table, String condition) { 34 | jni.setThreadContext(session); 35 | return jni.delete(table, condition); 36 | } 37 | 38 | public void commit(long session) { 39 | jni.setThreadContext(session); 40 | jni.commit(); 41 | } 42 | 43 | public void rollback(long session) { 44 | jni.setThreadContext(session); 45 | jni.rollback(); 46 | } 47 | 48 | public void lock(long session) { 49 | jni.setThreadContext(session); 50 | jni.lock(); 51 | } 52 | 53 | public long attach() { 54 | jni.attach(); 55 | return jni.getThreadContext(); 56 | } 57 | 58 | public void detach(long session, int flags) { 59 | jni.setThreadContext(session); 60 | jni.detach(flags); 61 | } 62 | 63 | public DatabaseSessionServer() { 64 | jni = new DatabaseJNI(true); 65 | } 66 | 67 | private DatabaseJNI jni; 68 | } 69 | 70 | -------------------------------------------------------------------------------- /CSharpRemoteCLI/csharpcli.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | Debug 4 | AnyCPU 5 | 6 | 7 | 8 | 9 | 10 | 11 | 0 12 | ProjectFiles 13 | 0 14 | 15 | 16 | false 17 | false 18 | false 19 | false 20 | false 21 | 22 | 23 | Project 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | true 35 | 36 | 37 | false 38 | false 39 | false 40 | false 41 | false 42 | 43 | 44 | Project 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | true 56 | 57 | -------------------------------------------------------------------------------- /GiST/doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | libGiST, v.0.9b1 5 | 6 | 7 | 8 | 9 |
    10 |

    libGiST, v.0.9b1

    11 |
12 | 13 |

14 |


15 | 16 |

Welcome to release 0.9 beta 1 of the GiST C++ library. This document 17 | should help you get the code installed, and get you writing your own index 18 | code quickly.

19 | 20 |

21 |


22 | 23 |

Table of Contents

24 | 25 | 34 | 35 |

36 |

37 | 38 |

Related Material

39 | 40 | 57 | 58 |

59 |


60 | 61 |

Comments, questions and suggestions may be directed to gist@postgres.berkeley.edu 62 |

63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /subsql4ce/subsql4ce.vcl: -------------------------------------------------------------------------------- 1 | 2 | 3 |
 4 | 

Build Log

5 |

6 | --------------------Configuration: subsql4ce - Win32 (WCE x86) Debug-------------------- 7 |

8 |

Command Lines

9 | Creating temporary file "C:\DOCUME~1\Knizhnik\LOCALS~1\Temp\RSP2EF.tmp" with contents 10 | [ 11 | /nologo /W3 /Zi /Od /I "..\inc" /D "DEBUG" /D "_i386_" /D UNDER_CE=400 /D _WIN32_WCE=400 /D "WCE_PLATFORM_STANDARDSDK" /D "i_386_" /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /Fp"X86Dbg/subsql4ce.pch" /YX /Fo"X86Dbg/" /Fd"X86Dbg/" /Gs8192 /GF /c 12 | "C:\fastdb\src\server.cpp" 13 | "C:\fastdb\src\subsql.cpp" 14 | ] 15 | Creating command line "cl.exe @C:\DOCUME~1\Knizhnik\LOCALS~1\Temp\RSP2EF.tmp" 16 | Creating temporary file "C:\DOCUME~1\Knizhnik\LOCALS~1\Temp\RSP2F0.tmp" with contents 17 | [ 18 | corelibc.lib ..\fastdb.lib commctrl.lib coredll.lib winsock.lib /nologo /base:"0x00010000" /stack:0x10000,0x1000 /entry:"WinMainCRTStartup" /incremental:yes /pdb:"X86Dbg/subsql.pdb" /debug /nodefaultlib:"OLDNAMES.lib" /nodefaultlib:libc.lib /nodefaultlib:libcd.lib /nodefaultlib:libcmt.lib /nodefaultlib:libcmtd.lib /nodefaultlib:msvcrt.lib /nodefaultlib:msvcrtd.lib /out:"subsql.exe" /subsystem:windowsce,4.00 /MACHINE:IX86 19 | .\X86Dbg\server.obj 20 | .\X86Dbg\subsql.obj 21 | ] 22 | Creating command line "link.exe @C:\DOCUME~1\Knizhnik\LOCALS~1\Temp\RSP2F0.tmp" 23 |

Output Window

24 | Compiling... 25 | server.cpp 26 | C:\fastdb\src\server.cpp(1324) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify -GX 27 | subsql.cpp 28 | C:\fastdb\src\subsql.cpp(197) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify -GX 29 | C:\Program Files\Windows CE Tools\wce400\STANDARDSDK\Include\x86\xstring(724) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify -GX 30 | C:\Program Files\Windows CE Tools\wce400\STANDARDSDK\Include\x86\xstring(720) : while compiling class-template member function 'void __thiscall std::basic_string,class std::allocator >::_Copy(unsigned int)' 31 | Linking... 32 | 33 | 34 | 35 | 36 |

Results

37 | subsql.exe - 0 error(s), 3 warning(s) 38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /jnicli/Cursor.java: -------------------------------------------------------------------------------- 1 | package jnicli; 2 | 3 | import java.util.Enumeration; 4 | 5 | /** 6 | * Iterator through result set returned by Database.select. 7 | * There are two types of cursors: incremental and prefetched. 8 | * Incremental cursor fetch records on demand (one record at each iteration). 9 | * And prefetched cursor loads all selected records. 10 | * Prefetched cursor is used in case of remote database connections and when AUTOCOMMIT flag is set in select 11 | */ 12 | public interface Cursor { // extends Enumeration { // if Cursor is derived from enumeration, then Hessian tries tp deserialize it as Vector 13 | /** 14 | * Tests if this enumeration contains more elements. 15 | * 16 | * @return true if and only if this enumeration object 17 | * contains at least one more element to provide; 18 | * false otherwise. 19 | */ 20 | boolean hasMoreElements(); 21 | 22 | /** 23 | * Returns the next element of this enumeration if this enumeration 24 | * object has at least one more element to provide. 25 | * 26 | * @return the next element of this enumeration. 27 | * @exception NoSuchElementException if no more elements exist. 28 | */ 29 | Object nextElement(); 30 | 31 | /** 32 | * Get OID of the current object. This method should be used only after 33 | * Enumeration.nextElement() method and its result is OID of the object returned 34 | * by nextElement(). 35 | * @exception java.util.NoSuchElementException if there is no current element 36 | */ 37 | long getOid(); 38 | 39 | /** 40 | * Update current object. This method should be invoked after Enumeration.nextElement() 41 | * and store updated object, returned by nextElement(). 42 | * This method is not supported for prefetched cursor (which is returned for remote database or 43 | * when AUTOCOMMIT flag is set in select). In this case you should use Database.update method 44 | * specifying OID of updated object. This OID can be obtained using Cursor.getOid() method. 45 | * @exception java.util.NoSuchElementException if there is no current element 46 | */ 47 | void update(); 48 | 49 | /** 50 | * Get number of selected records 51 | */ 52 | int size(); 53 | } -------------------------------------------------------------------------------- /inc/repsock.h: -------------------------------------------------------------------------------- 1 | //-< REPSOCK.H >-----------------------------------------------------*--------* 2 | // FastDB Version 1.0 (c) 1999 GARRET * ? * 3 | // (Main Memory Database Management System) * /\| * 4 | // * / \ * 5 | // Created: 6-May-2003 K.A. Knizhnik * / [] \ * 6 | // Last update: 6-Apr-2003 K.A. Knizhnik * GARRET * 7 | //-------------------------------------------------------------------*--------* 8 | // Replication socket 9 | //-------------------------------------------------------------------*--------* 10 | 11 | #ifndef __REPSOCK_H__ 12 | #define __REPSOCK_H__ 13 | 14 | #include "sockio.h" 15 | 16 | BEGIN_FASTDB_NAMESPACE 17 | 18 | 19 | // 20 | // Socket use for CLI level replication 21 | // 22 | class FASTDB_DLL_ENTRY replication_socket_t : public socket_t { 23 | public: 24 | virtual int read(void* buf, size_t min_size, size_t max_size, time_t timeout); 25 | virtual bool write(void const* buf, size_t size, time_t timeout); 26 | 27 | virtual bool is_ok(); 28 | virtual void get_error_text(char* buf, size_t buf_size); 29 | 30 | virtual bool shutdown(); 31 | 32 | virtual bool close(); 33 | 34 | virtual void handleError(int socket, const char* operation, const char* error); 35 | 36 | static replication_socket_t* connect(char const* addresses[], 37 | int n_addresses, 38 | int max_attempts = DEFAULT_CONNECT_MAX_ATTEMPTS, 39 | time_t timeout = DEFAULT_RECONNECT_TIMEOUT); 40 | 41 | // 42 | // Not implemented for replication socket 43 | // 44 | virtual socket_t* accept(); 45 | virtual bool cancel_accept(); 46 | virtual char* get_peer_name(); 47 | virtual socket_handle_t get_handle(); 48 | 49 | enum { 50 | MaxSockets = 8 51 | }; 52 | 53 | 54 | ~replication_socket_t(); 55 | 56 | protected: 57 | replication_socket_t(char const* addresses[], int n_adresses, int max_attempts, time_t timeout); 58 | 59 | socket_t** sockets; 60 | int n_sockets; 61 | bool succeed; 62 | }; 63 | 64 | END_FASTDB_NAMESPACE 65 | 66 | #endif 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /FastDB.bpg: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | VERSION = BWS.01 3 | #------------------------------------------------------------------------------ 4 | !ifndef ROOT 5 | ROOT = $(MAKEDIR)\.. 6 | !endif 7 | #------------------------------------------------------------------------------ 8 | MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$** 9 | DCC = $(ROOT)\bin\dcc32.exe $** 10 | BRCC = $(ROOT)\bin\brcc32.exe $** 11 | #------------------------------------------------------------------------------ 12 | PROJECTS = FastDB.dll TestDB.exe TestDDL.exe TestCLI.exe TestIdx.exe \ 13 | TestIref.exe TestJoin.exe TestLeak.exe TestPerf.exe TestRaw.exe TestSync.exe \ 14 | TestTrav.exe FastDBlib.lib 15 | #------------------------------------------------------------------------------ 16 | default: $(PROJECTS) 17 | #------------------------------------------------------------------------------ 18 | 19 | FastDB.dll: FastDB.bpr 20 | $(ROOT)\bin\bpr2mak $** 21 | $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak 22 | 23 | TestDB.exe: TestDB.bpr 24 | $(ROOT)\bin\bpr2mak $** 25 | $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak 26 | 27 | TestDDL.exe: TestDDL.bpr 28 | $(ROOT)\bin\bpr2mak $** 29 | $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak 30 | 31 | TestCLI.exe: TestCLI.bpr 32 | $(ROOT)\bin\bpr2mak $** 33 | $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak 34 | 35 | TestIdx.exe: TestIdx.bpr 36 | $(ROOT)\bin\bpr2mak $** 37 | $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak 38 | 39 | TestIref.exe: TestIref.bpr 40 | $(ROOT)\bin\bpr2mak $** 41 | $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak 42 | 43 | TestJoin.exe: TestJoin.bpr 44 | $(ROOT)\bin\bpr2mak $** 45 | $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak 46 | 47 | TestLeak.exe: TestLeak.bpr 48 | $(ROOT)\bin\bpr2mak $** 49 | $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak 50 | 51 | TestPerf.exe: TestPerf.bpr 52 | $(ROOT)\bin\bpr2mak $** 53 | $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak 54 | 55 | TestRaw.exe: TestRaw.bpr 56 | $(ROOT)\bin\bpr2mak $** 57 | $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak 58 | 59 | TestSync.exe: TestSync.bpr 60 | $(ROOT)\bin\bpr2mak $** 61 | $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak 62 | 63 | TestTrav.exe: TestTrav.bpr 64 | $(ROOT)\bin\bpr2mak $** 65 | $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak 66 | 67 | FastDBlib.lib: FastDBlib.bpr 68 | $(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $** 69 | $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak 70 | 71 | 72 | -------------------------------------------------------------------------------- /GiST/libGiST/GiSTpath.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // GiSTpath.h 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/libGiST/GiSTpath.h,v 1.1 2007/07/18 20:45:50 knizhnik Exp $ 7 | #ifndef GISTPATH_H 8 | #define GISTPATH_H 9 | 10 | // GiSTpath objects store the path to a node from the root of the tree. 11 | // The page number of each node visited is stored. For simplicity, 12 | // GiSTpaths are stored as an array with max GIST_MAX_LEVELS elements. 13 | // This can be expanded if you want a tree with more than 16 levels 14 | // (not likely unless you have big keys, or small pages!) 15 | 16 | #define GiSTRootPage 1 17 | 18 | #define GIST_MAX_LEVELS 16 19 | 20 | class GiSTpath : public GiSTobject 21 | { 22 | GiSTpage pages[GIST_MAX_LEVELS]; 23 | int len; 24 | public: 25 | GiSTpath() { 26 | len = 0; 27 | } 28 | GiSTpath(const GiSTpath& path) { 29 | len = path.len; 30 | for (int i=0; i1; i--) pages[i] = pages[i-1]; 63 | pages[1] = page; 64 | pages[0] = GiSTRootPage; 65 | } 66 | GiSTpath& operator = (const GiSTpath& path) { 67 | len = path.len; 68 | for (int i=0; i= 2 ? pages[len-2] : 0; } 81 | int IsRoot() const { return len==1; } 82 | }; 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /inc/unisock.h: -------------------------------------------------------------------------------- 1 | //-< UNISOCK.H >-----------------------------------------------------*--------* 2 | // FastDB Version 1.0 (c) 1997 GARRET * ? * 3 | // (Main Memory Database Management System) * /\| * 4 | // * / \ * 5 | // Created: 7-Jan-97 K.A. Knizhnik * / [] \ * 6 | // Last update: 7-Jan-97 K.A. Knizhnik * GARRET * 7 | //-------------------------------------------------------------------*--------* 8 | // Unix socket 9 | //-------------------------------------------------------------------*--------* 10 | 11 | #ifndef __UNISOCK_H__ 12 | #define __UNISOCK_H__ 13 | 14 | #include "sockio.h" 15 | 16 | BEGIN_FASTDB_NAMESPACE 17 | 18 | class unix_socket : public socket_t { 19 | protected: 20 | int fd; 21 | int errcode; // error code of last failed operation 22 | char* address; // host address 23 | socket_domain domain; // Unix domain or INET socket 24 | bool create_file; // Unix domain sockets use files for connection 25 | 26 | enum error_codes { 27 | ok = 0, 28 | not_opened = -1, 29 | bad_address = -2, 30 | connection_failed = -3, 31 | broken_pipe = -4, 32 | invalid_access_mode = -5 33 | }; 34 | 35 | public: 36 | // 37 | // Directory for Unix Domain socket files. This directory should be 38 | // either empty or be terminated with "/". Dafault value is "/tmp/" 39 | // 40 | static char* unix_socket_dir; 41 | 42 | bool open(int listen_queue_size); 43 | bool connect(int max_attempts, time_t timeout); 44 | 45 | int read(void* buf, size_t min_size, size_t max_size, time_t timeout); 46 | bool write(void const* buf, size_t size, time_t timeout); 47 | 48 | bool is_ok(); 49 | bool shutdown(); 50 | bool close(); 51 | char* get_peer_name(); 52 | void get_error_text(char* buf, size_t buf_size); 53 | 54 | socket_t* accept(); 55 | bool cancel_accept(); 56 | 57 | socket_handle_t get_handle(); 58 | 59 | unix_socket(const char* address, socket_domain domain); 60 | unix_socket(int new_fd); 61 | 62 | ~unix_socket(); 63 | }; 64 | 65 | END_FASTDB_NAMESPACE 66 | 67 | #endif 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /GiST/libGiST/GiST.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // GiST.h 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/libGiST/GiST.h,v 1.1 2007/07/18 20:45:49 knizhnik Exp $ 7 | 8 | #ifndef GIST_H 9 | #define GIST_H 10 | 11 | #include "GiSTdefs.h" 12 | #include "GiSTentry.h" 13 | #include "GiSTlist.h" 14 | #include "GiSTnode.h" 15 | #include "GiSTstore.h" 16 | #include "GiSTpredicate.h" 17 | #include "GiSTcursor.h" 18 | 19 | class GiST : public GiSTobject 20 | { 21 | public: 22 | GiST(); 23 | 24 | // a likely candidate for overloading 25 | GiSTobjid IsA() const { return GIST_CLASS; } 26 | 27 | void Create(const char *filename); 28 | void Open(const char *filename); 29 | void Close(); 30 | 31 | 32 | 33 | GiSTcursor *Search(const GiSTpredicate &query) const; 34 | void Insert(const GiSTentry& entry); 35 | void Delete(const GiSTpredicate& pred); 36 | void Sync(); 37 | GiSTstore *Store() { return store; } 38 | 39 | int IsOpen() { return isOpen; } 40 | virtual int IsOrdered() const { return 0; } 41 | virtual int ForcedReinsert() const { return 0; } 42 | 43 | #ifdef PRINTING_OBJECTS 44 | void DumpNode(ostream& os, GiSTpath path) const; 45 | void Print(ostream& os) const; 46 | #endif 47 | 48 | ~GiST(); 49 | 50 | protected: 51 | // The following must be overriden by descendant classes 52 | virtual GiSTstore *CreateStore() const = 0; 53 | virtual GiSTnode *CreateNode() const = 0; 54 | 55 | // These are default supports for Forced Reinsert 56 | virtual GiSTlist RemoveTop(GiSTnode *node); 57 | virtual double RemoveRatio() const { return 0.3; } 58 | 59 | // Reads/writes nodes 60 | GiSTnode *ReadNode(const GiSTpath& path) const; 61 | void WriteNode(GiSTnode *node); 62 | 63 | 64 | private: 65 | void InsertHelper(const GiSTentry &entry, int level, int *lvl_split = NULL); 66 | GiSTnode *ChooseSubtree(GiSTpage page, const GiSTentry &entry, int level); 67 | void Split(GiSTnode **node, const GiSTentry& entry); 68 | void AdjustKeys(GiSTnode *node, GiSTnode **parent); 69 | int CondenseTree(GiSTnode *leaf); 70 | void ShortenTree(); 71 | void OverflowTreatment(GiSTnode *node, const GiSTentry& entry, 72 | int *lvl_split); 73 | GiSTnode *NewNode(GiST *tree) const { 74 | GiSTnode *retval = CreateNode(); 75 | retval->SetTree(tree); 76 | return(retval); 77 | } 78 | 79 | GiSTstore *store; 80 | int isOpen; 81 | 82 | int debug; 83 | 84 | friend GiSTcursor; 85 | }; 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /src/symtab.cpp: -------------------------------------------------------------------------------- 1 | //-< SYMTAB.CPP >----------------------------------------------------*--------* 2 | // FastDB Version 1.0 (c) 1999 GARRET * ? * 3 | // (Main Memory Database Management System) * /\| * 4 | // * / \ * 5 | // Created: 20-Nov-98 K.A. Knizhnik * / [] \ * 6 | // Last update: 20-Nov-98 K.A. Knizhnik * GARRET * 7 | //-------------------------------------------------------------------*--------* 8 | // Symbol table implementation 9 | //-------------------------------------------------------------------*--------* 10 | 11 | #define INSIDE_FASTDB 12 | 13 | #include "stdtp.h" 14 | #include "sync.h" 15 | #include "symtab.h" 16 | 17 | BEGIN_FASTDB_NAMESPACE 18 | 19 | const size_t hashTableSize = 1009; 20 | dbSymbolTable::HashTableItem* dbSymbolTable::hashTable[hashTableSize]; 21 | 22 | dbSymbolTable dbSymbolTable::instance; 23 | 24 | dbSymbolTable::~dbSymbolTable() { 25 | for (int i = hashTableSize; --i >= 0;) { 26 | HashTableItem *ip, *next; 27 | for (ip = hashTable[i]; ip != NULL; ip = next) { 28 | next = ip->next; 29 | delete ip; 30 | } 31 | } 32 | } 33 | #ifdef IGNORE_CASE 34 | #define strcmp(x,y) stricmp(x,y) 35 | #endif 36 | 37 | int dbSymbolTable::add(char* &str, int tag, bool allocate) { 38 | static dbMutex mutex; 39 | dbCriticalSection cs(mutex); 40 | unsigned hash = 0; 41 | byte* p = (byte*)str; 42 | while (*p != 0) { 43 | byte b = *p++; 44 | #ifdef IGNORE_CASE 45 | b = tolower(b); 46 | #endif 47 | hash = hash*31 + b; 48 | } 49 | int index = hash % hashTableSize; 50 | HashTableItem *ip; 51 | for (ip = hashTable[index]; ip != NULL; ip = ip->next) { 52 | if (ip->hash == hash && strcmp(ip->str, str) == 0) { 53 | str = ip->str; 54 | if (tag > ip->tag) { 55 | ip->tag = tag; 56 | } 57 | return ip->tag; 58 | } 59 | } 60 | ip = new HashTableItem; 61 | ip->allocated = false; 62 | if (allocate) { 63 | char* dupstr = new char[strlen(str) + 1]; 64 | strcpy(dupstr, str); 65 | str = dupstr; 66 | ip->allocated = true; 67 | } 68 | ip->str = str; 69 | ip->hash = hash; 70 | ip->tag = tag; 71 | ip->next = hashTable[index]; 72 | hashTable[index] = ip; 73 | return tag; 74 | } 75 | 76 | END_FASTDB_NAMESPACE 77 | -------------------------------------------------------------------------------- /CSharpRemoteCLI/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | // 9 | [assembly: AssemblyTitle("")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("")] 14 | [assembly: AssemblyCopyright("")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | 18 | // 19 | // Version information for an assembly consists of the following four values: 20 | // 21 | // Major Version 22 | // Minor Version 23 | // Build Number 24 | // Revision 25 | // 26 | // You can specify all the values or you can default the Revision and Build Numbers 27 | // by using the '*' as shown below: 28 | 29 | [assembly: AssemblyVersion("1.0.*")] 30 | 31 | // 32 | // In order to sign your assembly you must specify a key to use. Refer to the 33 | // Microsoft .NET Framework documentation for more information on assembly signing. 34 | // 35 | // Use the attributes below to control which key is used for signing. 36 | // 37 | // Notes: 38 | // (*) If no key is specified, the assembly is not signed. 39 | // (*) KeyName refers to a key that has been installed in the Crypto Service 40 | // Provider (CSP) on your machine. KeyFile refers to a file which contains 41 | // a key. 42 | // (*) If the KeyFile and the KeyName values are both specified, the 43 | // following processing occurs: 44 | // (1) If the KeyName can be found in the CSP, that key is used. 45 | // (2) If the KeyName does not exist and the KeyFile does exist, the key 46 | // in the KeyFile is installed into the CSP and used. 47 | // (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. 48 | // When specifying the KeyFile, the location of the KeyFile should be 49 | // relative to the project output directory which is 50 | // %Project Directory%\obj\. For example, if your KeyFile is 51 | // located in the project directory, you would specify the AssemblyKeyFile 52 | // attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] 53 | // (*) Delay Signing is an advanced option - see the Microsoft .NET Framework 54 | // documentation for more information on this. 55 | // 56 | [assembly: AssemblyDelaySign(false)] 57 | [assembly: AssemblyKeyFile("")] 58 | [assembly: AssemblyKeyName("")] 59 | -------------------------------------------------------------------------------- /CSharp/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | // 9 | [assembly: AssemblyTitle("FastDbNet")] 10 | [assembly: AssemblyDescription(".NET interface to FastDB database using CLI interface.")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("IDT")] 13 | [assembly: AssemblyProduct("")] 14 | [assembly: AssemblyCopyright("2004, Serge Aleynikov")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | 18 | // 19 | // Version information for an assembly consists of the following four values: 20 | // 21 | // Major Version 22 | // Minor Version 23 | // Build Number 24 | // Revision 25 | // 26 | // You can specify all the values or you can default the Revision and Build Numbers 27 | // by using the '*' as shown below: 28 | 29 | [assembly: AssemblyVersion("3.0.1.*")] 30 | 31 | // 32 | // In order to sign your assembly you must specify a key to use. Refer to the 33 | // Microsoft .NET Framework documentation for more information on assembly signing. 34 | // 35 | // Use the attributes below to control which key is used for signing. 36 | // 37 | // Notes: 38 | // (*) If no key is specified, the assembly is not signed. 39 | // (*) KeyName refers to a key that has been installed in the Crypto Service 40 | // Provider (CSP) on your machine. KeyFile refers to a file which contains 41 | // a key. 42 | // (*) If the KeyFile and the KeyName values are both specified, the 43 | // following processing occurs: 44 | // (1) If the KeyName can be found in the CSP, that key is used. 45 | // (2) If the KeyName does not exist and the KeyFile does exist, the key 46 | // in the KeyFile is installed into the CSP and used. 47 | // (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. 48 | // When specifying the KeyFile, the location of the KeyFile should be 49 | // relative to the project output directory which is 50 | // %Project Directory%\obj\. For example, if your KeyFile is 51 | // located in the project directory, you would specify the AssemblyKeyFile 52 | // attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] 53 | // (*) Delay Signing is an advanced option - see the Microsoft .NET Framework 54 | // documentation for more information on this. 55 | // 56 | [assembly: AssemblyDelaySign(false)] 57 | [assembly: AssemblyKeyFile("")] 58 | [assembly: AssemblyKeyName("")] 59 | -------------------------------------------------------------------------------- /examples/testfrag.cpp: -------------------------------------------------------------------------------- 1 | //-< TESTFRAG.CPP >--------------------------------------------------*--------* 2 | // FastDB Version 1.0 (c) 1999 GARRET * ? * 3 | // (Main Memory Database Management System) * /\| * 4 | // * / \ * 5 | // Created: 26-Jul-2001 K.A. Knizhnik * / [] \ * 6 | // Last update: 26-Jul-2001 K.A. Knizhnik * GARRET * 7 | //-------------------------------------------------------------------*--------* 8 | // Memory allocator test 9 | //-------------------------------------------------------------------*--------* 10 | 11 | #include "fastdb.h" 12 | #include 13 | 14 | USE_FASTDB_NAMESPACE 15 | 16 | #define N_ITERATIONS 1000000 17 | #define N_RECORDS 100000 18 | #define MAX_VALUE_LENGTH 1000 19 | 20 | class Record { 21 | public: 22 | int id; 23 | db_int8 key; 24 | dbArray value; 25 | 26 | TYPE_DESCRIPTOR((KEY(id, HASHED), KEY(key, INDEXED), FIELD(value))); 27 | }; 28 | 29 | REGISTER(Record); 30 | 31 | int main(int argc, char* argv[]) 32 | { 33 | int i; 34 | dbDatabase db; 35 | int nIterations = N_ITERATIONS; 36 | if (argc > 1) { 37 | nIterations = atoi(argv[1]); 38 | } 39 | dbDatabase::OpenParameters params; 40 | params.databaseName = _T("testfrag"); 41 | params.fileOpenFlags = dbFile::no_sync; 42 | if (db.open(params)) { 43 | Record rec; 44 | db_int8 key = 1999; 45 | for (i = 0; i < N_RECORDS; i++) { 46 | key = (3141592621u*key + 2718281829u) % 1000000007u; 47 | rec.id = i; 48 | rec.key = key; 49 | db.insert(rec); 50 | } 51 | dbCursor cursor(dbCursorForUpdate); 52 | int id; 53 | dbQuery q; 54 | q = "id=",id; 55 | for (i = 0; i < nIterations; i++) { 56 | id = i % N_RECORDS; 57 | cursor.select(q); 58 | cursor->key = key = (3141592621u*key + 2718281829u) % 1000000007u; 59 | cursor->value.resize((unsigned)(key*4) % MAX_VALUE_LENGTH); 60 | cursor.update(); 61 | db.commit(); 62 | if (i % 1000 == 0) { 63 | printf("Iteration %d\r", i); 64 | fflush(stdout); 65 | } 66 | } 67 | printf("\nUpdate completed\n"); 68 | db.close(); 69 | } else { 70 | fprintf(stderr, "Failed to open database\n"); 71 | } 72 | return 0; 73 | } 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /examples/JniTestIndex.java: -------------------------------------------------------------------------------- 1 | import jnicli.*; 2 | 3 | import java.util.*; 4 | 5 | public class JniTestIndex { 6 | static class Record { 7 | String strKey; 8 | long intKey; 9 | 10 | static final String CONSTRAINTS = "strKey using index, intKey using index"; 11 | } 12 | 13 | final static int nRecords = 100000; 14 | final static int initSize = 8*1024*1024; // 40Mb page pool 15 | 16 | static public void main(String[] args) { 17 | Database db = new DatabaseJNI(); 18 | db.open(Database.READ_WRITE, "testjni", "testjni.dbs", initSize, 0); 19 | long start = System.currentTimeMillis(); 20 | long key = 1999; 21 | int i; 22 | for (i = 0; i < nRecords; i++) { 23 | Record rec = new Record(); 24 | key = (3141592621L*key + 2718281829L) % 1000000007L; 25 | rec.intKey = key; 26 | rec.strKey = Long.toString(key); 27 | db.insert(rec); 28 | } 29 | db.commit(); 30 | System.out.println("Elapsed time for inserting " + nRecords + " records: " 31 | + (System.currentTimeMillis() - start) + " milliseconds"); 32 | 33 | start = System.currentTimeMillis(); 34 | key = 1999; 35 | for (i = 0; i < nRecords; i++) { 36 | key = (3141592621L*key + 2718281829L) % 1000000007L; 37 | Cursor cursor1 = db.select(Record.class, "strKey='" + key + "'", 0); 38 | if (cursor1.size() != 1 ) { 39 | throw new Error("search by strKey returns " + cursor1.size() + " instead of 1"); 40 | } 41 | Record rec1 = (Record)cursor1.nextElement(); 42 | 43 | Cursor cursor2 = db.select(Record.class, "intKey=" + key, 0); 44 | if (cursor2.size() != 1 ) { 45 | throw new Error("search by intKey returns " + cursor2.size() + " instead of 1"); 46 | } 47 | Record rec2 = (Record)cursor2.nextElement(); 48 | if (rec1.intKey != rec2.intKey || rec1.intKey != key || !rec1.strKey.equals(rec2.strKey)) { 49 | throw new Error("Inconsitent fetch"); 50 | } 51 | } 52 | System.out.println("Elapsed time for performing " + nRecords*2 + " index searches: " 53 | + (System.currentTimeMillis() - start) + " milliseconds"); 54 | 55 | start = System.currentTimeMillis(); 56 | db.delete(Record.class, ""); 57 | System.out.println("Elapsed time for deleting " + nRecords + " records: " 58 | + (System.currentTimeMillis() - start) + " milliseconds"); 59 | db.close(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/fastdbShim.cpp: -------------------------------------------------------------------------------- 1 | #include "fastdbShim.h" 2 | //#include "platform_specific_include.h" 3 | 4 | /* 5 | * User should replace these functions with platform specific code. 6 | * Replace printf with platform logging facility. 7 | */ 8 | 9 | /* 10 | * All memory is shared in VxWorks. Naive implementation. 11 | * Replace allocation with platform dependent allocations. 12 | */ 13 | int shmget(key_t key, size_t size, int shmflg) 14 | { 15 | int *m_WorkBuffer = (int *)malloc(size); 16 | printf( "In shmget size key %p 0x%x %x\n", m_WorkBuffer, size, key); 17 | return (int)m_WorkBuffer; 18 | } 19 | void *shmat(int shmid, const void *shmaddr, int shmflg) 20 | { 21 | printf( "In shmat 0x%x \n", shmid); 22 | return shmid; 23 | } 24 | 25 | int shmdt(const void *shmaddr) 26 | { 27 | printf( "In shmdt ox%x \n", shmaddr); 28 | free((void *)shmaddr); 29 | return 0; 30 | } 31 | 32 | int shmctl(int shmid, int cmd, void *buf) 33 | { 34 | printf( "In shmctl %p \n", buf); 35 | return 0; 36 | } 37 | 38 | /* 39 | * This method is added as sqrt method is not available in vxWorks math lib. 40 | * Note that it uses floating point which may be disabled in the platform. 41 | */ 42 | extern "C" double sqrt(double n) 43 | { 44 | if(n==0) return 0; 45 | if(n==1) return 1; 46 | double guess = n/2; 47 | double oldguess = 0; 48 | while(guess!=oldguess) 49 | { 50 | oldguess=guess; 51 | guess = (guess+n/guess)/2; 52 | } 53 | return guess; 54 | } 55 | 56 | /* 57 | * getPageSize is not available in VxWorks. 58 | */ 59 | extern "C" int getpagesize() 60 | { 61 | int pagesize = 4*1024; 62 | return pagesize; 63 | } 64 | 65 | extern "C" int sysClkRateGet(void); 66 | extern "C" unsigned long long tick64Get(); 67 | 68 | extern "C" int gettimeofday(struct timeval *tp, void *tzp) 69 | { 70 | static int clkRate = 0; 71 | unsigned long long ticks; 72 | 73 | if ( clkRate == 0 ) 74 | clkRate = sysClkRateGet(); /* expensive call, via sysctl in RTP */ 75 | ticks = tick64Get(); /* also via sysctl, but unavoidable */ 76 | 77 | /* The tv_sec member of struct timeval is presently of type 'long'. 78 | * The tv_sec member of struct timespec is time_t, 79 | * which is unsigned long. * We don't want to return a 80 | * negative result for tv_sec. 81 | */ 82 | tp->tv_sec = ( long )( ticks / clkRate ) & LONG_MAX; 83 | tp->tv_usec = ( long )( ticks % clkRate ) * 1000000 / clkRate; 84 | 85 | return 0; 86 | } 87 | 88 | /* 89 | * this is not truly required for running fastdb. This is just a place holder to 90 | * resolve compilation issue. 91 | */ 92 | int uname (struct utsname *u) 93 | { 94 | return 0; 95 | } 96 | -------------------------------------------------------------------------------- /examples/Makefile.am: -------------------------------------------------------------------------------- 1 | INCLUDES = -I${top_srcdir}/inc 2 | 3 | noinst_PROGRAMS = \ 4 | guess testdb testleak testfrag testjoin testddl testperf testpar \ 5 | testindex testfuzzy testsync testconc testiref testtrav testidx clitest \ 6 | clitest2 testrect testalter testraw localclitest testharr testspat \ 7 | testtimeseries \ 8 | bugdb clidb 9 | 10 | guess_SOURCES = guess.cpp 11 | guess_LDADD = ${top_builddir}/src/libfastdb.la 12 | 13 | testdb_SOURCES = testdb.cpp 14 | testdb_LDADD = ${top_builddir}/src/libfastdb.la 15 | 16 | testleak_SOURCES = testleak.cpp 17 | testleak_LDADD = ${top_builddir}/src/libfastdb.la 18 | 19 | testfrag_SOURCES = testfrag.cpp 20 | testfrag_LDADD = ${top_builddir}/src/libfastdb.la 21 | 22 | testjoin_SOURCES = testjoin.cpp 23 | testjoin_LDADD = ${top_builddir}/src/libfastdb.la 24 | 25 | testddl_SOURCES = testddl.cpp 26 | testddl_LDADD = ${top_builddir}/src/libfastdb.la 27 | 28 | testperf_SOURCES = testperf.cpp 29 | testperf_LDADD = ${top_builddir}/src/libfastdb.la 30 | 31 | testpar_SOURCES = testpar.cpp 32 | testpar_LDADD = ${top_builddir}/src/libfastdb.la 33 | 34 | testindex_SOURCES = testindex.cpp 35 | testindex_LDADD = ${top_builddir}/src/libfastdb.la 36 | 37 | testfuzzy_SOURCES = testfuzzy.cpp 38 | testfuzzy_LDADD = ${top_builddir}/src/libfastdb.la 39 | 40 | testsync_SOURCES = testsync.cpp 41 | testsync_LDADD = ${top_builddir}/src/libfastdb.la 42 | 43 | testconc_SOURCES = testconc.cpp 44 | testconc_LDADD = ${top_builddir}/src/libfastdb.la 45 | 46 | testiref_SOURCES = testiref.cpp 47 | testiref_LDADD = ${top_builddir}/src/libfastdb.la 48 | 49 | testtrav_SOURCES = testtrav.cpp 50 | testtrav_LDADD = ${top_builddir}/src/libfastdb.la 51 | 52 | testidx_SOURCES = testidx.cpp 53 | testidx_LDADD = ${top_builddir}/src/libfastdb.la 54 | 55 | clitest_SOURCES = clitest.c 56 | clitest_LDADD = ${top_builddir}/src/libcli.la 57 | 58 | clitest2_SOURCES = clitest2.c 59 | clitest2_LDADD = ${top_builddir}/src/libfastdb.la 60 | 61 | testrect_SOURCES = testrect.cpp 62 | testrect_LDADD = ${top_builddir}/src/libfastdb.la 63 | 64 | testalter_SOURCES = testalter.cpp 65 | testalter_LDADD = ${top_builddir}/src/libfastdb.la 66 | 67 | testraw_SOURCES = testraw.cpp 68 | testraw_LDADD = ${top_builddir}/src/libfastdb.la 69 | 70 | localclitest_SOURCES = clitest.c 71 | localclitest_LDADD = ${top_builddir}/src/libfastdb.la 72 | 73 | testharr_SOURCES = testharr.cpp 74 | testharr_LDADD = ${top_builddir}/src/libfastdb.la 75 | 76 | testspat_SOURCES = testspat.cpp 77 | testspat_LDADD = ${top_builddir}/src/libfastdb.la 78 | 79 | testtimeseries_SOURCES = testtimeseries.cpp 80 | testtimeseries_LDADD = ${top_builddir}/src/libfastdb.la 81 | 82 | bugdb_SOURCES = bugdb.cpp 83 | bugdb_LDADD = ${top_builddir}/src/libfastdb.la 84 | 85 | clidb_SOURCES = clidb.cpp 86 | clidb_LDADD = ${top_builddir}/src/libfastdb.la 87 | -------------------------------------------------------------------------------- /fastdb.spec: -------------------------------------------------------------------------------- 1 | Summary: Fast In-Memory RDBMS 2 | Name: fastdb 3 | Version: 3.28 4 | Release: 1.%{?_vendorsuffix:%{_vendorsuffix}}%{!?_vendorsuffix:%{_vendor}} 5 | Copyright: BSD 6 | Group: Development/Libraries 7 | URL: http://www.fastdb.org 8 | Source: fastdb-3.28.tar.gz 9 | Packager: %{?_packager:%{_packager}}%{!?_packager:%{_vendor}} 10 | Vendor: %{?_vendorinfo:%{_vendorinfo}}%{!?_vendorinfo:%{_vendor}} 11 | Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}} 12 | Prefix: %{_prefix} 13 | BuildRoot: /var/tmp/%{name}-%{version}-%{release}-root 14 | 15 | %description 16 | FastDB is a highly efficient main memory database system with realtime 17 | capabilities and convenient C++ interface. It is optimized for 18 | applications with dominated read access pattern. High speed of query 19 | execution is provided by the elimination of data transfer overhead and 20 | a very effective locking implementation. FastDB supports 21 | transactions, online backup and automatic recovery after system crash. 22 | It is an application-oriented database whose tables are constructed 23 | using information about application classes. Automatic scheme 24 | evaluation based on classes and a flexible, convenient SQL-like 25 | interface for retrieving data from the database. Such post-relational 26 | capabilities as non-atomic fields, nested arrays, user-defined types 27 | and methods, direct interobject references simplifies the design of 28 | database applications and makes them more efficient. 29 | 30 | %prep 31 | %setup -q -n fastdb 32 | 33 | %build 34 | CFLAGS="%{?cflags:%{cflags}}%{!?cflags:$RPM_OPT_FLAGS}" 35 | CXXFLAGS="%{?cxxflags:%{cxxflags}}%{!?cflags:$RPM_OPT_FLAGS}" 36 | export CFLAGS CXXFLAGS 37 | %{__make} PREFIX=%{_prefix} %{?mflags} 38 | 39 | %install 40 | # Make examples dir. 41 | %{__mkdir_p} docs/examples 42 | %{__install} -m 644 buglogin.htm clilogin.htm clitest.sql testddl.sql \ 43 | docs/examples/ 44 | ( cd examples && %{__install} -m 644 bugdb.cpp bugdb.h clidb.cpp \ 45 | clidb.h clitest.c guess.cpp guess2.cpp \ 46 | guess_std.cpp testdb.cpp testddl.cpp testidx.cpp \ 47 | testiref.cpp testjoin.cpp testleak.cpp testperf.cpp testraw.cpp \ 48 | testsync.cpp docs/examples/ ) 49 | %{makeinstall} PREFIX=$RPM_BUILD_ROOT%{_prefix} %{?mflags_install} 50 | 51 | %clean 52 | test "x$RPM_BUILD_ROOT" != "x" && rm -rf $RPM_BUILD_ROOT 53 | 54 | %files 55 | %defattr(-, root, root) 56 | %doc CHANGES docs doxygen.cfg 57 | %{_bindir}/subsql 58 | %{_bindir}/cleanupsem 59 | %{_includedir}/%{name} 60 | %{_libdir}/libcli* 61 | %{_libdir}/libfastdb* 62 | 63 | %changelog 64 | * Sun Apr 30 2006 Wensong Zhang 3.27-1 65 | - update to 3.27 66 | * Wed Jul 21 2004 Mezzanine 67 | - Specfile auto-generated by Mezzanine 68 | 69 | -------------------------------------------------------------------------------- /GiST/BTree/BTentry.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // BTentry.cpp 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/BTree/BTentry.cpp,v 1.1 2007/07/18 20:45:45 knizhnik Exp $ 7 | // 8 | // B-Tree Entry Class 9 | 10 | #include "BT.h" 11 | 12 | BTkey NegInf(BTkey::NEG_INF), PosInf(BTkey::POS_INF); 13 | 14 | int BTkey::Compare(const BTkey& k) const { 15 | if (type == k.type && type != NORMAL) 16 | return 0; 17 | else if (type == NEG_INF || k.type == POS_INF) 18 | return (-1); 19 | else if (type == POS_INF || k.type == NEG_INF) 20 | return 1; 21 | else { 22 | for (int i = 0; i < len && i < k.len; i++) { 23 | if (key[i] != k.key[i]) 24 | return(key[i] - k.key[i]); 25 | else if (len == i+1 || k.len == i+1) 26 | return (len - k.len); 27 | else continue; 28 | } 29 | return 0; // make NT compiler happy 30 | } 31 | } 32 | 33 | GiSTcompressedEntry 34 | BTentry::Compress() const { 35 | GiSTcompressedEntry compressedEntry; 36 | 37 | // Compress the key 38 | if (Position() == 0 && !IsLeaf()) 39 | compressedEntry.keyLen = 0; 40 | else { 41 | compressedEntry.key = new char[LowerBound().len]; 42 | memcpy(compressedEntry.key, LowerBound().key, LowerBound().len); 43 | compressedEntry.keyLen = LowerBound().len; 44 | } 45 | 46 | // Copy the pointer 47 | compressedEntry.ptr = ptr; 48 | 49 | return compressedEntry; 50 | } 51 | 52 | void 53 | BTentry::Decompress(const GiSTcompressedEntry entry) 54 | { 55 | const GiSTnode *node = Node(); 56 | assert(node->IsA() == BTNODE_CLASS); 57 | 58 | // Decompress the key 59 | if (!IsLeaf()) { 60 | if (Position() == 0) // Leftmost 61 | SetLowerBound(NegInf); 62 | else { 63 | SetLowerBound(entry.key, entry.keyLen); 64 | } 65 | 66 | if (Position() == node->NumEntries()-1) 67 | SetUpperBound(PosInf); 68 | else { 69 | GiSTcompressedEntry nextEntry = node->Entry(Position()+1); 70 | SetUpperBound(nextEntry.key, nextEntry.keyLen); 71 | } 72 | } else { // node->IsLeaf() 73 | SetLowerBound(entry.key, entry.keyLen); 74 | SetUpperBound(LowerBound()); 75 | } 76 | 77 | // Copy the pointer 78 | ptr = entry.ptr; 79 | } 80 | 81 | GiSTpenalty * 82 | BTentry::Penalty(const GiSTentry &newEntry) const 83 | { 84 | GiSTpenalty* p = new GiSTpenalty; 85 | assert(newEntry.IsA() == BTENTRY_CLASS); 86 | 87 | const BTentry& e = (const BTentry &) newEntry; 88 | 89 | if (e.UpperBound() < LowerBound()) 90 | *p = 1; 91 | 92 | else if (e.LowerBound() > UpperBound()) 93 | *p = 1; 94 | 95 | else 96 | *p = 0; 97 | 98 | return p; 99 | } 100 | -------------------------------------------------------------------------------- /examples/testidx.cpp: -------------------------------------------------------------------------------- 1 | //-< TESTPERF.CPP >--------------------------------------------------*--------* 2 | // FastDB Version 1.0 (c) 1999 GARRET * ? * 3 | // (Main Memory Database Management System) * /\| * 4 | // * / \ * 5 | // Created: 10-Feb-98 K.A. Knizhnik * / [] \ * 6 | // Last update: 10-Feb-99 K.A. Knizhnik * GARRET * 7 | //-------------------------------------------------------------------*--------* 8 | // Test for index insert/search/delete operations 9 | //-------------------------------------------------------------------*--------* 10 | 11 | #include 12 | #include "fastdb.h" 13 | 14 | USE_FASTDB_NAMESPACE 15 | 16 | const int nInsertedRecords = 10000000; 17 | const int nRecords = 100000; 18 | const int maxDuplicates = 256; 19 | 20 | class Record { 21 | public: 22 | nat8 key; 23 | 24 | TYPE_DESCRIPTOR((KEY(key, INDEXED) )); 25 | }; 26 | 27 | REGISTER(Record); 28 | 29 | 30 | int main() 31 | { 32 | dbDatabase db(dbDatabase::dbAllAccess, 4096); // 32Mb page pool 33 | db.setFixedSizeAllocator(16, 32, 16, 10000); 34 | if (db.open(_T("testidx"))) { 35 | nat8 insKey = 1999; 36 | nat8 delKey = 1999; 37 | db_int8 key; 38 | dbQuery q; 39 | Record rec; 40 | dbCursor cursor(dbCursorForUpdate); 41 | q = "key=",key; 42 | time_t start = time(NULL); 43 | for (int i = 0, j = 0, n = 0; i < nInsertedRecords;) { 44 | if (n >= nRecords) { 45 | delKey = (3141592621u*delKey + 2718281829u) % 1000000007u; 46 | key = delKey; 47 | unsigned r = cursor.select(q); 48 | assert(r == ((unsigned)delKey % maxDuplicates) + 1); 49 | n -= r; 50 | cursor.removeAllSelected(); 51 | } 52 | insKey = (3141592621u*nat8(insKey) + 2718281829u) % 1000000007; 53 | unsigned r = ((unsigned)insKey % maxDuplicates) + 1; 54 | rec.key = insKey; 55 | n += r; 56 | i += r; 57 | do { 58 | insert(rec); 59 | } while (--r != 0); 60 | if (i > j) { 61 | printf("Insert %d objects...\r", i); 62 | fflush(stdout); 63 | j = i + 1000; 64 | } 65 | } 66 | printf("Elapsed time for %d record: %d seconds\n", 67 | nInsertedRecords, int(time(NULL) - start)); 68 | db.close(); 69 | return EXIT_SUCCESS; 70 | } else { 71 | printf("Failed to open database\n"); 72 | return EXIT_FAILURE; 73 | } 74 | } 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /inc/fastdbShim.h: -------------------------------------------------------------------------------- 1 | /* This is a new file that has been added to fastdb sources as part of the porting effort. This file 2 | * captures stubbed implementation of functionality that is not available in the CFW VxWorks image 3 | * such that fastdb can be made to work. fastdbShim.h.changes file gives details of the stubbed calls 4 | */ 5 | #ifndef __fastdbShim__ 6 | #define __fastdbShim__ 7 | 8 | #define IPC_CREAT 0 9 | #define IPC_RMID 0 10 | 11 | #include "vkiWrap.h" 12 | //#include "platform_specific_include.h" 13 | 14 | #include "sockLib.h" 15 | #include "selectLib.h" 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "socket.h" 22 | #include "hostLib.h" 23 | #include "sockLib.h" 24 | #include "selectLib.h" 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | extern "C" { 39 | #include 40 | } 41 | 42 | #include 43 | 44 | #define getpid taskIdSelf 45 | 46 | // VxWorks puts the module id in the high order bits of errno 47 | #if defined(VXWORKS) && defined(BUILDING_FASTDB) 48 | #undef errno 49 | #define errno ((__errnoRef()) & 0x7fff) 50 | #endif // VXWORKS && BUILDING_FASTDB 51 | 52 | 53 | extern "C" { 54 | 55 | #define UTSNAME_SHORT_NAME_SIZE 80 56 | #define UTSNAME_LONG_NAME_SIZE 256 57 | #define UTSNAME_NUMBER_SIZE 8 58 | 59 | // We need to include proper header file 60 | struct utsname 61 | { 62 | char sysname[UTSNAME_SHORT_NAME_SIZE]; /* operating system name */ 63 | char nodename[UTSNAME_LONG_NAME_SIZE]; /* network node name */ 64 | char release[UTSNAME_SHORT_NAME_SIZE]; /* OS release level */ 65 | char version[UTSNAME_LONG_NAME_SIZE]; /* operating system version */ 66 | char machine[UTSNAME_LONG_NAME_SIZE]; /* hardware type (BSP model) */ 67 | char endian[UTSNAME_NUMBER_SIZE]; /* architecture endianness */ 68 | char kernelversion[UTSNAME_SHORT_NAME_SIZE];/* VxWorks kernel version */ 69 | char processor[UTSNAME_SHORT_NAME_SIZE]; /* CPU type */ 70 | char bsprevision[UTSNAME_SHORT_NAME_SIZE]; /* VxWorks BSP revision */ 71 | char builddate[UTSNAME_SHORT_NAME_SIZE]; /* VxWorks kernel build date */ 72 | }; 73 | 74 | } 75 | 76 | extern "C" int gettimeofday(struct timeval *tp, void *tzp); 77 | 78 | extern "C" int getpagesize(); 79 | 80 | extern "C" double sqrt(double n); 81 | 82 | int shmget(key_t key, size_t size, int shmflg); 83 | void *shmat(int shmid, const void *shmaddr, int shmflg); 84 | int shmdt(const void *shmaddr); 85 | int shmctl(int shmid, int cmd, void *buf); 86 | 87 | int uname (struct utsname *u); 88 | 89 | #endif /* __fastdbShim__ */ 90 | -------------------------------------------------------------------------------- /examples/JniTestRelations.java: -------------------------------------------------------------------------------- 1 | import jnicli.*; 2 | 3 | import java.util.*; 4 | 5 | class Word { 6 | int sentence; 7 | String text; 8 | static final String CONSTRAINTS = "sentence references Sentence(words), text using index"; 9 | } 10 | 11 | class Sentence { 12 | int[] words; 13 | static final String CONSTRAINTS = "words references Word(sentence)"; 14 | } 15 | 16 | 17 | public class JniTestRelations { 18 | final static int nWords = 1000; 19 | final static int nSentences = 10000; 20 | final static int maxWordsPerSentense = 10; 21 | final static int initSize = 8*1024*1024; // 40Mb page pool 22 | 23 | static public void main(String[] args) throws java.io.IOException { 24 | Database db = new DatabaseJNI(); 25 | db.open(Database.READ_WRITE, "text", "text.dbs", initSize, 0); 26 | long start = System.currentTimeMillis(); 27 | long key = 1999; 28 | for (int i = 0; i < nSentences; i++) { 29 | key = (3141592621L*key + 2718281829L) % 1000000007L; 30 | Sentence s = new Sentence(); 31 | int sid = (int)db.insert(s); 32 | int nWordsInSentence = (int)(key % maxWordsPerSentense); 33 | for (int j = 0; j < nWordsInSentence; j++) { 34 | key = (3141592621L*key + 2718281829L) % 1000000007L; 35 | Word word = new Word(); 36 | word.sentence = sid; 37 | word.text = Long.toString(key % nWords); 38 | db.insert(word); 39 | } 40 | } 41 | db.commit(); 42 | System.out.println("Elapsed time for inserting " + nSentences + " records: " 43 | + (System.currentTimeMillis() - start) + " milliseconds"); 44 | 45 | start = System.currentTimeMillis(); 46 | int totalSentences = 0; 47 | for (int i = 0; i < nWords; i++) { 48 | Cursor sentences = db.select(Sentence.class, "exists i:(words[i].text='" + i + "')", 0); 49 | totalSentences += sentences.size(); 50 | SentenceLoop: 51 | while (sentences.hasMoreElements()) { 52 | Sentence s = (Sentence)sentences.nextElement(); 53 | for (int j = 0; j < s.words.length; j++) { 54 | Cursor words = db.select(Word.class, "current=" + s.words[j], 0); 55 | Word word = (Word)words.nextElement(); 56 | if (word.text.equals(Integer.toString(i))) { 57 | continue SentenceLoop; 58 | } 59 | } 60 | throw new Error("Word is not found"); 61 | } 62 | } 63 | System.out.println("Elapsed time for performing " + nWords + " word searches: " 64 | + (System.currentTimeMillis() - start) + " milliseconds"); 65 | db.close(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /examples/testpar.cpp: -------------------------------------------------------------------------------- 1 | //-< TESTPAR.CPP >---------------------------------------------------*--------* 2 | // FastDB Version 1.0 (c) 1999 GARRET * ? * 3 | // (Main Memory Database Management System) * /\| * 4 | // * / \ * 5 | // Created: 10-Dec-98 K.A. Knizhnik * / [] \ * 6 | // Last update: 20-Jan-99 K.A. Knizhnik * GARRET * 7 | //-------------------------------------------------------------------*--------* 8 | // Test parallel sequential search 9 | //-------------------------------------------------------------------*--------* 10 | 11 | #include "fastdb.h" 12 | #include 13 | 14 | USE_FASTDB_NAMESPACE 15 | 16 | const int nRecords = 10000; 17 | 18 | struct Record { 19 | int4 id; 20 | 21 | TYPE_DESCRIPTOR((FIELD(id))); 22 | }; 23 | 24 | REGISTER(Record); 25 | 26 | 27 | int main(int argc, char* argv[]) 28 | { 29 | int i, j; 30 | dbDatabase db(dbDatabase::dbAllAccess, 16*1024); // 96Mb page pool 31 | 32 | if (db.open(_T("testpar"))) { 33 | db.setConcurrency(4); 34 | for (i = 0; i < nRecords; i++) { 35 | Record rec; 36 | rec.id = i; 37 | insert(rec); 38 | } 39 | db.commit(); 40 | 41 | dbQuery q; 42 | dbCursor cursor; 43 | int min; 44 | int max; 45 | q = "id between",min,"and",max; 46 | time_t start = time(NULL); 47 | 48 | for (i = 0, j = 0; i+j < nRecords; i += j) { 49 | min = i; 50 | max = i + j; 51 | j += 1; 52 | int n = cursor.select(q); 53 | assert(n == j); 54 | int k = 0; 55 | int sum = 0; 56 | do { 57 | sum += cursor->id; 58 | k += 1; 59 | } while (cursor.next()); 60 | assert(k == j); 61 | assert(sum == k*(k-1)/2 + k*i); 62 | } 63 | printf("Elapsed time for %d sequential searchs in %d records: %d seconds\n", 64 | j, nRecords, int(time(NULL) - start)); 65 | 66 | q = "id between",min,"and",max,"order by id"; 67 | start = time(NULL); 68 | for (i = 0, j = 0; i+j < nRecords; i += j) { 69 | min = i; 70 | max = i + j; 71 | j += 1; 72 | int n = cursor.select(q); 73 | assert(n == j); 74 | int k = i; 75 | do { 76 | assert(cursor->id == k); 77 | k += 1; 78 | } while (cursor.next()); 79 | assert(k == i+j); 80 | } 81 | printf("Elapsed time for %d sequential searchs with sorting in %d records: %d seconds\n", 82 | j, nRecords, int(time(NULL) - start)); 83 | db.close(); 84 | } 85 | return 0; 86 | } 87 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | FastDB is embedded main memory database. 2 | It is intended to be used in your C/C++ application to provide 3 | fast access to persistent data. 4 | 5 | As far as FastDB is embedded database, there is need to start some server which 6 | will handle client's requests. FastDB is just an library which is linked in client 7 | application and provide access to the persistent objects. 8 | 9 | To build FastDB library you will need use the proper makefile. 10 | At Linux and most of other popular Unixes with GCC it is enough to 11 | do "make". You can also use standard way for most of unix systems: ./condifure ; make ; sudo make install. 12 | Alternatively you can look for specialized versions of makefile 13 | included in distributive (like makefile.sun), write you own makefile based 14 | on standard FastDB makefile or customize some existed makefile. 15 | 16 | At Windows with Microsoft Visual C++ you can just execute "make.bat" command. 17 | If error message is printed that "nmake" or "cl" command is not recognized, then 18 | MS Visual Studio environment variables are not properly set. 19 | There are two ways to solve the problem: 20 | 1. Run from "Microsoft Visual Studio" menu in start panel, choose "Microsoft Visual Studio Tools", 21 | and in it - "Microsoft Visual Studio Command Prompt". The in this window change directory to FastDB home 22 | and do "make.bat" 23 | 2. In "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin" directory there is vcvars32.bat file 24 | (this is the path for VS 2003, but Visual C++ 6.0 has the similar file). Run it to setup environment in current 25 | window. 26 | 27 | You can also use Microsoft Visual Studio project file (fastdb.sln or fastdb.dsw) and open it with Visual Studio. 28 | 29 | In config.h you will find various options for choosing yet or another configuration of FastDB. 30 | The preferable way of changing configuration is to edit this file (instead of specifying correspondent 31 | macros in compiler command line, because in last case there is a risk that you forget to specify somewhere this 32 | option which cause inconsistency between different modules of your applications and/or FastDB library). 33 | 34 | You can use SubSQL utility to inspect content of the database as well as for administration of database. 35 | SubSQL can be started concurrently with you application. But please notice, that FastDB uses 36 | single-writer-multiple-readers database level locking, so if you have performed some modification in SubSQL 37 | and did perform commit after it, then application may be blocked until you release (commit or abort) transaction 38 | in SubSQL. 39 | 40 | FastDB distribution also includes a lot of examples and tests located in examples directory. 41 | Them are also build by make. These tests are used for three different purposes: 42 | 1. Illustrate FastDB programming approach. 43 | 2. Regression tests 44 | 3. Performance measurement 45 | 46 | More information about FastDB can be found in FastDB.htm file which is located in this directory. 47 | -------------------------------------------------------------------------------- /inc/wince_time.h: -------------------------------------------------------------------------------- 1 | #ifndef __WINCE_TIME_H__ 2 | #define __WINCE_TIME_H__ 3 | 4 | #ifndef _TIME_T_DEFINED 5 | typedef unsigned time_t; /* time value */ 6 | #define _TIME_T_DEFINED /* avoid multiple def's of time_t */ 7 | #endif 8 | 9 | #include 10 | #ifndef _TM_DEFINED 11 | struct tm { 12 | int tm_sec; /* seconds after the minute - [0,59] */ 13 | int tm_min; /* minutes after the hour - [0,59] */ 14 | int tm_hour; /* hours since midnight - [0,23] */ 15 | int tm_mday; /* day of the month - [1,31] */ 16 | int tm_mon; /* months since January - [0,11] */ 17 | int tm_year; /* years since 1900 */ 18 | int tm_wday; /* days since Sunday - [0,6] */ 19 | int tm_yday; /* days since January 1 - [0,365] */ 20 | int tm_isdst; /* daylight savings time flag */ 21 | }; 22 | #define _TM_DEFINED 23 | #endif 24 | 25 | #define _CLOCALECP CP_ACP /* "C" locale Code page */ 26 | 27 | #define _DAY_SEC (24L * 60L * 60L) /* secs in a day */ 28 | 29 | #define _YEAR_SEC (365L * _DAY_SEC) /* secs in a year */ 30 | 31 | #define _FOUR_YEAR_SEC (1461L * _DAY_SEC) /* secs in a 4 year interval */ 32 | 33 | #define _DEC_SEC 315532800L /* secs in 1970-1979 */ 34 | 35 | #define _BASE_YEAR 70L /* 1970 is the base year */ 36 | 37 | #define _BASE_DOW 4 /* 01-01-70 was a Thursday */ 38 | 39 | #define _LEAP_YEAR_ADJUST 17L /* Leap years 1900 - 1970 */ 40 | 41 | #define _MAX_YEAR 138L /* 2038 is the max year */ 42 | 43 | /* 44 | * Number of milliseconds in one day 45 | */ 46 | #define DAY_MILLISEC (24L * 60L * 60L * 1000L) 47 | 48 | /* 49 | * The macro below is valid for years between 1901 and 2099, which easily 50 | * includes all years representable by the current implementation of time_t. 51 | */ 52 | #define IS_LEAP_YEAR(year) ( (year & 3) == 0 ) 53 | 54 | /* 55 | * Structure used to represent DST transition date/times. 56 | */ 57 | typedef struct { 58 | int yr; /* year of interest */ 59 | int yd; /* day of year */ 60 | long ms; /* milli-seconds in the day */ 61 | } transitiondate; 62 | 63 | 64 | /* non-zero if daylight savings time is used */ 65 | _CRTIMP extern int _daylight; 66 | 67 | /* offset for Daylight Saving Time */ 68 | _CRTIMP extern long _dstbias; 69 | 70 | /* difference in seconds between GMT and local time */ 71 | _CRTIMP extern long _timezone; 72 | 73 | /* standard/daylight savings time zone names */ 74 | _CRTIMP extern char * _tzname[2]; 75 | 76 | 77 | 78 | time_t __cdecl time(time_t *); 79 | time_t __cdecl mktime(struct tm *); 80 | struct tm * __cdecl localtime(const time_t *); 81 | _CRTIMP struct tm * __cdecl gmtime(const time_t *); 82 | #ifndef wcsftime 83 | size_t __cdecl wcsftime(wchar_t *, size_t, const wchar_t *, 84 | const struct tm *); 85 | #endif 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /examples/testharr.cpp: -------------------------------------------------------------------------------- 1 | //-< TESTHARR.CPP >--------------------------------------------------*--------* 2 | // FastDB Version 1.0 (c) 1999 GARRET * ? * 3 | // (Main Memory Database Management System) * /\| * 4 | // * / \ * 5 | // Created: 26-Mar-2003 K.A. Knizhnik * / [] \ * 6 | // Last update: 26-Mar-2003 K.A. Knizhnik * GARRET * 7 | //-------------------------------------------------------------------*--------* 8 | // Tets of hierarhical arrays and bitmap 9 | //-------------------------------------------------------------------*--------* 10 | 11 | 12 | #include "fastdb.h" 13 | #include "harray.h" 14 | 15 | USE_FASTDB_NAMESPACE 16 | 17 | class RootObject { 18 | public: 19 | dbBitmap bitmap; 20 | 21 | TYPE_DESCRIPTOR((FIELD(bitmap))); 22 | }; 23 | 24 | 25 | REGISTER(RootObject); 26 | 27 | int main() 28 | { 29 | dbDatabase db; 30 | char buf[128]; 31 | if (db.open(_T("testharr"))) { 32 | dbBitmap* bitmap; 33 | RootObject root; 34 | dbCursor cursor(dbCursorForUpdate); 35 | if (cursor.select() == 0) { 36 | root.bitmap.create(&db); 37 | insert(root); 38 | bitmap = &root.bitmap; 39 | } else { 40 | bitmap = &cursor->bitmap; 41 | } 42 | printf("Commands:\n" 43 | "\tset BITNO\n" 44 | "\tclear BITNO\n" 45 | "\ttest BITNO\n" 46 | "\texit\n"); 47 | while (fgets(buf, (int)sizeof(buf), stdin) != NULL) { 48 | char cmd[64]; 49 | int position; 50 | *cmd = '\0'; 51 | int n = sscanf(buf, "%s%d", cmd, &position); 52 | if (strcmp(cmd, "exit") == 0) { 53 | break; 54 | } 55 | if (n != 2) { 56 | fprintf(stderr, "The number of the bit should be specified\n"); 57 | } else { 58 | if (strcmp(cmd, "set") == 0) { 59 | bitmap->set(position, true, &db); 60 | } else if (strcmp(cmd, "clear") == 0) { 61 | bitmap->set(position, false, &db); 62 | } else if (strcmp(cmd, "test") == 0) { 63 | if (bitmap->get(position, &db)) { 64 | printf("The bit is set\n"); 65 | } else { 66 | printf("The bit not set\n"); 67 | } 68 | } else { 69 | fprintf(stderr, "Commands:\n" 70 | "\tset BITNO\n" 71 | "\tclear BITNO\n" 72 | "\ttest BITNO\n" 73 | "\texit\n"); 74 | } 75 | } 76 | } 77 | db.close(); 78 | printf("The program is terminated\n"); 79 | return EXIT_SUCCESS; 80 | } else { 81 | return EXIT_FAILURE; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /GiST/BTree/BTnode.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // BTnode.cpp 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/BTree/BTnode.cpp,v 1.1 2007/07/18 20:45:45 knizhnik Exp $ 7 | 8 | #include 9 | 10 | #include "BT.h" 11 | 12 | extern BTkey PosInf, NegInf; 13 | 14 | void 15 | BTnode::InsertBefore(const GiSTentry& entry, int index) 16 | { 17 | // Only BTentry's can be inserted into BTnodes. 18 | assert(entry.IsA() == BTENTRY_CLASS); 19 | 20 | BTentry e((const BTentry&) entry); 21 | 22 | // If this is an internal node, adjust the lower/upper bounds 23 | if (!IsLeaf()) { 24 | // If not leftmost entry... 25 | if (index != 0) { 26 | // -inf changes to the upper bound of previous item 27 | BTentry *prev = (BTentry*) (*this)[index-1].Ptr(); 28 | if (e.LowerBound() == NegInf) 29 | e.SetLowerBound(prev->UpperBound()); 30 | } 31 | // If not rightmost entry... 32 | if (index != NumEntries()) { 33 | // +inf changes to the lower bound of next item 34 | BTentry *next = (BTentry*) (*this)[index].Ptr(); 35 | if (e.UpperBound() == PosInf) 36 | e.SetUpperBound(next->LowerBound()); 37 | } 38 | } 39 | 40 | // Insert it into the node 41 | GiSTnode::InsertBefore(e, index); 42 | } 43 | 44 | void 45 | BTnode::Insert(const GiSTentry &entry) 46 | { 47 | // Only BTentry's can be inserted into BTnode's. 48 | assert(entry.IsA() == BTENTRY_CLASS); 49 | 50 | // This doesn't work for internal nodes. For internal nodes, 51 | // the caller must know exactly where to insert. 52 | assert(IsLeaf()); 53 | 54 | GiSTnode::Insert(entry); 55 | } 56 | 57 | // We are moving entries from node, which is to our right, to this. 58 | // If this is a non-empty internal page, the rightmost entry on this 59 | // has an upperbound of +inf, and the leftmost entry on node has 60 | // a lower bound of -inf. This code takes care of that -- both 61 | // these values should be set to the right bound of our parent entry. 62 | void 63 | BTnode::Coalesce(const GiSTnode& node, 64 | const GiSTentry& entry) // entry is in 1 level up, and 65 | // points to this 66 | { 67 | if (!NumEntries() || IsLeaf()) { 68 | GiSTnode::Coalesce(node, entry); 69 | } else { 70 | int n = NumEntries(); 71 | GiSTnode::Coalesce(node, entry); 72 | const BTentry &bte = (const BTentry&) entry; 73 | ((BTentry*)(*this)[n-1].Ptr())->SetUpperBound(bte.UpperBound()); 74 | ((BTentry*)(*this)[n].Ptr())->SetLowerBound(bte.UpperBound()); 75 | } 76 | } 77 | 78 | GiSTentry* 79 | BTnode::Union() const 80 | { 81 | BTentry *u = new BTentry; 82 | int first = 1; 83 | 84 | for (int i=0; iLowerBound() < u->LowerBound()) 87 | u->SetLowerBound(bte->LowerBound()); 88 | if (first || bte->UpperBound() > u->UpperBound()) 89 | u->SetUpperBound(bte->UpperBound()); 90 | first = 0; 91 | } 92 | 93 | //u->SetPtr(node.Path().Page()); 94 | return u; 95 | } 96 | -------------------------------------------------------------------------------- /GiST/RTree/RTnode.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | 3 | // RTnode.cpp 4 | // 5 | // Copyright (c) 1996, Regents of the University of California 6 | // $Header: /cvsroot/fastdb/fastdb/GiST/RTree/RTnode.cpp,v 1.1 2007/07/18 20:45:47 knizhnik Exp $ 7 | 8 | 9 | #include 10 | #include "RT.h" 11 | 12 | GiSTnode * 13 | RTnode::PickSplit() 14 | { 15 | int i; 16 | int j; 17 | double max = -1, tmp; 18 | int seed1 = -1, seed2 = -1; 19 | RTkey cover1, cover2, *expand1, *expand2; 20 | RTnode *rightnode; 21 | RTentry *tmpentry1, *tmpentry2; 22 | int rightdeletes = 0, leftdeletes = 0; 23 | int *rightvec, *leftvec; 24 | 25 | // Guttman's poly-time split algorithm 26 | // first, pick furthest-distance seeds 27 | for (i = 0; i < NumEntries(); i++) 28 | for (j = i+1; j < NumEntries(); j++) { 29 | tmpentry1 = (RTentry *)((*this)[i].Ptr()); 30 | tmpentry2 = (RTentry *)((*this)[j].Ptr()); 31 | tmp = ((RTkey)tmpentry1->bbox()).dist(tmpentry2->bbox()); 32 | if (tmp > max) { 33 | seed1 = i; 34 | seed2 = j; 35 | max = tmp; 36 | } 37 | } 38 | tmpentry1 = (RTentry *)((*this)[seed1].Ptr()); 39 | tmpentry2 = (RTentry *)((*this)[seed2].Ptr()); 40 | cover1 = tmpentry1->bbox(); 41 | cover2 = tmpentry2->bbox(); 42 | 43 | // copy current node into rightnode; we'll delete from the nodes 44 | // as appropriate 45 | rightnode = (RTnode *)Copy(); 46 | 47 | // now assign entries to the appropriate deletion vectors 48 | rightvec = new int[NumEntries()]; 49 | leftvec = new int[NumEntries()]; 50 | for (i = 0; i < NumEntries(); i++) { 51 | if (i == seed1) { 52 | rightvec[rightdeletes++] = i; 53 | continue; 54 | } 55 | if (i == seed2) { 56 | leftvec[leftdeletes++] = i; 57 | continue; 58 | } 59 | tmpentry1 = (RTentry *)((*this)[i].Ptr()); 60 | expand1 = cover1.expand(tmpentry1->bbox()); 61 | expand2 = cover2.expand(tmpentry1->bbox()); 62 | if (expand2->area() > expand1->area()) 63 | leftvec[leftdeletes++] = i; 64 | else 65 | rightvec[rightdeletes++] = i; 66 | delete expand1; 67 | delete expand2; 68 | } 69 | 70 | // given the deletion vectors, do bulk deletes 71 | DeleteBulk(leftvec, leftdeletes); 72 | rightnode->DeleteBulk(rightvec, rightdeletes); 73 | delete leftvec; 74 | delete rightvec; 75 | 76 | // Return the right node 77 | return rightnode; 78 | } 79 | 80 | GiSTentry * 81 | RTnode::Union() const 82 | { 83 | RTentry *u = new RTentry; 84 | int first = 1; 85 | 86 | u->InitKey(); 87 | for (int i=0; ixlower() < u->xlower()) 90 | u->setxlower(rte->xlower()); 91 | if (first || rte->xupper() > u->xupper()) 92 | u->setxupper(rte->xupper()); 93 | if (first || rte->ylower() < u->ylower()) 94 | u->setylower(rte->ylower()); 95 | if (first || rte->yupper() > u->yupper()) 96 | u->setyupper(rte->yupper()); 97 | first = 0; 98 | } 99 | 100 | return u; 101 | } 102 | 103 | 104 | -------------------------------------------------------------------------------- /examples/TestIndex.java: -------------------------------------------------------------------------------- 1 | import javacli.*; 2 | 3 | class Record { 4 | String strKey; 5 | long intKey; 6 | } 7 | 8 | public class TestIndex { 9 | final static int nRecords = 100000; 10 | 11 | static public void main(String[] args) { 12 | Connection con = new Connection(); 13 | con.open("localhost", 6100); 14 | 15 | if (con.createTable(Record.class, null)) { 16 | con.addIndex("Record", "strKey"); 17 | con.addIndex("Record", "intKey"); 18 | } 19 | 20 | long start = System.currentTimeMillis(); 21 | long key = 1999; 22 | int i; 23 | for (i = 0; i < nRecords; i++) { 24 | Record rec = new Record(); 25 | key = (3141592621L*key + 2718281829L) % 1000000007L; 26 | rec.intKey = key; 27 | rec.strKey = Long.toString(key); 28 | con.insert(rec); 29 | } 30 | con.commit(); 31 | System.out.println("Elapsed time for inserting " + nRecords + " records: " 32 | + (System.currentTimeMillis() - start) + " milliseconds"); 33 | 34 | Statement strQuery = con.createStatement("select * from Record where strKey=%strKey"); 35 | Statement intQuery = con.createStatement("select * from Record where intKey=%intKey"); 36 | ObjectSet cursor; 37 | start = System.currentTimeMillis(); 38 | key = 1999; 39 | for (i = 0; i < nRecords; i++) { 40 | key = (3141592621L*key + 2718281829L) % 1000000007L; 41 | strQuery.setString("%strKey", Long.toString(key)); 42 | intQuery.setLong("%intKey", key); 43 | cursor = strQuery.fetch(); 44 | if (cursor.size() != 1) { 45 | throw new Error("stmt->fetch 1 returns " + cursor.size() + " instead of 1"); 46 | } 47 | Record rec1 = (Record)cursor.getNext(); 48 | cursor.close(); 49 | 50 | cursor = intQuery.fetch(); 51 | if (cursor.size() != 1) { 52 | throw new Error("stmt->fetch 2 returns " + cursor.size() + " instead of 1"); 53 | } 54 | Record rec2 = (Record)cursor.getNext(); 55 | cursor.close(); 56 | 57 | if (rec1.intKey != rec2.intKey || rec1.intKey != key || !rec1.strKey.equals(rec2.strKey)) { 58 | throw new Error("Inconsitent fetch"); 59 | } 60 | } 61 | System.out.println("Elapsed time for performing " + nRecords*2 + " index searches: " 62 | + (System.currentTimeMillis() - start) + " milliseconds"); 63 | 64 | start = System.currentTimeMillis(); 65 | key = 1999; 66 | for (i = 0; i < nRecords; i++) { 67 | key = (3141592621L*key + 2718281829L) % 1000000007L; 68 | intQuery.setLong("%intKey", key); 69 | cursor = intQuery.fetch(true); 70 | if (cursor.size() != 1) { 71 | throw new Error("stmt->fetch 3 returns " + cursor.size() + " instead of 1"); 72 | } 73 | cursor.removeAll(); 74 | } 75 | System.out.println("Elapsed time for deleting " + nRecords + " records: " 76 | + (System.currentTimeMillis() - start) + " milliseconds"); 77 | con.close(); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /examples/testfuzzy.cpp: -------------------------------------------------------------------------------- 1 | //-< TESTPERF.CPP >--------------------------------------------------*--------* 2 | // FastDB Version 1.0 (c) 1999 GARRET * ? * 3 | // (Main Memory Database Management System) * /\| * 4 | // * / \ * 5 | // Created: 10-Dec-98 K.A. Knizhnik * / [] \ * 6 | // Last update: 20-Jan-99 K.A. Knizhnik * GARRET * 7 | //-------------------------------------------------------------------*--------* 8 | // Performance test for index and sequential searches 9 | //-------------------------------------------------------------------*--------* 10 | 11 | #include "fastdb.h" 12 | #include 13 | 14 | USE_FASTDB_NAMESPACE 15 | 16 | const int nRecords = 1000000; 17 | const int nIterations = 10; 18 | const int nReadsPerWrite = 1013; 19 | 20 | class Record { 21 | public: 22 | char const* key; 23 | char const* value; 24 | int counter; 25 | 26 | TYPE_DESCRIPTOR((KEY(key, HASHED|INDEXED), FIELD(value), FIELD(counter))); 27 | }; 28 | 29 | REGISTER(Record); 30 | 31 | 32 | int main(int argc, char* argv[]) 33 | { 34 | int i, j, n; 35 | char buf[32]; 36 | 37 | dbDatabase db; 38 | if (db.open(_T("testfuzzy"))) { 39 | nat8 key = 1999; 40 | time_t start = time(NULL); 41 | for (i = 0; i < nRecords; i++) { 42 | Record rec; 43 | key = (3141592621u*key + 2718281829u) % 1000000007u; 44 | sprintf(buf, INT8_FORMAT ".", key); 45 | rec.key = buf; 46 | rec.value = buf; 47 | insert(rec); 48 | } 49 | printf("Elapsed time for inserting %d record: %d seconds\n", 50 | nRecords, int(time(NULL) - start)); 51 | start = time(NULL); 52 | db.commit(); 53 | printf("Commit time: %d\n", int(time(NULL) - start)); 54 | 55 | dbQuery q; 56 | dbCursor cursor; 57 | dbCursor updateCursor(dbCursorForUpdate); 58 | 59 | q = "key=",buf; 60 | for (j = 0; j < nIterations; j++) { 61 | key = 1999; 62 | for (i = 0; i < nRecords; i++) { 63 | key = (3141592621u*key + 2718281829u) % 1000000007u; 64 | sprintf(buf, INT8_FORMAT ".", key); 65 | if (i*j % nReadsPerWrite == 0) { 66 | n = updateCursor.select(q); 67 | updateCursor->counter += 1; 68 | db.commit(); 69 | } else { 70 | n = cursor.select(q); 71 | } 72 | assert(n == 1); 73 | } 74 | } 75 | printf("Elapsed time for %d reads and %d writes: %d seconds\n", 76 | nIterations*nRecords, nIterations*nRecords/nReadsPerWrite, 77 | int(time(NULL) - start)); 78 | start = time(NULL); 79 | updateCursor.removeAll(); 80 | printf("Elapsed time for deleting all %d records: %d seconds\n", 81 | nRecords, int(time(NULL) - start)); 82 | db.close(); 83 | return EXIT_SUCCESS; 84 | } else { 85 | printf("Failed to open database\n"); 86 | return EXIT_FAILURE; 87 | } 88 | } 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /javacli/LocalSocket.java: -------------------------------------------------------------------------------- 1 | package javacli; 2 | 3 | 4 | import java.net.*; 5 | import java.io.*; 6 | 7 | 8 | public class LocalSocket extends Socket { 9 | private long implObj; 10 | 11 | class LocalInputStream extends InputStream { 12 | public int read() throws IOException { 13 | byte buf[] = new byte[1]; 14 | return (read(buf, 0, 1) == 1) ? (buf[0] & 0xFF) : -1; 15 | } 16 | public int read(byte b[], int off, int len) throws IOException { 17 | if (implObj == 0) { 18 | throw new SocketException("Socket is not connected"); 19 | } 20 | return readSocket(implObj, b, off, len); 21 | } 22 | } 23 | 24 | class LocalOutputStream extends OutputStream { 25 | public void write(int b) throws IOException { 26 | byte buf[] = new byte[1]; 27 | buf[0] = (byte)b; 28 | write(buf, 0, 1); 29 | } 30 | 31 | public void write(byte b[], int off, int len) throws IOException { 32 | if (implObj == 0) { 33 | throw new SocketException("Socket is not connected"); 34 | } 35 | writeSocket(implObj, b, off, len); 36 | } 37 | } 38 | 39 | public InputStream getInputStream() throws IOException { 40 | return new LocalInputStream(); 41 | } 42 | 43 | public OutputStream getOutputStream() throws IOException { 44 | return new LocalOutputStream(); 45 | } 46 | 47 | public void setTcpNoDelay(boolean on) {} 48 | public void setSoLinger(boolean on, int linger) {} 49 | 50 | public void open(String address, int port) { 51 | implObj = openSocket(address, port); 52 | } 53 | 54 | public void close() { 55 | closeSocket(implObj); 56 | implObj = 0; 57 | } 58 | 59 | public LocalSocket accept() throws SocketException { 60 | return new LocalSocket(acceptSocket(implObj)); 61 | } 62 | 63 | public void cancelAccept() { 64 | cancelAcceptSocket(implObj); 65 | } 66 | 67 | public static LocalSocket create(int port) throws SocketException { 68 | return new LocalSocket(createSocket(port)); 69 | } 70 | 71 | public LocalSocket(long implObj) throws SocketException { 72 | super((SocketImpl)null); 73 | this.implObj = implObj; 74 | } 75 | 76 | public LocalSocket(String address, int port) throws SocketException { 77 | super((SocketImpl)null); 78 | open(address, port); 79 | } 80 | 81 | public LocalSocket() throws SocketException { 82 | super((SocketImpl)null); 83 | } 84 | 85 | private static native int readSocket(long implObj, byte b[], int off, int len); 86 | private static native void writeSocket(long implObj, byte b[], int off, int len); 87 | 88 | private static native void closeSocket(long implObj); 89 | private static native long openSocket(String address, int port); 90 | 91 | private static native long createSocket(int port); 92 | private static native long acceptSocket(long implObj); 93 | private static native void cancelAcceptSocket(long implObj); 94 | 95 | static { 96 | Runtime.getRuntime().loadLibrary("jnilocalsock"); 97 | } 98 | }; 99 | 100 | 101 | -------------------------------------------------------------------------------- /examples/testleak.cpp: -------------------------------------------------------------------------------- 1 | //-< TESTLEAK.CPP >--------------------------------------------------*--------* 2 | // FastDB Version 1.0 (c) 1999 GARRET * ? * 3 | // (Main Memory Database Management System) * /\| * 4 | // * / \ * 5 | // Created: 26-Jul-2001 K.A. Knizhnik * / [] \ * 6 | // Last update: 26-Jul-2001 K.A. Knizhnik * GARRET * 7 | //-------------------------------------------------------------------*--------* 8 | // Memory allocator test 9 | //-------------------------------------------------------------------*--------* 10 | 11 | #include "fastdb.h" 12 | #include 13 | 14 | USE_FASTDB_NAMESPACE 15 | 16 | #define N_ITERATIONS 2000 17 | #define N_KEYS 1000 18 | #define VALUE_LENGTH 10000 19 | 20 | class Test { 21 | public: 22 | char const* key; 23 | char const* value; 24 | 25 | TYPE_DESCRIPTOR((KEY(key, INDEXED), FIELD(value))); 26 | }; 27 | 28 | REGISTER(Test); 29 | 30 | class Record { 31 | public: 32 | db_int8 count; 33 | 34 | TYPE_DESCRIPTOR((FIELD(count))); 35 | }; 36 | 37 | REGISTER(Record); 38 | 39 | int main(int argc, char* argv[]) 40 | { 41 | int i; 42 | dbDatabase db; 43 | int nIterations = N_ITERATIONS; 44 | if (argc > 1) { 45 | nIterations = atoi(argv[1]); 46 | } 47 | if (db.open(_T("testleak"))) { 48 | Record rec; 49 | rec.count = 0; 50 | db.insert(rec); 51 | dbCursor uc(dbCursorForUpdate); 52 | for (i = 0; i < nIterations; i++) { 53 | uc.select(); 54 | assert(uc->count == i); 55 | uc->count += 1; 56 | uc.update(); 57 | db.commit(); 58 | if (i % 100 == 0) { 59 | printf("%d records\r", i); 60 | fflush(stdout); 61 | } 62 | } 63 | printf("\nUpdate test passed\n"); 64 | Test t; 65 | char buf[64]; 66 | sprintf(buf, "KEY-%08d", 0); 67 | char* p = new char[VALUE_LENGTH]; 68 | memset(p, ' ', VALUE_LENGTH); 69 | p[VALUE_LENGTH-1] = '\0'; 70 | t.value = p; 71 | dbCursor cursor(dbCursorForUpdate); 72 | cursor.select(); 73 | cursor.removeAll(); 74 | dbQuery q; 75 | q = "key = ", buf; 76 | for (i = 0; i < nIterations; i++) { 77 | if (i > N_KEYS) { 78 | sprintf(buf, "KEY-%08d", i - N_KEYS); 79 | int rc = cursor.select(q); 80 | assert(rc == 1); 81 | cursor.remove(); 82 | } 83 | sprintf(buf, "KEY-%08d", i); 84 | t.key = buf; 85 | insert(t); 86 | db.commit(); 87 | if (i % 100 == 0) { 88 | printf("%d records\r", i); 89 | fflush(stdout); 90 | } 91 | } 92 | printf("\nRemove test passed\n"); 93 | db.close(); 94 | printf("\nDone\n"); 95 | } else { 96 | fprintf(stderr, "Failed to open database\n"); 97 | } 98 | return 0; 99 | } 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | --------------------------------------------------------------------------------