if (log.isDebugEnabled()) {log.debug("op_get_segment ");}
log.debug("op_get_segment ");
    public byte[] isc_get_segment(isc_blob_handle blob_handle,                                  int requested) throws GDSException {        isc_blob_handle_impl blob = (isc_blob_handle_impl) blob_handle;        isc_db_handle_impl db = blob.db;        if (db == null) {            throw new GDSException(isc_bad_db_handle);        }        isc_tr_handle_impl tr = blob.tr;        if (tr == null) {            throw new GDSException(isc_bad_trans_handle);        }        synchronized (db) {            try {                if (log.isDebugEnabled()) {log.debug("op_get_segment ");}                db.out.writeInt(op_get_segment);                db.out.writeInt(blob.rbl_id); //short???                //            if (log.isDebugEnabled()) {log.debug("trying to read bytes: " + Math.min(blob.rbl_buffer_length, maxread) + 2);}                //db.out.writeInt(Math.min(blob.rbl_buffer_length, maxread) + 2); //Actually needs to be less than max short value                if (log.isDebugEnabled()) {log.debug("trying to read bytes: " +Math.min(requested + 2, Short.MAX_VALUE));}                db.out.writeInt(Math.min(requested + 2, Short.MAX_VALUE));                db.out.writeInt(0);//writeBuffer for put segment;                db.out.flush();                            if (log.isDebugEnabled()) {log.debug("sent");}                Response resp = receiveResponse(db);                blob.rbl_flags &= ~RBL_segment;                if (resp.resp_object == 1) {                    blob.rbl_flags |= RBL_segment;                }                else if (resp.resp_object == 2) {                    blob.rbl_flags |= RBL_eof_pending;                }                byte[] buffer = resp.resp_data;                if (buffer.length == 0) {//previous segment was last, this has no data                    return buffer;                }                int len = 0;                int srcpos = 0;                int destpos = 0;                while (srcpos < buffer.length) {                    len = isc_vax_integer(buffer, srcpos, 2);                    srcpos += 2;                    System.arraycopy(buffer, srcpos, buffer, destpos, len);                    srcpos += len;                    destpos += len;                }                byte[] result = new byte[destpos];                System.arraycopy(buffer, 0, result, 0, destpos);                return result;            }            catch (IOException ioe) {                throw new GDSException(isc_net_read_err);            }        }    }