directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Selcuk AYA <ayasel...@gmail.com>
Subject Re: UserLogRecord class : some questions
Date Wed, 26 Oct 2011 16:46:39 GMT
On Tue, Oct 25, 2011 at 7:23 PM, Emmanuel Lecharny <elecharny@gmail.com> wrote:
> Hi,
>
> I have a few questions about this class.
>
> 1) We keep an offset field, which is not used. Can we remove it, or is it
> intended to be activated later, and if so, in which purpose ?
 I was originally planning to use an offset but then removed the use
for it. I forgot to remove the declaration. Will do.

>
> 2) The stored data aren't copied, which might put the code at risk, if any
> external code modifies the byte array (as we just store a ref on it). Should
> we copy this array, or at least warn the user about this potential issue ?

UserlogRecord is used to communicate data to/from log manager. I dont
know what you mean by data stored is not copied. When user log record
is submitted to log data, it is either copied to the internal buffer
or written to the log file directly in case data is larger than the
internal buffer. When data is read from logs, data read is copied to
the buffer inside the user log record.

>
> 3) We also have a 'length' field, I'm wondering if it's a useful addition.
> We can either consider that the buffer contains all the bytes the use wants
> to store, or that it may be bigger than the data we want to store. I'm not
> sure it worth the extra effort, and it would propably be a simpler idea to
> have the buffer contain all the bytes, and nothing else.

it is useful in a couple of cases:
*when reading, suppose you have 1K buffer and you repeatedly read
small user log records. In this case, instead of allocating a buffer
separately for each record read, the same buffer can be used over and
over.

*when writing data, suppose you have a large enough buffer. Then
instead of forming a separate bytearraystream everytime data is
serialized, caller can wrap the array in a stream and reuse it for
serializing different objects. This avoids the cost of constructing
streams each time a user log record is serialized.

>
> 4) Can't we use a constructor instead of an init() method ?

init could evolve into an interface method.
>
> --
> Regards,
> Cordialement,
> Emmanuel L├ęcharny
> www.iktek.com
>
>

Mime
View raw message