public BlobChunk deepCopy() { return new BlobChunk(this); }
@Override public void clear() { free(); this.chunk = null; setLastIsSet(false); this.last = false; setLobIdIsSet(false); this.lobId = 0; setOffsetIsSet(false); this.offset = 0; setTotalLengthIsSet(false); this.totalLength = 0; }
public Object getFieldValue(_Fields field) { switch (field) { case CHUNK: return getChunk(); case LAST: return isLast(); case LOB_ID: return getLobId(); case OFFSET: return getOffset(); case TOTAL_LENGTH: return getTotalLength(); } throw new IllegalStateException(); }
@Override public void write(org.apache.thrift.protocol.TProtocol oprot, BlobChunk struct) throws org.apache.thrift.TException { struct.validate(); final ByteBuffer chunk = struct.getBufferForWrite(oprot); try { writeData(oprot, struct, chunk); } finally { // free the blob once written struct.free(); } }
case CHUNK: if (value == null) { unsetChunk(); } else { setChunk((ByteBuffer)value); unsetLast(); } else { setLast((Boolean)value); unsetLobId(); } else { setLobId((Long)value); unsetOffset(); } else { setOffset((Long)value); unsetTotalLength(); } else { setTotalLength((Long)value);
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.setLast(false); .getLocator(); chunk.setLobId(lobId); } else { chunk = getAsLastChunk(blob, (int)length);
/** 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(); }
long 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()); chunk.free(); return lobId; } catch (Throwable t) {
boolean this_present_lobId = true && this.isSetLobId(); boolean that_present_lobId = true && that.isSetLobId(); if (this_present_lobId || that_present_lobId) { if (!(this_present_lobId && that_present_lobId)) boolean this_present_offset = true && this.isSetOffset(); boolean that_present_offset = true && that.isSetOffset(); if (this_present_offset || that_present_offset) { if (!(this_present_offset && that_present_offset)) boolean this_present_totalLength = true && this.isSetTotalLength(); boolean that_present_totalLength = true && that.isSetTotalLength(); if (this_present_totalLength || that_present_totalLength) { if (!(this_present_totalLength && that_present_totalLength))
private void freeChunk() { final BlobChunk chunk = this.currentChunk; if (chunk != null) { chunk.free(); this.currentChunk = null; } }
ClientBlob(BlobChunk firstChunk, ClientService service, HostConnection source, boolean freeForStream) throws SQLException { super(service, firstChunk.last ? snappydataConstants.INVALID_ID : firstChunk.lobId, source); this.baseChunkSize = firstChunk.size(); this.currentChunk = firstChunk; this.freeForStream = freeForStream; long length = -1; if (firstChunk.isSetTotalLength()) { length = firstChunk.getTotalLength(); } else if (firstChunk.last) { length = this.baseChunkSize; } checkLength(length); this.length = (int)length; }
Long.toString(length), Long.toString(Integer.MAX_VALUE)); BlobChunk chunk = new BlobChunk().setLobId(lobId).setOffset(offset); if (chunkSize > 0 && chunkSize < length) { chunk.chunk = ByteBuffer.wrap(blob.getBytes(offset + 1, chunkSize)); chunk.setLast(false); } else { chunk = getAsLastChunk(blob, (int)length);
lastComparison = Boolean.valueOf(isSetLast()).compareTo(other.isSetLast()); if (lastComparison != 0) { return lastComparison; if (isSetLast()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.last, other.last); if (lastComparison != 0) { lastComparison = Boolean.valueOf(isSetLobId()).compareTo(other.isSetLobId()); if (lastComparison != 0) { return lastComparison; if (isSetLobId()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.lobId, other.lobId); if (lastComparison != 0) { lastComparison = Boolean.valueOf(isSetOffset()).compareTo(other.isSetOffset()); if (lastComparison != 0) { return lastComparison; if (isSetOffset()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.offset, other.offset); if (lastComparison != 0) { lastComparison = Boolean.valueOf(isSetTotalLength()).compareTo(other.isSetTotalLength()); if (lastComparison != 0) { return lastComparison; if (isSetTotalLength()) {
if (chunk.isSetLobId()) { Object lob = conn.getLOBMapping(chunk.lobId); if (lob instanceof Blob) { if (chunk.isSetOffset()) { offset += chunk.offset; blob.setBytes(offset, chunk.getChunk()); chunk.free(); pstmt.setBlob(paramPosition, blob);
@Override public int hashCode() { List<Object> list = new ArrayList<Object>(); boolean present_chunk = chunk != null; list.add(present_chunk); if (present_chunk) list.add(chunk); boolean present_last = true; list.add(present_last); if (present_last) list.add(last); boolean present_lobId = true && (isSetLobId()); list.add(present_lobId); if (present_lobId) list.add(lobId); boolean present_offset = true && (isSetOffset()); list.add(present_offset); if (present_offset) list.add(offset); boolean present_totalLength = true && (isSetTotalLength()); list.add(present_totalLength); if (present_totalLength) list.add(totalLength); int hash = list.hashCode(); return hash; }
public void setChunkIsSet(boolean value) { if (!value) { free(); this.chunk = null; } }
if (!isSetChunk()) { sb.append("null"); } else { 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:");
private void writeData(org.apache.thrift.protocol.TProtocol prot, BlobChunk struct, ByteBuffer buffer) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; oprot.writeBinary(buffer); 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.writeI64(struct.lobId); } if (struct.isSetOffset()) { oprot.writeI64(struct.offset); } if (struct.isSetTotalLength()) { oprot.writeI64(struct.totalLength); } }