From bf35a46362301e5e6ac3d342252294c1a72e0463 Mon Sep 17 00:00:00 2001 From: arjunsk Date: Sat, 17 Dec 2022 03:43:40 -0600 Subject: [PATCH] Final Commit --- docs/diagrams/D_CalciteQueryEngine.puml | 4 +- .../common/catalog/MetadataMgr.java | 4 +- .../common/catalog/index/IndexInfo.java | 2 +- .../common/catalog/index/IndexMgr.java | 136 +++++++------- .../catalog/stats}/StatMgr.java | 4 +- .../catalog/stats}/domain/StatInfo.java | 2 +- .../common/catalog/table/TableMgr.java | 172 +++++++++--------- .../catalog/table/TablePhysicalLayout.java | 5 +- .../plan/impl/A_TablePlan.java | 2 +- .../plan/impl/B_SelectPlan.java | 2 +- .../plan/impl/B_SelectWithIndexPlan.java | 2 +- .../plan/impl/C_ProjectPlan.java | 2 +- .../A_SelectUsingIndex_RORecordScan.java | 2 +- .../A_Select_RWRecordScan.java | 2 +- .../C_Project_RORecordScan.java | 2 +- .../impl/calcite/core/B_Table.java | 1 + 16 files changed, 174 insertions(+), 170 deletions(-) rename src/main/java/edu/utdallas/tiny_db/server/b_query_engine/{impl/basic/b_stats_manager => common/catalog/stats}/StatMgr.java (88%) rename src/main/java/edu/utdallas/tiny_db/server/b_query_engine/{impl/basic/b_stats_manager => common/catalog/stats}/domain/StatInfo.java (94%) rename src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/{c_sql_scans => b_sql_scans}/A_SelectUsingIndex_RORecordScan.java (96%) rename src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/{c_sql_scans => b_sql_scans}/A_Select_RWRecordScan.java (97%) rename src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/{c_sql_scans => b_sql_scans}/C_Project_RORecordScan.java (96%) diff --git a/docs/diagrams/D_CalciteQueryEngine.puml b/docs/diagrams/D_CalciteQueryEngine.puml index 1c1eec8..1e706c9 100644 --- a/docs/diagrams/D_CalciteQueryEngine.puml +++ b/docs/diagrams/D_CalciteQueryEngine.puml @@ -13,8 +13,8 @@ package MetadataMgr_TableCatalog package RW_HeapRecordScan -CalciteEnumerator <...> MetadataMgr_TableCatalog -CalciteEnumerator <...> RW_HeapRecordScan +CalciteEnumerator <..> MetadataMgr_TableCatalog +CalciteEnumerator <..> RW_HeapRecordScan CalciteEnumerator ---> CalciteTable MetadataMgr_TableCatalog -> RW_HeapRecordScan diff --git a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/MetadataMgr.java b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/MetadataMgr.java index 97c0b61..0f8a0a4 100755 --- a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/MetadataMgr.java +++ b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/MetadataMgr.java @@ -1,7 +1,7 @@ package edu.utdallas.tiny_db.server.b_query_engine.common.catalog; -import edu.utdallas.tiny_db.server.b_query_engine.impl.basic.b_stats_manager.StatMgr; -import edu.utdallas.tiny_db.server.b_query_engine.impl.basic.b_stats_manager.domain.StatInfo; +import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.stats.StatMgr; +import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.stats.domain.StatInfo; import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.index.IndexInfo; import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.index.IndexMgr; import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.table.TableMgr; diff --git a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/index/IndexInfo.java b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/index/IndexInfo.java index a9bed8b..4e2fb02 100644 --- a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/index/IndexInfo.java +++ b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/index/IndexInfo.java @@ -2,7 +2,7 @@ import static java.sql.Types.INTEGER; -import edu.utdallas.tiny_db.server.b_query_engine.impl.basic.b_stats_manager.domain.StatInfo; +import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.stats.domain.StatInfo; import edu.utdallas.tiny_db.server.d_storage_engine.common.transaction.Transaction; import edu.utdallas.tiny_db.server.d_storage_engine.RWIndexScan; import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.table.TablePhysicalLayout; diff --git a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/index/IndexMgr.java b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/index/IndexMgr.java index accefd1..1b0b961 100755 --- a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/index/IndexMgr.java +++ b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/index/IndexMgr.java @@ -1,87 +1,87 @@ package edu.utdallas.tiny_db.server.b_query_engine.common.catalog.index; -import edu.utdallas.tiny_db.server.b_query_engine.impl.basic.b_stats_manager.StatMgr; -import edu.utdallas.tiny_db.server.b_query_engine.impl.basic.b_stats_manager.domain.StatInfo; +import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.stats.StatMgr; +import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.stats.domain.StatInfo; +import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.table.TableDefinition; import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.table.TableMgr; +import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.table.TablePhysicalLayout; import edu.utdallas.tiny_db.server.d_storage_engine.common.transaction.Transaction; import edu.utdallas.tiny_db.server.d_storage_engine.impl.data.heap.HeapRWRecordScan; -import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.table.TablePhysicalLayout; -import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.table.TableDefinition; - import java.util.HashMap; import java.util.Map; /** - * The index manager. - * The index manager has similar functionality to the table manager. + * The index manager. The index manager has similar functionality to the table manager. * * @author Edward Sciore */ public class IndexMgr { - private TablePhysicalLayout recordValueLayout; - private TableMgr tblmgr; - private StatMgr statmgr; - /** - * Create the index manager. - * This constructor is called during system startup. - * If the database is new, then the idxcat table is created. - * - * @param isnew indicates whether this is a new database - * @param tx the system startup transaction - */ - public IndexMgr(boolean isnew, TableMgr tblmgr, StatMgr statmgr, Transaction tx) { - if (isnew) { - TableDefinition sch = new TableDefinition(); - sch.addStringField("indexname", TableMgr.MAX_NAME); - sch.addStringField("tablename", TableMgr.MAX_NAME); - sch.addStringField("fieldname", TableMgr.MAX_NAME); - tblmgr.createTable("idxcat", sch, tx); - } - this.tblmgr = tblmgr; - this.statmgr = statmgr; - recordValueLayout = tblmgr.getLayout("idxcat", tx); - } + private TablePhysicalLayout recordValueLayout; + private TableMgr tblmgr; + private StatMgr statmgr; + + /** + * Create the index manager. This constructor is called during system startup. If the database is + * new, then the idxcat table is created. + * + * @param isnew indicates whether this is a new database + * @param tx the system startup transaction + */ + public IndexMgr(boolean isnew, TableMgr tblmgr, StatMgr statmgr, Transaction tx) { + if (isnew) { + TableDefinition sch = new TableDefinition(); + sch.addStringField("indexname", TableMgr.MAX_NAME); + sch.addStringField("tablename", TableMgr.MAX_NAME); + sch.addStringField("fieldname", TableMgr.MAX_NAME); - /** - * Create an index of the specified type for the specified field. - * A unique ID is assigned to this index, and its information - * is stored in the idxcat table. - * - * @param idxname the name of the index - * @param tblname the name of the indexed table - * @param fldname the name of the indexed field - * @param tx the calling transaction - */ - public void createIndex(String idxname, String tblname, String fldname, Transaction tx) { - HeapRWRecordScan ts = new HeapRWRecordScan(tx, "idxcat", recordValueLayout); - ts.seekToInsertStart(); - ts.setString("indexname", idxname); - ts.setString("tablename", tblname); - ts.setString("fieldname", fldname); - ts.close(); + tblmgr.createTable("idxcat", sch, tx); } + this.tblmgr = tblmgr; + this.statmgr = statmgr; + recordValueLayout = tblmgr.getLayout("idxcat", tx); + } + + /** + * Create an index of the specified type for the specified field. A unique ID is assigned to this + * index, and its information is stored in the idxcat table. + * + * @param idxname the name of the index + * @param tblname the name of the indexed table + * @param fldname the name of the indexed field + * @param tx the calling transaction + */ + public void createIndex(String idxname, String tblname, String fldname, Transaction tx) { + HeapRWRecordScan ts = new HeapRWRecordScan(tx, "idxcat", recordValueLayout); + ts.seekToInsertStart(); + ts.setString("indexname", idxname); + ts.setString("tablename", tblname); + ts.setString("fieldname", fldname); + ts.close(); + } + + /** + * Return a map containing the index info for all indexes on the specified table. + * + * @param tblname the name of the table + * @param tx the calling transaction + * @return a map of IndexInfo objects, keyed by their field names + */ + public Map getIndexInfo(String tblname, Transaction tx) { + Map result = new HashMap(); + HeapRWRecordScan ts = new HeapRWRecordScan(tx, "idxcat", recordValueLayout); + while (ts.next()) { + if (ts.getString("tablename").equals(tblname)) { + String idxname = ts.getString("indexname"); + String fldname = ts.getString("fieldname"); + TablePhysicalLayout tblRecordValueLayout = tblmgr.getLayout(tblname, tx); + StatInfo tblsi = statmgr.getStatInfo(tblname, tblRecordValueLayout, tx); - /** - * Return a map containing the index info for all indexes - * on the specified table. - * - * @param tblname the name of the table - * @param tx the calling transaction - * @return a map of IndexInfo objects, keyed by their field names - */ - public Map getIndexInfo(String tblname, Transaction tx) { - Map result = new HashMap(); - HeapRWRecordScan ts = new HeapRWRecordScan(tx, "idxcat", recordValueLayout); - while (ts.next()) if (ts.getString("tablename").equals(tblname)) { - String idxname = ts.getString("indexname"); - String fldname = ts.getString("fieldname"); - TablePhysicalLayout tblRecordValueLayout = tblmgr.getLayout(tblname, tx); - StatInfo tblsi = statmgr.getStatInfo(tblname, tblRecordValueLayout, tx); - IndexInfo ii = new IndexInfo(idxname, fldname, tblRecordValueLayout.schema(), tx, tblsi); - result.put(fldname, ii); - } - ts.close(); - return result; + IndexInfo ii = new IndexInfo(idxname, fldname, tblRecordValueLayout.schema(), tx, tblsi); + result.put(fldname, ii); + } } + ts.close(); + return result; + } } diff --git a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/b_stats_manager/StatMgr.java b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/stats/StatMgr.java similarity index 88% rename from src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/b_stats_manager/StatMgr.java rename to src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/stats/StatMgr.java index 39ceefe..5d6eaf0 100644 --- a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/b_stats_manager/StatMgr.java +++ b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/stats/StatMgr.java @@ -1,6 +1,6 @@ -package edu.utdallas.tiny_db.server.b_query_engine.impl.basic.b_stats_manager; +package edu.utdallas.tiny_db.server.b_query_engine.common.catalog.stats; -import edu.utdallas.tiny_db.server.b_query_engine.impl.basic.b_stats_manager.domain.StatInfo; +import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.stats.domain.StatInfo; import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.table.TableMgr; import edu.utdallas.tiny_db.server.d_storage_engine.common.transaction.Transaction; import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.table.TablePhysicalLayout; diff --git a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/b_stats_manager/domain/StatInfo.java b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/stats/domain/StatInfo.java similarity index 94% rename from src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/b_stats_manager/domain/StatInfo.java rename to src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/stats/domain/StatInfo.java index 867afe0..359f5d7 100755 --- a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/b_stats_manager/domain/StatInfo.java +++ b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/stats/domain/StatInfo.java @@ -1,4 +1,4 @@ -package edu.utdallas.tiny_db.server.b_query_engine.impl.basic.b_stats_manager.domain; +package edu.utdallas.tiny_db.server.b_query_engine.common.catalog.stats.domain; /** * A StatInfo object holds three pieces of diff --git a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/table/TableMgr.java b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/table/TableMgr.java index 3a8e086..ee45fab 100755 --- a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/table/TableMgr.java +++ b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/table/TableMgr.java @@ -2,108 +2,110 @@ import edu.utdallas.tiny_db.server.d_storage_engine.common.transaction.Transaction; import edu.utdallas.tiny_db.server.d_storage_engine.impl.data.heap.HeapRWRecordScan; - import java.util.HashMap; import java.util.Map; /** - * The table manager. - * There are methods to create a table, save the metadata - * in the catalog, and obtain the metadata of a - * previously-created table. + * The table manager. There are methods to create a table, save the metadata in the catalog, and + * obtain the metadata of a previously-created table. * * @author Edward Sciore */ public class TableMgr { - // The max characters a tablename or fieldname can have. - public static final int MAX_NAME = 16; - private TablePhysicalLayout tcatRecordValueLayout, fcatRecordValueLayout; - /** - * Create a new catalog manager for the database system. - * If the database is new, the two catalog tables - * are created. - * - * @param isNew has the value true if the database is new - * @param tx the startup transaction - */ - public TableMgr(boolean isNew, Transaction tx) { - TableDefinition tcatTableDefinition = new TableDefinition(); - tcatTableDefinition.addStringField("tblname", MAX_NAME); - tcatTableDefinition.addIntField("slotsize"); - tcatRecordValueLayout = new TablePhysicalLayout(tcatTableDefinition); + // The max characters a tablename or fieldname can have. + public static final int MAX_NAME = 16; + private TablePhysicalLayout tcatRecordValueLayout, fcatRecordValueLayout; + + /** + * Create a new catalog manager for the database system. If the database is new, the two catalog + * tables are created. + * + * @param isNew has the value true if the database is new + * @param tx the startup transaction + */ + public TableMgr(boolean isNew, Transaction tx) { + TableDefinition tcatTableDefinition = new TableDefinition(); + tcatTableDefinition.addStringField("tblname", MAX_NAME); + tcatTableDefinition.addIntField("slotsize"); + tcatRecordValueLayout = new TablePhysicalLayout(tcatTableDefinition); - TableDefinition fcatTableDefinition = new TableDefinition(); - fcatTableDefinition.addStringField("tblname", MAX_NAME); - fcatTableDefinition.addStringField("fldname", MAX_NAME); - fcatTableDefinition.addIntField("type"); - fcatTableDefinition.addIntField("length"); - fcatTableDefinition.addIntField("offset"); - fcatRecordValueLayout = new TablePhysicalLayout(fcatTableDefinition); + TableDefinition fcatTableDefinition = new TableDefinition(); + fcatTableDefinition.addStringField("tblname", MAX_NAME); + fcatTableDefinition.addStringField("fldname", MAX_NAME); + fcatTableDefinition.addIntField("type"); + fcatTableDefinition.addIntField("length"); + fcatTableDefinition.addIntField("offset"); + fcatRecordValueLayout = new TablePhysicalLayout(fcatTableDefinition); - if (isNew) { - createTable("tinydb_tables", tcatTableDefinition, tx); - createTable("tinydb_columns", fcatTableDefinition, tx); - } + if (isNew) { + createTable("tinydb_tables", tcatTableDefinition, tx); + createTable("tinydb_columns", fcatTableDefinition, tx); } + } - /** - * Create a new table having the specified name and schema. - * - * @param tblname the name of the new table - * @param sch the table's schema - * @param tx the transaction creating the table - */ - public void createTable(String tblname, TableDefinition sch, Transaction tx) { - TablePhysicalLayout recordValueLayout = new TablePhysicalLayout(sch); + /** + * Create a new table having the specified name and schema. + * + * @param tblname the name of the new table + * @param sch the table's schema + * @param tx the transaction creating the table + */ + public void createTable(String tblname, TableDefinition sch, Transaction tx) { + TablePhysicalLayout recordValueLayout = new TablePhysicalLayout(sch); - HeapRWRecordScan tcat = new HeapRWRecordScan(tx, "tinydb_tables", tcatRecordValueLayout); - tcat.seekToInsertStart(); - tcat.setString("tblname", tblname); - tcat.setInt("slotsize", recordValueLayout.slotSize()); - tcat.close(); + HeapRWRecordScan tcat = new HeapRWRecordScan(tx, "tinydb_tables", tcatRecordValueLayout); + tcat.seekToInsertStart(); + tcat.setString("tblname", tblname); + tcat.setInt("slotsize", recordValueLayout.slotSize()); + tcat.close(); - HeapRWRecordScan fcat = new HeapRWRecordScan(tx, "tinydb_columns", fcatRecordValueLayout); - for (String fldname : sch.fields()) { - fcat.seekToInsertStart(); - fcat.setString("tblname", tblname); - fcat.setString("fldname", fldname); - fcat.setInt("type", sch.type(fldname)); - fcat.setInt("length", sch.length(fldname)); - fcat.setInt("offset", recordValueLayout.offset(fldname)); - } - fcat.close(); + HeapRWRecordScan fcat = new HeapRWRecordScan(tx, "tinydb_columns", fcatRecordValueLayout); + for (String fldname : sch.fields()) { + fcat.seekToInsertStart(); + fcat.setString("tblname", tblname); + fcat.setString("fldname", fldname); + fcat.setInt("type", sch.type(fldname)); + fcat.setInt("length", sch.length(fldname)); + fcat.setInt("offset", recordValueLayout.offset(fldname)); } + fcat.close(); + } - /** - * Retrieve the layout of the specified table - * from the catalog. - * - * @param tblname the name of the table - * @param tx the transaction - * @return the table's stored metadata - */ - public TablePhysicalLayout getLayout(String tblname, Transaction tx) { - int size = -1; - HeapRWRecordScan tcat = new HeapRWRecordScan(tx, "tinydb_tables", tcatRecordValueLayout); - while (tcat.next()) if (tcat.getString("tblname").equals(tblname)) { - size = tcat.getInt("slotsize"); - break; - } - tcat.close(); + /** + * Retrieve the layout of the specified table from the catalog. + * + * @param tblname the name of the table + * @param tx the transaction + * @return the table's stored metadata + */ + public TablePhysicalLayout getLayout(String tblname, Transaction tx) { + int size = -1; + HeapRWRecordScan tcat = new HeapRWRecordScan(tx, "tinydb_tables", tcatRecordValueLayout); + // [tableName1, slotsize1] | [tableName2, slotsize2] | [tableName3, slotsize3] + while (tcat.next()) { + if (tcat.getString("tblname").equals(tblname)) { + size = tcat.getInt("slotsize"); + break; + } + } + tcat.close(); - TableDefinition sch = new TableDefinition(); - Map offsets = new HashMap(); - HeapRWRecordScan fcat = new HeapRWRecordScan(tx, "tinydb_columns", fcatRecordValueLayout); - while (fcat.next()) if (fcat.getString("tblname").equals(tblname)) { - String fldname = fcat.getString("fldname"); - int fldtype = fcat.getInt("type"); - int fldlen = fcat.getInt("length"); - int offset = fcat.getInt("offset"); - offsets.put(fldname, offset); - sch.addField(fldname, fldtype, fldlen); - } - fcat.close(); - return new TablePhysicalLayout(sch, offsets, size); + TableDefinition sch = new TableDefinition(); + Map offsets = new HashMap(); + HeapRWRecordScan fcat = new HeapRWRecordScan(tx, "tinydb_columns", fcatRecordValueLayout); + // [tableName1, A, int, 4, offset] | [tableName1, B, varchar, 9, offset] | [tableName3, fldname, type, length offset] + while (fcat.next()) { + if (fcat.getString("tblname").equals(tblname)) { + String fldname = fcat.getString("fldname"); + int fldtype = fcat.getInt("type"); + int fldlen = fcat.getInt("length"); + int offset = fcat.getInt("offset"); + offsets.put(fldname, offset); + sch.addField(fldname, fldtype, fldlen); + } } + fcat.close(); + return new TablePhysicalLayout(sch, offsets, size); + } } \ No newline at end of file diff --git a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/table/TablePhysicalLayout.java b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/table/TablePhysicalLayout.java index 686efc1..3563221 100755 --- a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/table/TablePhysicalLayout.java +++ b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/common/catalog/table/TablePhysicalLayout.java @@ -33,6 +33,7 @@ public TablePhysicalLayout(TableDefinition tableDefinition) { this.tableDefinition = tableDefinition; offsets = new HashMap<>(); int pos = Integer.BYTES; // leave space for the empty/inuse flag + // [Inuse [0], A [1 Byte], B [5 Byte] for (String fldname : tableDefinition.fields()) { offsets.put(fldname, pos); pos += lengthInBytes(fldname); @@ -87,8 +88,8 @@ public int slotSize() { private int lengthInBytes(String fldname) { int fldtype = tableDefinition.type(fldname); if (fldtype == INTEGER) - return Integer.BYTES; - else + return Integer.BYTES; // 4 + else // VARCHAR(-->9) return Page.maxBytesRequiredForString(tableDefinition.length(fldname)); } } diff --git a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/a_query_optimizer/plan/impl/A_TablePlan.java b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/a_query_optimizer/plan/impl/A_TablePlan.java index fab1822..a86189c 100755 --- a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/a_query_optimizer/plan/impl/A_TablePlan.java +++ b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/a_query_optimizer/plan/impl/A_TablePlan.java @@ -2,7 +2,7 @@ import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.MetadataMgr; import edu.utdallas.tiny_db.server.b_query_engine.impl.basic.a_query_optimizer.plan.Plan; -import edu.utdallas.tiny_db.server.b_query_engine.impl.basic.b_stats_manager.domain.StatInfo; +import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.stats.domain.StatInfo; import edu.utdallas.tiny_db.server.d_storage_engine.RORecordScan; import edu.utdallas.tiny_db.server.d_storage_engine.common.transaction.Transaction; import edu.utdallas.tiny_db.server.d_storage_engine.impl.data.heap.HeapRWRecordScan; diff --git a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/a_query_optimizer/plan/impl/B_SelectPlan.java b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/a_query_optimizer/plan/impl/B_SelectPlan.java index 28c3fa2..76e9562 100644 --- a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/a_query_optimizer/plan/impl/B_SelectPlan.java +++ b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/a_query_optimizer/plan/impl/B_SelectPlan.java @@ -2,7 +2,7 @@ import edu.utdallas.tiny_db.server.a_frontend.common.domain.clause.A_Predicate; import edu.utdallas.tiny_db.server.b_query_engine.impl.basic.a_query_optimizer.plan.Plan; -import edu.utdallas.tiny_db.server.b_query_engine.impl.basic.c_sql_scans.A_Select_RWRecordScan; +import edu.utdallas.tiny_db.server.b_query_engine.impl.basic.b_sql_scans.A_Select_RWRecordScan; import edu.utdallas.tiny_db.server.d_storage_engine.RORecordScan; import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.table.TableDefinition; diff --git a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/a_query_optimizer/plan/impl/B_SelectWithIndexPlan.java b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/a_query_optimizer/plan/impl/B_SelectWithIndexPlan.java index f52133f..9bd33e3 100755 --- a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/a_query_optimizer/plan/impl/B_SelectWithIndexPlan.java +++ b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/a_query_optimizer/plan/impl/B_SelectWithIndexPlan.java @@ -3,7 +3,7 @@ import edu.utdallas.tiny_db.server.a_frontend.common.domain.clause.D_Constant; import edu.utdallas.tiny_db.server.b_query_engine.impl.basic.a_query_optimizer.plan.Plan; import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.index.IndexInfo; -import edu.utdallas.tiny_db.server.b_query_engine.impl.basic.c_sql_scans.A_SelectUsingIndex_RORecordScan; +import edu.utdallas.tiny_db.server.b_query_engine.impl.basic.b_sql_scans.A_SelectUsingIndex_RORecordScan; import edu.utdallas.tiny_db.server.d_storage_engine.RORecordScan; import edu.utdallas.tiny_db.server.d_storage_engine.RWIndexScan; import edu.utdallas.tiny_db.server.d_storage_engine.impl.data.heap.HeapRWRecordScan; diff --git a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/a_query_optimizer/plan/impl/C_ProjectPlan.java b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/a_query_optimizer/plan/impl/C_ProjectPlan.java index f57eb6a..1ef77ae 100755 --- a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/a_query_optimizer/plan/impl/C_ProjectPlan.java +++ b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/a_query_optimizer/plan/impl/C_ProjectPlan.java @@ -1,7 +1,7 @@ package edu.utdallas.tiny_db.server.b_query_engine.impl.basic.a_query_optimizer.plan.impl; import edu.utdallas.tiny_db.server.b_query_engine.impl.basic.a_query_optimizer.plan.Plan; -import edu.utdallas.tiny_db.server.b_query_engine.impl.basic.c_sql_scans.C_Project_RORecordScan; +import edu.utdallas.tiny_db.server.b_query_engine.impl.basic.b_sql_scans.C_Project_RORecordScan; import edu.utdallas.tiny_db.server.d_storage_engine.RORecordScan; import edu.utdallas.tiny_db.server.b_query_engine.common.catalog.table.TableDefinition; diff --git a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/c_sql_scans/A_SelectUsingIndex_RORecordScan.java b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/b_sql_scans/A_SelectUsingIndex_RORecordScan.java similarity index 96% rename from src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/c_sql_scans/A_SelectUsingIndex_RORecordScan.java rename to src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/b_sql_scans/A_SelectUsingIndex_RORecordScan.java index ec4dc67..4ce52fd 100755 --- a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/c_sql_scans/A_SelectUsingIndex_RORecordScan.java +++ b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/b_sql_scans/A_SelectUsingIndex_RORecordScan.java @@ -1,4 +1,4 @@ -package edu.utdallas.tiny_db.server.b_query_engine.impl.basic.c_sql_scans; +package edu.utdallas.tiny_db.server.b_query_engine.impl.basic.b_sql_scans; import edu.utdallas.tiny_db.server.a_frontend.common.domain.clause.D_Constant; import edu.utdallas.tiny_db.server.d_storage_engine.RORecordScan; diff --git a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/c_sql_scans/A_Select_RWRecordScan.java b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/b_sql_scans/A_Select_RWRecordScan.java similarity index 97% rename from src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/c_sql_scans/A_Select_RWRecordScan.java rename to src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/b_sql_scans/A_Select_RWRecordScan.java index 9f39b92..def7233 100755 --- a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/c_sql_scans/A_Select_RWRecordScan.java +++ b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/b_sql_scans/A_Select_RWRecordScan.java @@ -1,4 +1,4 @@ -package edu.utdallas.tiny_db.server.b_query_engine.impl.basic.c_sql_scans; +package edu.utdallas.tiny_db.server.b_query_engine.impl.basic.b_sql_scans; import edu.utdallas.tiny_db.server.a_frontend.common.domain.clause.A_Predicate; import edu.utdallas.tiny_db.server.a_frontend.common.domain.clause.D_Constant; diff --git a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/c_sql_scans/C_Project_RORecordScan.java b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/b_sql_scans/C_Project_RORecordScan.java similarity index 96% rename from src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/c_sql_scans/C_Project_RORecordScan.java rename to src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/b_sql_scans/C_Project_RORecordScan.java index 31c0d4f..dfb926a 100755 --- a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/c_sql_scans/C_Project_RORecordScan.java +++ b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/basic/b_sql_scans/C_Project_RORecordScan.java @@ -1,4 +1,4 @@ -package edu.utdallas.tiny_db.server.b_query_engine.impl.basic.c_sql_scans; +package edu.utdallas.tiny_db.server.b_query_engine.impl.basic.b_sql_scans; import edu.utdallas.tiny_db.server.a_frontend.common.domain.clause.D_Constant; import edu.utdallas.tiny_db.server.d_storage_engine.RORecordScan; diff --git a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/calcite/core/B_Table.java b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/calcite/core/B_Table.java index 996c931..2207098 100644 --- a/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/calcite/core/B_Table.java +++ b/src/main/java/edu/utdallas/tiny_db/server/b_query_engine/impl/calcite/core/B_Table.java @@ -47,6 +47,7 @@ public B_Table(String tableName, List fieldNames, List fiel @Override public RelDataType getRowType(RelDataTypeFactory typeFactory) { + // singleton pattern if (rowType == null) { List fields = new ArrayList<>(fieldNames.size());