Package com.google.protobuf

Examples of com.google.protobuf.ByteString.toByteArray()


  public static SenseiResult convert(SenseiResultBPO.Result req)
  {
    try
    {
      ByteString value = req.getVal();
      byte[] raw = value.toByteArray();
      ByteArrayInputStream bais = new ByteArrayInputStream(raw);
      ObjectInputStream ois = new ObjectInputStream(bais);
      SenseiResult ret = (SenseiResult) ois.readObject();
      return ret;
    } catch (Exception e)
View Full Code Here


            out[i] = new RiakObject(vclock, bucket, key, resp.getContent(i));
        }

        boolean unchanged = resp.getUnchanged();

        return new FetchResponse(out, unchanged, vclock.toByteArray());
  }

  // /////////////////////
 
  /**
 
View Full Code Here

            out[i] = new RiakObject(vclock, bucket, key, resp.getContent(i));
        }

        boolean unchanged = resp.getUnchanged();

        return new FetchResponse(out, unchanged, vclock.toByteArray());
  }

  // /////////////////////

  public ByteString[] store(RiakObject[] values, RequestMeta meta)
View Full Code Here

        componentBuilder.addField(nameValueBuilder);
        entityBuilder.addComponent(componentBuilder.build());
        worldBuilder.addEntity(entityBuilder.build());
        EntityData.GlobalStore actual = persistAndRetrieve(worldBuilder.build());
        assertEquals(VALUE_NAME, actual.getEntity(0).getComponent(0).getField(0).getName());
        assertArrayEquals(bytes.toByteArray(), actual.getEntity(0).getComponent(0).getField(0).getValue().getBytes().toByteArray());
    }

    @Test
    public void testPersistEmptyPrefab() throws Exception {
        worldBuilder.addPrefab(prefabBuilder);
View Full Code Here

    }

    private Object[] decodeBaseProperties(DTClass cls) {
        ByteString s = baseline.getValueByName(String.valueOf(cls.getClassId()));
        return BaseInstanceDecoder.decode(
            s.toByteArray(),
            cls.getReceiveProps()
            );
    }

}
View Full Code Here

        protected Object valueFromRaw(Object raw) {
            ByteString bytes = (ByteString)raw;
            int precision = type.attribute(DecimalAttribute.PRECISION);
            int scale = type.attribute(DecimalAttribute.SCALE);
            StringBuilder sb = new StringBuilder();
            ConversionHelperBigDecimal.decodeToString(bytes.toByteArray(), 0, precision, scale, AkibanAppender.of(sb));
            return new BigDecimalWrapperImpl(sb.toString());
        }

        @Override
        protected Object rawFromValue(ValueSource value) {
View Full Code Here

  }

  /** Deserializes a protobuf to a HashedVersion POJO. */
  public static HashedVersion deserialize(ProtocolHashedVersion hashedVersion) {
    final ByteString historyHash = hashedVersion.getHistoryHash();
    return HashedVersion.of(hashedVersion.getVersion(), historyHash.toByteArray());
  }

  /** Serializes a HashedVersion POJO to a protobuf. */
  public static ProtocolHashedVersion serialize(HashedVersion hashedVersion) {
    return ProtocolHashedVersion.newBuilder().setVersion(hashedVersion.getVersion()).
View Full Code Here

    } else if (fieldDescriptor.getType() == FieldDescriptor.Type.BOOL && fieldValue != null) {
      Boolean boolValue = (Boolean)fieldValue;
      return new Integer(boolValue ? 1 : 0);
    } else if (fieldDescriptor.getType() == FieldDescriptor.Type.BYTES && fieldValue != null) {
      ByteString bsValue = (ByteString)fieldValue;
      return new DataByteArray(bsValue.toByteArray());
    }
    return fieldValue;
  }

  /**
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.