本文整理了Java中com.google.cloud.Timestamp.fromProto()
方法的一些代码示例,展示了Timestamp.fromProto()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Timestamp.fromProto()
方法的具体详情如下:
包路径:com.google.cloud.Timestamp
类名称:Timestamp
方法名:fromProto
[英]Creates an instance of Timestamp from com.google.protobuf.Timestamp.
[中]从com创建时间戳的实例。谷歌。protobuf。时间戳。
代码示例来源:origin: googleapis/google-cloud-java
@Override
protected Timestamp getValue(com.google.datastore.v1.Value from) {
return Timestamp.fromProto(from.getTimestampValue());
}
代码示例来源:origin: googleapis/google-cloud-java
static WriteResult fromProto(
com.google.firestore.v1beta1.WriteResult writeResult,
com.google.protobuf.Timestamp commitTime) {
Timestamp timestamp =
Timestamp.fromProto(writeResult.hasUpdateTime() ? writeResult.getUpdateTime() : commitTime);
return new WriteResult(timestamp);
}
代码示例来源:origin: googleapis/google-cloud-java
static Map<String, AttributeValue> getTransactionAnnotations(Transaction t) {
return ImmutableMap.of(
"Id",
AttributeValue.stringAttributeValue(t.getId().toStringUtf8()),
"Timestamp",
AttributeValue.stringAttributeValue(Timestamp.fromProto(t.getReadTimestamp()).toString()));
}
代码示例来源:origin: googleapis/google-cloud-java
static DocumentSnapshot fromDocument(
FirestoreImpl firestore, Timestamp readTime, Document document) {
return new DocumentSnapshot(
firestore,
new DocumentReference(firestore, ResourcePath.create(document.getName())),
document.getFieldsMap(),
readTime,
Timestamp.fromProto(document.getUpdateTime()),
Timestamp.fromProto(document.getCreateTime()));
}
代码示例来源:origin: googleapis/google-cloud-java
static QueryDocumentSnapshot fromDocument(
FirestoreImpl firestore, Timestamp readTime, Document document) {
return new QueryDocumentSnapshot(
firestore,
new DocumentReference(firestore, ResourcePath.create(document.getName())),
document.getFieldsMap(),
readTime,
Timestamp.fromProto(document.getUpdateTime()),
Timestamp.fromProto(document.getCreateTime()));
}
代码示例来源:origin: googleapis/google-cloud-java
@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);
}
}
}
}
代码示例来源:origin: googleapis/google-cloud-java
@Override
public void onNext(RunQueryResponse response) {
if (!firstResponse) {
firstResponse = true;
Tracing.getTracer().getCurrentSpan().addAnnotation("Firestore.Query: First response");
}
if (response.hasDocument()) {
numDocuments++;
if (numDocuments % 100 == 0) {
Tracing.getTracer()
.getCurrentSpan()
.addAnnotation("Firestore.Query: Received 100 documents");
}
Document document = response.getDocument();
QueryDocumentSnapshot documentSnapshot =
QueryDocumentSnapshot.fromDocument(
firestore, Timestamp.fromProto(response.getReadTime()), document);
documentObserver.onNext(documentSnapshot);
}
if (readTime == null) {
readTime = Timestamp.fromProto(response.getReadTime());
}
}
代码示例来源:origin: googleapis/google-cloud-java
return v.getDoubleValue();
case TIMESTAMP_VALUE:
return Timestamp.fromProto(v.getTimestampValue());
case STRING_VALUE:
return v.getStringValue();
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void fromProto() {
com.google.protobuf.Timestamp proto =
com.google.protobuf.Timestamp.newBuilder().setSeconds(1234).setNanos(567).build();
Timestamp timestamp = Timestamp.fromProto(proto);
assertThat(timestamp.getSeconds()).isEqualTo(1234);
assertThat(timestamp.getNanos()).isEqualTo(567);
}
代码示例来源:origin: googleapis/google-cloud-java
/** Converts a Protobuf Precondition to its API counterpart. */
private com.google.cloud.firestore.Precondition convertPrecondition(Precondition precondition) {
switch (precondition.getConditionTypeCase()) {
case EXISTS:
return com.google.cloud.firestore.Precondition.exists(precondition.getExists());
case UPDATE_TIME:
return com.google.cloud.firestore.Precondition.updatedAt(
Timestamp.fromProto(precondition.getUpdateTime()));
default:
return com.google.cloud.firestore.Precondition.NONE;
}
}
代码示例来源:origin: googleapis/google-cloud-java
DocumentSnapshot.fromDocument(
FirestoreImpl.this,
Timestamp.fromProto(response.getReadTime()),
response.getFound());
break;
FirestoreImpl.this,
documentReference,
Timestamp.fromProto(response.getReadTime()));
break;
default:
代码示例来源:origin: googleapis/google-cloud-java
Timestamp readTime = Timestamp.fromProto(testSnapshot.getReadTime());
documentSnapshots.add(
QueryDocumentSnapshot.fromDocument(
firestoreMock, Timestamp.fromProto(testSnapshot.getReadTime()), document));
QueryDocumentSnapshot.fromDocument(
firestoreMock,
Timestamp.fromProto(testSnapshot.getReadTime()),
documentChange.getDoc());
DocumentChange.Type changeType = convertKind(documentChange.getKind());
代码示例来源:origin: googleapis/google-cloud-java
ErrorCode.INTERNAL, "Missing commitTimestamp:\n" + session.getName());
commitTimestamp = Timestamp.fromProto(commitResponse.getCommitTimestamp());
opSpan.end();
} catch (RuntimeException e) {
代码示例来源:origin: googleapis/google-cloud-java
pushSnapshot(Timestamp.fromProto(change.getReadTime()), change.getResumeToken());
代码示例来源:origin: googleapis/google-cloud-java
Timestamp t = Timestamp.fromProto(response.getCommitTimestamp());
span.end();
return t;
代码示例来源:origin: googleapis/google-cloud-java
timestamp = Timestamp.fromProto(transaction.getReadTimestamp());
} catch (IllegalArgumentException e) {
throw SpannerExceptionFactory.newSpannerException(
代码示例来源:origin: com.google.cloud/google-cloud-firestore
static WriteResult fromProto(
com.google.firestore.v1beta1.WriteResult writeResult,
com.google.protobuf.Timestamp commitTime) {
Timestamp timestamp =
Timestamp.fromProto(writeResult.hasUpdateTime() ? writeResult.getUpdateTime() : commitTime);
return new WriteResult(timestamp);
}
代码示例来源:origin: com.google.cloud/google-cloud-spanner
static Map<String, AttributeValue> getTransactionAnnotations(Transaction t) {
return ImmutableMap.of(
"Id",
AttributeValue.stringAttributeValue(t.getId().toStringUtf8()),
"Timestamp",
AttributeValue.stringAttributeValue(Timestamp.fromProto(t.getReadTimestamp()).toString()));
}
代码示例来源:origin: com.google.cloud/google-cloud-firestore
static DocumentSnapshot fromDocument(
FirestoreImpl firestore, Timestamp readTime, Document document) {
return new DocumentSnapshot(
firestore,
new DocumentReference(firestore, ResourcePath.create(document.getName())),
document.getFieldsMap(),
readTime,
Timestamp.fromProto(document.getUpdateTime()),
Timestamp.fromProto(document.getCreateTime()));
}
代码示例来源:origin: com.google.cloud/google-cloud-firestore
static QueryDocumentSnapshot fromDocument(
FirestoreImpl firestore, Timestamp readTime, Document document) {
return new QueryDocumentSnapshot(
firestore,
new DocumentReference(firestore, ResourcePath.create(document.getName())),
document.getFieldsMap(),
readTime,
Timestamp.fromProto(document.getUpdateTime()),
Timestamp.fromProto(document.getCreateTime()));
}
内容来源于网络,如有侵权,请联系作者删除!