com.google.appengine.api.datastore.Blob.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中com.google.appengine.api.datastore.Blob.<init>()方法的一些代码示例,展示了Blob.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Blob.<init>()方法的具体详情如下:
包路径:com.google.appengine.api.datastore.Blob
类名称:Blob
方法名:<init>

Blob.<init>介绍

暂无

代码示例

代码示例来源:origin: org.vesalainen.dsql/dsql

@Override
public Object getCellEditorValue()
{
  byte[] bytes = dialog.getBytes();
  if (bytes != null)
  {
    return new Blob(bytes);
  }
  else
  {
    return null;
  }
}

代码示例来源:origin: bedatadriven/activityinfo

public static Blob appendString(Blob stringPool, String string) {
  if(stringPool == null) {
    return new Blob(newPool(string));
  } else {
    return new Blob(appendString(stringPool.getBytes(), string.getBytes(Charsets.UTF_8)));
  }
}

代码示例来源:origin: bedatadriven/activityinfo

/**
 * Zeros out the value at the given index. Unallocated values are assumed to be zero,
 * so if the array is only updated if it is already long enough to include the given index.
 *
 * @param values the value blob
 * @param index the index within the blob
 */
public static Blob updateToZero(Blob values, int index) {
  if(values == null) {
    return null;
  }
  byte[] bytes = values.getBytes();
  int pos = index * BYTES;
  if(pos < bytes.length) {
    bytes[pos] = 0;
    bytes[pos + 1] = 0;
  }
  return new Blob(bytes);
}

代码示例来源:origin: com.googlecode.cedar-common/objectify

@Override
public Object forDatastore(Object value, ConverterSaveContext ctx)
{
  if (!value.getClass().isArray())
    return null;
  if (ctx.inEmbeddedCollection())
    throw new IllegalStateException("You cannot have arrays within @Embedded arrays or collections");
  
  if (value.getClass().getComponentType() == Byte.TYPE)
  {
    // Special case!  byte[] gets turned into Blob.
    return new Blob((byte[])value);
  }
  else
  {
    // The datastore cannot persist arrays, but it can persist ArrayList
    int length = Array.getLength(value);
    ArrayList<Object> list = new ArrayList<Object>(length);
    
    for (int i=0; i<length; i++)
      list.add(this.conversions.forDatastore(Array.get(value, i), ctx));
    
    return list;
  }
}

代码示例来源:origin: com.google.appengine.orm/datanucleus-appengine

return new Blob((byte[]) obj);
} else if (obj instanceof Byte[]) {
 return new Blob(PrimitiveArrays.toByteArray(Arrays.asList((Byte[]) obj)));
  oos = new ObjectOutputStream(baos);
  oos.writeObject(obj);
  return new Blob(baos.toByteArray());
 } finally {
  try {

代码示例来源:origin: com.googlecode.cedar-common/objectify

oos.writeObject(value);
return new Blob(baos.toByteArray());

代码示例来源:origin: com.google.appengine.tools/appengine-pipeline

@Override
 public Entity toEntity() {
  Entity entity = toProtoEntity();
  entity.setUnindexedProperty(PAYLOAD_PROPERTY, new Blob(payload));
  return entity;
 }
}

代码示例来源:origin: bedatadriven/activityinfo

/**
 * Updates the value at the given {@code index} in the array, allocating a new, larger
 * array only if necessary.
 *
 * @return
 */
public static Blob update(Blob values, int index, int value) {
  byte[] bytes = ensureCapacity(values, index);
  set(bytes, index, value);
  return new Blob(bytes);
}

代码示例来源:origin: bedatadriven/activityinfo

public static Blob update(Blob values, int index, double value) {
  byte[] bytes = ensureCapacity(values, index);
  set(bytes, index, value);
  return new Blob(bytes);
}

代码示例来源:origin: com.googlecode.cedar-common/objectify

public static Blob instantiate(SerializationStreamReader streamReader)
    throws SerializationException
{
  byte[] bytes;
  int len = streamReader.readInt();
  if (len == -1) {
    bytes = null;
  } else {
    bytes = new byte[len];
    for (int i = 0; i < len; i++) {
      bytes[i] = streamReader.readByte();
    }
  }
  return new Blob(bytes);
}

代码示例来源:origin: io.konig/konig-gae-datastore

return new Blob(label.getBytes());

代码示例来源:origin: com.google.appengine.tools/appengine-pipeline

@Override
 public Entity toEntity() {
  try {
   Entity entity = toProtoEntity();
   byte[] serializedException = SerializationUtils.serialize(exception);
   entity.setUnindexedProperty(EXCEPTION_PROPERTY, new Blob(serializedException));
   return entity;
  } catch (IOException e) {
   throw new RuntimeException("Failed to serialize exception for " + getKey(), e);
  }
 }
}

代码示例来源:origin: bedatadriven/activityinfo

public static Blob update(Blob values, int index, char offset) {
  if(offset == 0) {
    return updateToZero(values, index);
  } else {
    byte[] bytes = ValueArrays.ensureCapacity(values, index, BYTES);
    ValueArrays.setChar(bytes, index, offset);
    return new Blob(bytes);
  }
}

代码示例来源:origin: com.google.appengine.tools/appengine-pipeline

@Override
public Entity toEntity() {
 Entity entity = toProtoEntity();
 entity.setUnindexedProperty(SHARD_ID_PROPERTY, shardId);
 entity.setUnindexedProperty(VALUE_PROPERTY, new Blob(value));
 return entity;
}

代码示例来源:origin: bedatadriven/activityinfo

public static Blob update(Blob values, int index, double value1, double value2) {
  byte[] bytes = ensureCapacity(values, index + 1);
  set(bytes, index, value1);
  set(bytes, index, value2);
  return new Blob(bytes);
}

代码示例来源:origin: bedatadriven/activityinfo

public static Blob update(Blob blob, int index, boolean value) {
  if(blob == null && !value) {
    return null;
  }
  int capacity = 0;
  if(blob != null) {
    capacity = blob.getBytes().length * 8;
  }
  // Unallocated bits at the end of the blob are assumed to be false
  if(index >= capacity && !value) {
    return blob;
  }
  byte[] bytes = ensureCapacity(blob, index);
  set(bytes, index, value);
  return new Blob(bytes);
}

代码示例来源:origin: com.google.http-client/google-http-client-appengine

@Override
public AppEngineDataStore<V> set(String key, V value) throws IOException {
 Preconditions.checkNotNull(key);
 Preconditions.checkNotNull(value);
 lock.lock();
 try {
  Entity entity = new Entity(getId(), key);
  entity.setUnindexedProperty(FIELD_VALUE, new Blob(IOUtils.serialize(value)));
  dataStoreService.put(entity);
  if (memcache != null) {
   memcache.put(key, value, memcacheExpiration);
  }
 } finally {
  lock.unlock();
 }
 return this;
}

代码示例来源:origin: org.eiichiro.acidhouse/acidhouse-appengine

EntityProto proto = EntityTranslator.convertToPb(e);
byte[] bytes = proto.toByteArray();
blobs.add(new Blob(bytes));

代码示例来源:origin: GoogleCloudPlatform/appengine-tck

@Test
public void testSize() {
  String kind = kindName + "-size";
  int recordSize = (1000 * 1000);  // Max. 1000000.
  byte[] filledRec = new byte[recordSize];
  Arrays.fill(filledRec, (byte) 0x41);
  Blob bigBlob = new Blob(filledRec);
  assertEquals(recordSize, bigBlob.getBytes().length);
  Entity eBlob = new Entity(kind, rootKey);
  eBlob.setProperty("blobProp", bigBlob);
  service.put(eBlob);
  recordSize = 500 ;  // Max. 500.
  filledRec = new byte[recordSize];
  Arrays.fill(filledRec, (byte) 0x41);
  ShortBlob shortBlob = new ShortBlob(filledRec);
  assertEquals(recordSize, shortBlob.getBytes().length);
  Entity eShortBlob = new Entity(kind, rootKey);
  eShortBlob.setProperty("byteStrProp", shortBlob);
  service.put(eShortBlob);
  service.delete(eBlob.getKey(), eShortBlob.getKey());
}

代码示例来源:origin: GoogleCloudPlatform/appengine-tck

@Test
public void testUnindexedProperties() throws Exception {
  Entity entity = new Entity(UNINDEXED_ENTITY);
  entity.setUnindexedProperty("unindexedString", "unindexedString");
  entity.setUnindexedProperty("unindexedList", new ArrayList<String>(Arrays.asList("listElement1", "listElement2", "listElement3")));
  entity.setUnindexedProperty("unindexedText", new Text("unindexedText"));
  entity.setUnindexedProperty("unindexedBlob", new Blob("unindexedBlob".getBytes()));
  entity.setProperty("text", new Text("text"));
  entity.setProperty("blob", new Blob("blob".getBytes()));
  Key key = service.put(entity);
  sync(3000);  // Not using ancestor queries, so pause before doing queries below.
  Entity entity2 = service.get(key);
  assertTrue(isUnindexed(getRawProperty(entity2, "unindexedString")));
  assertTrue(isUnindexed(getRawProperty(entity2, "unindexedList")));
  assertTrue(isUnindexed(getRawProperty(entity2, "unindexedText")));
  assertTrue(isUnindexed(getRawProperty(entity2, "unindexedBlob")));
  assertTrue(isUnindexed(getRawProperty(entity2, "text")));
  assertTrue(isUnindexed(getRawProperty(entity2, "blob")));
  assertNull(getResult(new Query(UNINDEXED_ENTITY).setFilter(new FilterPredicate("unindexedString", EQUAL, "unindexedString"))));
  assertNull(getResult(new Query(UNINDEXED_ENTITY).setFilter(new FilterPredicate("unindexedList", EQUAL, "listElement1"))));
  assertNull(getResult(new Query(UNINDEXED_ENTITY).setFilter(new FilterPredicate("unindexedText", EQUAL, "unindexedText"))));
  assertNull(getResult(new Query(UNINDEXED_ENTITY).setFilter(new FilterPredicate("text", EQUAL, "text"))));
  service.delete(key);
}

相关文章