Long.toString(length), Long.toString(Integer.MAX_VALUE)); BlobChunk chunk = new BlobChunk().setOffset(0).setTotalLength(length); final int chunkSize; if (attrs != null && attrs.isSetLobChunkSize()) { chunk.setChunk(blob.getBytes(1, chunkSize)).setLast(false); lobId = connHolder.getConnection().addLOBMapping(blob); chunk.setLobId(lobId); chunk.setChunk(blob.getBytes(1, (int)length)).setLast(true);
public Object getFieldValue(_Fields field) { switch (field) { case CHUNK: return getChunk(); case LAST: return Boolean.valueOf(isLast()); case LOB_ID: return Integer.valueOf(getLobId()); case OFFSET: return Long.valueOf(getOffset()); case TOTAL_LENGTH: return Long.valueOf(getTotalLength()); } throw new IllegalStateException(); }
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case CHUNK: return isSetChunk(); case LAST: return isSetLast(); case LOB_ID: return isSetLobId(); case OFFSET: return isSetOffset(); case TOTAL_LENGTH: return isSetTotalLength(); } throw new IllegalStateException(); }
case CHUNK: if (value == null) { unsetChunk(); } else { setChunk((ByteBuffer)value); unsetLast(); } else { setLast((Boolean)value); unsetLobId(); } else { setLobId((Integer)value); unsetOffset(); } else { setOffset((Long)value); unsetTotalLength(); } else { setTotalLength((Long)value);
int lobId; Blob blob; if (chunk.isSetLobId()) { lobId = chunk.lobId; Object lob = conn.getLOBMapping(lobId); if (chunk.isSetOffset()) { offset += chunk.offset; blob.setBytes(offset, chunk.getChunk()); return lobId; } catch (Throwable t) {
@Override public void write(org.apache.thrift.protocol.TProtocol prot, BlobChunk struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; oprot.writeBinary(struct.chunk); oprot.writeBool(struct.last); BitSet optionals = new BitSet(); if (struct.isSetLobId()) { optionals.set(0); } if (struct.isSetOffset()) { optionals.set(1); } if (struct.isSetTotalLength()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetLobId()) { oprot.writeI32(struct.lobId); } if (struct.isSetOffset()) { oprot.writeI64(struct.offset); } if (struct.isSetTotalLength()) { oprot.writeI64(struct.totalLength); } }
public void write(org.apache.thrift.protocol.TProtocol oprot, BlobChunk struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.chunk != null) { oprot.writeFieldBegin(CHUNK_FIELD_DESC); oprot.writeBinary(struct.chunk); oprot.writeFieldEnd(); } oprot.writeFieldBegin(LAST_FIELD_DESC); oprot.writeBool(struct.last); oprot.writeFieldEnd(); if (struct.isSetLobId()) { oprot.writeFieldBegin(LOB_ID_FIELD_DESC); oprot.writeI32(struct.lobId); oprot.writeFieldEnd(); } if (struct.isSetOffset()) { oprot.writeFieldBegin(OFFSET_FIELD_DESC); oprot.writeI64(struct.offset); oprot.writeFieldEnd(); } if (struct.isSetTotalLength()) { oprot.writeFieldBegin(TOTAL_LENGTH_FIELD_DESC); oprot.writeI64(struct.totalLength); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); }
public static byte[] getBlobAsBytes(BlobChunk blob, LobService lobService) throws SQLException { if (blob.last) { return blob.getChunk(); final long totalLength = blob.getTotalLength(); if (totalLength <= 0) { throw ThriftExceptionUtil.newSQLException( Long.toString(Integer.MAX_VALUE)); if (!blob.isSetLobId()) { throw ThriftExceptionUtil.newSQLException( SQLState.LOB_LOCATOR_INVALID, new RuntimeException("missing LOB id")); byte[] chunk = blob.getChunk(); int chunkSize = chunk.length; System.arraycopy(chunk, 0, fullBytes, 0, chunkSize); offset += chunkSize; blob = lobService.getBlobChunk(lobId, offset, chunkSize, true); chunk = blob.getChunk(); chunkSize = chunk.length; System.arraycopy(chunk, 0, fullBytes, offset, chunkSize);
ClientBlob(BlobChunk firstChunk, ClientService service, HostConnection source) throws SQLException { super(service, firstChunk.last ? gfxdConstants.INVALID_ID : firstChunk.lobId, source); this.baseChunkSize = firstChunk.chunk.remaining(); this.currentChunk = firstChunk; if (firstChunk.isSetTotalLength()) { this.length = firstChunk.getTotalLength(); } else if (firstChunk.last) { this.length = this.baseChunkSize; } else { throw ThriftExceptionUtil.newSQLException( SQLState.BLOB_NONPOSITIVE_LENGTH, null, 0); } }
public final BlobChunk getBlobChunk(int index, boolean clearFinalizer) { final int lobIndex = (-this.positionMap[index]) - 1; final BlobChunk chunk = (BlobChunk)this.nonPrimitives[lobIndex]; if (clearFinalizer && chunk != null && chunk.isSetLobId()) { final FinalizeObject finalizer = (FinalizeObject)this.nonPrimitives[lobIndex + 1]; if (finalizer != null) { finalizer.clearAll(); this.nonPrimitives[lobIndex + 1] = null; } } return chunk; }
public BlobChunk setChunk(byte[] chunk) { setChunk(chunk == null ? (ByteBuffer)null : ByteBuffer.wrap(chunk)); return this; }
public BlobChunk deepCopy() { return new BlobChunk(this); }
int lobId; Blob blob; if (chunk.isSetLobId()) { lobId = chunk.lobId; Object lob = conn.getLOBMapping(lobId); if (chunk.isSetOffset()) { offset += chunk.offset; blob.setBytes(offset, chunk.getChunk()); return lobId; } catch (Throwable t) {
sb.append(this.last); first = false; if (isSetLobId()) { if (!first) sb.append(", "); sb.append("lobId:"); first = false; if (isSetOffset()) { if (!first) sb.append(", "); sb.append("offset:"); first = false; if (isSetTotalLength()) { if (!first) sb.append(", "); sb.append("totalLength:");
lobIndex = (-positionMap[index]) - 1; BlobChunk chunk = (BlobChunk)nonPrimitives[lobIndex]; if (chunk != null && chunk.isSetLobId()) { if (lobIndices == null) { lobIndices = new TIntArrayList(4);
public byte[] getChunk() { setChunk(org.apache.thrift.TBaseHelper.rightSize(chunk)); return chunk == null ? null : chunk.array(); }
this.blob_val = new BlobChunk(other.blob_val);
Long.toString(length), Long.toString(Integer.MAX_VALUE)); BlobChunk chunk = new BlobChunk().setOffset(0).setTotalLength(length); final int chunkSize; if (attrs != null && attrs.isSetLobChunkSize()) { chunk.setChunk(blob.getBytes(1, chunkSize)).setLast(false); lobId = connHolder.getConnection().addLOBMapping(blob); chunk.setLobId(lobId); chunk.setChunk(blob.getBytes(1, (int)length)).setLast(true);