Skip to content

Commit d070988

Browse files
committed
Implement PaxosGet and PaxosSet.
1 parent 53bb8ae commit d070988

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

contrib/mmts/multimaster.c

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,14 +1192,43 @@ void MtmOnNodeConnect(int nodeId)
11921192
*/
11931193
void* PaxosGet(char const* key, int* size, PaxosTimestamp* ts, bool nowait)
11941194
{
1195-
if (size != NULL) {
1195+
unsigned enclen, declen, len;
1196+
char *enc, *dec;
1197+
Assert(ts == NULL); // not implemented
1198+
1199+
enc = raftable_get(key);
1200+
if (enc == NULL)
1201+
{
11961202
*size = 0;
1203+
return NULL;
1204+
}
1205+
1206+
enclen = strlen(enc);
1207+
declen = hex_dec_len(enc, enclen);
1208+
dec = palloc(declen);
1209+
len = hex_decode(enc, enclen, dec);
1210+
pfree(enc);
1211+
Assert(len == declen);
1212+
1213+
if (size != NULL) {
1214+
*size = declen;
11971215
}
1198-
return NULL;
1216+
return dec;
11991217
}
12001218

12011219
void PaxosSet(char const* key, void const* value, int size, bool nowait)
1202-
{}
1220+
{
1221+
unsigned enclen, declen, len;
1222+
char *enc, *dec;
1223+
1224+
enclen = hex_enc_len(value, size);
1225+
enc = palloc(enclen);
1226+
len = hex_encode(value, size, enc);
1227+
Assert(len == enclen);
1228+
1229+
raftable_set(key, enc, nowait ? 1 : INT_MAX);
1230+
pfree(enc);
1231+
}
12031232

12041233

12051234
/*

contrib/mmts/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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy