aboutsummaryrefslogtreecommitdiff
path: root/java/README.txt
diff options
context:
space:
mode:
authorJuan Silveira <jjso@google.com>2014-06-17 15:01:22 +0100
committerJuan Silveira <jjso@google.com>2014-07-14 16:54:28 +0100
commit79f19eb9f1d97aff7c6ab14eda49ee8888e51b33 (patch)
treef42f4dd65b2bb03139a96da796ef2d65e32a47b4 /java/README.txt
parent70ef74aaa69013945b60aea5bbb3c5a7932c41d4 (diff)
downloadprotobuf-79f19eb9f1d97aff7c6ab14eda49ee8888e51b33.tar.gz
protobuf-79f19eb9f1d97aff7c6ab14eda49ee8888e51b33.tar.bz2
protobuf-79f19eb9f1d97aff7c6ab14eda49ee8888e51b33.zip
Keep pointers to extension values.
The current implementation of getExtension deserialises the field from bytes and returns a new object every time. This means that changes to those objects are reflected when the messages is serialised unless setExtension is called. It also means that every call to getExtension and setExtension is expensive. This change introduces a FieldData class that contains everything that's known about the field at the time. This can be all the tag/byte[] pairs associated with a given field or an Extension and a value object. This is so that two messages with a repeated extension can be compared even if the extension has been deserialised in one of them but not the other. This change also adds FieldArray class based on SparseArray from the Android compatibility library. This is used in ExtendableMessageNano to make lookup of FieldDatas by their field number faster. Implications: * calling getExtension multiple times deserialises the field only once and returns the same object. * calling setExtension doesn't cause the object to be serialised immediately, that only happens when the container message is serialised. * getExtension is no longer a read-only thread-safe operation. README.txt has been updated to relfect that. * comparison using equals and hashCode continues to work. Bug: 10863158 Change-Id: I81c7cb0c73cc0611a1f7c1eabf5eed259738e8bc
Diffstat (limited to 'java/README.txt')
-rw-r--r--java/README.txt7
1 files changed, 4 insertions, 3 deletions
diff --git a/java/README.txt b/java/README.txt
index c6933138..4dfef142 100644
--- a/java/README.txt
+++ b/java/README.txt
@@ -442,9 +442,10 @@ used simultaneously from multiple threads in a read-only manner.
In other words, an appropriate synchronization mechanism (such as
a ReadWriteLock) must be used to ensure that a message, its
ancestors, and descendants are not accessed by any other threads
-while the message is being modified. Field reads, getter methods,
-toByteArray(...), writeTo(...), getCachedSize(), and
-getSerializedSize() are all considered read-only operations.
+while the message is being modified. Field reads, getter methods
+(but not getExtension(...)), toByteArray(...), writeTo(...),
+getCachedSize(), and getSerializedSize() are all considered read-only
+operations.
IMPORTANT: If you have fields with defaults and opt out of accessors