}
// if the column is a null column, write the field header now.
if (column instanceof Storable)
{
Storable sColumn = (Storable) column;
if (sColumn.isNull())
{
fieldStatus = StoredFieldHeader.setNull(fieldStatus, true);
StoredFieldHeader.write(out, fieldStatus, 0, LARGE_SLOT_SIZE);
return;
}
}
int beginPosition = out.getPosition();
int fieldDataLength = 0;
// write out the header, mostly to reserve the space
StoredFieldHeader.write(
out, fieldStatus, fieldDataLength, LARGE_SLOT_SIZE);
if (column instanceof StreamStorable)
{
if (((StreamStorable) column).returnStream() != null)
{
column = (InputStream) ((StreamStorable) column).returnStream();
}
}
if (column instanceof InputStream)
{
InputStream inColumn = (InputStream) column;
int bufferLen = inColumn.available();
byte[] bufData = new byte[bufferLen];
do
{
int lenRead = inColumn.read(bufData, bufferLen, 0);
if (lenRead != -1)
{
fieldDataLength += lenRead;
out.write(bufData, lenRead, 0);
}
else
{
break;
}
} while (true);
}
else if (column instanceof Storable)
{
Storable sColumn = (Storable) column;
// write field data to the stream, we already handled the null case
sColumn.writeExternal(logicalDataOut);
fieldDataLength =
out.getPosition() - beginPosition - FIELD_HEADER_SIZE;
}
else