IPQualityScore / JavaIPQSDBReader

A java implementation of the IPQualityScore flat file DB Reader.
MIT License
0 stars 3 forks source link

Does DBReader handle file system refresh of underlying ipqs file #1

Open menacher opened 2 years ago

menacher commented 2 years ago

If we periodically update the ipqs file in the file system by overwriting existing file with new one, do we have to invoke FileReader reader = DBReader.Open and create a new FileReader instance manually or will the existing one work transparently? Will the FileReader throw exceptions when the file is overwritten with new one?

IPQualityScore commented 2 years ago

Based on my knowledge I'd invoke a new instance manually. The existing instance is likely to have cached data about the file and potentially be doing a read on the existing file when you swap the files out. If the headers of the original file and the replacement file are identical then I would expect things to operate normally after the swap. The existing reader will likely throw exceptions if the bytes it's reading don't line up with it's existing map. You may (though very unlikely) get random data out of a call happening exactly when the file is replaced if say record data changes positions suddenly during a read.

If having the library detect a swap out and automatically correct for that is a feature you'd like to request we'd probably need a ticket in our support system on our site to begin racking and stacking the upgrades. I can't promise when our team would be able to look into it at the moment as it depends on what they have going on currently.

menacher commented 2 years ago

Yes, this is definitely a feature we would like to have where file swaps are handled transparently. It should ideally be an inbuilt feature as the files are not static or designed to be. They change over time, but having to deal with it on the application layer is problematic.