def __field_type(self, fldname: str) -> Schema: schema = Schema() if self._lex.match_keyword("int"): self._lex.eat_keyword("int") schema.add_int_field(fldname) else: self._lex.eat_keyword("varchar") self._lex.eat_delim("(") str_len = self._lex.eat_int_constant() self._lex.eat_delim(")") schema.add_string_field(fldname, str_len) return schema
def __field_type(self, fldname: str) -> Schema: schema = Schema() if self._lex.match_keyword("int"): self._lex.eat_keyword("int") schema.add_int_field(fldname) else: self._lex.eat_keyword("varchar") self._lex.eat_delim("(") str_len = self._lex.eat_int_constant() self._lex.eat_delim(")") schema.add_string_field(fldname, str_len) return schema
def __init__(self, is_new, tx): """ Creates a new catalog manager for the database system. If the database is new, then the two catalog tables are created. :param is_new: has the value true if the database is new :param tx: the startup transaction """ assert isinstance(tx, Transaction) tcat_schema = Schema() tcat_schema.add_string_field("tblname", self.MAX_NAME) tcat_schema.add_int_field("reclength") self._tcat_info = TableInfo("tblcat", tcat_schema) fcat_schema = Schema() fcat_schema.add_string_field("tblname", self.MAX_NAME) fcat_schema.add_string_field("fldname", self.MAX_NAME) fcat_schema.add_int_field("type") fcat_schema.add_int_field("length") fcat_schema.add_int_field("offset") self._fcat_info = TableInfo("fldcat", fcat_schema) if is_new: self.create_table("tblcat", tcat_schema, tx) self.create_table("fldcat", fcat_schema, tx)
def __init__(self, is_new, tx): """ Creates a new catalog manager for the database system. If the database is new, then the two catalog tables are created. :param is_new: has the value true if the database is new :param tx: the startup transaction """ assert isinstance(tx, Transaction) tcat_schema = Schema() tcat_schema.add_string_field("tblname", self.MAX_NAME) tcat_schema.add_int_field("reclength") self._tcat_info = TableInfo("tblcat", tcat_schema) fcat_schema = Schema() fcat_schema.add_string_field("tblname", self.MAX_NAME) fcat_schema.add_string_field("fldname", self.MAX_NAME) fcat_schema.add_int_field("type") fcat_schema.add_int_field("length") fcat_schema.add_int_field("offset") self._fcat_info = TableInfo("fldcat", fcat_schema) if is_new: self.create_table("tblcat", tcat_schema, tx) self.create_table("fldcat", fcat_schema, tx)
def __schema(self) -> Schema: """ Returns the schema of the index records. The schema consists of the dataRID (which is represented as two integers, the block number and the record ID) and the dataval (which is the indexed field). Schema information about the indexed field is obtained via the table's metadata. :return the schema of the index records """ sch = Schema() sch.add_int_field("block") sch.add_int_field("id") if self._ti.schema().type(self._fldname) == INTEGER: sch.add_int_field("dataval") else: fldlen = self._ti.schema().length(self._fldname) sch.add_string_field("dataval", fldlen)
def __schema(self) -> Schema: """ Returns the schema of the index records. The schema consists of the dataRID (which is represented as two integers, the block number and the record ID) and the dataval (which is the indexed field). Schema information about the indexed field is obtained via the table's metadata. :return the schema of the index records """ sch = Schema() sch.add_int_field("block") sch.add_int_field("id") if self._ti.schema().type(self._fldname) == INTEGER: sch.add_int_field("dataval") else: fldlen = self._ti.schema().length(self._fldname) sch.add_string_field("dataval", fldlen)