com.google.cloud.Timestamp.fromProto()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(251)

本文整理了Java中com.google.cloud.Timestamp.fromProto()方法的一些代码示例,展示了Timestamp.fromProto()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Timestamp.fromProto()方法的具体详情如下:
包路径:com.google.cloud.Timestamp
类名称:Timestamp
方法名:fromProto

Timestamp.fromProto介绍

[英]Creates an instance of Timestamp from com.google.protobuf.Timestamp.
[中]从com创建时间戳的实例。谷歌。protobuf。时间戳。

代码示例

代码示例来源:origin: googleapis/google-cloud-java

  1. @Override
  2. protected Timestamp getValue(com.google.datastore.v1.Value from) {
  3. return Timestamp.fromProto(from.getTimestampValue());
  4. }

代码示例来源:origin: googleapis/google-cloud-java

  1. static WriteResult fromProto(
  2. com.google.firestore.v1beta1.WriteResult writeResult,
  3. com.google.protobuf.Timestamp commitTime) {
  4. Timestamp timestamp =
  5. Timestamp.fromProto(writeResult.hasUpdateTime() ? writeResult.getUpdateTime() : commitTime);
  6. return new WriteResult(timestamp);
  7. }

代码示例来源:origin: googleapis/google-cloud-java

  1. static Map<String, AttributeValue> getTransactionAnnotations(Transaction t) {
  2. return ImmutableMap.of(
  3. "Id",
  4. AttributeValue.stringAttributeValue(t.getId().toStringUtf8()),
  5. "Timestamp",
  6. AttributeValue.stringAttributeValue(Timestamp.fromProto(t.getReadTimestamp()).toString()));
  7. }

代码示例来源:origin: googleapis/google-cloud-java

  1. static DocumentSnapshot fromDocument(
  2. FirestoreImpl firestore, Timestamp readTime, Document document) {
  3. return new DocumentSnapshot(
  4. firestore,
  5. new DocumentReference(firestore, ResourcePath.create(document.getName())),
  6. document.getFieldsMap(),
  7. readTime,
  8. Timestamp.fromProto(document.getUpdateTime()),
  9. Timestamp.fromProto(document.getCreateTime()));
  10. }

代码示例来源:origin: googleapis/google-cloud-java

  1. static QueryDocumentSnapshot fromDocument(
  2. FirestoreImpl firestore, Timestamp readTime, Document document) {
  3. return new QueryDocumentSnapshot(
  4. firestore,
  5. new DocumentReference(firestore, ResourcePath.create(document.getName())),
  6. document.getFieldsMap(),
  7. readTime,
  8. Timestamp.fromProto(document.getUpdateTime()),
  9. Timestamp.fromProto(document.getCreateTime()));
  10. }

代码示例来源:origin: googleapis/google-cloud-java

  1. @Override
  2. public void onTransactionMetadata(Transaction transaction) {
  3. synchronized (lock) {
  4. if (!transaction.hasReadTimestamp()) {
  5. throw newSpannerException(
  6. ErrorCode.INTERNAL, "Missing expected transaction.read_timestamp metadata field");
  7. }
  8. try {
  9. timestamp = Timestamp.fromProto(transaction.getReadTimestamp());
  10. } catch (IllegalArgumentException e) {
  11. throw newSpannerException(
  12. ErrorCode.INTERNAL, "Bad value in transaction.read_timestamp metadata field", e);
  13. }
  14. }
  15. }
  16. }

代码示例来源:origin: googleapis/google-cloud-java

  1. @Override
  2. public void onNext(RunQueryResponse response) {
  3. if (!firstResponse) {
  4. firstResponse = true;
  5. Tracing.getTracer().getCurrentSpan().addAnnotation("Firestore.Query: First response");
  6. }
  7. if (response.hasDocument()) {
  8. numDocuments++;
  9. if (numDocuments % 100 == 0) {
  10. Tracing.getTracer()
  11. .getCurrentSpan()
  12. .addAnnotation("Firestore.Query: Received 100 documents");
  13. }
  14. Document document = response.getDocument();
  15. QueryDocumentSnapshot documentSnapshot =
  16. QueryDocumentSnapshot.fromDocument(
  17. firestore, Timestamp.fromProto(response.getReadTime()), document);
  18. documentObserver.onNext(documentSnapshot);
  19. }
  20. if (readTime == null) {
  21. readTime = Timestamp.fromProto(response.getReadTime());
  22. }
  23. }

代码示例来源:origin: googleapis/google-cloud-java

  1. return v.getDoubleValue();
  2. case TIMESTAMP_VALUE:
  3. return Timestamp.fromProto(v.getTimestampValue());
  4. case STRING_VALUE:
  5. return v.getStringValue();

代码示例来源:origin: googleapis/google-cloud-java

  1. @Test
  2. public void fromProto() {
  3. com.google.protobuf.Timestamp proto =
  4. com.google.protobuf.Timestamp.newBuilder().setSeconds(1234).setNanos(567).build();
  5. Timestamp timestamp = Timestamp.fromProto(proto);
  6. assertThat(timestamp.getSeconds()).isEqualTo(1234);
  7. assertThat(timestamp.getNanos()).isEqualTo(567);
  8. }

代码示例来源:origin: googleapis/google-cloud-java

  1. /** Converts a Protobuf Precondition to its API counterpart. */
  2. private com.google.cloud.firestore.Precondition convertPrecondition(Precondition precondition) {
  3. switch (precondition.getConditionTypeCase()) {
  4. case EXISTS:
  5. return com.google.cloud.firestore.Precondition.exists(precondition.getExists());
  6. case UPDATE_TIME:
  7. return com.google.cloud.firestore.Precondition.updatedAt(
  8. Timestamp.fromProto(precondition.getUpdateTime()));
  9. default:
  10. return com.google.cloud.firestore.Precondition.NONE;
  11. }
  12. }

代码示例来源:origin: googleapis/google-cloud-java

  1. DocumentSnapshot.fromDocument(
  2. FirestoreImpl.this,
  3. Timestamp.fromProto(response.getReadTime()),
  4. response.getFound());
  5. break;
  6. FirestoreImpl.this,
  7. documentReference,
  8. Timestamp.fromProto(response.getReadTime()));
  9. break;
  10. default:

代码示例来源:origin: googleapis/google-cloud-java

  1. Timestamp readTime = Timestamp.fromProto(testSnapshot.getReadTime());
  2. documentSnapshots.add(
  3. QueryDocumentSnapshot.fromDocument(
  4. firestoreMock, Timestamp.fromProto(testSnapshot.getReadTime()), document));
  5. QueryDocumentSnapshot.fromDocument(
  6. firestoreMock,
  7. Timestamp.fromProto(testSnapshot.getReadTime()),
  8. documentChange.getDoc());
  9. DocumentChange.Type changeType = convertKind(documentChange.getKind());

代码示例来源:origin: googleapis/google-cloud-java

  1. ErrorCode.INTERNAL, "Missing commitTimestamp:\n" + session.getName());
  2. commitTimestamp = Timestamp.fromProto(commitResponse.getCommitTimestamp());
  3. opSpan.end();
  4. } catch (RuntimeException e) {

代码示例来源:origin: googleapis/google-cloud-java

  1. pushSnapshot(Timestamp.fromProto(change.getReadTime()), change.getResumeToken());

代码示例来源:origin: googleapis/google-cloud-java

  1. Timestamp t = Timestamp.fromProto(response.getCommitTimestamp());
  2. span.end();
  3. return t;

代码示例来源:origin: googleapis/google-cloud-java

  1. timestamp = Timestamp.fromProto(transaction.getReadTimestamp());
  2. } catch (IllegalArgumentException e) {
  3. throw SpannerExceptionFactory.newSpannerException(

代码示例来源:origin: com.google.cloud/google-cloud-firestore

  1. static WriteResult fromProto(
  2. com.google.firestore.v1beta1.WriteResult writeResult,
  3. com.google.protobuf.Timestamp commitTime) {
  4. Timestamp timestamp =
  5. Timestamp.fromProto(writeResult.hasUpdateTime() ? writeResult.getUpdateTime() : commitTime);
  6. return new WriteResult(timestamp);
  7. }

代码示例来源:origin: com.google.cloud/google-cloud-spanner

  1. static Map<String, AttributeValue> getTransactionAnnotations(Transaction t) {
  2. return ImmutableMap.of(
  3. "Id",
  4. AttributeValue.stringAttributeValue(t.getId().toStringUtf8()),
  5. "Timestamp",
  6. AttributeValue.stringAttributeValue(Timestamp.fromProto(t.getReadTimestamp()).toString()));
  7. }

代码示例来源:origin: com.google.cloud/google-cloud-firestore

  1. static DocumentSnapshot fromDocument(
  2. FirestoreImpl firestore, Timestamp readTime, Document document) {
  3. return new DocumentSnapshot(
  4. firestore,
  5. new DocumentReference(firestore, ResourcePath.create(document.getName())),
  6. document.getFieldsMap(),
  7. readTime,
  8. Timestamp.fromProto(document.getUpdateTime()),
  9. Timestamp.fromProto(document.getCreateTime()));
  10. }

代码示例来源:origin: com.google.cloud/google-cloud-firestore

  1. static QueryDocumentSnapshot fromDocument(
  2. FirestoreImpl firestore, Timestamp readTime, Document document) {
  3. return new QueryDocumentSnapshot(
  4. firestore,
  5. new DocumentReference(firestore, ResourcePath.create(document.getName())),
  6. document.getFieldsMap(),
  7. readTime,
  8. Timestamp.fromProto(document.getUpdateTime()),
  9. Timestamp.fromProto(document.getCreateTime()));
  10. }

相关文章