public Builder mergeFrom(com.google.spanner.v1.Transaction other) { if (other == com.google.spanner.v1.Transaction.getDefaultInstance()) return this; if (other.getId() != com.google.protobuf.ByteString.EMPTY) { setId(other.getId()); } if (other.hasReadTimestamp()) { mergeReadTimestamp(other.getReadTimestamp()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
@java.lang.Override public com.google.spanner.v1.Transaction buildPartial() { com.google.spanner.v1.Transaction result = new com.google.spanner.v1.Transaction(this); result.id_ = id_; if (readTimestampBuilder_ == null) { result.readTimestamp_ = readTimestamp_; } else { result.readTimestamp_ = readTimestampBuilder_.build(); } onBuilt(); return result; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.spanner.v1.Transaction)) { return super.equals(obj); } com.google.spanner.v1.Transaction other = (com.google.spanner.v1.Transaction) obj; boolean result = true; result = result && getId().equals(other.getId()); result = result && (hasReadTimestamp() == other.hasReadTimestamp()); if (hasReadTimestamp()) { result = result && getReadTimestamp().equals(other.getReadTimestamp()); } result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + ID_FIELD_NUMBER; hash = (53 * hash) + getId().hashCode(); if (hasReadTimestamp()) { hash = (37 * hash) + READ_TIMESTAMP_FIELD_NUMBER; hash = (53 * hash) + getReadTimestamp().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public com.google.spanner.v1.Transaction getDefaultInstanceForType() { return com.google.spanner.v1.Transaction.getDefaultInstance(); }
/** * * * <pre> * `id` may be used to identify the transaction in subsequent * [Read][google.spanner.v1.Spanner.Read], * [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], * [Commit][google.spanner.v1.Spanner.Commit], or * [Rollback][google.spanner.v1.Spanner.Rollback] calls. * Single-use read-only transactions do not have IDs, because * single-use transactions do not support multiple requests. * </pre> * * <code>bytes id = 1;</code> */ public Builder clearId() { id_ = getDefaultInstance().getId(); onChanged(); return this; }
static Map<String, AttributeValue> getTransactionAnnotations(Transaction t) { return ImmutableMap.of( "Id", AttributeValue.stringAttributeValue(t.getId().toStringUtf8()), "Timestamp", AttributeValue.stringAttributeValue(Timestamp.fromProto(t.getReadTimestamp()).toString())); }
@Override public void onTransactionMetadata(Transaction transaction) { synchronized (lock) { if (!transaction.hasReadTimestamp()) { throw newSpannerException( ErrorCode.INTERNAL, "Missing expected transaction.read_timestamp metadata field"); } try { timestamp = Timestamp.fromProto(transaction.getReadTimestamp()); } catch (IllegalArgumentException e) { throw newSpannerException( ErrorCode.INTERNAL, "Bad value in transaction.read_timestamp metadata field", e); } } } }
ByteString initTransaction() { final BeginTransactionRequest request = BeginTransactionRequest.newBuilder() .setSession(session.getName()) .setOptions( TransactionOptions.newBuilder() .setPartitionedDml(TransactionOptions.PartitionedDml.getDefaultInstance())) .build(); Transaction txn = runWithRetries( new Callable<Transaction>() { @Override public Transaction call() throws Exception { return rpc.beginTransaction(request, session.options); } }); if (txn.getId().isEmpty()) { throw SpannerExceptionFactory.newSpannerException( ErrorCode.INTERNAL, "Failed to init transaction, missing transaction id\n" + session.getName()); } return txn.getId(); }
/** * * * <pre> * For snapshot read-only transactions, the read timestamp chosen * for the transaction. Not returned by default: see * [TransactionOptions.ReadOnly.return_read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.return_read_timestamp]. * A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. * Example: `"2014-10-02T15:01:23.045123456Z"`. * </pre> * * <code>.google.protobuf.Timestamp read_timestamp = 2;</code> */ public com.google.protobuf.TimestampOrBuilder getReadTimestampOrBuilder() { return getReadTimestamp(); }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (getPartitionsCount() > 0) { hash = (37 * hash) + PARTITIONS_FIELD_NUMBER; hash = (53 * hash) + getPartitionsList().hashCode(); } if (hasTransaction()) { hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; hash = (53 * hash) + getTransaction().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.spanner.v1.PartitionResponse)) { return super.equals(obj); } com.google.spanner.v1.PartitionResponse other = (com.google.spanner.v1.PartitionResponse) obj; boolean result = true; result = result && getPartitionsList().equals(other.getPartitionsList()); result = result && (hasTransaction() == other.hasTransaction()); if (hasTransaction()) { result = result && getTransaction().equals(other.getTransaction()); } result = result && unknownFields.equals(other.unknownFields); return result; }
if (!transaction.hasReadTimestamp()) { throw SpannerExceptionFactory.newSpannerException( ErrorCode.INTERNAL, "Missing expected transaction.read_timestamp metadata field"); if (transaction.getId().isEmpty()) { throw SpannerExceptionFactory.newSpannerException( ErrorCode.INTERNAL, "Missing expected transaction.id metadata field"); timestamp = Timestamp.fromProto(transaction.getReadTimestamp()); } catch (IllegalArgumentException e) { throw SpannerExceptionFactory.newSpannerException( ErrorCode.INTERNAL, "Bad value in transaction.read_timestamp metadata field", e); transactionId = transaction.getId(); span.addAnnotation( "Transaction Creation Done", TraceUtil.getTransactionAnnotations(transaction));
/** * * * <pre> * If the read or SQL query began a transaction as a side-effect, the * information about the new transaction is yielded here. * </pre> * * <code>.google.spanner.v1.Transaction transaction = 2;</code> */ public com.google.spanner.v1.Transaction getTransaction() { return transaction_ == null ? com.google.spanner.v1.Transaction.getDefaultInstance() : transaction_; } /**
static Map<String, AttributeValue> getTransactionAnnotations(Transaction t) { return ImmutableMap.of( "Id", AttributeValue.stringAttributeValue(t.getId().toStringUtf8()), "Timestamp", AttributeValue.stringAttributeValue(Timestamp.fromProto(t.getReadTimestamp()).toString())); }
@Override public void onTransactionMetadata(Transaction transaction) { synchronized (lock) { if (!transaction.hasReadTimestamp()) { throw newSpannerException( ErrorCode.INTERNAL, "Missing expected transaction.read_timestamp metadata field"); } try { timestamp = Timestamp.fromProto(transaction.getReadTimestamp()); } catch (IllegalArgumentException e) { throw newSpannerException( ErrorCode.INTERNAL, "Bad value in transaction.read_timestamp metadata field", e); } } } }
ByteString beginTransaction() { Span span = tracer.spanBuilder(BEGIN_TRANSACTION).startSpan(); try (Scope s = tracer.withSpan(span)) { final BeginTransactionRequest request = BeginTransactionRequest.newBuilder() .setSession(name) .setOptions( TransactionOptions.newBuilder() .setReadWrite(TransactionOptions.ReadWrite.getDefaultInstance())) .build(); Transaction txn = runWithRetries( new Callable<Transaction>() { @Override public Transaction call() throws Exception { return gapicRpc.beginTransaction(request, options); } }); if (txn.getId().isEmpty()) { throw newSpannerException(ErrorCode.INTERNAL, "Missing id in transaction\n" + getName()); } span.end(); return txn.getId(); } catch (RuntimeException e) { TraceUtil.endSpanWithFailure(span, e); throw e; } }
@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (!id_.isEmpty()) { output.writeBytes(1, id_); } if (readTimestamp_ != null) { output.writeMessage(2, getReadTimestamp()); } unknownFields.writeTo(output); }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (hasRowType()) { hash = (37 * hash) + ROW_TYPE_FIELD_NUMBER; hash = (53 * hash) + getRowType().hashCode(); } if (hasTransaction()) { hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; hash = (53 * hash) + getTransaction().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }