public void selectRecord(String tableName, ArrayList<Condition> conditions) throws TableNotFoundException { Table table = cm.getTable(tableName); if (table == null) throw new TableNotFoundException(tableName); Data selectResult = new Data(); for (int blockOffset = 0; blockOffset < table.blockNum; blockOffset++) { BufferNode bn = bm.getBufferNode(table.name + ".table", blockOffset); byte[] block = bn.data; int recordNum = getRecordNum(block); int recordIndex = 0; int accessedRecordNum = 0; while (accessedRecordNum < recordNum) { int pos = getPositionFromIndex(table, recordIndex); if (block[pos] == EMPTY) { // record is empty, skip recordIndex++; continue; } byte[] recordBytes = bn.getBytes(pos + 1, table.totalLength); if (matchAllCond(table, recordBytes, conditions)) { byte[] bytes = bn.getBytes(pos + 1, table.totalLength); selectResult.add(new Row(bytesToString(table, bytes))); } recordIndex++; accessedRecordNum++; } } displaySelectResult(table, selectResult); }