예제 #1
0
  /** @throws ReadDriverException TODO */
  public void order() throws ReadDriverException {
    int rowCount = (int) dataSource.getRowCount();
    columnCache = new Value[rowCount][fieldIndexes.length];
    for (int field = 0; field < fieldIndexes.length; field++) {
      for (int i = 0; i < rowCount; i++) {
        columnCache[i][field] = dataSource.getFieldValue(i, fieldIndexes[field]);
      }
    }

    TreeSet set = new TreeSet(new SortComparator());

    for (int i = 0; i < dataSource.getRowCount(); i++) {
      set.add(new Integer(i));
    }

    orderIndexes = new long[(int) dataSource.getRowCount()];
    int index = 0;
    Iterator it = set.iterator();
    while (it.hasNext()) {
      Integer integer = (Integer) it.next();

      orderIndexes[index] = integer.intValue();
      index++;
    }
  }
예제 #2
0
  /**
   * DOCUMENT ME!
   *
   * @param ret
   * @param fieldNames
   * @param types
   * @throws ReadDriverException TODO
   */
  public OrderedDataSource(OperationDataSource ret, String[] fieldNames, int[] types)
      throws ReadDriverException {
    this.dataSource = ret;

    fieldIndexes = new int[fieldNames.length];
    for (int i = 0; i < fieldNames.length; i++) {
      fieldIndexes[i] = dataSource.getFieldIndexByName(fieldNames[i]);
    }

    orders = new int[types.length];
    for (int i = 0; i < types.length; i++) {
      orders[i] = (types[i] == SelectAdapter.ORDER_ASC) ? 1 : -1;
    }
  }
예제 #3
0
 /** @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldType(int) */
 public int getFieldType(int i) throws ReadDriverException {
   return dataSource.getFieldType(i);
 }
예제 #4
0
 /** @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getRowCount() */
 public long getRowCount() throws ReadDriverException {
   return dataSource.getRowCount();
 }
예제 #5
0
 /** @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldName(int) */
 public String getFieldName(int fieldId) throws ReadDriverException {
   return dataSource.getFieldName(fieldId);
 }
예제 #6
0
 /** @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldCount() */
 public int getFieldCount() throws ReadDriverException {
   return dataSource.getFieldCount();
 }
예제 #7
0
 /** @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getFieldValue(long, int) */
 public Value getFieldValue(long rowIndex, int fieldId) throws ReadDriverException {
   return dataSource.getFieldValue(orderIndexes[(int) rowIndex], fieldId);
 }
예제 #8
0
 /** @see com.hardcode.gdbms.engine.data.DataSource#getFieldIndexByName(java.lang.String) */
 public int getFieldIndexByName(String fieldName) throws ReadDriverException {
   return dataSource.getFieldIndexByName(fieldName);
 }
예제 #9
0
 /** @see com.hardcode.gdbms.engine.data.DataSource#getMemento() */
 public Memento getMemento() throws MementoException {
   return new OperationLayerMemento(getName(), new Memento[] {dataSource.getMemento()}, getSQL());
 }
예제 #10
0
 /** @see com.hardcode.gdbms.engine.data.DataSource#stop() */
 public void stop() throws ReadDriverException {
   dataSource.stop();
 }