Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/Design/B+ Tree Layer.md
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,6 @@ int BPlusTree::splitInternal(int intBlockNum, InternalEntry internalEntries[]) {

// set leftBlkHeader with the following values
// - number of entries = (MAX_KEYS_INTERNAL)/2 = 50
// - rblock = rightBlkNum
// and update the header using BlockBuffer::setHeader()

/*
Expand Down
6 changes: 3 additions & 3 deletions docs/Design/Buffer Layer/BlockBuffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ int BlockBuffer::setHeader(struct HeadInfo *head){

#### Description

The block number to which this instance of `BlockBuffer` is associated (given by the `blockNum` member field) is freed from the buffer and the disk. The `blockNum` field of the object is invalidated (set to `INVALID_BLOCK` (-1)).
The block number to which this instance of `BlockBuffer` is associated (given by the `blockNum` member field) is freed from the buffer and the disk. The `blockNum` field of the object is invalidated (set to `INVALID_BLOCKNUM` (-1)).

#### Arguments

Expand All @@ -245,7 +245,7 @@ Nil

:::caution note

- The `BlockBuffer` class is a higher level abstraction to the disk blocks. It makes use of the `StaticBuffer` to access/modify the values in the disk block. When `releaseBlock()` is called, the corresponding disk block is freed from the buffer(if present) and set as an unused block in the disk. However, the `BlockBuffer` object itself remains as is with its `blockNum` set to `INVALID_BLOCK`. This object is only deallocated at the end of it's lifetime.
- The `BlockBuffer` class is a higher level abstraction to the disk blocks. It makes use of the `StaticBuffer` to access/modify the values in the disk block. When `releaseBlock()` is called, the corresponding disk block is freed from the buffer(if present) and set as an unused block in the disk. However, the `BlockBuffer` object itself remains as is with its `blockNum` set to `INVALID_BLOCKNUM`. This object is only deallocated at the end of it's lifetime.
- If `releaseBlock()` method is called again after having successfully released for the first time (or if the `blockNum` field is invalid), then this method will not perform any operation.

:::
Expand All @@ -255,7 +255,7 @@ Nil
```cpp
void BlockBuffer::releaseBlock(){

// if blockNum is INVALID_BLOCK (-1), or it is invalidated already, do nothing
// if blockNum is INVALID_BLOCKNUM (-1), or it is invalidated already, do nothing

// else
/* get the buffer number of the buffer assigned to the block
Expand Down
12 changes: 6 additions & 6 deletions docs/Design/Schema Layer.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ int Schema::deleteRel(char *relName) {
// if the relation to delete is either Relation Catalog or Attribute Catalog,
// return E_NOTPERMITTED
// (check if the relation names are either "RELATIONCAT" and "ATTRIBUTECAT".
// you may use the following constants: RELCAT_NAME and ATTRCAT_NAME)
// you may use the following constants: RELCAT_RELNAME and ATTRCAT_RELNAME)

// get the rel-id using appropriate method of OpenRelTable class by
// passing relation name as argument
Expand Down Expand Up @@ -218,7 +218,7 @@ int createIndex(char relName[ATTR_SIZE],char attrName[ATTR_SIZE]){
// if the relName is either Relation Catalog or Attribute Catalog,
// return E_NOTPERMITTED
// (check if the relation names are either "RELATIONCAT" and "ATTRIBUTECAT".
// you may use the following constants: RELCAT_NAME and ATTRCAT_NAME)
// you may use the following constants: RELCAT_RELNAME and ATTRCAT_RELNAME)

// get the relation's rel-id using OpenRelTable::getRelId() method

Expand Down Expand Up @@ -262,7 +262,7 @@ int Schema::dropIndex(char *relName, char *attrName) {
// if the relName is either Relation Catalog or Attribute Catalog,
// return E_NOTPERMITTED
// (check if the relation names are either "RELATIONCAT" and "ATTRIBUTECAT".
// you may use the following constants: RELCAT_NAME and ATTRCAT_NAME)
// you may use the following constants: RELCAT_RELNAME and ATTRCAT_RELNAME)

// get the rel-id using OpenRelTable::getRelId()

Expand Down Expand Up @@ -322,7 +322,7 @@ int renameRel(char oldRelName[ATTR_SIZE], char newRelName[ATTR_SIZE]) {
// if the oldRelName or newRelName is either Relation Catalog or Attribute Catalog,
// return E_NOTPERMITTED
// (check if the relation names are either "RELATIONCAT" and "ATTRIBUTECAT".
// you may use the following constants: RELCAT_NAME and ATTRCAT_NAME)
// you may use the following constants: RELCAT_RELNAME and ATTRCAT_RELNAME)

// if the relation is open
// (check if OpenRelTable::getRelId() returns E_RELNOTOPEN)
Expand Down Expand Up @@ -367,7 +367,7 @@ int Schema::renameAttr(char *relName, char *oldAttrName, char *newAttrName) {
// if the relName is either Relation Catalog or Attribute Catalog,
// return E_NOTPERMITTED
// (check if the relation names are either "RELATIONCAT" and "ATTRIBUTECAT".
// you may use the following constants: RELCAT_NAME and ATTRCAT_NAME)
// you may use the following constants: RELCAT_RELNAME and ATTRCAT_RELNAME)

// if the relation is open
// (check if OpenRelTable::getRelId() returns E_RELNOTOPEN)
Expand Down Expand Up @@ -442,7 +442,7 @@ int closeRel(char relName[ATTR_SIZE]) {
// if the relName is either Relation Catalog or Attribute Catalog,
// return E_NOTPERMITTED
// (check if the relation names are either "RELATIONCAT" and "ATTRIBUTECAT".
// you may use the following constants: RELCAT_NAME and ATTRCAT_NAME)
// you may use the following constants: RELCAT_RELNAME and ATTRCAT_RELNAME)

// get the relation's rel-id using OpenRelTable::getRelationId() method

Expand Down
4 changes: 2 additions & 2 deletions docs/Roadmap/Stage01.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The [Disk class](../Design/Physical%20Layer.md#disk-class) has a _constructor_ a

## Reading and Writing

In this stage, we will try to use the provided Disk functions to do I/O operations on the disk. In your `mynitcbase` folder, you will find a `main.c` file. We will be editing this file to read and write from a random block on the disk. In the very first line of the `main` function, you will find a declaration of an instance of `Disk` class for reasons we mentioned earlier. The commented-out lines following this declaration are relevant only in later stages and will be covered in due time.
In this stage, we will try to use the provided Disk functions to do I/O operations on the disk. In your `mynitcbase` folder, you will find a `main.cpp` file. We will be editing this file to read and write from a random block on the disk. In the very first line of the `main` function, you will find a declaration of an instance of `Disk` class for reasons we mentioned earlier. The commented-out lines following this declaration are relevant only in later stages and will be covered in due time.

As you read in [Disk model](../Design/Physical%20Layer.md#disk-model), each block of the disk is 2048 bytes. The disk functions expect two arguments: a buffer of size 2048 bytes and the block number that we want to work with.

Expand Down Expand Up @@ -93,7 +93,7 @@ Additionally comment out the call to the `handleFrontend` function for now. We w

So, in summary, your main function should look like so.

```cpp title="the modified main.c file"
```cpp title="the modified main.cpp file"
int main(int argc, char *argv[]) {
Disk disk_run;

Expand Down
2 changes: 1 addition & 1 deletion docs/Roadmap/Stage02.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ int main(int argc, char *argv[]) {

</details>

Now, let us implement the functions that we invoked from the `main()` function. Open the `BlockAccess.cpp` file in the `Buffer` folder and complete the following.
Now, let us implement the functions that we invoked from the `main()` function. Open the `BlockBuffer.cpp` file in the `Buffer` folder and complete the following.

<details>
<summary>Buffer/BlockBuffer.cpp</summary>
Expand Down
4 changes: 2 additions & 2 deletions docs/Roadmap/Stage04.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ We discussed the relation and attribute cache in the previous stage. Your implem

## The Search Operation

A search operation involves fetching all records that satisfy some condition. This is also known as a selection operation in [relational algebra](https://en.wikipedia.org/wiki/Relational_algebra). NITCbase supports selection with the following operators: `=`, `!=`, `>`, `>=`, `<` `>=`. We'll implement a function that will do the appropriate search and return to us a record that satisfies our condition each time it's called. Higher levels can call this function repeatedly until there are no more records to be found.
A search operation involves fetching all records that satisfy some condition. This is also known as a selection operation in [relational algebra](https://en.wikipedia.org/wiki/Relational_algebra). NITCbase supports selection with the following operators: `=`, `!=`, `>`, `>=`, `<` `<=`. We'll implement a function that will do the appropriate search and return to us a record that satisfies our condition each time it's called. Higher levels can call this function repeatedly until there are no more records to be found.

You might've realized that the above function would require some global state to work as intended. We'll need to keep track of the previously found record so that we can fetch the next record that satisfies the condition. And that is exactly what the `searchIndex` field in the relation cache does. `searchIndex` in a relation cache entry stores the `rec-id = {block, slot}` of the last hit during linear search on that relation. A value of `rec-id = {-1, -1}` indicates that the search should start over from the beginning again.

Expand Down Expand Up @@ -518,5 +518,5 @@ SELECT * FROM Students INTO null WHERE Marks>=90;
```plain
SELECT * FROM RELATIONCAT INTO null WHERE #Records > five; # Error: Mismatch in attribute type
SELECT * FROM RELATIONCAT INTO null WHERE Name = Students; # Error: Attribute does not exist
SELECT * FROM Students INTO null WHERE Batch=J; # Error: Relation is not open
SELECT * FROM Participants INTO null WHERE regNo>0; # Error: Relation is not open
```
2 changes: 1 addition & 1 deletion docs/Roadmap/Stage05.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ Selected successfully into null
Selected successfully into null
```

**Q3.** In this exercise, we will test the error conditions of the _open_ functionality. Run the following **in your NITCbase** to create some test relations. (You could make use of the [run](../User%20Interface%20Commands/utility.md#run-batch-execution-command) command to run multiple commands easily.)
**Q3.** In this exercise, we will test the error conditions of the _open_ functionality. Run the following **in your XFS interface** to create some test relations. (You could make use of the [run](../User%20Interface%20Commands/utility.md#run-batch-execution-command) command to run multiple commands easily.)

```sql
create table a(id NUM);
Expand Down
2 changes: 1 addition & 1 deletion docs/Roadmap/Stage08.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ Your NITCbase now supports the creation of relations. With that, we have now imp

## Exercises

**Q1.** In your NITCbase, run the file [s8test.txt](/roadmap_files/stage8/script.txt) to test your implementation. Place the files [products.csv](/roadmap_files/stage8/products.txt) and [stores.csv](/roadmap_files/stage8/stores.txt) in the `Files/Input_Files` directory. Place [s8test.txt](/roadmap_files/stage8/script.txt) in the `Files/Batch_Execution_Files` directory. Once you have placed the files, execute the [run](../User%20Interface%20Commands/utility.md#run-batch-execution-command) command in your NITCbase as below.
**Q1.** In your NITCbase, run the file [s8test.txt](/roadmap_files/stage8/script.txt) to test your implementation. Place the files [s8products.csv](/roadmap_files/stage8/products.txt) and [s8stores.csv](/roadmap_files/stage8/stores.txt) in the `Files/Input_Files` directory. Place [s8test.txt](/roadmap_files/stage8/script.txt) in the `Files/Batch_Execution_Files` directory. Once you have placed the files, execute the [run](../User%20Interface%20Commands/utility.md#run-batch-execution-command) command in your NITCbase as below.

```
run s8test.txt
Expand Down
Loading