/**
   * For deferred update, get a deferred sparse row based on the deferred non-sparse row. Share the
   * underlying columns. If there is no column bit map, make them the same row.
   *
   * @exception StandardException Thrown on error
   */
  protected ExecRow makeDeferredSparseRow(
      ExecRow deferredBaseRow, FormatableBitSet baseRowReadList, LanguageConnectionContext lcc)
      throws StandardException {
    ExecRow deferredSparseRow;

    if (baseRowReadList == null) {
      /* No sparse row */
      deferredSparseRow = deferredBaseRow;
    } else {
      /*
       ** We need to do a fetch doing a partial row
       ** read.  We need to shift our 1-based bit
       ** set to a zero based bit set like the store
       ** expects.
       */
      deferredSparseRow = RowUtil.getEmptyValueRow(baseRowReadList.getLength() - 1, lcc);
      /*
       ** getColumn(), setColumn(), and baseRowReadList are
       ** one-based.
       */
      int fromPosition = 1;
      for (int i = 1; i <= deferredSparseRow.nColumns(); i++) {
        if (baseRowReadList.isSet(i)) {
          deferredSparseRow.setColumn(i, deferredBaseRow.getColumn(fromPosition++));
        }
      }
    }

    return deferredSparseRow;
  }
Example #2
0
  /**
   * Store the stored representation of the column value in the stream.
   *
   * <p>For more detailed description of the ACCESS_B2I_V3_ID format see documentation at top of
   * file.
   *
   * @see java.io.Externalizable#writeExternal
   */
  public void writeExternal_v10_2(ObjectOutput out) throws IOException {
    super.writeExternal(out);
    out.writeLong(baseConglomerateId);
    out.writeInt(rowLocationColumn);

    // write the columns ascend/descend information as bits
    FormatableBitSet ascDescBits = new FormatableBitSet(ascDescInfo.length);

    for (int i = 0; i < ascDescInfo.length; i++) {
      if (ascDescInfo[i]) ascDescBits.set(i);
    }
    ascDescBits.writeExternal(out);
  }
Example #3
0
  /**
   * Restore the in-memory representation from the stream.
   *
   * <p>
   *
   * @exception ClassNotFoundException Thrown if the stored representation is serialized and a class
   *     named in the stream could not be found.
   * @see java.io.Externalizable#readExternal
   */
  private final void localReadExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    super.readExternal(in);
    baseConglomerateId = in.readLong();
    rowLocationColumn = in.readInt();

    // read the column sort order info
    FormatableBitSet ascDescBits = new FormatableBitSet();
    ascDescBits.readExternal(in);
    ascDescInfo = new boolean[ascDescBits.getLength()];
    for (int i = 0; i < ascDescBits.getLength(); i++) ascDescInfo[i] = ascDescBits.isSet(i);

    // In memory maintain a collation id per column in the template.
    collation_ids = new int[format_ids.length];
    if (SanityManager.DEBUG) {
      SanityManager.ASSERT(!hasCollatedTypes);
    }

    // initialize all the entries to COLLATION_TYPE_UCS_BASIC,
    // and then reset as necessary.  For version ACCESS_B2I_V3_ID,
    // this is the default and no resetting is necessary.
    for (int i = 0; i < format_ids.length; i++)
      collation_ids[i] = StringDataValue.COLLATION_TYPE_UCS_BASIC;

    // initialize the unique with null setting to false, to be reset
    // below when read from disk.  For version ACCESS_B2I_V3_ID and
    // ACCESS_B2I_V4_ID, this is the default and no resetting is necessary.
    setUniqueWithDuplicateNulls(false);

    if (conglom_format_id == StoredFormatIds.ACCESS_B2I_V4_ID
        || conglom_format_id == StoredFormatIds.ACCESS_B2I_V5_ID) {
      // current format id, read collation info from disk
      if (SanityManager.DEBUG) {
        // length must include row location column and at least
        // one other field.
        SanityManager.ASSERT(collation_ids.length >= 2, "length = " + collation_ids.length);
      }

      hasCollatedTypes = ConglomerateUtil.readCollationIdArray(collation_ids, in);
    } else if (conglom_format_id != StoredFormatIds.ACCESS_B2I_V3_ID) {
      // Currently only V3, V4 and V5 should be possible in a Derby DB.
      // Actual work for V3 is handled by default code above, so no
      // special work is necessary.

      if (SanityManager.DEBUG) {
        SanityManager.THROWASSERT("Unexpected format id: " + conglom_format_id);
      }
    }
    if (conglom_format_id == StoredFormatIds.ACCESS_B2I_V5_ID) {
      setUniqueWithDuplicateNulls(in.readBoolean());
    }
  }
  /**
   * Copy columns from srcrow into destrow, or insert ROW_NUMBER.
   *
   * <p><b>FIXME</b> This is temporary. Window function treatment needs to generalized to work for
   * other window functions.
   *
   * @exception StandardException thrown on failure to open
   */
  public void populateFromSourceRow(ExecRow srcrow, ExecRow destrow) throws StandardException {
    int srcindex = 1;

    try {
      DataValueDescriptor[] columns = destrow.getRowArray();
      for (int index = 0; index < columns.length; index++) {

        if (referencedColumns != null && !referencedColumns.get(index)) {
          columns[index].setValue((long) this.rownumber);
        } else {
          destrow.setColumn(index + 1, srcrow.getColumn(srcindex));
          srcindex++;
        }
      }
    } catch (StandardException se) {
      throw se;
    } catch (Throwable t) {
      throw StandardException.unexpectedUserException(t);
    }
  }