Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/main/java/com/dbms/Interpreter.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.dbms.queryplan.LogicalPlanBuilder;
import com.dbms.queryplan.PhysicalPlanBuilder;
import com.dbms.utils.Catalog;
import io.github.pixee.security.BoundedLineReader;
import java.io.BufferedReader;
import java.io.IOException;
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
Expand Down Expand Up @@ -43,7 +44,7 @@ public static void run() throws IOException {
BufferedReader fileReader = Catalog.getQueriesFile();
int i = 1;
String currentQuery;
while ((currentQuery = fileReader.readLine()) != null) executeQuery(currentQuery, i++);
while ((currentQuery = BoundedLineReader.readLine(fileReader, 5_000_000)) != null) executeQuery(currentQuery, i++);
}

/** Initializes the catalog with the provided input and output paths, then runs the interpreter.
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/com/dbms/utils/Catalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.dbms.index.Index;
import com.dbms.index.TreeIndexBuilder;
import io.github.pixee.security.BoundedLineReader;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
Expand Down Expand Up @@ -76,9 +77,9 @@ private static BufferedReader readerFromPath(String... path) throws FileNotFound
* @throws IOException */
public static void init(String path) throws IOException {
BufferedReader br = new BufferedReader(new FileReader(path));
Catalog.input = br.readLine();
Catalog.output = br.readLine();
Catalog.temp = br.readLine();
Catalog.input = BoundedLineReader.readLine(br, 5_000_000);
Catalog.output = BoundedLineReader.readLine(br, 5_000_000);
Catalog.temp = BoundedLineReader.readLine(br, 5_000_000);
br.close();
schema = getSchema(Catalog.input);
INDEXES = getIndexInfo(readerFromPath(Catalog.input, "db", "index_info.txt"));
Expand All @@ -96,7 +97,7 @@ public static void setSchema(Map<String, List<Attribute>> s) {
private static Map<String, List<Index>> getIndexInfo(BufferedReader br) throws IOException {
Map<String, List<Index>> indexes = new HashMap<>();
String line;
while ((line = br.readLine()) != null) {
while ((line = BoundedLineReader.readLine(br, 5_000_000)) != null) {
String info[] = line.split(" ");
String table = info[0];
String column = info[1];
Expand Down Expand Up @@ -124,7 +125,7 @@ private static Map<String, List<Attribute>> getSchema(String input) throws IOExc
Map<String, List<Attribute>> schemaMap = new HashMap<>();
BufferedReader schemaBr = readerFromPath(input, "db", "schema.txt");
String line;
while ((line = schemaBr.readLine()) != null) {
while ((line = BoundedLineReader.readLine(schemaBr, 5_000_000)) != null) {
StringTokenizer table = new StringTokenizer(line, " ");
String tableName = table.nextToken();
List<Attribute> attributes = new LinkedList<>();
Expand Down