Tag Info

Hot answers tagged

11

Since you are using this information for billing purposes, I do not see why you would not want it in the database where it can be easily queried, aggregated, reported on, and joined to other data. I also think it's much easier to maintain a single database table containing the log information than a bunch of separate log files. Same with your concern ...


6

It sounds like you are trying to optimize the file comparison because that can be a potentially expensive operation: If two files have different sizes, they must be different files. If the first and last 4K of two files hash to different values, they must be different files. The first portion will check stuff like a file identifier commonly included in the ...


2

Are there any clear (measurable?) guidelines (besides "it depends") for setting the degree of explicitness/inderection. Not many. The first is the Law of Demeter, which focuses on how many "steps" it takes to get to what you want, which directly relates to your question about indirection. Another is Tell, don't Ask. If you have some implicit state ...


2

Your approach is good... if the files have completely random data. Here are some things to consider: How bad is it if there are collisions? If you need a mission critical guarantee (e.g. those astronauts on the ISS will die if a collision occurs), your algorithm may not be good enough, even though there are 10^38 possible MD5 hashes. People do win the ...


2

First you have to decide if it is sufficient to have runtime safety about the number of images or if you want to have compiletime safety. Runtime safety Achieving runtime safety is quite easy. All you have to do is remove the default setter for Images and implement a setter that performs a check before saving the given ICollection<string> argument ...


1

I would use option Change the API so every request for an image returns the image + a status information. If there is no image, you return a 0 byte stream for the image and a status like "no image available". So the user of the API needs only one roundtrip to retrieve the full information, the operation is atomic, you don't return an error for a valid ...


1

I would prefer option 1. This would involve expanding your current definition of an Incident to contain a hasImage flag so that the client can decide for which Incidents to call the image fetching API (eg, getIncidentImage(...)) Thos covers modelling and API design. As other people have mentioned, from a UX perspective, you might want to include a ...


1

It depends on the technology you use. Normally in this case you would return a Type that describes the possibility of an image. In some languages these types are built in (Option in Scala, Maybe in Haskell). In other ones you can write them yourselves or use a library that includes these types. For javascript (which may be what you can use, I guess), you can ...


1

Elaborating a bit on Snowman's answer, I think I would go for a hierarchy of hash values over (exponentially) increasing subsets of the file, computed on-demand whenever collisions occur, and memorized in a suitable data structure (hash table, but even a simple prefix tree would do) for quick future access. This should ensure quick failure in case of 'almost ...


1

Data deduplication is also often called "record linkage", so you may want to also use that as a search term when researching this. There is an article on the Eventbrite engineering blog that explains how you could greatly reduce the number of file comparisons by using Multi Index Locality Sensitive Hashing. In short, you create a special kind of hash value ...


1

You are asking two very different questions. The former one is not a generalization of the latter, because answering the first won't answer the second. There are many other things that might influence the second question, like how you would tackle transactions with multiple users and such. As for the first question, everybody agrees that a shorter ...


1

In the code: Validate in the setter the collection has at least one item, and raise and exception if it doesn't. In the database: Create an episode_image table. That table would have a foreign key with the image table. Unfortunately, there's no way to enforce that for every row in the parent table, there's at least one corresponding row in the child ...



Only top voted, non community-wiki answers of a minimum length are eligible