-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dynmi
committed
Feb 28, 2021
1 parent
7038074
commit 8a8a2d2
Showing
28 changed files
with
7,827 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
CPP=g++ | ||
|
||
|
||
TARGET=./wsql | ||
LIBDIR=/usr/lib/ | ||
SRCDIR=./src/ | ||
CPPFLAG=-w -lm -lpthread | ||
|
||
PF_FLIES = pf_buffermgr.cc pf_error.cc pf_filehandle.cc \ | ||
pf_pagehandle.cc pf_hashtable.cc pf_statistics.cc \ | ||
statistics.cc | ||
RM_FILES = rm_filehandle.cc bitmap.cc rm_record.cc | ||
IX_FILES = ix_indexhandle.cc btree_node.cc | ||
SM_FILES = sm_tablehandle.cc | ||
|
||
PF_SOURCES = $(addprefix $(SRCDIR), $(PF_FLIES)) | ||
RM_SOURCES = $(addprefix $(SRCDIR), $(RM_FILES)) | ||
IX_SOURCES = $(addprefix $(SRCDIR), $(IX_FILES)) | ||
SM_SOURCES = $(addprefix $(SRCDIR), $(SM_FILES)) | ||
|
||
PF_LIBSO = $(LIBDIR)libWSQLpf.so | ||
RM_LIBSO = $(LIBDIR)libWSQLrm.so | ||
IX_LIBSO = $(LIBDIR)libWSQLix.so | ||
SM_LIBSO = $(LIBDIR)libWSQLsm.so | ||
|
||
$(PF_LIBSO): | ||
$(CPP) -o $(PF_LIBSO) $(PF_SOURCES) -fPIC -shared | ||
|
||
$(RM_LIBSO): $(PF_LIBSO) | ||
$(CPP) -o $(RM_LIBSO) $(RM_SOURCES) $(PF_LIBSO) -fPIC -shared | ||
|
||
$(IX_LIBSO): $(PF_LIBSO) | ||
$(CPP) -o $(IX_LIBSO) $(IX_SOURCES) $(PF_LIBSO) -fPIC -shared | ||
|
||
$(SM_LIBSO): $(RM_LIBSO) $(IX_LIBSO) | ||
$(CPP) -o $(SM_LIBSO) $(SM_SOURCES) $(RM_LIBSO) $(IX_LIBSO) -fPIC -shared | ||
|
||
$(TARGET): $(SM_LIBSO) $(IX_LIBSO) $(RM_LIBSO) | ||
$(CPP) -o $(TARGET) $(SRCDIR)wsql.cc -w -L/usr/lib -lWSQLpf -lWSQLrm -lWSQLix -lWSQLsm | ||
|
||
|
||
all: $(TARGET) | ||
|
||
clean: | ||
rm -rf $(PF_LIBSO) | ||
rm -rf $(RM_LIBSO) | ||
rm -rf $(IX_LIBSO) | ||
rm -rf $(TARGET) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# WSQL | ||
|
||
## Introduction | ||
|
||
WSQL is a complete single-user relational database management system. | ||
|
||
## Usage | ||
|
||
### Install | ||
``` | ||
sudo make clean && sudo make all | ||
``` | ||
|
||
### Run | ||
``` | ||
./wsql | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// | ||
// File: bitmap.cc | ||
// | ||
// Description: bitmap class implementation | ||
// | ||
// Author: Haris Wang ([email protected]) | ||
// | ||
|
||
#include <cstdio> | ||
#include <cstring> | ||
#include <cassert> | ||
#include <climits> | ||
#include <math.h> | ||
#include <unistd.h> | ||
#include <iostream> | ||
#include "rm.h" | ||
|
||
|
||
bitmap::bitmap(int numBits, char *buf) | ||
{ | ||
size = numBits; | ||
NumChars = ceil(1.0 * size / 8); | ||
buffer = new char[NumChars]; | ||
|
||
if(buf==NULL) | ||
{ | ||
memset((void*)buffer, 0 , NumChars); | ||
} | ||
else | ||
{ | ||
memcpy(buffer, buf, NumChars); | ||
} | ||
|
||
} | ||
|
||
|
||
bitmap::~bitmap() | ||
{ | ||
delete [] buffer; | ||
} | ||
|
||
|
||
RC bitmap::to_char_buf(char * buf, int len) const | ||
{ | ||
assert( buf!=NULL && len==NumChars ); | ||
|
||
memcpy((void*)buf, buffer, len); | ||
return 0; | ||
} | ||
|
||
|
||
void bitmap::set(unsigned int pos, bool sign) | ||
{ | ||
int byte, offset; | ||
|
||
if (pos != UINT_MAX) | ||
{ | ||
assert(pos < size); | ||
// set given bit to 1/0 | ||
byte = pos / 8; | ||
offset = pos % 8; | ||
if(sign) | ||
{ | ||
buffer[byte] |= (1 << offset); | ||
} | ||
else | ||
{ | ||
buffer[byte] &= ~(1 << offset); | ||
} | ||
}else { | ||
// set all bits to 1/0 | ||
for(pos = 0; pos < size; pos++) | ||
{ | ||
byte = pos / 8; | ||
offset = pos % 8; | ||
if(sign) | ||
{ | ||
buffer[byte] |= (1 << offset); | ||
} | ||
else | ||
{ | ||
buffer[byte] &= ~(1 << offset); | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
|
||
RC bitmap::getSize() const | ||
{ | ||
return size; | ||
} | ||
|
||
bool bitmap::test(unsigned int bitNumber) const | ||
{ | ||
assert(bitNumber <= size - 1); | ||
int byte = bitNumber/8; | ||
int offset = bitNumber%8; | ||
|
||
return buffer[byte] & (1 << offset); | ||
} |
Oops, something went wrong.