Package com.google.storage.onestore.v3.OnestoreEntity

Examples of com.google.storage.onestore.v3.OnestoreEntity.PropertyValue


  }

  public static EntityProto convertToPb(Entity entity) {
    Reference reference = KeyTranslator.convertToPb(entity.getKey());

    EntityProto proto = new EntityProto();
    proto.setKey(reference);

    Path entityGroup = proto.getMutableEntityGroup();
    Key key = entity.getKey();
    if (key.isComplete()) {
      entityGroup.addElement(reference.getPath().elements().get(0));
    }
View Full Code Here


    }

    @Override
    public void setPropertyValue(PropertyValue propertyValue, Object value) {
      EmbeddedEntity structProp = (EmbeddedEntity) value;
      EntityProto proto = new EntityProto();
      if (structProp.getKey() != null) {
        proto.setKey(KeyTranslator.convertToPb(structProp.getKey()));
      }
      addPropertiesToPb(structProp.getPropertyMap(), proto);
      propertyValue.setStringValueAsBytes(proto.toByteArray());
    }
View Full Code Here

      propertyValue.setStringValueAsBytes(proto.toByteArray());
    }

    @Override
    public EmbeddedEntity getPropertyValue(PropertyValue propertyValue) {
      EntityProto proto = new EntityProto();
      proto.mergeFrom(propertyValue.getStringValueAsBytes());
      EmbeddedEntity result = new EmbeddedEntity();
      if (proto.hasKey() && !proto.getKey().getApp().isEmpty()) {
        result.setKey(KeyTranslator.createFromPb(proto.getKey()));
      }
      extractPropertiesFromPb(proto, result.getPropertyMap());
      return result;
    }
View Full Code Here

    final int baseEncodedReqSize = baseReq.encodingSize();
    final List<Future<PutResponse>> futures = new ArrayList<Future<PutResponse>>();
    int encodedReqSize = baseEncodedReqSize;
    PutRequest req = baseReq.clone();
    for (Entity entity : entities) {
      EntityProto proto = EntityTranslator.convertToPb(entity);
      int encodedEntitySize = Protocol.stringSize(proto.encodingSize()) + 1;
      if (getDatastoreServiceConfig().exceedsWriteLimits(
          req.entitySize() + 1, encodedReqSize + encodedEntitySize)) {
        futures.add(makeAsyncCall(apiConfig, "Put", req, new PutResponse()));
        encodedReqSize = baseEncodedReqSize;
        req = baseReq.clone();
View Full Code Here

    private int calculateCosts(DatastorePb.PutRequest res) {
      Iterator<EntityProto> i = res.entityIterator();
      int cost = 0;
      while (i.hasNext()) {
        cost += 25;
        EntityProto ep = i.next();
        Iterator<Property> pi = ep.propertyIterator();
        while (pi.hasNext()) {
          Property p = pi.next();
          Meaning m = p.getMeaningEnum();
          if (m != null) {
            if (m.compareTo(Meaning.BLOB) != 0
View Full Code Here

    private int calculateCosts(DatastorePb.QueryResult res) {
      Iterator<EntityProto> i = res.resultIterator();
      int cost = 0;
      while (i.hasNext()) {
        cost += 25;
        EntityProto ep = i.next();
        Iterator<Property> pi = ep.propertyIterator();
        while (pi.hasNext()) {
          Property p = pi.next();
          Meaning m = p.getMeaningEnum();
          if (m != null) {
            if (m.compareTo(Meaning.BLOB) != 0
View Full Code Here

  public static Entity read(DataInputStream stream) throws IOException {
    int readInt = stream.readInt();
    byte[] arr = new byte[readInt];
    stream.readFully(arr);
    EntityProto pr = new EntityProto();
    pr.mergeFrom(arr);
    return EntityTranslator.createFromPb(pr);
  }
View Full Code Here

  public static Entity read(DataInputStream stream) throws IOException {
    int readInt = stream.readInt();
    byte[] arr = new byte[readInt];
    stream.readFully(arr);
    EntityProto pr = new EntityProto();
    pr.mergeFrom(arr);
    return EntityTranslator.createFromPb(pr);
  }
View Full Code Here

            throws NullPointerException {
        if (entity == null) {
            throw new NullPointerException(
                "The entity parameter must not be null.");
        }
        EntityProto pb = EntityTranslator.convertToPb(entity);
        byte[] buf = new byte[pb.encodingSize()];
        pb.outputTo(buf, 0);
        return buf;
    }
View Full Code Here

            throws NullPointerException {
        if (bytes == null) {
            throw new NullPointerException(
                "The bytes parameter must not be null.");
        }
        EntityProto pb = new EntityProto();
        pb.mergeFrom(bytes);
        return EntityTranslator.createFromPb(pb);
    }
View Full Code Here

TOP

Related Classes of com.google.storage.onestore.v3.OnestoreEntity.PropertyValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.