Jazz 1.26.+
Loading...
Searching...
No Matches
container.h
1/* Jazz (c) 2018-2026 kaalam.ai (The Authors of Jazz), using (under the same license):
2
3 1. Biomodelling - The AATBlockQueue class (c) Jacques BasaldĂșa, 2009-2012 licensed
4 exclusively for the use in the Jazz server software.
5
6 Copyright 2009-2012 Jacques BasaldĂșa
7
8 2. BBVA - Jazz: A lightweight analytical web server for data-driven applications.
9
10 Copyright 2016-2017 Banco Bilbao Vizcaya Argentaria, S.A.
11
12 This product includes software developed at
13
14 BBVA (https://www.bbva.com/)
15
16 3. LMDB, Copyright 2011-2017 Howard Chu, Symas Corp. All rights reserved.
17
18 Licensed under http://www.OpenLDAP.org/license.html
19
20
21 Licensed under the Apache License, Version 2.0 (the "License");
22 you may not use this file except in compliance with the License.
23 You may obtain a copy of the License at
24
25 http://www.apache.org/licenses/LICENSE-2.0
26
27 Unless required by applicable law or agreed to in writing, software
28 distributed under the License is distributed on an "AS IS" BASIS,
29 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30 See the License for the specific language governing permissions and
31 limitations under the License.
32*/
33
34
35#include <map>
36#include <atomic>
37#include <thread>
38#include <regex>
39
40
41#include "src/jazz_elements/tuple.h"
42
43#ifdef CATCH_TEST
44#ifndef INCLUDED_JAZZ_CATCH2
45#define INCLUDED_JAZZ_CATCH2
46
47#include "src/catch2/catch.hpp"
48
49#endif
50#endif
51
52
53#ifndef INCLUDED_JAZZ_ELEMENTS_CONTAINER
54#define INCLUDED_JAZZ_ELEMENTS_CONTAINER
55
56namespace jazz_elements
57{
58
60#define MAX_SIZE_OF_CELL_AS_TEXT 48
61
63#define NA_AS_TEXT {"NA\0"}
64#define LENGTH_NA_AS_TEXT 2
65
67#define PARSE_ERROR_UNEXPECTED_EOF 101
68#define PARSE_ERROR_UNEXPECTED_CHAR 102
69#define PARSE_ERROR_ITEM_NAME 103
70#define PARSE_ERROR_ITEM_NAME_MISMATCH 104
71#define PARSE_ERROR_TENSOR_EXPLORATION 105
72
73#define PARSE_ERROR_KIND_EXPLORATION 106
74#define PARSE_ERROR_TOO_MANY_ITEMS 107
75#define PARSE_ERROR_EXPECTED_EOF 108
76#define PARSE_ERROR_TENSOR_FILLING 109
77#define PARSE_ERROR_TEXT_FILLING 110
78
80#define FILL_NEW_DONT_FILL 0
81#define FILL_NEW_WITH_ZERO 1
82#define FILL_NEW_WITH_NA 2
83#define FILL_WITH_TEXTFILE 3
84
85#define BUILD_TUPLE 1
86#define BUILD_KIND 2
87
89#define BLOCK_STATUS_READY 0
90#define BLOCK_STATUS_EMPTY 1
91#define BLOCK_STATUS_DESTROYED 2
92
94#define LOCK_NUM_RETRIES_BEFORE_YIELD 100
95
97#define LOCK_WEIGHT_OF_WRITE 46341
98
99// State based parser types:
100#define EIGHT_BIT_LONG 256
101#define MAX_TRANSITION_REGEX_LEN 32
102#define PSTATE_INVALID_CHAR 255
103
104// Writing modes for put(1): What to do is block exists:
105#define WRITE_ONLY_IF_EXISTS 0x01
106#define WRITE_ONLY_IF_NOT_EXISTS 0x02
107#define WRITE_ANY_RESTRICTION 0x03
108
109// Writing modes for put(2): What to write
110#define WRITE_AS_BASE_DEFAULT 0x00
111#define WRITE_AS_STRING 0x04
112#define WRITE_AS_CONTENT 0x08
113#define WRITE_AS_FULL_BLOCK 0x10
114#define WRITE_AS_ANY_WRITE 0x1C
115
116// Bit masks to trigger failures in tests when set in debug_trigger_failure
117#define TRIGGER_FAIL_TEXT_BLOCK 0x01
118#define TRIGGER_FAIL_FILL_TENSOR 0x02
119#define TRIGGER_FAIL_NEW_STRING_BLOCK 0x04
120
121
125 unsigned char next[EIGHT_BIT_LONG];
126};
127
128
132 int from;
133 int to;
134 char rex[MAX_TRANSITION_REGEX_LEN];
135};
136
137
145void compile_next_state_LUT(ParseNextStateLUT lut[], int num_states, ParseStateTransition trans[]);
146
147
149typedef std::atomic<int32_t> Lock32;
150
151
153typedef class Container *pContainer;
154
155
157typedef std::map<String, pContainer> BaseNames;
158
159
177
178
179typedef struct ExtraLocator *pExtraLocator;
180
189struct Locator {
190 char base [SHORT_NAME_SIZE];
193
194 union {
197 };
198};
200
201
207
208
210typedef std::map<String, int> MapSI;
211
212
287class Container : public Service {
288
289 public:
290
291 Container(pLogger a_logger, pConfigFile a_config);
292 ~Container();
293
294 // Service API
295
296 StatusCode start ();
298
299 // .enter_read() .enter_write() .leave_read() .leave_write() .lock_container() .unlock_container()
300
301 void enter_read (pTransaction p_txn);
302 void enter_write(pTransaction p_txn, int total_times = 0);
303 void leave_read (pTransaction p_txn);
304 void leave_write(pTransaction p_txn);
305
306 // - Allocation: .new_block(), .destroy_transaction()
307
308 // 1. new_block(): Create a Tensor from raw data specifying everything from scratch.
310 int cell_type,
311 int *dim,
312 int fill_tensor = FILL_NEW_DONT_FILL,
313 int stringbuff_size = 0,
314 const char *p_text = nullptr,
315 char eol = '\n',
316 AttributeMap *att = nullptr);
317
318 // 2. new_block(): Create a Kind or Tuple from arrays of StaticBlockHeader, names, and, in the case of a tuple, Tensors.
320 int num_items,
321 StaticBlockHeader p_hea[],
322 Name p_names[],
323 pBlock p_block[],
324 AttributeMap *dims = nullptr,
325 AttributeMap *att = nullptr);
326
327 // 3. new_block(): Create a Tensor by selecting rows (filtering) from another Tensor.
329 pBlock p_from,
330 pBlock p_row_filter,
331 AttributeMap *att = nullptr);
332
333 // 4. new_block(): Create a Tensor by selecting an item from a Tuple.
335 pTuple p_from,
336 pChar name,
337 AttributeMap *att = nullptr);
338
339 // 5. new_block(): Create a Tensor, Kind or Tuple from a Text block kept as a Tensor of CELL_TYPE_BYTE of rank == 1.
341 pBlock p_from_text,
342 int cell_type,
343 pKind p_as_kind = nullptr,
344 AttributeMap *att = nullptr);
345
346 // 6. new_block(): Create a Tensor of CELL_TYPE_BYTE of rank == 1 with a text serialization of a Tensor, Kind or Tuple.
348 pBlock p_from_raw,
349 pChar p_fmt = nullptr,
350 bool ret_as_string = false,
351 AttributeMap *att = nullptr);
352
353 // 7. new_block(): Create an empty Index block.
355 int cell_type);
356
357 // 8. new_block(): Create a Tuple of (key:STRING[length],value:STRING[length]) with the content of an Index.
359 Index &index);
360
361 // Support for transactions creation/destruction
362
364 virtual void destroy_transaction (pTransaction &p_txn);
365
366 // Crud: .get(), .header(), .put(), .new_entity(), .remove(), .copy()
367
368 // The "easy" interface: Uses strings instead of locators. Is translated to the native interface by an as_locator() call.
369 virtual StatusCode get (pTransaction &p_txn,
370 pChar p_what);
371 virtual StatusCode get (pTransaction &p_txn,
372 pChar p_what,
373 pBlock p_row_filter);
374 virtual StatusCode get (pTransaction &p_txn,
375 pChar p_what,
376 pChar name);
377 virtual StatusCode locate (Locator &location,
378 pChar p_what);
379 virtual StatusCode header (StaticBlockHeader &hea,
380 pChar p_what);
381 virtual StatusCode header (pTransaction &p_txn,
382 pChar p_what);
383 virtual StatusCode put (pChar p_where,
384 pBlock p_block,
385 int mode = WRITE_AS_BASE_DEFAULT);
386 virtual StatusCode new_entity (pChar p_where);
387 virtual StatusCode remove (pChar p_where);
388 virtual StatusCode copy (pChar p_where,
389 pChar p_what);
390
391 // The function call interface: exec()/modify().
392 virtual StatusCode exec (pTransaction &p_txn,
393 Locator &function,
394 pTuple p_args);
395 virtual StatusCode modify (Locator &function,
396 pTuple p_args);
397
398 // The parser: This simple regex-based parser only needs override for Channels.
399 virtual StatusCode as_locator (Locator &result,
400 pChar p_what);
401
402 // The "native" interface: This is what really does the job and all Container descendants implement.
403 virtual StatusCode get (pTransaction &p_txn,
404 Locator &what);
405 virtual StatusCode get (pTransaction &p_txn,
406 Locator &what,
407 pBlock p_row_filter);
408 virtual StatusCode get (pTransaction &p_txn,
409 Locator &what,
410 pChar name);
411 virtual StatusCode locate (Locator &location,
412 Locator &what);
413 virtual StatusCode header (StaticBlockHeader &hea,
414 Locator &what);
415 virtual StatusCode header (pTransaction &p_txn,
416 Locator &what);
417 virtual StatusCode put (Locator &where,
418 pBlock p_block,
419 int mode = WRITE_AS_BASE_DEFAULT);
420 virtual StatusCode new_entity (Locator &where);
421 virtual StatusCode remove (Locator &where);
422 virtual StatusCode copy (Locator &where,
423 Locator &what);
424
439
440 if (p_txn->p_block->cell_type == CELL_TYPE_STRING)
441 if (p_txn->p_block->size == 1)
442 return SERVICE_NO_ERROR; // The block is already a string, we just leave it as it is.
443 else {
444 destroy_transaction(p_txn);
445
446 return SERVICE_ERROR_WRONG_TYPE;
447 }
448
449 if ((p_txn->p_block->cell_type != CELL_TYPE_BYTE) || (p_txn->p_block->rank != 1)) {
450 destroy_transaction(p_txn);
451
452 return SERVICE_ERROR_WRONG_TYPE;
453 }
454
455 pBlock p_blk = (pBlock) &p_txn->p_block->tensor.cell_byte[0];
456 int size = p_txn->p_block->size;
457
458 if (p_blk->total_bytes == size && p_blk->check_hash()) {
459 pBlock p_new = block_malloc(size);
460 if (p_new == nullptr) {
461 destroy_transaction(p_txn);
462
463 return SERVICE_ERROR_NO_MEM;
464 }
465 memcpy(p_new, p_blk, size);
466
467 alloc_bytes -= p_txn->p_block->total_bytes;
468 free(p_txn->p_block);
469
470 p_txn->p_block = p_new;
471
472 return SERVICE_NO_ERROR;
473 }
474
475 int block_len = strnlen((pChar) p_blk, size);
476 if (block_len < size - 1)
477 return SERVICE_NO_ERROR; // This is when the content is not a string, we just leave it as it is.
478
479 pTransaction p_aux;
480
481 reinterpret_cast <pChar>(p_blk)[size] = 0;
482
483 if (new_block(p_aux, CELL_TYPE_STRING, nullptr, FILL_WITH_TEXTFILE, 0, (pChar) p_blk, 0) != SERVICE_NO_ERROR) {
484 destroy_transaction(p_txn);
485
486 return SERVICE_ERROR_NO_MEM;
487 }
488 std::swap(p_txn->p_block, p_aux->p_block);
489
490 destroy_transaction(p_aux);
491
492 return SERVICE_NO_ERROR;
493 }
494
506 inline StatusCode unwrap_received(pTransaction &p_txn, pBlock p_maybe_block, int rec_size) {
507
508 if (rec_size > sizeof(BlockHeader) && p_maybe_block->total_bytes == rec_size && p_maybe_block->check_hash()) {
509 int ret = new_transaction(p_txn);
510
511 if (ret != SERVICE_NO_ERROR)
512 return ret;
513
514 pBlock p_new = block_malloc(rec_size);
515 if (p_new == nullptr) {
516 destroy_transaction(p_txn);
517
518 return SERVICE_ERROR_NO_MEM;
519 }
520 memcpy(p_new, p_maybe_block, rec_size);
521
522 p_txn->p_block = p_new;
523 p_txn->status = BLOCK_STATUS_READY;
524
525 return SERVICE_NO_ERROR;
526 }
527 if (strnlen((pChar) p_maybe_block, rec_size) != rec_size) {
528 int dim[MAX_TENSOR_RANK] = {rec_size, 0};
529 int ret = new_block(p_txn, CELL_TYPE_BYTE, dim, FILL_NEW_DONT_FILL);
530
531 if (ret == SERVICE_NO_ERROR)
532 memcpy(&p_txn->p_block->tensor.cell_byte[0], p_maybe_block, rec_size);
533
534 return ret;
535 }
536
537 return new_block(p_txn, CELL_TYPE_STRING, nullptr, FILL_WITH_TEXTFILE, 0, (pChar) p_maybe_block, 0);
538 }
539
540 // Support for container names in the BaseAPI .base_names()
541
543
544#ifndef CATCH_TEST
545 protected:
546#endif
547
553 inline void* malloc(size_t size) {
554 if (alloc_bytes + size >= fail_alloc_bytes)
555 return nullptr;
556
557 void * ret = std::malloc(size);
558
559 if (ret != nullptr)
560 alloc_bytes += size;
561
562 return ret;
563 }
564
570 inline pBlock block_malloc(size_t size) {
571 pBlock p_blk = (pBlock) malloc(size);
572
573 if (p_blk != nullptr) {
574 p_blk->cell_type = 0;
575 p_blk->total_bytes = 0;
576 }
577
578 return p_blk;
579 }
580
587 inline void lock_container(int total_times = 0) {
588 int retry = 0;
589
590 while (true) {
591 int32_t lock = 0;
592 int32_t next = 1;
593 if (_lock_.compare_exchange_weak(lock, next))
594 return;
595
596 if (++retry > LOCK_NUM_RETRIES_BEFORE_YIELD) {
597 std::this_thread::yield();
598 retry = 0;
599 if (total_times) {
600 if (--total_times == 0)
601 return;
602 }
603 }
604 }
605 }
606
610 _lock_ = 0;
611 }
612
614
620 inline int from_hex(char c) {
621 return (c < 65) ? c - 48 : (c > 96) ? c - 87 : c - 55;
622 }
623
627 uint64_t alloc_bytes;
632 int log_error_level = LOG_ERROR;
633
634#ifndef CATCH_TEST
635 private:
636#endif
637
638 char HEX[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
639
641
649 inline int skip_space(pChar &p_in, int &num_bytes) {
650 while (num_bytes > 0) {
651 if (*p_in == 0)
652 return 0;
653
654 if (*p_in == ' ' || *p_in == '\t' || *p_in == '\n') {
655 p_in++;
656 num_bytes--;
657 } else
658 break;
659 }
660
661 return num_bytes;
662 }
663
671 inline char get_char(pChar &p_in, int &num_bytes) {
672 if (num_bytes < 1)
673 return 0;
674
675 num_bytes--;
676
677 return *(p_in++);
678 }
679
691 inline bool get_item_name(pChar &p_in,
692 int &num_bytes,
693 pChar p_out,
694 bool check_quotes = true,
695 bool check_colon = true,
696 bool dot_ended = false) {
697 if (skip_space(p_in, num_bytes) <= 1)
698 return false;
699
700 if (check_quotes && (get_char(p_in, num_bytes) != '"'))
701 return false;
702
703 char ch = get_char(p_in, num_bytes);
704
705 if (ch < 'A' || ch > 'z' || (ch > 'Z' && ch < 'a'))
706 return false;
707
708 *(p_out++) = ch;
709
710 for (int i = 1; i < NAME_LENGTH; i++) {
711 if (!check_quotes && (*p_in == ',' || *p_in == ']'))
712 break;
713
714 if (dot_ended && (*p_in == '.'))
715 break;
716
717 ch = get_char(p_in, num_bytes);
718
719 if ((check_quotes || dot_ended) && ch == '"')
720 break;
721
722 if (ch < '0' || ch > 'z' || (ch > '9' && ch < 'A') || (ch > 'Z' && ch < '_') || ch == 0x60)
723 return false;
724
725 *(p_out++) = ch;
726 }
727
728 *p_out = 0;
729
730 if (check_quotes && (ch != '"') && (get_char(p_in, num_bytes) != '"'))
731 return false;
732
733 if (check_colon) {
734 if (skip_space(p_in, num_bytes) <= 1)
735 return false;
736
737 if (get_char(p_in, num_bytes) != ':')
738 return false;
739 }
740
741 return true;
742 }
743
752 inline bool sscanf_int32(pChar &p_in, int &num_bytes, int &result) {
753 int r_len;
754
755 if (sscanf(p_in, "%i%n", &result, &r_len) > 0) {
756 p_in += r_len;
757 num_bytes -= r_len;
758
759 return num_bytes >= 0;
760 } else
761 return false;
762 }
763
772 inline bool push_int_cell(pChar cell, pChar &p_st, int * &p_out) {
773
774 if (p_st == cell) {
775 *(p_out++) = INTEGER_NA;
776
777 return true;
778 }
779 *p_st = 0;
780 p_st = cell;
781
782 if (sscanf(p_st, "%i", p_out) != 1)
783 return false;
784
785 p_out++;
786
787 return true;
788 }
789
798 inline bool push_int_cell(pChar cell, pChar &p_st, long long * &p_out) {
799
800 if (p_st == cell) {
801 *(p_out++) = LONG_INTEGER_NA;
802
803 return true;
804 }
805 *p_st = 0;
806 p_st = cell;
807
808 if (sscanf(p_st, "%lli", p_out) != 1)
809 return false;
810
811 p_out++;
812
813 return true;
814 }
815
824 inline bool push_bool_cell(pChar cell, pChar &p_st, bool * &p_out) {
825
826 if (p_st == cell) {
827 *reinterpret_cast<uint8_t *>(p_out++) = BYTE_BOOLEAN_NA;
828
829 return true;
830 }
831 *p_st = 0;
832 p_st = cell;
833
834 *(p_out++) = cell[0] == '1';
835
836 return true;
837 }
838
847 inline bool push_bool_cell(pChar cell, pChar &p_st, uint32_t * &p_out) {
848
849 if (p_st == cell) {
850 *(p_out++) = BOOLEAN_NA;
851
852 return true;
853 }
854 *p_st = 0;
855 p_st = cell;
856
857 *(p_out++) = cell[0] == '1';
858
859 return true;
860 }
861
870 inline bool push_real_cell(pChar cell, pChar &p_st, float * &p_out) {
871
872 if (p_st == cell) {
873 *(p_out++) = SINGLE_NA;
874
875 return true;
876 }
877 *p_st = 0;
878 p_st = cell;
879
880 if (sscanf(p_st, "%f", p_out) != 1)
881 return false;
882
883 p_out++;
884
885 return true;
886 }
887
896 inline bool push_real_cell(pChar cell, pChar &p_st, double * &p_out) {
897
898 if (p_st == cell) {
899 *(p_out++) = DOUBLE_NA;
900
901 return true;
902 }
903 *p_st = 0;
904 p_st = cell;
905
906 if (sscanf(p_st, "%lf", p_out) != 1)
907 return false;
908
909 p_out++;
910
911 return true;
912 }
913
923 inline bool push_time_cell(pChar cell, pChar &p_st, time_t * &p_out, pChar fmt) {
924
925 if (p_st == cell) {
926 *(p_out++) = TIME_POINT_NA;
927
928 return true;
929 }
930 *p_st = 0;
931 p_st = cell;
932
933 struct tm timeinfo = {0};
934
935 if (strptime(p_st, fmt, &timeinfo) == nullptr)
936 return false;
937
938 time_t xx = timegm(&timeinfo);
939 if (xx < 0) return false;
940
941 *(p_out++) = xx;
942
943 return true;
944 }
945
946 bool get_type_and_shape (pChar &p_in, int &num_bytes, ItemHeader *item_hea, MapSI &dims);
947 bool get_shape_and_size (pChar &p_in, int &num_bytes, int cell_type, ItemHeader *item_hea);
948 bool fill_text_buffer (pChar &p_in, int &num_bytes, pChar p_out, int num_cells, int is_NA[], int hasLN[]);
949 bool fill_tensor (pChar &p_in, int &num_bytes, pBlock p_block);
950
951 int new_text_block (pTransaction &p_txn, ItemHeader &item_hea, pChar &p_in, int &num_bytes, AttributeMap *att = nullptr);
952
953 int tensor_int_as_text (pBlock p_block, pChar p_dest, pChar p_fmt);
954 int tensor_bool_as_text (pBlock p_block, pChar p_dest);
955 int tensor_float_as_text (pBlock p_block, pChar p_dest, pChar p_fmt);
956 int tensor_string_as_text(pBlock p_block, pChar p_dest);
957 int tensor_time_as_text (pBlock p_block, pChar p_dest, pChar p_fmt);
958 int tuple_as_text (pTuple p_tuple, pChar p_dest, pChar p_fmt, int item_len[]);
959 int kind_as_text (pKind p_kind, pChar p_dest);
960
966 inline void opening_brackets(int rank, pChar &p_ret) {
967 for (int i = 0; i < rank; i++)
968 *(p_ret++) = '[';
969
970 *p_ret = 0;
971 }
972
982 inline pChar as_shape(int rank, int dim[], pChar p_ret, pKind p_kind) {
983 *(p_ret++) = '[';
984
985 for (int i = 0; i < rank; i++) {
986 int k = dim[i];
987 if (k < 0) {
988 char *p_dim_name = &p_kind->p_string_buffer()->buffer[-k];
989 strcpy(p_ret, p_dim_name);
990 p_ret += strlen(p_dim_name);
991
992 } else
993 p_ret += sprintf(p_ret, "%i", k);
994
995 if (i < rank - 1) {
996 *(p_ret++) = ',';
997 *(p_ret++) = ' ';
998 }
999 }
1000
1001 *(p_ret++) = ']';
1002
1003 *p_ret = 0;
1004
1005 return p_ret;
1006 }
1007
1013 inline void as_hex(pChar &p_dest, uint8_t bl) {
1014 *(p_dest++) = '\\';
1015 *(p_dest++) = 'x';
1016 *(p_dest++) = HEX[bl >> 4];
1017 *(p_dest++) = HEX[bl & 0x0f];
1018 }
1019
1027 inline void separator(int rank_1, int dim[], int idx[], pChar &p_ret) {
1028 for (int i = rank_1; i >= 0; i--) {
1029 idx[i]++;
1030
1031 if (idx[i] == dim[i]) {
1032 idx[i] = 0;
1033 *(p_ret++) = ']';
1034 } else {
1035 *(p_ret++) = ',';
1036 *(p_ret++) = ' ';
1037
1038 for (int j = 0; j < rank_1 - i; j++)
1039 *(p_ret++) = '[';
1040
1041 break;
1042 }
1043 }
1044 *p_ret = 0;
1045 }
1046
1055 inline int separator_len(int rank_1, int dim[], int idx[]) {
1056 int ret = 0;
1057
1058 for (int i = rank_1; i >= 0; i--) {
1059 idx[i]++;
1060
1061 if (idx[i] == dim[i]) {
1062 idx[i] = 0;
1063 ret++;
1064 } else {
1065 ret += 2;
1066
1067 if (i == rank_1)
1068 return ret;
1069
1070 ret += rank_1 - i;
1071
1072 return ret;
1073 }
1074 }
1075 return ret;
1076 }
1077
1078#ifdef CATCH_TEST
1079 uint32_t debug_trigger_failure = 0;
1080#endif
1081
1082};
1083
1084// Instancing container, logger and config
1085// ---------------------------------------
1086
1089
1090#ifdef CATCH_TEST
1091
1092void compare_full_blocks(pBlock p_bl1, pBlock p_bl2, bool skip_value_check = false);
1093
1094extern Container CNT;
1095
1096#endif
1097
1098} // namespace jazz_elements
1099
1100#endif // ifndef INCLUDED_JAZZ_ELEMENTS_CONTAINER
pStringBuffer p_string_buffer()
Definition block.h:363
A configuration file as a key/value store.
Definition utils.h:218
Container: A Service to manage Jazz blocks. All Jazz blocks are managed by this or a descendant of th...
Definition container.h:287
StatusCode start()
Definition container.cpp:292
bool fill_text_buffer(pChar &p_in, int &num_bytes, pChar p_out, int num_cells, int is_NA[], int hasLN[])
Definition container.cpp:2638
int tensor_float_as_text(pBlock p_block, pChar p_dest, pChar p_fmt)
Definition container.cpp:3623
bool push_bool_cell(pChar cell, pChar &p_st, uint32_t *&p_out)
Definition container.h:847
int tuple_as_text(pTuple p_tuple, pChar p_dest, pChar p_fmt, int item_len[])
Definition container.cpp:3968
int new_text_block(pTransaction &p_txn, ItemHeader &item_hea, pChar &p_in, int &num_bytes, AttributeMap *att=nullptr)
Definition container.cpp:3288
void leave_write(pTransaction p_txn)
Definition container.cpp:434
bool get_shape_and_size(pChar &p_in, int &num_bytes, int cell_type, ItemHeader *item_hea)
Definition container.cpp:2473
char get_char(pChar &p_in, int &num_bytes)
Definition container.h:671
virtual StatusCode put(pChar p_where, pBlock p_block, int mode=WRITE_AS_BASE_DEFAULT)
Definition container.cpp:1927
int skip_space(pChar &p_in, int &num_bytes)
Definition container.h:649
StatusCode destroy_container()
Definition container.cpp:2338
bool push_real_cell(pChar cell, pChar &p_st, double *&p_out)
Definition container.h:896
int tensor_string_as_text(pBlock p_block, pChar p_dest)
Definition container.cpp:3742
virtual StatusCode as_locator(Locator &result, pChar p_what)
Definition container.cpp:2046
virtual StatusCode remove(pChar p_where)
Definition container.cpp:1965
char HEX[16]
Hex chars.
Definition container.h:638
void unlock_container()
Definition container.h:609
bool push_bool_cell(pChar cell, pChar &p_st, bool *&p_out)
Definition container.h:824
void opening_brackets(int rank, pChar &p_ret)
Definition container.h:966
int separator_len(int rank_1, int dim[], int idx[])
Definition container.h:1055
void enter_read(pTransaction p_txn)
Definition container.cpp:339
int kind_as_text(pKind p_kind, pChar p_dest)
Definition container.cpp:4087
int tensor_bool_as_text(pBlock p_block, pChar p_dest)
Definition container.cpp:3518
virtual StatusCode locate(Locator &location, pChar p_what)
Definition container.cpp:1857
virtual StatusCode new_transaction(pTransaction &p_txn)
Definition container.cpp:449
virtual StatusCode new_entity(pChar p_where)
Definition container.cpp:1946
pTransaction p_free
The free list of transactions.
Definition container.h:629
int log_error_level
The log level for LMDB errors made a variable to silence it in tests.
Definition container.h:632
StatusCode unwrap_received(pTransaction &p_txn, pBlock p_maybe_block, int rec_size)
Definition container.h:506
int tensor_int_as_text(pBlock p_block, pChar p_dest, pChar p_fmt)
Definition container.cpp:3362
bool alloc_warning_issued
True if a warning was issued for over-allocation.
Definition container.h:630
bool sscanf_int32(pChar &p_in, int &num_bytes, int &result)
Definition container.h:752
StatusCode new_container()
Definition container.cpp:2296
Lock32 _lock_
A lock for the deque of transactions.
Definition container.h:631
virtual StatusCode exec(pTransaction &p_txn, Locator &function, pTuple p_args)
Definition container.cpp:2014
void separator(int rank_1, int dim[], int idx[], pChar &p_ret)
Definition container.h:1027
int max_transactions
The configured ONE_SHOT_MAX_TRANSACTIONS.
Definition container.h:624
bool push_real_cell(pChar cell, pChar &p_st, float *&p_out)
Definition container.h:870
uint64_t alloc_bytes
The current allocation in bytes.
Definition container.h:627
virtual StatusCode copy(pChar p_where, pChar p_what)
Definition container.cpp:1987
void enter_write(pTransaction p_txn, int total_times=0)
Definition container.cpp:369
void * malloc(size_t size)
Definition container.h:553
void base_names(BaseNames &base_names)
Definition container.cpp:2289
virtual StatusCode get(pTransaction &p_txn, pChar p_what)
Definition container.cpp:1784
int from_hex(char c)
Definition container.h:620
bool push_int_cell(pChar cell, pChar &p_st, int *&p_out)
Definition container.h:772
pBlock block_malloc(size_t size)
Definition container.h:570
bool push_time_cell(pChar cell, pChar &p_st, time_t *&p_out, pChar fmt)
Definition container.h:923
bool fill_tensor(pChar &p_in, int &num_bytes, pBlock p_block)
Definition container.cpp:2786
StatusCode new_block(pTransaction &p_txn, int cell_type, int *dim, int fill_tensor=FILL_NEW_DONT_FILL, int stringbuff_size=0, const char *p_text=nullptr, char eol='\n', AttributeMap *att=nullptr)
Definition container.cpp:568
void as_hex(pChar &p_dest, uint8_t bl)
Definition container.h:1013
pTransaction p_buffer
The buffer for the transactions.
Definition container.h:628
bool push_int_cell(pChar cell, pChar &p_st, long long *&p_out)
Definition container.h:798
bool get_item_name(pChar &p_in, int &num_bytes, pChar p_out, bool check_quotes=true, bool check_colon=true, bool dot_ended=false)
Definition container.h:691
uint64_t fail_alloc_bytes
Taken from ONE_SHOT_ERROR_BLOCK_KBYTES.
Definition container.h:626
int tensor_time_as_text(pBlock p_block, pChar p_dest, pChar p_fmt)
Definition container.cpp:3896
pChar as_shape(int rank, int dim[], pChar p_ret, pKind p_kind)
Definition container.h:982
virtual StatusCode header(StaticBlockHeader &hea, pChar p_what)
Definition container.cpp:1878
bool get_type_and_shape(pChar &p_in, int &num_bytes, ItemHeader *item_hea, MapSI &dims)
Definition container.cpp:2369
void lock_container(int total_times=0)
Definition container.h:587
uint64_t warn_alloc_bytes
Taken from ONE_SHOT_WARN_BLOCK_KBYTES.
Definition container.h:625
void leave_read(pTransaction p_txn)
Definition container.cpp:414
virtual StatusCode modify(Locator &function, pTuple p_args)
Definition container.cpp:2031
StatusCode shut_down()
Definition container.cpp:325
StatusCode unwrap_received(pTransaction &p_txn)
Definition container.h:438
virtual void destroy_transaction(pTransaction &p_txn)
Definition container.cpp:488
Kind: A type definition for Jazz Blocks and Tuples.
Definition kind.h:96
A simple logger.
Definition utils.h:248
A Jazz Service is a globally instanced configurable object that may allocate RAM.
Definition utils.h:288
Tuple: A Jazz Block with multiple Tensors.
Definition tuple.h:94
The namespace for Jazz Utils, Blocks, Kinds, Tuples, Containers, etc.
Definition block.cpp:39
Logger LOGGER(CONFIG, "LOGGER_PATH")
The logger.
Definition container.h:1088
struct ExtraLocator * pExtraLocator
A pointer to an ExtraLocator.
Definition container.h:179
ConfigFile CONFIG(JAZZ_DEFAULT_CONFIG_PATH)
The configuration file.
Definition container.h:1087
Transaction * pTransaction
A pointer to a Transaction.
Definition container.h:176
Locator * pLocator
A pointer to a Locator.
Definition container.h:199
std::map< String, pContainer > BaseNames
A map of names for the containers (or structure engines like "map" or "tree" inside Volatile).
Definition container.h:157
StoredTransaction * pStoredTransaction
A pointer to a StoredTransaction.
Definition container.h:206
char * pChar
A pointer to a char buffer.
Definition types.h:189
class Block * pBlock
A (forward defined) pointer to a Block.
Definition block.h:66
char Name[NAME_SIZE]
A short identifier used in Blocks, Containers and API.
Definition types.h:187
void compile_next_state_LUT(ParseNextStateLUT lut[], int num_states, ParseStateTransition trans[])
Definition container.cpp:59
std::map< String, int > MapSI
An internal map for managing dimension parsing.
Definition container.h:210
std::atomic< int32_t > Lock32
An atomically increased (via fetch_add() and fetch_sub()) 32 bit signed integer to use as a lock.
Definition container.h:149
class Container * pContainer
A (forward defined) pointer to a Container.
Definition container.h:153
int StatusCode
Type returned by the Service API.
Definition utils.h:142
std::map< int, const char * > AttributeMap
An stdlib map to store all the attributes of a Block at the same time used by the some Block methods.
Definition block.h:63
std::map< String, String > Index
An Index kept in RAM by Volatile implemented as an stdlib map (string, string)
Definition types.h:243
Header for a Movable Block (Tensor, Kind or Tuple) or a Dynamic Block (Index)
Definition types.h:247
Header for an item (of a Kind or Tuple)
Definition types.h:202
Locator: A minimal structure to define the location of resources inside a Container.
Definition container.h:189
char base[SHORT_NAME_SIZE]
A Jazz node level unique name to locate a Container and possibly a type of service inside it.
Definition container.h:190
Name entity
Another abstraction inside node.container.base, like the name of a table in a database.
Definition container.h:191
Name key
A key identifying a block inside the entity.
Definition container.h:192
int attribute
Used by API to store the attribute.
Definition container.h:195
pExtraLocator p_extra
A pointer to extend this structure with Container specific data (like URLs, cookies,...
Definition container.h:196
A lookup table for all the possible values of a char mapped into an 8-bit state.
Definition container.h:124
unsigned char next[EIGHT_BIT_LONG]
The next state for each possible char.
Definition container.h:125
A way to build constants defining the transition from one state to the next via a regex.
Definition container.h:131
int from
The state to transition from.
Definition container.h:132
char rex[MAX_TRANSITION_REGEX_LEN]
The regex that, when matched, the transition applies.
Definition container.h:134
int to
The state to transition to.
Definition container.h:133
A Binary Compatible BlockHeader without Index (and therefore constructors/destructors)
Definition types.h:270
An internal (for Container) Transaction with pointers for a deque.
Definition container.h:203
StoredTransaction * p_next
A pointer to the next StoredTransaction.
Definition container.h:204
char buffer[]
The buffer where strings are stored starting with two zeroes for STRING_NA & STRING_EMPTY.
Definition types.h:292
Transaction: A wrapper over a Block that defines the communication of a block with a Container.
Definition container.h:167
pBlockHeader p_hea
A pointer to the Block (if status == BLOCK_STATUS_READY) for Index.
Definition container.h:170
Lock32 _lock_
An atomically updated int to lock the Transaction to support modifying the Block.
Definition container.h:172
int status
The status of the block transaction.
Definition container.h:173
pBlock p_block
A pointer to the Block (if status == BLOCK_STATUS_READY) for Tensor, Kind and Tuple.
Definition container.h:169
pContainer p_owner
A pointer to the Container instance serving API calls related to this block.
Definition container.h:174