diff --git a/src/main/java/com/dbms/Interpreter.java b/src/main/java/com/dbms/Interpreter.java index e2550f8..6a323b9 100644 --- a/src/main/java/com/dbms/Interpreter.java +++ b/src/main/java/com/dbms/Interpreter.java @@ -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; @@ -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. diff --git a/src/main/java/com/dbms/utils/Catalog.java b/src/main/java/com/dbms/utils/Catalog.java index 9853827..47cac89 100644 --- a/src/main/java/com/dbms/utils/Catalog.java +++ b/src/main/java/com/dbms/utils/Catalog.java @@ -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; @@ -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")); @@ -96,7 +97,7 @@ public static void setSchema(Map> s) { private static Map> getIndexInfo(BufferedReader br) throws IOException { Map> 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]; @@ -124,7 +125,7 @@ private static Map> getSchema(String input) throws IOExc Map> 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 attributes = new LinkedList<>();