*/
public void allocateLobForResult(ResultLob result,
InputStream inputStream) {
try {
CountdownInputStream countStream;
switch (result.getSubType()) {
case ResultLob.LobResultTypes.REQUEST_CREATE_BYTES : {
long blobId;
long blobLength = result.getBlockLength();
if (blobLength < 0) {
// embedded session + unknown lob length
allocateBlobSegments(result, result.getInputStream());
break;
}
if (inputStream == null) {
// embedded session + known lob length
blobId = result.getLobID();
inputStream = result.getInputStream();
} else {
// server session + known or unknown lob length
BlobData blob = session.createBlob(blobLength);
blobId = blob.getId();
resultLobs.put(result.getLobID(), blobId);
}
countStream = new CountdownInputStream(inputStream);
countStream.setCount(blobLength);
database.lobManager.setBytesForNewBlob(
blobId, countStream, result.getBlockLength());
break;
}
case ResultLob.LobResultTypes.REQUEST_CREATE_CHARS : {
long clobId;
long clobLength = result.getBlockLength();
if (clobLength < 0) {
// embedded session + unknown lob length
allocateClobSegments(result, result.getReader());
break;
}
if (inputStream == null) {
clobId = result.getLobID();
// embedded session + known lob length
if (result.getReader() != null) {
inputStream =
new ReaderInputStream(result.getReader());
} else {
inputStream = result.getInputStream();
}
} else {
// server session + known or unknown lob length
ClobData clob = session.createClob(clobLength);
clobId = clob.getId();
resultLobs.put(result.getLobID(), clobId);
}
countStream = new CountdownInputStream(inputStream);
countStream.setCount(clobLength * 2);
database.lobManager.setCharsForNewClob(
clobId, countStream, result.getBlockLength(), false);
break;
}