Skip to content

[Feature Request] Add function to return object size [JIRA: CLIENTS-362] #403

Open
@mbbroberg

Description

@mbbroberg

A community conversation started on the riak-user list. The full conversation is here.

I'm using the python client (by the way).

obj = RIAK.bucket('my_bucket').get('my_key')

Is there any way to know the actual size of an object stored in Riak? to make sure something mutable > (like a set) didn't added up to more than 1MB in storage size.

It appears running getsizeof() is not a reliable measurement:

Map object:
curl -I

1058 bytes
print sys.getsizeof(obj.value)
3352 bytes

Standard object:
curl -I

9718 bytes
print sys.getsizeof(obj.encoded_data)
9755 bytes

The standard object seems pretty accurate in both approaches even >the image binary data was only 5kbs (I assume some overhead here)

The map object is about 3x the difference between curl and getting >the object via Python.

Not so sure if this is a realistic way to measure their growth (>moreover because the objects i would need this monitorization are >Maps, not unaltered binary data that I can know the size before >storing it).

Would it be possible in some way that the Python get() function would return something like "obj.content-lenght" returning the size is currently taking? that would be a pretty nice feature.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions