database course homework in compscicenter
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
project
src
INSTALL
README
build.sbt

README

---
Running test — to run test with sbt:
 SBT_OPTS="-Xms512M -Xmx1024M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M" sbt test

Without -Xmx1g some tests could fail

----
Run:
after sbt compile and creation of one-jar for server
 java -cp DBCSC/target/scala-2.10/classes -jar dbcsc_2.10-0.01-one-jar.jar  NodeName — start server, you should create
    NodeName folder with akka (=> this node) config

after sbt compile and creation of one-jar for client
 java -cp DBCSC/target/scala-2.10/classes -jar dbcsc_2.10-0.01-one-jar.jar nodes akka, where nodes — file with
 node actor adress per line
 akka - akka config file


Or just run: sbt run cmd and choose class to load
 Example of akka config and how to test nodes on remote systems you could find in test/resources/distributedTests/ThreeNodeTest/ManualTestNodes
----

API (console)
insert key->value //insert, if key exists - rewrite it
get key // get key, if no key found -> error
remove key //delete key, if succesufull -> report, if can't delete -> can't delete message, if no key found - succeed message
update key->value // == insert
quit // quit
----

DataBase Format:
DB:
blocks of keySizeValueSizeBooleankeyValue
To fast adress  - using indexes
----

Cache:
Database all operations proceed on disk, for fast access uses cache


---
index format:
sorted by key keyLenKeyfileIdOffset array of bytes on disk

merge databases:
db1 & db2: all operations in db1 < operations in db2
db should be keyLenKeyStatus(if status not removed =>  valueLenkeyvalue,else key)   sorted by key
then we merge db1 and db2 to new file

1) merge sort of indexes, prior to db2
2) create new file for dbMerge


--
Merge files policy
we don't want a lot of files, because index search degradation, so:
1) storage don't do anything, expect update list of db files and index
2)  node ask storage about current fileList length and if length > n (10), then merge 2 oldest files (time1, time2) in other thread
after merging and indexing this file, we add to db dir new file with name time2 + 1 (all file names — time of damp,
our storage not so fast to create file every millisecond, so time2 + 1 ≠ name of next file.
after replacing, send to node message about it with new files descriptors
3) node get message, says to storage to remove oldest files and add new instead.
 Then it remove old files and ready to proceed messages again









This file was modified by IntelliJ IDEA 12.1.4 for binding GitHub repository