[
https://issues.apache.org/jira/browse/SOLR-11892?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16338503#comment-16338503
]
Erick Erickson commented on SOLR-11892:
---------------------------------------
[~rcmuir]
Is the argument you're making that catching an occasional exception is cheaper
than testing if a file exists first? I.e. since a large majority of the deletes
are successful it would be a net loss to test first. Stack traces are not
cheap, but the argument would be that it's cheaper than adding a seek to the
file to test existence. Or am I misinterpreting your link?
Uh oh. Just looked at the code for FileSystemProvider.deleteIfExists. So if I
read this correctly deleteIfExists doesn't really avoid the exception anyway,
just conceals it. So changing FSDirectory to use deleteIfExists seems like a
net-zero change .vs. catching an exception, do you agree?
{{public boolean deleteIfExists(Path path) throws IOException {}}
{{ try {}}
{{ delete(path);}}
{{ return true;}}
{{ } catch (NoSuchFileException ignore) {}}
{{ return false; }}
{{ }}}
{{}}}
Another take is that the effort would be better spent understanding why we try
to delete files that don't exist in the first place and fix _that_.
Yeah, this should be a Lucene issue, I'll move it over if we decide to take it
forward.
> Avoid unnecessary exceptions in FSDirectory and RAMDirectory
> ------------------------------------------------------------
>
> Key: SOLR-11892
> URL: https://issues.apache.org/jira/browse/SOLR-11892
> Project: Solr
> Issue Type: Improvement
> Security Level: Public(Default Security Level. Issues are Public)
> Reporter: Erick Erickson
> Assignee: Erick Erickson
> Priority: Minor
>
> In privateDeleteFile, just use deleteIfExists.
> in RamDirectory we can declare a static exception and create it once.
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]