I am writing a module in my Google AppEngine project in Go for performance reasons but need to be able to read from some of the entities I have in datastore. I wrote out the
The solution by someone1 works great but I have many millions of entities and didn't want to have to re-put them all (to add the keep_keys=True to the LocalStructuredProperty).
So, I created a cut-down version of EntityProto which removes the dependency on the key & path etc... Simply replace pb.EntityProto with LocalEntityProto and the existing python-written entities should load OK (I'm using a PropertyLoadSaver for the nested struct).
Disclaimer: I'm only using this to read from Go - I haven't tried writing the same entities back to see if they still load in Python.
import pb "google.golang.org/appengine/internal/datastore"
import proto "github.com/golang/protobuf/proto"
type LocalEntityProto struct {
Kind *pb.EntityProto_Kind `protobuf:"varint,4,opt,name=kind,enum=appengine.EntityProto_Kind" json:"kind,omitempty"`
KindUri *string `protobuf:"bytes,5,opt,name=kind_uri" json:"kind_uri,omitempty"`
Property []*pb.Property `protobuf:"bytes,14,rep,name=property" json:"property,omitempty"`
RawProperty []*pb.Property `protobuf:"bytes,15,rep,name=raw_property" json:"raw_property,omitempty"`
Rank *int32 `protobuf:"varint,18,opt,name=rank" json:"rank,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *LocalEntityProto) Reset() { *m = LocalEntityProto{} }
func (m *LocalEntityProto) String() string { return proto.CompactTextString(m) }
func (*LocalEntityProto) ProtoMessage() {}
func (m *LocalEntityProto) GetKind() pb.EntityProto_Kind {
if m != nil && m.Kind != nil {
return *m.Kind
}
return pb.EntityProto_GD_CONTACT
}
func (m *LocalEntityProto) GetKindUri() string {
if m != nil && m.KindUri != nil {
return *m.KindUri
}
return ""
}
func (m *LocalEntityProto) GetProperty() []*pb.Property {
if m != nil {
return m.Property
}
return nil
}
func (m *LocalEntityProto) GetRawProperty() []*pb.Property {
if m != nil {
return m.RawProperty
}
return nil
}
func (m *LocalEntityProto) GetRank() int32 {
if m != nil && m.Rank != nil {
return *m.Rank
}
return 0
}