Commit Graph

22 Commits

Author SHA1 Message Date
pjulien 599f5e3915 Can now use ``CharSequence`` of ``String``. Works with
1. [AsciiString]
(http://netty.io/4.1/api/io/netty/util/AsciiString.html)
2. [CharBuffer]
(https://docs.oracle.com/javase/8/docs/api/java/nio/CharBuffer.html)
3. [StringBuilder]
(https://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html)
2016-04-25 22:07:57 -04:00
Wouter van Oortmerssen a0d1161feb Merge pull request #3850 from pjulien/3849
Fix for #3849
2016-04-22 11:42:14 -07:00
pjulien 6908826f95 Fix for #3849
This avoids the following allocations over repeated use:

- A ``CharsetEncoder``
- A byte array to contain the contents of the string
- A wrapper, via ``ByteBuffer#wrap``, for the previously mentioned byte
  array

This also removes a copy of the temporary byte array.  This extra copy
is needed because ``String#getBytes`` returns a byte array and its
length must match the exact size of the contents.

This implementation requires that the builder retain a ``ByteBuffer``
and ``CharEncoder``.  This is considered slower only for users that
will only allocate a single string in their buffers or none at all.

The improvement is especially potent if the builder is constantly reused
by its caller.  This also eliminates the penalty for users that do not
use strings at all since the cost of allocating these fields is
now amortized.

The only allocation left in this code is a ``CharBuffer`` wrapper.  It's
possible to eliminate this allocation using an additional copy but need
further profiling to see which is the bigger problem.
2016-04-21 20:20:14 -04:00
pjulien fdfaf23361 3847 2016-04-16 20:09:28 -04:00
Mark Klara 69a31b807a Revamping the FlatBuffers docs.
Adding an API reference for the supported languages.

General docs cleanup, including a new `tutorial` section that
supports all of the supported languages.

Added samples for each supported language to mirror the new
tutorial page.

Cleaned up all the links by making them `@ref` style links,
instead of referencing the names of the generated `.html` files.

Removed all generated files that were unnecessarily committed.

Also fixed the C# tests (two were failing due to a missing file).

Bug: b/25801305

Tested: Tested all samples on Ubuntu, Mac, and Android. Docs were
generated using doxygen and viewed on Chrome.

Change-Id: I2acaba6e332a15ae2deff5f26a4a25da7bd2c954
2016-01-19 14:31:17 -08:00
Wouter van Oortmerssen 54dc4395b9 Java builder now checks if buffer was finished upon access.
Also checks for nesting of objects in vector construction.

This avoids common errors in FlatBuffer construction.

Change-Id: I5507c5d767684e20e94883a92448f05acefba4d6
Tested: on Linux.
2015-12-02 11:12:39 -08:00
Wouter van Oortmerssen fbe085601b Java: Allow access to the underlying ByteBuffer from a table.
Change-Id: Id268e35de207c25c809a09071b81eea873c9123e
Tested: on Linux.
2015-05-20 16:21:22 -07:00
gwvo 361bfb6764 Merge pull request #189 from pjulien/188
Issue #188
2015-05-11 14:07:40 -07:00
gwvo 3f96eead4c Merge pull request #192 from Jiboo/fix190
Added a default constructor for Java's FlatBufferBuilder.
2015-05-11 13:59:22 -07:00
Jean-Baptiste "Jiboo" Lepesme 9fa3e2f387 Added a default costructor for Java's FlatBufferBuilder.
Default's size of 1024b like in cpp. Fixes #190.
2015-05-11 19:17:01 +02:00
pjulien d322eec3c3 Issue #188
When accessing the array directly of a byte buffer, need to offset
by ``arrayOffset``
2015-05-09 14:08:28 -04:00
pjulien e5a1a3129d Initially discussed in #178.
Allows adding an already encoded UTF-8 string directly without
having to convert to a ``String`` first.

Change-Id: I23f9c738eec18fd35f4c14f58dbd0f6cf0970dc7
2015-05-08 16:21:54 -07:00
pjulien 4d3db99283 Issue #136
The satellite data of the ``ByteBuffer`` cannot be modified in
any way and stay thread safe in the presence of concurrent readers.

This implementation is simple and does introduce an allocation, however
without it multiple readers will quickly and continuously encounter
``IndexOutOfBoundsException`` exceptions.

An alternative, but possibly more controversial, implementation would
be to use ``Unsafe``.  Using ``Unsafe``, it's possible to do an
array copy with a provided buffer index.

Change-Id: I851d4034e753b3be2931ee2249ec2c82dde43135
2015-02-04 13:53:02 -08:00
Florian Enner 72b9501e69 Added force-defaults to Java bindings
Change-Id: I62d10b639112788be3b0f670280bd50ef9fcf094
2015-02-02 14:04:22 -08:00
Florian Enner 9c169083ad Added FlatBufferBuilder reuse
init resets internal variables, but keeps memory that has been allocated
for temporary storage

Change-Id: If2aa7d27de3c2717cf4c82b1e4e4b6732e495cea
2015-02-02 14:02:22 -08:00
Wouter van Oortmerssen 79c2d80ed4 Fix for previous Java commit.
optimization would cause vtable fields from previous tables to be written.

Bug: 19046968
Change-Id: I781f7bcbceeaec0b499d4f1e4e5e8a1e750e0707
Tested: on Linux.
2015-01-26 14:12:20 -08:00
Wouter van Oortmerssen cf7135ff58 Reducing garbage produced by Java serializer.
startObject() now only allocates a new vtable array when it needs to grow.

Tested: on Linux.

Change-Id: Idd041605afcb9487a34d63bda067172d797f437a
2015-01-26 13:35:20 -08:00
pjulien 2b01247b30 PR for issue #130. Improves the javadoc of ``FlatBufferBuilder``
and marks ``dataStart`` deprecated.

Change-Id: I48409e20948117c5cf17a1bfabecf64b033eab27
2015-01-26 13:08:44 -08:00
Wouter van Oortmerssen 4fb5a764df Support for booleans in the Java/C# API
Change-Id: I72e92183a7b5f4145ea51fcec29257dc9553a461
2015-01-26 13:08:44 -08:00
Patrick Julien c95ad9cc55 Reuse the same charset instance
Change-Id: I58b411a2c0f1ee6b856d5b1eaa42787036da1384
2015-01-16 11:05:58 -08:00
Wouter van Oortmerssen 517c964fe2 Support for required fields.
Change-Id: I560c7ca11b3d665eecafb528f3737b7e139ca9b0
Tested: on Linux and Windows.
2014-09-22 15:53:19 -07:00
Wouter van Oortmerssen c01c77a7f2 Prepended com.google to the Java namespace.
Bug: 16507831
Change-Id: I5beee18f63f174e425dc1ab395807b578d5f9477
Tested: on Linux.
2014-09-15 17:45:15 -07:00