Compare commits

..

No commits in common. "39e7b2945ab03fd569ab96c1d9f65999191872db" and "ddb137b7543ceaa304e872cb51459fbfa79da734" have entirely different histories.

32 changed files with 106 additions and 496 deletions

Binary file not shown.

Binary file not shown.

View File

@ -39,15 +39,10 @@ params [["_taskType", "", [""]], ["_key", "", [""]], ["_keyField", "", [""]], ["
private _task = [_taskType, _key, _keyField, _index, _value, _function, _call, _netId];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_addTask' Added Task '%1' to Queue", _task];
#endif
GVAR(taskQueue) pushBack _task;
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_addTask' Queue: %1", GVAR(taskQueue)];
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_addTask' Queue Size: %1", count GVAR(taskQueue)];
#endif
if !(GVAR(isProcessing)) then { [] spawn FUNC(processQueue); };

View File

@ -30,12 +30,6 @@
params [["_key", "", [""]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_delete' Key: '%1'", _key];
#endif
if (_key == "") exitWith {
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_delete' Invalid Input for Key '%1'", _key];
};
if (_key == "") exitWith { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_delete' Invalid Input for Key '%1'", _key]; };
"ArmaRAMDb" callExtension ["del", [_key]];

View File

@ -20,12 +20,11 @@
["uniqueID", "function", "index", "indextotal", "datachunk", "call", "netId"]
*/
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_fetch' Input: %1", _this];
#endif
params ["_uniqueID", "_function", "_index", "_total", "_datachunk", "_call", "_netId"];
private _dataString = "";
private _index_array = [];
private _count_total = -1;
@ -42,36 +41,14 @@ _count_total = {
if (_count_total == _total) then {
_index_array sort true;
private _allElements = [];
{
private _chunkData = _x select 1;
private _chunkArray = [];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: Processing chunk: %1", _chunkData];
#endif
try {
_chunkArray = parseSimpleArray _chunkData;
_allElements append _chunkArray;
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: Parsed chunk successfully with %1 elements", count _chunkArray];
#endif
} catch {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: Error parsing chunk: %1", _chunkData];
#endif
for "_i" from 0 to (_total - 1) do {
_dataString = _dataString + ((_index_array select _i) select 1);
};
} forEach _index_array;
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_fetch' Combined %1 chunks into array with %2 elements", count _index_array, count _allElements];
#endif
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_fetch' DataString: %1", _dataString];
[_uniqueID, _function, _call, _allElements, _netId] call FUNC(handler);
[_uniqueID, _function, _call, (parseSimpleArray _dataString), _netId] call FUNC(handler);
// Cleanup
ramdb_db_fetch_array = ramdb_db_fetch_array select {!((_x select 0) in [_uniqueID])};
};

View File

@ -33,9 +33,7 @@
params [["_key", "", [""]], ["_function", "", [""]], ["_call", false, [false]], ["_netId", "", [""]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_get' Key: '%1', Function: '%2', Call: '%3', NetId: '%4'", _key, _function, _call, _netId];
#endif
if (_key == "" || _function == "") exitWith {
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_get' Invalid Input for Key '%1' or Function '%2'", _key, _function];
@ -44,20 +42,14 @@ if (_key == "" || _function == "") exitWith {
private _return = "";
if (_netId != "") then {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_get' Using NetId: '%1'", _netId];
#endif
if (_call) then {
_return = "ArmaRAMDb" callExtension ["get", [_key, _function, _netId, _call]];
} else {
_return = "ArmaRAMDb" callExtension ["get", [_key, _function, _netId]];
};
} else {
#ifdef __A3__DEBUG__
diag_log text "ArmaRAMDb: 'ramdb_db_fnc_get' Using current player";
#endif
if (_call) then {
_return = "ArmaRAMDb" callExtension ["get", [_key, _function, _call]];
} else {
@ -65,8 +57,5 @@ if (_netId != "") then {
};
};
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_get' Return: '%1'", _return];
#endif
[(_return select 0)] call FUNC(scheduler);

View File

@ -34,9 +34,7 @@
params [["_uniqueID", "", [""]], ["_function", "", [""]], ["_call", false, [false]], ["_data", [], [[]]], ["_netId", nil, [""]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_handler' UniqueID: '%1', Function: '%2', Call: '%3', Data: '%4', NetId: '%5'", _uniqueID, _function, _call, _data, _netId];
#endif
if (_function == "" || count _data == 0) exitWith {
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_handler' Invalid Input for Function '%1' or Data '%2'", _function, _data];

View File

@ -30,9 +30,7 @@
params [["_key", "", [""]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashDeleteId' Key: '%1'", _key];
#endif
if (_key == "") exitWith {
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashDeleteId' Invalid Input for Key '%1'", _key];

View File

@ -33,9 +33,7 @@
params [["_keyField", "", [""]], ["_function", "", [""]], ["_call", false, [false]], ["_netId", "", [""]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashGet' KeyField: '%1', Function: '%2', Call: '%3', NetId: '%4'", _keyField, _function, _call, _netId];
#endif
if (_keyField == "" || _function == "") exitWith {
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashGet' Invalid Input for KeyField '%1' or Function '%2'", _keyField, _function];
@ -44,20 +42,14 @@ if (_keyField == "" || _function == "") exitWith {
private _return = "";
if (_netId != "") then {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashGet' Using NetId: '%1'", _netId];
#endif
if (_call) then {
_return = "ArmaRAMDb" callExtension ["hget", [_keyField, _function, _netId, _call]];
} else {
_return = "ArmaRAMDb" callExtension ["hget", [_keyField, _function, _netId]];
};
} else {
#ifdef __A3__DEBUG__
diag_log text "ArmaRAMDb: 'ramdb_db_fnc_hashGet' Using current player";
#endif
if (_call) then {
_return = "ArmaRAMDb" callExtension ["hget", [_keyField, _function, _call]];
} else {
@ -65,8 +57,5 @@ if (_netId != "") then {
};
};
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashGet' Return: '%1'", _return];
#endif
[(_return select 0)] call FUNC(scheduler);

View File

@ -32,9 +32,7 @@
params [["_function", "", [""]], ["_call", false, [false]], ["_netId", "", [""]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashGetAll' Function: '%1', Call: '%2', NetId: '%3'", _function, _call, _netId];
#endif
if (_function isEqualTo "") exitWith {
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashGetAll' Invalid Input for Function '%1'", _function];
@ -43,20 +41,14 @@ if (_function isEqualTo "") exitWith {
private _return = "";
if (_netId != "") then {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashGetAll' Using NetId: '%1'", _netId];
#endif
if (_call) then {
_return = "ArmaRAMDb" callExtension ["hgetall", [_function, _netId, _call]];
} else {
_return = "ArmaRAMDb" callExtension ["hgetall", [_function, _netId]];
};
} else {
#ifdef __A3__DEBUG__
diag_log text "ArmaRAMDb: 'ramdb_db_fnc_hashGetAll' Using current player";
#endif
if (_call) then {
_return = "ArmaRAMDb" callExtension ["hgetall", [_function, _call]];
} else {
@ -64,8 +56,5 @@ if (_netId != "") then {
};
};
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashGetAll' Return: '%1'", _return];
#endif
[(_return select 0)] call FUNC(scheduler);

View File

@ -33,9 +33,7 @@
params [["_key", "", [""]], ["_function", "", [""]], ["_call", false, [false]], ["_netId", "", [""]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashGetAllId' Key: '%1', Function: '%2', Call: '%3', NetId: '%4'", _key, _function, _call, _netId];
#endif
if (_key == "" || _function == "") exitWith {
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashGetAllId' Invalid Input for Key '%1' or Function '%2'", _key, _function];
@ -44,20 +42,14 @@ if (_key == "" || _function == "") exitWith {
private _return = "";
if (_netId != "") then {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashGetAllId' Using NetId: '%1'", _netId];
#endif
if (_call) then {
_return = "ArmaRAMDb" callExtension ["hgetallid", [_key, _function, _netId, _call]];
} else {
_return = "ArmaRAMDb" callExtension ["hgetallid", [_key, _function, _netId]];
};
} else {
#ifdef __A3__DEBUG__
diag_log text "ArmaRAMDb: 'ramdb_db_fnc_hashGetAllId' Using current player";
#endif
if (_call) then {
_return = "ArmaRAMDb" callExtension ["hgetallid", [_key, _function, _call]];
} else {
@ -65,8 +57,5 @@ if (_netId != "") then {
};
};
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashGetAllId' Return: '%1'", _return];
#endif
[(_return select 0)] call FUNC(scheduler);

View File

@ -34,9 +34,7 @@
params [["_key", "", [""]], ["_keyField", "", [""]], ["_function", "", [""]], ["_call", false, [false]], ["_netId", "", [""]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashGetId' Key: '%1', KeyField: '%2', Function: '%3', Call: '%4', NetId: '%5'", _key, _keyField, _function, _call, _netId];
#endif
if (_key == "" || _keyField == "" || _function == "") exitWith {
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashGetId' Invalid Input for Key '%1', KeyField '%2' or Function '%3'", _key, _keyField, _function];
@ -45,20 +43,14 @@ if (_key == "" || _keyField == "" || _function == "") exitWith {
private _return = "";
if (_netId != "") then {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashGetId' Using NetId: '%1'", _netId];
#endif
if (_call) then {
_return = "ArmaRAMDb" callExtension ["hgetid", [_key, _keyField, _function, _netId, _call]];
} else {
_return = "ArmaRAMDb" callExtension ["hgetid", [_key, _keyField, _function, _netId]];
};
} else {
#ifdef __A3__DEBUG__
diag_log text "ArmaRAMDb: 'ramdb_db_fnc_hashGetId' Using current player";
#endif
if (_call) then {
_return = "ArmaRAMDb" callExtension ["hgetid", [_key, _keyField, _function, _call]];
} else {
@ -66,8 +58,5 @@ if (_netId != "") then {
};
};
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashGetId' Return: '%1'", _return];
#endif
[(_return select 0)] call FUNC(scheduler);

View File

@ -30,9 +30,7 @@
params [["_keyField", "", [""]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashRemove' KeyField: '%1'", _keyField];
#endif
if (_keyField == "") exitWith {
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashRemove' Invalid Input for KeyField '%1'", _keyField];

View File

@ -31,9 +31,7 @@
params [["_key", "", [""]], ["_keyField", "", [""]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashRemoveId' Key: '%1', KeyField: '%2'", _key, _keyField];
#endif
if (_key == "" || _keyField == "") exitWith {
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashRemoveId' Invalid Input for Key '%1' or KeyField '%2'", _key, _keyField];

View File

@ -31,9 +31,7 @@
params [["_keyField", "", [""]], ["_data", [], [[]]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashSet' KeyField: '%1', Data: '%2'", _keyField, _data];
#endif
if (_keyField == "" || isNil "_data") exitWith {
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashSet' Invalid Input for KeyField '%1' or Data '%2'", _keyField, _data];

View File

@ -30,9 +30,7 @@
params [["_data", [], [[]]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashSetBulk' Data: %1", _data];
#endif
if (isNil "_data") exitWith {
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashSetBulk' Invalid Input for Data '%1'", _data];

View File

@ -32,9 +32,7 @@
params [["_key", "", [""]], ["_keyField", "", [""]], ["_data", [], [[]]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashSetId' Key: '%1', KeyField: '%2', Data: '%3'", _key, _keyField, _data];
#endif
if (_key == "" || _keyField == "" || isNil "_data") exitWith {
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashSetId' Invalid Input for Key '%1', KeyField '%2' or Data '%3'", _key, _keyField, _data];

View File

@ -30,9 +30,7 @@
params [["_data", [], [[]]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashSetIdBulk' Data: %1", _data];
#endif
if (isNil "_data") exitWith {
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_hashSetIdBulk' Invalid Input for Data '%1'", _data];

View File

@ -31,9 +31,7 @@
params [["_key", "", [""]], ["_data", [], [[]]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_listAdd' Key: '%1', Data: '%2'", _key, _data];
#endif
if (_key == "" || isNil "_data") exitWith {
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_listAdd' Invalid Input for Key '%1' or Data '%2'", _key, _data];

View File

@ -30,9 +30,7 @@
params [["_key", "", [""]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_listDelete' Key: '%1'", _key];
#endif
if (_key == "") exitWith {
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_listDelete' Invalid Input for Key '%1'", _key];

View File

@ -34,9 +34,7 @@
params [["_key", "", [""]], ["_index", -1, [0]], ["_function", "", [""]], ["_call", false, [false]], ["_netId", "", [""]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_listGet' Key: '%1', Index: '%2', Function: '%3', Call: '%4', NetId: '%5'", _key, _index, _function, _call, _netId];
#endif
if (_key == "" || _function == "") exitWith {
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_listGet' Invalid Input for Key '%1' or Function '%2'", _key, _function];
@ -45,20 +43,14 @@ if (_key == "" || _function == "") exitWith {
private _return = "";
if (_netId != "") then {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_listGet' Using NetId: '%1'", _netId];
#endif
if (_call) then {
_return = "ArmaRAMDb" callExtension ["listidx", [_key, _index, _function, _netId, _call]];
} else {
_return = "ArmaRAMDb" callExtension ["listidx", [_key, _index, _function, _netId]];
};
} else {
#ifdef __A3__DEBUG__
diag_log text "ArmaRAMDb: 'ramdb_db_fnc_listGet' Using current player";
#endif
if (_call) then {
_return = "ArmaRAMDb" callExtension ["listidx", [_key, _index, _function, _call]];
} else {
@ -66,8 +58,5 @@ if (_netId != "") then {
};
};
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_listGet' Return: '%1'", _return];
#endif
[(_return select 0)] call FUNC(scheduler);

View File

@ -33,9 +33,7 @@
params [["_key", "", [""]], ["_function", "", [""]], ["_call", false, [false]], ["_netId", "", [""]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_listLoad' Key: '%1', Function: '%2', Call: '%3', NetId: '%4'", _key, _function, _call, _netId];
#endif
if (_key == "" || _function == "") exitWith {
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_listLoad' Invalid Input for Key '%1' or Function '%2'", _key, _function];
@ -44,20 +42,14 @@ if (_key == "" || _function == "") exitWith {
private _return = "";
if (_netId != "") then {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_listLoad' Using NetId: '%1'", _netId];
#endif
if (_call) then {
_return = "ArmaRAMDb" callExtension ["listrng", [_key, 0, -1, _function, _netId, _call]];
} else {
_return = "ArmaRAMDb" callExtension ["listrng", [_key, 0, -1, _function, _netId]];
};
} else {
#ifdef __A3__DEBUG__
diag_log text "ArmaRAMDb: 'ramdb_db_fnc_listLoad' Using current player";
#endif
if (_call) then {
_return = "ArmaRAMDb" callExtension ["listrng", [_key, 0, -1, _function, _call]];
} else {
@ -65,8 +57,5 @@ if (_netId != "") then {
};
};
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_listLoad' Return: '%1'", _return];
#endif
[(_return select 0)] call FUNC(scheduler);

View File

@ -31,9 +31,7 @@
params [["_key", "", [""]], ["_index", -1, [0]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_listRemove' Key: '%1', Index: '%2'", _key, _index];
#endif
if (_key == "") exitWith {
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_listRemove' Invalid Input for Key '%1'", _key];

View File

@ -32,9 +32,7 @@
params [["_key", "", [""]], ["_index", -1, [0]], ["_data", [], [[]]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_listSet' Key: '%1', Index: '%2', Data: '%3'", _key, _index, _data];
#endif
if (_key == "" || isNil "_data") exitWith {
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_listSet' Invalid Input for Key '%1' or Data '%2'", _key, _data];

View File

@ -41,123 +41,25 @@ while { count GVAR(taskQueue) > 0} do {
private _call = _task select 6;
private _netId = _task select 7;
#ifdef __A3__DEBUG__
diag_log text format ["Initializing Task: %1", _task];
#endif
switch (_taskType) do {
case "get": {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _function, _call, _netId] call FUNC(get);
};
case "set": {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _value] call FUNC(set);
};
case "del": {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key] call FUNC(delete);
};
case "hget": {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_keyField, _function, _call, _netId] call FUNC(hashGet);
};
case "hgetid": {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _keyField, _function, _call, _netId] call FUNC(hashGetId);
};
case "hgetall": {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_function, _call, _netId] call FUNC(hashGetAll);
};
case "hgetallid": {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _function, _call, _netId] call FUNC(hashGetAllId);
};
case "hset": {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_keyField, _value] call FUNC(hashSet);
};
case "hsetbulk": {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_value] call FUNC(hashSetBulk);
};
case "hsetid": {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _keyField, _value] call FUNC(hashSetId);
};
case "hsetidbulk": {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_value] call FUNC(hashSetIdBulk);
};
case "listadd": {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _value] call FUNC(listAdd);
};
case "listidx": {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _index, _function, _call, _netId] call FUNC(listGet);
};
case "listrng": {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _function, _call, _netId] call FUNC(listLoad);
};
case "listrem": {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _index] call FUNC(listRemove);
};
case "listset": {
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType];
#endif
[_key, _index, _value] call FUNC(listSet);
};
case "get": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _function, _call, _netId] call FUNC(get); };
case "set": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _value] call FUNC(set); };
case "del": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key] call FUNC(delete); };
case "hget": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_keyField, _function, _call, _netId] call FUNC(hashGet); };
case "hgetid": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _keyField, _function, _call, _netId] call FUNC(hashGetId); };
case "hgetall": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_function, _call, _netId] call FUNC(hashGetAll); };
case "hgetallid": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _function, _call, _netId] call FUNC(hashGetAllId); };
case "hset": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_keyField, _value] call FUNC(hashSet); };
case "hsetbulk": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_value] call FUNC(hashSetBulk); };
case "hsetid": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _keyField, _value] call FUNC(hashSetId); };
case "hsetidbulk": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_value] call FUNC(hashSetIdBulk); };
case "listadd": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _value] call FUNC(listAdd); };
case "listidx": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _index, _function, _call, _netId] call FUNC(listGet); };
case "listrng": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _function, _call, _netId] call FUNC(listLoad); };
case "listrem": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _index] call FUNC(listRemove); };
case "listset": { diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _index, _value] call FUNC(listSet); };
};
sleep 1;

View File

@ -31,9 +31,7 @@
params [["_key", "", [""]], ["_data", "", [[]]]];
#ifdef __A3__DEBUG__
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_set' Key: '%1', Data: '%2'", _key, _data];
#endif
if (_key == "" || isNil "_data") exitWith {
diag_log text format ["ArmaRAMDb: 'ramdb_db_fnc_set' Invalid Input for Key '%1' or Data '%2'", _key, _data];

View File

@ -22,8 +22,14 @@ namespace ArmaRAMDb
lock (list)
{
// Store the raw value without any formatting
if (value.StartsWith('[') && value.EndsWith(']'))
{
list.Add(value);
}
else
{
list.Add($"[\"{value}\"]");
}
Main.Log($"ListAdd: {listName} - Value: {value}", "debug");
}
}
@ -47,13 +53,6 @@ namespace ArmaRAMDb
{
int idx = int.Parse(index);
string value = idx >= 0 && idx < list.Count ? list[idx] : string.Empty;
// Format the value if it's not already formatted as an array
if (!string.IsNullOrEmpty(value) && !(value.StartsWith('[') && value.EndsWith(']')))
{
value = $"[\"{value.Replace("\"", "\\\"")}\"]";
}
Main.Log($"ListIndex: {listName} - Index: {idx} - Value: {value}", "debug");
Utils.CheckByteCount(uniqueId, value, function, entity, Convert.ToBoolean(call), bufferSize);
}
@ -81,11 +80,7 @@ namespace ArmaRAMDb
{
int count = end - start + 1;
var value = list.GetRange(start, count);
// Format each item as a JSON string if it's not already
var formattedItems = value.Select(item => (item.StartsWith('[') && item.EndsWith(']')) ? item : $"[\"{item.Replace("\"", "\\\"")}\"]");
string data = string.Join(",", formattedItems);
string data = string.Join(",", value);
Main.Log($"ListRange: {listName} - StartIndex: {start} - EndIndex: {end} - Count: {count}", "debug");
Utils.CheckByteCount(uniqueId, $"[{data}]", function, entity, Convert.ToBoolean(call), bufferSize);
}
@ -114,8 +109,14 @@ namespace ArmaRAMDb
int idx = int.Parse(index);
if (idx >= 0 && idx < list.Count)
{
// Store the value as-is, just like ListAddAsync
if (value.StartsWith('[') && value.EndsWith(']'))
{
list[idx] = value;
}
else
{
list[idx] = $"[\"{value}\"]";
}
Main.Log($"ListSet: {listName} - Index: {idx} - Value: {value}", "debug");
}
}

View File

@ -18,7 +18,7 @@ namespace ArmaRAMDb
public class Main
{
private const string ARDB_VERSION = "1.0.0";
public const int ARDB_BUFFERSIZE = 10240;
public const int ARDB_BUFFERSIZE = 1024;
public static readonly string DEFAULT_ARDB_PATH = $"@ramdb{Path.DirectorySeparatorChar}ArmaRAMDb.ardb";
public static string ARDB_LOGFOLDER { get; private set; } = $"{Path.DirectorySeparatorChar}@ramdb{Path.DirectorySeparatorChar}logs";
public static bool ARDB_DEBUG {get; private set; } = false;

View File

@ -24,76 +24,16 @@ namespace ArmaRAMDb
return str;
}
public static List<string> SplitIntoChunks(string data, int maxChunkSize)
public static List<string> SplitIntoChunks(string data, int chunkSize)
{
int chunksNeeded = (int)Math.Ceiling((double)data.Length / chunkSize);
List<string> chunks = [];
if (data.StartsWith("[") && data.EndsWith("]"))
for (int i = 0; i < chunksNeeded; i++)
{
string innerData = data[1..^1];
List<string> elements = [];
int depth = 0;
int startPos = 0;
for (int i = 0; i < innerData.Length; i++)
{
char c = innerData[i];
if (c == '[') depth++;
else if (c == ']') depth--;
else if (c == ',' && depth == 0)
{
elements.Add(innerData[startPos..i]);
startPos = i + 1;
}
}
if (startPos < innerData.Length)
{
elements.Add(innerData[startPos..]);
}
StringBuilder currentChunk = new StringBuilder();
foreach (string element in elements)
{
if (currentChunk.Length > 0 &&
Encoding.UTF8.GetByteCount(currentChunk.ToString() + "," + element) > maxChunkSize)
{
chunks.Add(currentChunk.ToString());
currentChunk.Clear();
}
if (currentChunk.Length > 0)
{
currentChunk.Append(",");
}
currentChunk.Append(element);
}
if (currentChunk.Length > 0)
{
chunks.Add(currentChunk.ToString());
}
}
else
{
int bytesProcessed = 0;
while (bytesProcessed < Encoding.UTF8.GetByteCount(data))
{
int charCount = 0;
while (bytesProcessed + Encoding.UTF8.GetByteCount(data.Substring(bytesProcessed, Math.Min(charCount + 1, data.Length - bytesProcessed))) <= maxChunkSize &&
bytesProcessed + charCount < data.Length)
{
charCount++;
}
chunks.Add(data.Substring(bytesProcessed, charCount));
bytesProcessed += charCount;
}
int start = i * chunkSize;
int end = Math.Min(data.Length, start + chunkSize);
chunks.Add(data[start..end]);
}
return chunks;
@ -105,122 +45,26 @@ namespace ArmaRAMDb
{
if (!data.StartsWith('['))
data = BuildArray(data);
Main.Log($"Single chunk data: {data}", "debug");
Main.Log($"{data}", "debug");
string dataAsString = $"[\"{uniqueId}\",\"{function}\",{call.ToString().ToLower()},{data},\"{entity}\"]";
string dataAsString = $"[\"{uniqueId}\",\"{function}\",{call},{data},\"{entity}\"]";
Main.Log($"{dataAsString}", "debug");
Main.Callback("ArmaRAMDb", "ramdb_db_fnc_handler", dataAsString);
}
else
{
if (!data.StartsWith('[') || !data.EndsWith(']'))
{
if (!data.StartsWith('['))
data = BuildArray(data);
}
Main.Log($"{data}", "debug");
var chunks = SplitIntoChunks(data, bufferSize);
int totalChunks = chunks.Count;
List<string> elements = ParseArrayElements(data);
int totalChunks = CalculateChunks(elements, bufferSize);
for (int chunkIndex = 0; chunkIndex < totalChunks; chunkIndex++)
foreach (string chunk in chunks)
{
List<string> chunkElements = GetChunkElements(elements, chunkIndex, totalChunks);
string chunkData = "[" + string.Join(",", chunkElements) + "]";
string escapedChunkData = chunkData.Replace("\"", "\"\"");
string chunkAsString = $"[\"{uniqueId}\",\"{function}\",{chunkIndex+1},{totalChunks},\"{escapedChunkData}\",{call.ToString().ToLower()},\"{entity}\"]";
Main.Log($"Sending chunk {chunkIndex+1}/{totalChunks}: {chunkAsString}", "debug");
string chunkAsString = $"[{uniqueId},{function},{chunks.IndexOf(chunk)},{totalChunks},\"{chunk}\",{call},\"{entity}\"]";
Main.Callback("ArmaRAMDb", "ramdb_db_fnc_fetch", chunkAsString);
}
}
}
private static List<string> ParseArrayElements(string arrayString)
{
List<string> elements = [];
string content = arrayString[1..^1].Trim();
if (string.IsNullOrEmpty(content))
return elements;
int startPos = 0;
int nestLevel = 0;
bool inQuotes = false;
for (int i = 0; i < content.Length; i++)
{
char c = content[i];
if (c == '\\' && i + 1 < content.Length && content[i + 1] == '"')
{
i++;
continue;
}
if (c == '"')
inQuotes = !inQuotes;
if (!inQuotes)
{
if (c == '[') nestLevel++;
else if (c == ']') nestLevel--;
if (nestLevel == 0 && c == ',')
{
elements.Add(content[startPos..i].Trim());
startPos = i + 1;
}
}
}
if (startPos < content.Length)
{
elements.Add(content[startPos..].Trim());
}
return elements;
}
private static int CalculateChunks(List<string> elements, int bufferSize)
{
int chunks = 1;
int currentSize = 2;
foreach (string element in elements)
{
int elementSize = Encoding.UTF8.GetByteCount(element) + 1;
if (currentSize + elementSize > bufferSize)
{
chunks++;
currentSize = 2 + elementSize;
}
else
{
currentSize += elementSize;
}
}
return chunks;
}
private static List<string> GetChunkElements(List<string> allElements, int chunkIndex, int totalChunks)
{
int elementsPerChunk = (int)Math.Ceiling((double)allElements.Count / totalChunks);
int startIdx = chunkIndex * elementsPerChunk;
int count = Math.Min(elementsPerChunk, allElements.Count - startIdx);
List<string> result = [];
for (int i = 0; i < count; i++)
{
if (startIdx + i < allElements.Count)
result.Add(allElements[startIdx + i]);
}
return result;
}
}
}