break;
default:
throw new RuntimeException("Unexpected type in " + property);
}
if (bytes.length > MAX_INLINE_VALUE_BYTES) {
BlobKey blobKey;
try {
blobKey = dump(
"Oversized value of " + property + " for entity " + entity.getKey(),
bytes);
} catch (ApiProxyException e) {
throw new RuntimeException("Failed to dump " + property + " to file: " + entity, e);
} catch (IOException e) {
throw new RuntimeException("Failed to dump " + property + " to file: " + entity, e);
}
log.info("Moved " + bytes.length + " bytes from " + property + " to " + blobKey);
listener.blobCreated(entity.getKey(), property, blobKey);
entity.removeProperty(property.getPropertyName());
// We deliberately leave this indexable. This way, a hypothetical
// garbage collection algorithm could use the single-property index to
// find out which blob keys are referenced. Maybe this makes the
// listener mechanism redundant...
entity.setProperty(property.getMovedPropertyName(), blobKey.getKeyString());
}
}
}
}