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

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


    }

    @Override
    public Key getPropertyValue(PropertyValue propertyValue) {

      Reference reference = new Reference();
      ReferenceValue refValue = propertyValue.getReferenceValue();
      reference.setApp(refValue.getApp());
      if (refValue.hasNameSpace()) {
        reference.setNameSpace(refValue.getNameSpace());
      }
      Path path = new Path();
      for (ReferenceValuePathElement element : refValue.pathElements()) {
        Element newElement = new Element();
        newElement.setType(element.getType());
        if (element.hasName()) {
          newElement.setName(element.getName());
        }
        if (element.hasId()) {
          newElement.setId(element.getId());
        }
        path.addElement(newElement);
      }
      reference.setPath(path);

      return KeyTranslator.createFromPb(reference);
    }
View Full Code Here


    int encodedReqSize = baseEncodedReqSize;
    for (Key key : keys) {
      if (!key.isComplete()) {
        throw new IllegalArgumentException(key + " is incomplete.");
      }
      Reference ref = KeyTranslator.convertToPb(key);

      int encodedKeySize = Protocol.stringSize(ref.encodingSize()) + 1;
      if (getDatastoreServiceConfig().exceedsReadLimits(
          req.keySize() + 1, encodedReqSize + encodedKeySize)) {
        futures.add(makeAsyncCall(apiConfig, "Get", req, new GetResponse()));
        encodedReqSize = baseEncodedReqSize;
        req = baseReq.clone();
View Full Code Here

    DeleteRequest req = baseReq.clone();
    for (Key key : keys) {
      if (!key.isComplete()) {
        throw new IllegalArgumentException(key + " is incomplete.");
      }
      Reference ref = KeyTranslator.convertToPb(key);

      int encodedKeySize = Protocol.stringSize(ref.encodingSize()) + 1;
      if (getDatastoreServiceConfig().exceedsWriteLimits(
          req.keySize() + 1, encodedReqSize + encodedKeySize)) {
        futures.add(makeAsyncCall(apiConfig, "Delete", req, new DeleteResponse()));
        encodedReqSize = baseEncodedReqSize;
        req = baseReq.clone();
View Full Code Here

    if (num > 1000000000) {
      throw new IllegalArgumentException("num must be < 1 billion");
    }

    final AppIdNamespace appIdNamespace = getDatastoreServiceConfig().getAppIdNamespace();
    Reference allocateIdsRef = buildAllocateIdsRef(parent, kind, appIdNamespace);
    AllocateIdsRequest req =
        new AllocateIdsRequest().setSize(num).setModelKey(allocateIdsRef);
    AllocateIdsResponse resp = new AllocateIdsResponse();
    Future<AllocateIdsResponse> future = makeAsyncCall(apiConfig, "AllocateIds", req, resp);
    return new FutureWrapper<AllocateIdsResponse, KeyRange>(future) {
View Full Code Here

    private int calculateCosts(DatastorePb.DeleteRequest req) {
      Iterator<Reference> ref = req.keyIterator();
      int cost = 0;
      while (ref.hasNext()) {
        cost += 25;
        Reference reff = ref.next();
        PropertyDescriptor[] prd = reff.getPropertyDescriptors();
        /*
         * for (PropertyDescriptor prde : prd) { if
         * (!Blob.class.isAssignableFrom(prde.getPropertyType()) &&
         * !Text.class.isAssignableFrom(prde .getPropertyType())) { cost
         * +=20; } }
View Full Code Here

     * @throws Exception
     */
    @Test
    public void refereceToKeyForId() throws Exception {
        Key key = KeyFactory.createKey("Hoge", 1);
        Reference reference = new Reference();
        Path path = new Path();
        reference.setPath(path);
        Element element = path.addElement();
        element.setType("Hoge");
        element.setId(1);
        assertThat(DatastoreUtil.referenceToKey(reference), is(key));
    }
View Full Code Here

     * @throws Exception
     */
    @Test
    public void refereceToKeyForMinusId() throws Exception {
        Key key = KeyFactory.createKey("Hoge", -1);
        Reference reference = new Reference();
        Path path = new Path();
        reference.setPath(path);
        Element element = path.addElement();
        element.setType("Hoge");
        element.setId(-1);
        assertThat(DatastoreUtil.referenceToKey(reference), is(key));
    }
View Full Code Here

     * @throws Exception
     */
    @Test
    public void refereceToKeyForName() throws Exception {
        Key key = KeyFactory.createKey("Hoge", "aaa");
        Reference reference = new Reference();
        Path path = new Path();
        reference.setPath(path);
        Element element = path.addElement();
        element.setType("Hoge");
        element.setName("aaa");
        assertThat(DatastoreUtil.referenceToKey(reference), is(key));
    }
View Full Code Here

     */
    @Test
    public void refereceToKeyForParent() throws Exception {
        Key parentKey = KeyFactory.createKey("Parent", 1);
        Key childKey = KeyFactory.createKey(parentKey, "Child", 1);
        Reference reference = new Reference();
        Path path = new Path();
        reference.setPath(path);
        Element element = path.addElement();
        element.setType("Parent");
        element.setId(1);
        element = path.addElement();
        element.setType("Child");
View Full Code Here

    Map<Key, Entity> newMap = new HashMap<Key, Entity>();
    int size = requestPb.entitySize();
    List<EntityProto> entitys = requestPb.entitys();
    for (int i = 0; i < size; i++) {
      EntityProto proto = entitys.get(i);
      Reference reference = responsePb.getKey(i);
      Key key = PbKeyUtil.toKey(reference);
      Entity entity = new Entity();
      entity.setEntity(proto);
      entity.setKey(reference);
      newMap.put(key, entity);
View Full Code Here

TOP

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

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.