JavaGDSImpl.calculateBLR(xsqlda); JavaGDSImpl.calculateIOLength(xsqlda);
AbstractJavaGDSImpl.calculateBLR(xsqlda); AbstractJavaGDSImpl.calculateIOLength(xsqlda);
    public void testCreateAndWriteBlobStreamInStreamPieces() throws Exception {        byte[] a = new String("a").getBytes();        byte[] testbuf = new byte[4096];//2030];        int reps = 10;//10000;        Arrays.fill(testbuf, a[0]);        if (log!=null) log.info("test- testCreateAndWriteBlobInStreamPieces");        db1 = setupTable2();        t1 = startTransaction(db1);    isc_blob_handle_impl blob1 = (isc_blob_handle_impl)gds.createIscBlobHandle();    final BlobParameterBuffer blobParameterBuffer = gds.createBlobParameterBuffer();    blobParameterBuffer.addArgument(ISCConstants.isc_bpb_type, ISCConstants.isc_bpb_type_stream);    //Clumplet bpb = GDSFactory.newClumplet(ISCConstants.isc_bpb_type, ISCConstants.isc_bpb_type_segmented);    gds.iscCreateBlob2(db1, t1, blob1, blobParameterBuffer);    if (log!=null) log.info("test- new blob_id: " + blob1.getBlobId());    for (int i = 0; i< reps; i++) {        gds.iscPutSegment(blob1, testbuf);    }        if (log!=null) log.info("test- wrote bytes: " + (100 * testbuf.length));        XSQLDA xsqlda = new XSQLDA(2);        XSQLVAR xsqlvar = new XSQLVAR();        xsqlvar.sqltype = ISCConstants.SQL_SHORT;        xsqlvar.sqllen = 2;        xsqlvar.sqldata = xsqlvar.encodeShort((short) 3);        xsqlda.sqlvar[0] = xsqlvar;        xsqlvar = new XSQLVAR();        xsqlvar.sqltype = ISCConstants.SQL_BLOB;        xsqlvar.sqllen = 8;        xsqlvar.sqldata = xsqlvar.encodeLong(blob1.getBlobId());        xsqlda.sqlvar[1] = xsqlvar;        JavaGDSImpl.calculateBLR(xsqlda);        JavaGDSImpl.calculateIOLength(xsqlda);        gds.iscCloseBlob(blob1);        if (log!=null) log.info("test- isc_dsql_exec_immed2");        gds.iscDsqlExecImmed2(db1, t1, "INSERT INTO R2 VALUES (?, ?)",                                 ISCConstants.SQL_DIALECT_CURRENT, xsqlda, null);        isc_stmt_handle_impl stmt1 = (isc_stmt_handle_impl) gds.createIscStmtHandle();        if (log!=null) log.info("test- isc_dsql_allocate_statement");        gds.iscDsqlAllocateStatement(db1, stmt1);        XSQLDA out_xsqlda = gds.iscDsqlPrepare(t1, stmt1, "SELECT COL1, COL2 FROM R2",                             ISCConstants.SQL_DIALECT_CURRENT);        if (log!=null) log.info("test- isc_dsql_execute2");        gds.iscDsqlExecute2(t1, stmt1, 1, null, null);        isc_blob_handle_impl blob2 = (isc_blob_handle_impl)gds.createIscBlobHandle();        byte[][] row = null;        gds.iscDsqlFetch(stmt1, 1, out_xsqlda, 200);        Object[] rows = stmt1.getRows();        int size = stmt1.size();        for (int rowNum=0; rowNum < size; rowNum++){           row = (byte[][]) rows[rowNum];           String out = "";            for (int i = 0; i < out_xsqlda.sqld; i++) {                Object data =  row[i];                out += "column: " + i + ", value: " + data;            }            if (log!=null) log.info(out);            blob2.setBlobId(xsqlvar.decodeLong(row[1]));            // blob2.rbl_buffer_length = 10;//1024;            gds.iscOpenBlob2(db1, t1, blob2, blobParameterBuffer);            int readcount = 0;            do {                byte[] answer = gds.iscGetSegment(blob2, 1052);// 1050)                readcount += answer.length;            } while (!blob2.isEof());            if (log!=null) log.info("test- read bytes: " + readcount);            if (readcount != (reps * testbuf.length)) {                throw new Exception("Retrieved wrong size");            }        gds.iscCloseBlob(blob2);        }        if (log!=null) log.info("test- isc_dsql_free_statement");        gds.iscDsqlFreeStatement(stmt1, ISCConstants.DSQL_drop);    commit(t1);    teardownTable2(db1);    //        dropDatabase(db1);    }