Refine search
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
@Override Object convert(com.google.datastore.v1.Entity entityPb) { if (entityPb.getPropertiesMap().isEmpty()) { if (!entityPb.hasKey()) { return null; } return Key.fromPb(entityPb.getKey()); } return ProjectionEntity.fromPb(entityPb); } };
logger.debug("Read entity: " + entity.toString()); Map<String, Value> properties = entity.getProperties(); Set<String> propertiesToReturn = (fields == null ? properties.keySet() : fields);
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.datastore.v1.Entity)) { return super.equals(obj); } com.google.datastore.v1.Entity other = (com.google.datastore.v1.Entity) obj; boolean result = true; result = result && (hasKey() == other.hasKey()); if (hasKey()) { result = result && getKey().equals(other.getKey()); } result = result && internalGetProperties().equals(other.internalGetProperties()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (key_ != null) { output.writeMessage(1, getKey()); } com.google.protobuf.GeneratedMessageV3.serializeStringMapTo( output, internalGetProperties(), PropertiesDefaultEntryHolder.defaultEntry, 3); unknownFields.writeTo(output); }
if (updateBuilder_ == null) { if (operationCase_ == 5 && operation_ != com.google.datastore.v1.Entity.getDefaultInstance()) { operation_ = com.google.datastore.v1.Entity.newBuilder((com.google.datastore.v1.Entity) operation_) .mergeFrom(value) .buildPartial(); } else { operation_ = value;
/** * * * <pre> * The entity's key. * An entity must have a key, unless otherwise documented (for example, * an entity in `Value.entity_value` may have no key). * An entity's kind is its key path's last element's kind, * or null if it has no key. * </pre> * * <code>.google.datastore.v1.Key key = 1;</code> */ public com.google.datastore.v1.KeyOrBuilder getKeyOrBuilder() { return getKey(); }
@ProcessElement public void processElement(ProcessContext c) throws InvalidProtocolBufferException { String entityJson = c.element(); Entity.Builder entityBuilder = Entity.newBuilder(); entityJsonParser.merge(entityJson, entityBuilder); // Build entity who's key has an empty project Id. // This allows DatastoreIO to handle what project Entities are loaded into Key k = entityBuilder.build().getKey(); entityBuilder.setKey(Key.newBuilder() .addAllPath(k.getPathList()) .setPartitionId(PartitionId.newBuilder() .setProjectId("") .setNamespaceId(k.getPartitionId().getNamespaceId()))); c.output(entityBuilder.build()); } }
public Builder mergeFrom(com.google.datastore.v1.Entity other) { if (other == com.google.datastore.v1.Entity.getDefaultInstance()) return this; if (other.hasKey()) { mergeKey(other.getKey()); } internalGetMutableProperties().mergeFrom(other.internalGetProperties()); this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
private Builder(final com.google.datastore.v1.Entity entity) { this.entity = com.google.datastore.v1.Entity.newBuilder(entity); this.properties = entity.getProperties().entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, e -> Value.builder(e.getValue()).build())); }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (hasKey()) { hash = (37 * hash) + KEY_FIELD_NUMBER; hash = (53 * hash) + getKey().hashCode(); } if (!internalGetProperties().getMap().isEmpty()) { hash = (37 * hash) + PROPERTIES_FIELD_NUMBER; hash = (53 * hash) + internalGetProperties().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
Entity.Builder entityBuilder = Entity.newBuilder(); entityBuilder.setKey(datastoreKey); for (Entry<String, ByteIterator> val : values.entrySet()) { entityBuilder.getMutableProperties() .put(val.getKey(), Value.newBuilder() .setExcludeFromIndexes(skipIndex).build()); Entity entity = entityBuilder.build(); logger.debug("entity built as: " + entity.toString());
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptorForType().hashCode(); if (hasKey()) { hash = (37 * hash) + KEY_FIELD_NUMBER; hash = (53 * hash) + getKey().hashCode(); } if (!internalGetProperties().getMap().isEmpty()) { hash = (37 * hash) + PROPERTIES_FIELD_NUMBER; hash = (53 * hash) + internalGetProperties().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (hasEntity()) { hash = (37 * hash) + ENTITY_FIELD_NUMBER; hash = (53 * hash) + getEntity().hashCode(); } hash = (37 * hash) + VERSION_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getVersion()); hash = (37 * hash) + CURSOR_FIELD_NUMBER; hash = (53 * hash) + getCursor().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
/** Use {@link #getPropertiesMap()} instead. */ @java.lang.Deprecated public java.util.Map<java.lang.String, com.google.datastore.v1.Value> getProperties() { return getPropertiesMap(); } /**
/** * Return a map of properties to their values for this entity. * * @return a map of property values. */ public Map<String, Value> getProperties() { if (properties == null) { properties = entity .getProperties() .entrySet() .stream() .collect(Collectors.toMap(Map.Entry::getKey, e -> Value.builder(e.getValue()).build())); } return properties; }
@ProcessElement public void processElement(ProcessContext c) throws IOException { Entity entity = c.element(); if (entity.hasKey()) { c.output(entity); } else { ErrorMessage errorMessage = ErrorMessage.newBuilder() .setMessage("Datastore Entity Without Key") .setData(entityJsonPrinter.print(entity)) .build(); c.output(failureTag(), errorMessage.toJson()); } } })
if (insertBuilder_ == null) { if (operationCase_ == 4 && operation_ != com.google.datastore.v1.Entity.getDefaultInstance()) { operation_ = com.google.datastore.v1.Entity.newBuilder((com.google.datastore.v1.Entity) operation_) .mergeFrom(value) .buildPartial(); } else { operation_ = value;
@Override Key convert(com.google.datastore.v1.Entity entityPb) { return Key.fromPb(entityPb.getKey()); } };
/** Test that entities with valid keys are transformed to delete mutations. */ @Test public void testDeleteEntities() throws Exception { Key key = makeKey("bird", "finch").build(); Entity entity = Entity.newBuilder().setKey(key).build(); DeleteEntityFn deleteEntityFn = new DeleteEntityFn(); Mutation exceptedMutation = makeDelete(entity.getKey()).build(); assertEquals(deleteEntityFn.apply(entity), exceptedMutation); }