Neos Coin
2015-11-06 17:04:43 UTC
Hi folks,
I'm new to the group, but have been a long-time leveldb user. I'm
currently experiencing a very odd issue which isn't quite making sense to
either myself or any colleagues. The function being used to handle this
data has a few basic operations:
1. Check via Get() return if a key exists
2. If key doesn't exist, base64 encode the value, and insert it into the
database
3. If key exists, fetch the data, base64 decode it, append the new value
to the existing value, base64 encode it, and insert it into the database
The function below is the actual handler:
void linkMatch (int64_t foundID, string ID, int64_t personID) {
char mKey[4096],mVal[4096],aVal[4096];
/* Debug */
ofstream linklog("linkfound.log", std::ios_base::app | std::ios_base::
out);
sprintf(mKey, "lm:%lld", foundID);
sprintf(mVal, "lt:%lld|%s", foundID, ID.c_str());
Slice mKeys(mKey);
Slice mVals(mVal);
string qR,aM,dC;
leveldb::Status qstat = nxgodb->Get(ReadOptions, mKeys, &qR);
linklog << "==== CURRENT ENTRY ====\n\n" << qR << "\n";
if (!qstat.ok()) {
linklog << "Initial entry not found\n";
aM = EncodeBase64(mVal);
linklog << "Plain data being encoded for insertion: " << mVal << "\n";
linklog << "Encoded entry being set: " << aM << "\n";
Slice aMs(aM);
linklog << "Current slice being inserted: " << aMs.ToString() << "\n";
nxgodb->Put(writeOptions, mKeys, aMs);
} else {
linklog << "Initial entry found\n";
dC = DecodeBase64(qR);
linklog << "Decoded existing data: " << dC << "\n";
sprintf(aVal, "%s,lt:%lld|%s", dC.c_str(), personID, ID.c_str());
Slice aVals(EncodeBase64(aVal));
linklog << "New data going in: " << aVals.ToString() << "\n";
nxgodb->Put(writeOptions, mKeys, aVals);
}
linklog << "==== END DEBUG ====\n\n";
linklog.close();
}
I was experimenting between using sprintf() and ostringstream() to
determine if the results would differ or improve, but neither yielded
improvement. The following is the debug log from the operation:
==== CURRENT ENTRY ====
Initial entry not found
Plain data being encoded for insertion: lt:1|Pt4p63IyYNYjKBeRnI5G
Encoded entry being set: bHQ6MXxQdDRwNjNJeVlOWWpLQmVSbkk1Rw==
Current slice being inserted: bHQ6MXxQdDRwNjNJeVlOWWpLQmVSbkk1Rw==
==== END DEBUG ====
==== CURRENT ENTRY ====
bHQ6MXxQdDRwNjNJeVlOWWpLQmVSbkk1Rw==
Initial entry found
Decoded existing data: lt:1|Pt4p63IyYNYjKBeRnI5G
New data going in:
bHQ6MXxQdDRwNjNJeVlOWWpLQmVSbkk1RyxsdDoxfEZyN2VCNnV2czlWWlpRbzdvR2VU
==== END DEBUG ====
==== CURRENT ENTRY ====
bHQ6MXxQdDRwNjNJeVlOWWpLQmVSbkk1RyxsdDoxfEZyN2VCNnV2czlWWlpRbzdvR2VU
Initial entry found
Decoded existing data:
lt:1|Pt4p63IyYNYjKBeRnI5G,lt:1|Fr7eB6uvs9VZZQo7oGeT
New data going in:
bHQ6MXxQdDRwNjNJeVlOWWpLQmVSbkk1RyxsdDoxfEZyN2VCNnV2czlWWlpRbzdvR2VULGx0OjF8VFZ5SVpRajRUaU9TbVZVeUxHcGE=
==== END DEBUG ====
==== CURRENT ENTRY ====
^@^@^@^@^@^@^@^@^A^@^@^@^A^Dlm:1h^@^@^@^@^@^@^@^@^A^@^@^@^A^DlmsdDoxfEZy^@^@^A^@^@^@^A^DlmsdDoxfbzdvR2VULGx0OsdDoxfbzdvR2VULGx0OsdDoxfbzdvR2
Initial entry found
Decoded existing data:
New data going in: LGx0OjF8emdnVW5oa2Jpb29YZmt6OVJMUXQ=
==== END DEBUG ====
If anyone can shed any light on this, I'd be sincerely grateful.
I'm new to the group, but have been a long-time leveldb user. I'm
currently experiencing a very odd issue which isn't quite making sense to
either myself or any colleagues. The function being used to handle this
data has a few basic operations:
1. Check via Get() return if a key exists
2. If key doesn't exist, base64 encode the value, and insert it into the
database
3. If key exists, fetch the data, base64 decode it, append the new value
to the existing value, base64 encode it, and insert it into the database
The function below is the actual handler:
void linkMatch (int64_t foundID, string ID, int64_t personID) {
char mKey[4096],mVal[4096],aVal[4096];
/* Debug */
ofstream linklog("linkfound.log", std::ios_base::app | std::ios_base::
out);
sprintf(mKey, "lm:%lld", foundID);
sprintf(mVal, "lt:%lld|%s", foundID, ID.c_str());
Slice mKeys(mKey);
Slice mVals(mVal);
string qR,aM,dC;
leveldb::Status qstat = nxgodb->Get(ReadOptions, mKeys, &qR);
linklog << "==== CURRENT ENTRY ====\n\n" << qR << "\n";
if (!qstat.ok()) {
linklog << "Initial entry not found\n";
aM = EncodeBase64(mVal);
linklog << "Plain data being encoded for insertion: " << mVal << "\n";
linklog << "Encoded entry being set: " << aM << "\n";
Slice aMs(aM);
linklog << "Current slice being inserted: " << aMs.ToString() << "\n";
nxgodb->Put(writeOptions, mKeys, aMs);
} else {
linklog << "Initial entry found\n";
dC = DecodeBase64(qR);
linklog << "Decoded existing data: " << dC << "\n";
sprintf(aVal, "%s,lt:%lld|%s", dC.c_str(), personID, ID.c_str());
Slice aVals(EncodeBase64(aVal));
linklog << "New data going in: " << aVals.ToString() << "\n";
nxgodb->Put(writeOptions, mKeys, aVals);
}
linklog << "==== END DEBUG ====\n\n";
linklog.close();
}
I was experimenting between using sprintf() and ostringstream() to
determine if the results would differ or improve, but neither yielded
improvement. The following is the debug log from the operation:
==== CURRENT ENTRY ====
Initial entry not found
Plain data being encoded for insertion: lt:1|Pt4p63IyYNYjKBeRnI5G
Encoded entry being set: bHQ6MXxQdDRwNjNJeVlOWWpLQmVSbkk1Rw==
Current slice being inserted: bHQ6MXxQdDRwNjNJeVlOWWpLQmVSbkk1Rw==
==== END DEBUG ====
==== CURRENT ENTRY ====
bHQ6MXxQdDRwNjNJeVlOWWpLQmVSbkk1Rw==
Initial entry found
Decoded existing data: lt:1|Pt4p63IyYNYjKBeRnI5G
New data going in:
bHQ6MXxQdDRwNjNJeVlOWWpLQmVSbkk1RyxsdDoxfEZyN2VCNnV2czlWWlpRbzdvR2VU
==== END DEBUG ====
==== CURRENT ENTRY ====
bHQ6MXxQdDRwNjNJeVlOWWpLQmVSbkk1RyxsdDoxfEZyN2VCNnV2czlWWlpRbzdvR2VU
Initial entry found
Decoded existing data:
lt:1|Pt4p63IyYNYjKBeRnI5G,lt:1|Fr7eB6uvs9VZZQo7oGeT
New data going in:
bHQ6MXxQdDRwNjNJeVlOWWpLQmVSbkk1RyxsdDoxfEZyN2VCNnV2czlWWlpRbzdvR2VULGx0OjF8VFZ5SVpRajRUaU9TbVZVeUxHcGE=
==== END DEBUG ====
==== CURRENT ENTRY ====
^@^@^@^@^@^@^@^@^A^@^@^@^A^Dlm:1h^@^@^@^@^@^@^@^@^A^@^@^@^A^DlmsdDoxfEZy^@^@^A^@^@^@^A^DlmsdDoxfbzdvR2VULGx0OsdDoxfbzdvR2VULGx0OsdDoxfbzdvR2
Initial entry found
Decoded existing data:
New data going in: LGx0OjF8emdnVW5oa2Jpb29YZmt6OVJMUXQ=
==== END DEBUG ====
If anyone can shed any light on this, I'd be sincerely grateful.
--
You received this message because you are subscribed to the Google Groups "leveldb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leveldb+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "leveldb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leveldb+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.