private static BlobChunk getAsLastChunk(Blob blob, int length) throws SQLException { if (blob instanceof BufferedBlob) { return ((BufferedBlob)blob).getAsLastChunk(); } else { return new BlobChunk(ByteBuffer.wrap(blob.getBytes(1, length)), true); } }
public void setBlob(OptimizedElementArray row, int columnPosition, Blob x) throws SQLException { long len = x.length(); if (len <= Integer.MAX_VALUE) { if (x instanceof BufferedBlob) { row.setObject(columnPosition - 1, ((BufferedBlob)x).getAsLastChunk(), SnappyType.BLOB); } else { setBytes(row, columnPosition, x.getBytes(1, (int)len)); } } else { throw ThriftExceptionUtil.newSQLException( SQLState.BLOB_TOO_LARGE_FOR_CLIENT, null, len, Integer.MAX_VALUE); } }