Hoi RGJ,
Ik probeer om town (onderdeel van postcode database) als eerste om deze onderling te synchroniseren. De town tabel zie er als volgt uit:
[quote]create table towntest ( #01 - deze tabel gaan synchoniseren met andere remote peers.
ts TIMESTAMP,
id bigint(16) unsigned not null,
importance bigint(15) not null default 0,#The current rating of this content.
priority bigint(15) not null default 0,#How important is this content for the end-user
town varchar(26) not null default’’,#hash
townPC varchar(26) not null default’’,#hash
gemeente varchar(32) not null default’’,#hash
provincie varchar(16) not null default’’,#hash
rd_x double not null default 0,
rd_y double not null default 0,
wgs84Lat double not null default 0,#hash
wgs84Lon double not null default 0,#hash
hash varchar(255) not null default’’,
status varchar(255) not null default’’,
action varchar(255) not null default’’,
owner varchar(255) not null default’’,
recordCheck bigint(10) not null default 0,
UpdateEntry TIMESTAMP,
BeginEntry TIMESTAMP,
EndEntry TIMESTAMP,
index (town(16)),
index (townPC(16)),
index (gemeente(16)),
index (provincie(16)),
index (rd_x, rd_y),
index (wgs84Lat, wgs84Lon),
index (hash(16)),
index (owner(16)),
index (recordCheck),
index (UpdateEntry),
index (ts),
primary key (id)
) type=myisam; [/quote]
Rd_x en Rd_y zijn afleidbaar velden. Hoeft m.i. niet gesynchroniseerd te worden. De hash wordt berekend door de volgende velden te gaan hashen (town,townPC,gemeente,provincie,wgs84Lat,wgs84Lon)
De hash is 144 bytes groot. Eerst zal je moeten bepalen hoeveel bytes je nodig hebt van de hash om de remote peer duidelijk te maken welke records je in de town tabel hebt. Ik ga dit analoog aan de “binary search techniek” doen. Je maakt temp tabel aan en stopt de linker helft van de hashes er in. Als je geen dubbelen krijgt dan ga je een vierde van de hash in deze temp tabel stoppen. Als je wel een dubbele krijgt dan driekwart van de hash in tabel stoppen. Dit doe je net zo lang totdat je precies weet hoeveel bytes je nodig hebt.
Om te synchroniseren stuur je x bytes van de hash * aantal plaatsen (=2454) naar de remote peer. De remote peer heeft ook zijn hashes uitgerekend en kan gemakkelijk zien welke records hij wel en niet heeft. De volgende slag is dat remote peer de ontbrekende records aan jou terugstuurt en de hashes aan jou stuurt welke hij niet heeft.
De hartelijke groet Jan Marco