|
From: Doug C. <cu...@ap...> - 2008-03-31 22:04:08
|
Ning Li wrote: >> - the point where we have a new log event from a neighbor, and need to >> resolve it against ourselves seems like a good point for a method call. > > The database should decide whether a version of a doc already > exists, right? Should we add a method to the database class? The naive approach is simply to db.getDoc() and check the version, no? If the existing version is newer, then we ignore. Note that deletes come with a version, so if the indexed version is newer than the deletion, we ignore the delete, just like an add. > Also, there will be a delay between checking if a version of a doc > already exists and adding the version of the doc into the database > (after retrieving it from a neighbor). Does this mean we always > have to check if a version of a doc already exists before adding it? Yes, in general. We might be able to avoid it when copying new ranges into a node, if the log is de-duplicated. But for general synchronization I think we always need to check versions. So it might be worth optimizing the doc->version implementation. So the method to add might be db.getVersion(String id). This doesn't make sense for end users, so should be added to the Database API we use in a node, not to the base abstract class. > I thought getDoc() means getting the full document. I want to use > getDocs() in log processing - after we process a number of log > entries from a node and identify the docs we should retrieve, we > call getDocs() to get those docs. What do you think? Yes, that sounds reasonable. I was just questioning whether this belongs the top-level Database API, or rather just in HostToHostProtocol. I just want to hide as much as we can from end-users, so that we can more freely re-arrange things underneath later. Eventually the top-level API might add a method like getDocs(String[] ids, String[] fields), which looks similar, but has a different purpose. Doug |