1 24 25 package com.mckoi.database; 26 27 import com.mckoi.util.IntegerVector; 28 import com.mckoi.util.BlockIntegerList; 29 30 46 47 public class VirtualTable extends JoinedTable { 48 49 53 protected IntegerVector[] row_list; 54 55 58 private int row_count; 59 60 63 protected void init(Table[] tables) { 64 super.init(tables); 65 66 int table_count = tables.length; 67 row_list = new IntegerVector[table_count]; 68 for (int i = 0; i < table_count; ++i) { 69 row_list[i] = new IntegerVector(); 70 } 71 } 72 73 77 VirtualTable(Table[] tables) { 78 super(tables); 79 } 80 81 VirtualTable(Table table) { 82 super(table); 83 } 84 85 protected VirtualTable() { 86 super(); 87 } 88 89 93 protected IntegerVector[] getReferenceRows() { 94 return row_list; 95 } 96 97 100 public int getRowCount() { 101 return row_count; 102 } 103 104 108 void set(Table table, IntegerVector rows) { 109 row_list[0] = new IntegerVector(rows); 110 row_count = rows.size(); 111 } 112 113 119 void set(Table[] tables, IntegerVector[] rows) { 120 for (int i = 0; i < tables.length; ++i) { 121 row_list[i] = new IntegerVector(rows[i]); 122 } 123 if (rows.length > 0) { 124 row_count = rows[0].size(); 125 } 126 } 127 128 132 void set(Table table, BlockIntegerList rows) { 133 row_list[0] = new IntegerVector(rows); 134 row_count = rows.size(); 135 } 136 137 141 void set(Table[] tables, BlockIntegerList[] rows) { 142 for (int i = 0; i < tables.length; ++i) { 143 row_list[i] = new IntegerVector(rows[i]); 144 } 145 if (rows.length > 0) { 146 row_count = rows[0].size(); 147 } 148 } 149 150 152 protected int resolveRowForTableAt(int row_number, int table_num) { 153 return row_list[table_num].intAt(row_number); 154 } 155 156 protected void resolveAllRowsForTableAt( 157 IntegerVector row_set, int table_num) { 158 IntegerVector cur_row_list = row_list[table_num]; 159 for (int n = row_set.size() - 1; n >= 0; --n) { 160 int aa = row_set.intAt(n); 161 int bb = cur_row_list.intAt(aa); 162 row_set.setIntAt(bb, n); 163 } 164 } 165 166 167 } 168 | Popular Tags |