RFR(JDK12/NIO) 8202285: (fs) Add a method to Files for comparing file contents

Joe Wang huizhe.wang at oracle.com
Thu Sep 20 18:04:05 UTC 2018



On 9/20/18, 12:12 AM, Alan Bateman wrote:
> On 19/09/2018 22:02, Roger Riggs wrote:
>> This came up in off-line discussions, it seems unlikely that two 
>> files will differ only in the last of 100Mb
>> and it will require a separate code path that will very infrequently 
>> be exercised.  So I'd still to a single
>> technique even if it is slightly slower for very large files to keep 
>> the size of the code in check.
>> If it shows up later as a performance problem it can be added.
>>
> I think this will eventually have a different implementation for the 
> default file system where it can used memory mapping of file files. If 
> the first 1MB of large files are identical then that it might switch 
> over to mapping by chunk to compare the rest of the file. Starting out 
> with a basic implementation is okay of course.

Sounds good. Will keep the basic impl, probably use 
FileChannel/ByteBuffer as Brian suggested, and look forward to the more 
complicated version if we hear any complaints. For the majority of text 
files, the basic impl would be enough. For example, the largest file in 
java.nio is about 180K.

Thanks,
Joe
>
> -Alan.
>


More information about the core-libs-dev mailing list