Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9994464

Browse files
kvapkelvich
authored andcommitted
Implement PaxosGet and PaxosSet.
1 parentf78894b commit9994464

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

‎multimaster.c

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,14 +1191,43 @@ void MtmOnNodeConnect(int nodeId)
11911191
*/
11921192
void*PaxosGet(charconst*key,int*size,PaxosTimestamp*ts,boolnowait)
11931193
{
1194-
if (size!=NULL) {
1194+
unsignedenclen,declen,len;
1195+
char*enc,*dec;
1196+
Assert(ts==NULL);// not implemented
1197+
1198+
enc=raftable_get(key);
1199+
if (enc==NULL)
1200+
{
11951201
*size=0;
1202+
returnNULL;
1203+
}
1204+
1205+
enclen=strlen(enc);
1206+
declen=hex_dec_len(enc,enclen);
1207+
dec=palloc(declen);
1208+
len=hex_decode(enc,enclen,dec);
1209+
pfree(enc);
1210+
Assert(len==declen);
1211+
1212+
if (size!=NULL) {
1213+
*size=declen;
11961214
}
1197-
returnNULL;
1215+
returndec;
11981216
}
11991217

12001218
voidPaxosSet(charconst*key,voidconst*value,intsize,boolnowait)
1201-
{}
1219+
{
1220+
unsignedenclen,declen,len;
1221+
char*enc,*dec;
1222+
1223+
enclen=hex_enc_len(value,size);
1224+
enc=palloc(enclen);
1225+
len=hex_encode(value,size,enc);
1226+
Assert(len==enclen);
1227+
1228+
raftable_set(key,enc,nowait ?1 :INT_MAX);
1229+
pfree(enc);
1230+
}
12021231

12031232

12041233
/*

‎multimaster.control

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ comment = 'Multimaster'
22
default_version = '1.0'
33
module_pathname = '$libdir/multimaster'
44
schema = mtm
5-
relocatable = false
5+
relocatable = false
6+
requires = raftable

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp