You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by Chetan Mehrotra <ch...@gmail.com> on 2016/08/03 06:21:15 UTC
Way to capture metadata related to commit as part of CommitInfo from
within CommitHook
Hi Team,
Currently as part of commit the caller can provide a CommitInfo
instance which captures some metadata related to commit being
performed. Note that CommitInfo instance passed to NodeStore is
immutable.
For some usecases we need a way to add some more metadata to on going
commit from within the CommitHook
OAK-4586 - Collect affected node types on commit
Here we need to record nodetypes of nodes which got modified as part
of current commit
OAK-4412 - Lucene hybrid index
Here we want to generate Documents for modified nodestate (per index
definition) and "attach" it to current commit
This meta information would later be used by Observer. Currently there
no std way in API to achieve that.
#A -Probably we can introduce a new type CommitAttributes which can be
attached to CommitInfo and which can be modified by the CommitHooks.
The CommitAttributes can then later be accessed by Observer
OR
#B - We can just add a mutable attribute map to the CommitInfo
instance and that can be populated by CommitHooks
Thoughts on which approach to go forward
Chetan Mehrotra
Re: Way to capture metadata related to commit as part of CommitInfo
from within CommitHook
Posted by Chetan Mehrotra <ch...@gmail.com>.
Opened OAK-4640 to track this
Chetan Mehrotra
On Wed, Aug 3, 2016 at 9:36 PM, Michael Dürig <md...@apache.org> wrote:
>
>
> On 3.8.16 5:58 , Chetan Mehrotra wrote:
>>
>> On Wed, Aug 3, 2016 at 8:57 PM, Michael Dürig <md...@apache.org> wrote:
>>>
>>> I would suggest to add an new, internal mechanism to CommitInfo for your
>>> purpose.
>>
>>
>> So introduce a new CommitAttributes instance which would be returned
>> by CommitInfo ... ?
>
>
> Probably the best of all ugly solutions yes ;-) (Meaning I don't have a
> better idea neither...)
>
> Michael
>
>>
>> Chetan Mehrotra
>>
>
Re: Way to capture metadata related to commit as part of CommitInfo
from within CommitHook
Posted by Michael Dürig <md...@apache.org>.
On 3.8.16 5:58 , Chetan Mehrotra wrote:
> On Wed, Aug 3, 2016 at 8:57 PM, Michael D�rig <md...@apache.org> wrote:
>> I would suggest to add an new, internal mechanism to CommitInfo for your
>> purpose.
>
> So introduce a new CommitAttributes instance which would be returned
> by CommitInfo ... ?
Probably the best of all ugly solutions yes ;-) (Meaning I don't have a
better idea neither...)
Michael
>
> Chetan Mehrotra
>
Re: Way to capture metadata related to commit as part of CommitInfo
from within CommitHook
Posted by Chetan Mehrotra <ch...@gmail.com>.
On Wed, Aug 3, 2016 at 8:57 PM, Michael Dürig <md...@apache.org> wrote:
> I would suggest to add an new, internal mechanism to CommitInfo for your
> purpose.
So introduce a new CommitAttributes instance which would be returned
by CommitInfo ... ?
Chetan Mehrotra
Re: Way to capture metadata related to commit as part of CommitInfo
from within CommitHook
Posted by Michael Dürig <md...@apache.org>.
So maybe we need some additional means to survey this context then. If
you look at https://issues.apache.org/jira/browse/OAK-1438 where the
commit info map was introduced and at the usages of the same, it is
evident that this map belongs to the client (i.e. caller). Modifying it
midway through is not expected. One of the more subtle "usages" is the
info map being part of the CommitInfo's equals() and hashCode()
implementations. It is very difficult to know what parts of the code
rely on this and what impact a mutable map would have here.
I would suggest to add an new, internal mechanism to CommitInfo for your
purpose.
Michael
On 3.8.16 5:01 , Chetan Mehrotra wrote:
> That would depend on the CommitHook impl which client code would not
> be aware of. And commit hook would also know only as commit traversal
> is done. So it needs to be some mutable state
> Chetan Mehrotra
>
>
> On Wed, Aug 3, 2016 at 8:27 PM, Michael D�rig <md...@apache.org> wrote:
>>
>> Couldn't we keep the map immutable and instead add some "WhateverCollector"
>> instances as values? E.g. add a AffectedNodeTypeCollector right from the
>> beginning?
>>
>> Michael
>>
>>
>>
>> On 3.8.16 4:06 , Chetan Mehrotra wrote:
>>>
>>> So would it be ok to make the map within CommitInfo mutable ?
>>> Chetan Mehrotra
>>>
>>>
>>> On Wed, Aug 3, 2016 at 7:29 PM, Michael D�rig <md...@apache.org> wrote:
>>>>
>>>>
>>>>>
>>>>> #A -Probably we can introduce a new type CommitAttributes which can be
>>>>> attached to CommitInfo and which can be modified by the CommitHooks.
>>>>> The CommitAttributes can then later be accessed by Observer
>>>>
>>>>
>>>>
>>>> This is already present via the CommitInfo.info map. It is even used in a
>>>> similar way. See CommitInfo.getPath() and its usages. AFAIU the only part
>>>> where your cases would differ is that the information is assembled by
>>>> some
>>>> commit hooks instead of being provided at the point the commit was
>>>> initiated.
>>>>
>>>>
>>>> Michael
Re: Way to capture metadata related to commit as part of CommitInfo
from within CommitHook
Posted by Chetan Mehrotra <ch...@gmail.com>.
That would depend on the CommitHook impl which client code would not
be aware of. And commit hook would also know only as commit traversal
is done. So it needs to be some mutable state
Chetan Mehrotra
On Wed, Aug 3, 2016 at 8:27 PM, Michael Dürig <md...@apache.org> wrote:
>
> Couldn't we keep the map immutable and instead add some "WhateverCollector"
> instances as values? E.g. add a AffectedNodeTypeCollector right from the
> beginning?
>
> Michael
>
>
>
> On 3.8.16 4:06 , Chetan Mehrotra wrote:
>>
>> So would it be ok to make the map within CommitInfo mutable ?
>> Chetan Mehrotra
>>
>>
>> On Wed, Aug 3, 2016 at 7:29 PM, Michael Dürig <md...@apache.org> wrote:
>>>
>>>
>>>>
>>>> #A -Probably we can introduce a new type CommitAttributes which can be
>>>> attached to CommitInfo and which can be modified by the CommitHooks.
>>>> The CommitAttributes can then later be accessed by Observer
>>>
>>>
>>>
>>> This is already present via the CommitInfo.info map. It is even used in a
>>> similar way. See CommitInfo.getPath() and its usages. AFAIU the only part
>>> where your cases would differ is that the information is assembled by
>>> some
>>> commit hooks instead of being provided at the point the commit was
>>> initiated.
>>>
>>>
>>> Michael
Re: Way to capture metadata related to commit as part of CommitInfo
from within CommitHook
Posted by Michael Dürig <md...@apache.org>.
Couldn't we keep the map immutable and instead add some
"WhateverCollector" instances as values? E.g. add a
AffectedNodeTypeCollector right from the beginning?
Michael
On 3.8.16 4:06 , Chetan Mehrotra wrote:
> So would it be ok to make the map within CommitInfo mutable ?
> Chetan Mehrotra
>
>
> On Wed, Aug 3, 2016 at 7:29 PM, Michael D�rig <md...@apache.org> wrote:
>>
>>>
>>> #A -Probably we can introduce a new type CommitAttributes which can be
>>> attached to CommitInfo and which can be modified by the CommitHooks.
>>> The CommitAttributes can then later be accessed by Observer
>>
>>
>> This is already present via the CommitInfo.info map. It is even used in a
>> similar way. See CommitInfo.getPath() and its usages. AFAIU the only part
>> where your cases would differ is that the information is assembled by some
>> commit hooks instead of being provided at the point the commit was
>> initiated.
>>
>>
>> Michael
Re: Way to capture metadata related to commit as part of CommitInfo
from within CommitHook
Posted by Chetan Mehrotra <ch...@gmail.com>.
So would it be ok to make the map within CommitInfo mutable ?
Chetan Mehrotra
On Wed, Aug 3, 2016 at 7:29 PM, Michael Dürig <md...@apache.org> wrote:
>
>>
>> #A -Probably we can introduce a new type CommitAttributes which can be
>> attached to CommitInfo and which can be modified by the CommitHooks.
>> The CommitAttributes can then later be accessed by Observer
>
>
> This is already present via the CommitInfo.info map. It is even used in a
> similar way. See CommitInfo.getPath() and its usages. AFAIU the only part
> where your cases would differ is that the information is assembled by some
> commit hooks instead of being provided at the point the commit was
> initiated.
>
>
> Michael
Re: Way to capture metadata related to commit as part of CommitInfo
from within CommitHook
Posted by Michael Dürig <md...@apache.org>.
>
> #A -Probably we can introduce a new type CommitAttributes which can be
> attached to CommitInfo and which can be modified by the CommitHooks.
> The CommitAttributes can then later be accessed by Observer
This is already present via the CommitInfo.info map. It is even used in
a similar way. See CommitInfo.getPath() and its usages. AFAIU the only
part where your cases would differ is that the information is assembled
by some commit hooks instead of being provided at the point the commit
was initiated.
Michael