/**
   * 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;
  }
예제 #2
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());
    }
  }