Jazz 1.25.+
Loading...
Searching...
No Matches
container.h
1/* Jazz (c) 2018-2025 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
56
57namespace jazz_elements
58{
59
61#define MAX_SIZE_OF_CELL_AS_TEXT 48
62
64#define NA_AS_TEXT {"NA\0"}
65#define LENGTH_NA_AS_TEXT 2
66
68#define PARSE_ERROR_UNEXPECTED_EOF 101
69#define PARSE_ERROR_UNEXPECTED_CHAR 102
70#define PARSE_ERROR_ITEM_NAME 103
71#define PARSE_ERROR_ITEM_NAME_MISMATCH 104
72#define PARSE_ERROR_TENSOR_EXPLORATION 105
73
74#define PARSE_ERROR_KIND_EXPLORATION 106
75#define PARSE_ERROR_TOO_MANY_ITEMS 107
76#define PARSE_ERROR_EXPECTED_EOF 108
77#define PARSE_ERROR_TENSOR_FILLING 109
78#define PARSE_ERROR_TEXT_FILLING 110
79
81#define FILL_NEW_DONT_FILL 0
82#define FILL_NEW_WITH_ZERO 1
83#define FILL_NEW_WITH_NA 2
84#define FILL_WITH_TEXTFILE 3
85
86#define BUILD_TUPLE 1
87#define BUILD_KIND 2
88
90#define BLOCK_STATUS_READY 0
91#define BLOCK_STATUS_EMPTY 1
92#define BLOCK_STATUS_DESTROYED 2
93
95#define LOCK_NUM_RETRIES_BEFORE_YIELD 100
96
98#define LOCK_WEIGHT_OF_WRITE 46341
99
100// State based parser types:
101#define EIGHT_BIT_LONG 256
102#define MAX_TRANSITION_REGEX_LEN 32
103#define PSTATE_INVALID_CHAR 255
104
105// Writing modes for put(1): What to do is block exists:
106#define WRITE_ONLY_IF_EXISTS 0x01
107#define WRITE_ONLY_IF_NOT_EXISTS 0x02
108#define WRITE_ANY_RESTRICTION 0x03
109
110// Writing modes for put(2): What to write
111#define WRITE_AS_BASE_DEFAULT 0x00
112#define WRITE_AS_STRING 0x04
113#define WRITE_AS_CONTENT 0x08
114#define WRITE_AS_FULL_BLOCK 0x10
115#define WRITE_AS_ANY_WRITE 0x1C
116
120 unsigned char next[EIGHT_BIT_LONG];
121};
122
123
127 int from;
128 int to;
129 char rex[MAX_TRANSITION_REGEX_LEN];
130};
131
132
140void compile_next_state_LUT(ParseNextStateLUT lut[], int num_states, ParseStateTransition trans[]);
141
142
144typedef std::atomic<int32_t> Lock32;
145
146
148typedef class Container *pContainer;
149
150
152typedef std::map<std::string, pContainer> BaseNames;
153
154
172
173
174typedef struct ExtraLocator *pExtraLocator;
175
184struct Locator {
185 char base [SHORT_NAME_SIZE];
188
189 union {
192 };
193};
195
196
202
203
205typedef std::map<std::string, int> MapSI;
206
207
282class Container : public Service {
283
284 public:
285
286 Container(pLogger a_logger, pConfigFile a_config);
287 ~Container();
288
289 // Service API
290
291 StatusCode start ();
293
294 // .enter_read() .enter_write() .leave_read() .leave_write() .lock_container() .unlock_container()
295
296 void enter_read (pTransaction p_txn);
297 void enter_write(pTransaction p_txn);
298 void leave_read (pTransaction p_txn);
299 void leave_write(pTransaction p_txn);
300
301 // - Allocation: .new_block(), .destroy_transaction()
302
303 // 1. new_block(): Create a Tensor from raw data specifying everything from scratch.
305 int cell_type,
306 int *dim,
307 int fill_tensor = FILL_NEW_DONT_FILL,
308 int stringbuff_size = 0,
309 const char *p_text = nullptr,
310 char eol = '\n',
311 AttributeMap *att = nullptr);
312
313 // 2. new_block(): Create a Kind or Tuple from arrays of StaticBlockHeader, names, and, in the case of a tuple, Tensors.
315 int num_items,
316 StaticBlockHeader p_hea[],
317 Name p_names[],
318 pBlock p_block[],
319 AttributeMap *dims = nullptr,
320 AttributeMap *att = nullptr);
321
322 // 3. new_block(): Create a Tensor by selecting rows (filtering) from another Tensor.
324 pBlock p_from,
325 pBlock p_row_filter,
326 AttributeMap *att = nullptr);
327
328 // 4. new_block(): Create a Tensor by selecting an item from a Tuple.
330 pTuple p_from,
331 pChar name,
332 AttributeMap *att = nullptr);
333
334 // 5. new_block(): Create a Tensor, Kind or Tuple from a Text block kept as a Tensor of CELL_TYPE_BYTE of rank == 1.
336 pBlock p_from_text,
337 int cell_type,
338 pKind p_as_kind = nullptr,
339 AttributeMap *att = nullptr);
340
341 // 6. new_block(): Create a Tensor of CELL_TYPE_BYTE of rank == 1 with a text serialization of a Tensor, Kind or Tuple.
343 pBlock p_from_raw,
344 pChar p_fmt = nullptr,
345 bool ret_as_string = false,
346 AttributeMap *att = nullptr);
347
348 // 7. new_block(): Create an empty Index block.
350 int cell_type);
351
352 // 8. new_block(): Create a Tuple of (key:STRING[length],value:STRING[length]) with the content of an Index.
354 Index &index);
355
356 // Support for transactions creation/destruction
357
359 virtual void destroy_transaction (pTransaction &p_txn);
360
361 // Crud: .get(), .header(), .put(), .new_entity(), .remove(), .copy()
362
363 // The "easy" interface: Uses strings instead of locators. Is translated to the native interface by an as_locator() call.
364 virtual StatusCode get (pTransaction &p_txn,
365 pChar p_what);
366 virtual StatusCode get (pTransaction &p_txn,
367 pChar p_what,
368 pBlock p_row_filter);
369 virtual StatusCode get (pTransaction &p_txn,
370 pChar p_what,
371 pChar name);
372 virtual StatusCode locate (Locator &location,
373 pChar p_what);
374 virtual StatusCode header (StaticBlockHeader &hea,
375 pChar p_what);
376 virtual StatusCode header (pTransaction &p_txn,
377 pChar p_what);
378 virtual StatusCode put (pChar p_where,
379 pBlock p_block,
380 int mode = WRITE_AS_BASE_DEFAULT);
381 virtual StatusCode new_entity (pChar p_where);
382 virtual StatusCode remove (pChar p_where);
383 virtual StatusCode copy (pChar p_where,
384 pChar p_what);
385
386 // The function call interface: exec()/modify().
387 virtual StatusCode exec (pTransaction &p_txn,
388 Locator &function,
389 pTuple p_args);
390 virtual StatusCode modify (Locator &function,
391 pTuple p_args);
392
393 // The parser: This simple regex-based parser only needs override for Channels.
394 virtual StatusCode as_locator (Locator &result,
395 pChar p_what);
396
397 // The "native" interface: This is what really does the job and all Container descendants implement.
398 virtual StatusCode get (pTransaction &p_txn,
399 Locator &what);
400 virtual StatusCode get (pTransaction &p_txn,
401 Locator &what,
402 pBlock p_row_filter);
403 virtual StatusCode get (pTransaction &p_txn,
404 Locator &what,
405 pChar name);
406 virtual StatusCode locate (Locator &location,
407 Locator &what);
408 virtual StatusCode header (StaticBlockHeader &hea,
409 Locator &what);
410 virtual StatusCode header (pTransaction &p_txn,
411 Locator &what);
412 virtual StatusCode put (Locator &where,
413 pBlock p_block,
414 int mode = WRITE_AS_BASE_DEFAULT);
415 virtual StatusCode new_entity (Locator &where);
416 virtual StatusCode remove (Locator &where);
417 virtual StatusCode copy (Locator &where,
418 Locator &what);
419
430
431 pBlock p_blk = (pBlock) &p_txn->p_block->tensor.cell_byte[0];
432 int size = p_txn->p_block->size;
433
434 if (p_blk->total_bytes == size && p_blk->check_hash()) {
435 pBlock p_new = block_malloc(size);
436 if (p_new == nullptr) {
437 destroy_transaction(p_txn);
438
439 return SERVICE_ERROR_NO_MEM;
440 }
441 memcpy(p_new, p_blk, size);
442
443 alloc_bytes -= p_txn->p_block->total_bytes;
444 free(p_txn->p_block);
445
446 p_txn->p_block = p_new;
447
448 return SERVICE_NO_ERROR;
449 }
450 if (strnlen((pChar) p_blk, size) != size)
451 return SERVICE_NO_ERROR;
452
453 pTransaction p_aux;
454
455 reinterpret_cast <pChar>(p_blk)[size] = 0;
456
457 if (new_block(p_aux, CELL_TYPE_STRING, nullptr, FILL_WITH_TEXTFILE, 0, (pChar) p_blk, 0) != SERVICE_NO_ERROR) {
458 destroy_transaction(p_txn);
459
460 return SERVICE_ERROR_NO_MEM;
461 }
462 std::swap(p_txn->p_block, p_aux->p_block);
463
464 destroy_transaction(p_aux);
465
466 return SERVICE_NO_ERROR;
467 }
468
480 inline StatusCode unwrap_received(pTransaction &p_txn, pBlock p_maybe_block, int rec_size) {
481
482 if (rec_size > sizeof(BlockHeader) && p_maybe_block->total_bytes == rec_size && p_maybe_block->check_hash()) {
483 int ret = new_transaction(p_txn);
484
485 if (ret != SERVICE_NO_ERROR)
486 return ret;
487
488 pBlock p_new = block_malloc(rec_size);
489 if (p_new == nullptr) {
490 destroy_transaction(p_txn);
491
492 return SERVICE_ERROR_NO_MEM;
493 }
494 memcpy(p_new, p_maybe_block, rec_size);
495
496 p_txn->p_block = p_new;
497 p_txn->status = BLOCK_STATUS_READY;
498
499 return SERVICE_NO_ERROR;
500 }
501 if (strnlen((pChar) p_maybe_block, rec_size) != rec_size) {
502 int dim[MAX_TENSOR_RANK] = {rec_size, 0};
503 int ret = new_block(p_txn, CELL_TYPE_BYTE, dim, FILL_NEW_DONT_FILL);
504
505 if (ret == SERVICE_NO_ERROR)
506 memcpy(&p_txn->p_block->tensor.cell_byte[0], p_maybe_block, rec_size);
507
508 return ret;
509 }
510
511 return new_block(p_txn, CELL_TYPE_STRING, nullptr, FILL_WITH_TEXTFILE, 0, (pChar) p_maybe_block, 0);
512 }
513
514 // Support for container names in the BaseAPI .base_names()
515
517
518#ifndef CATCH_TEST
519 protected:
520#endif
521
527 inline void* malloc(size_t size) {
528 if (alloc_bytes + size >= fail_alloc_bytes)
529 return nullptr;
530
531 void * ret = std::malloc(size);
532
533 if (ret != nullptr)
534 alloc_bytes += size;
535
536#ifdef CATCH_TEST
537 if ((uint64_t) ret & 0x7)
538 log(LOG_ERROR, "Misaligned block !!");
539#endif
540
541 return ret;
542 }
543
549 inline pBlock block_malloc(size_t size) {
550 pBlock p_blk = (pBlock) malloc(size);
551
552 if (p_blk != nullptr) {
553 p_blk->cell_type = 0;
554 p_blk->total_bytes = 0;
555 }
556
557 return p_blk;
558 }
559
564 inline void lock_container() {
565 int retry = 0;
566 int32_t lock = 0;
567 int32_t next = 1;
568
569 while (true) {
570 if (_lock_.compare_exchange_weak(lock, next))
571 return;
572
573 if (++retry > LOCK_NUM_RETRIES_BEFORE_YIELD) {
574 std::this_thread::yield();
575 retry = 0;
576 }
577 }
578 }
579
583 _lock_ = 0;
584 }
585
587
593 inline int from_hex(char c) {
594 return (c < 65) ? c - 48 : (c > 96) ? c - 87 : c - 55;
595 }
596
600 uint64_t alloc_bytes;
605
606#ifndef CATCH_TEST
607 private:
608#endif
609
610 char HEX[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
611
613
621 inline int skip_space(pChar &p_in, int &num_bytes) {
622 while (num_bytes > 0) {
623 if (*p_in == 0)
624 return 0;
625
626 if (*p_in == ' ' || *p_in == '\t' || *p_in == '\n') {
627 p_in++;
628 num_bytes--;
629 } else
630 break;
631 }
632
633 return num_bytes;
634 }
635
643 inline char get_char(pChar &p_in, int &num_bytes) {
644 if (num_bytes < 1)
645 return 0;
646
647 num_bytes--;
648
649 return *(p_in++);
650 }
651
662 inline bool get_item_name(pChar &p_in, int &num_bytes, pChar p_out, bool check_quotes = true, bool check_colon = true) {
663 if (skip_space(p_in, num_bytes) <= 1)
664 return false;
665
666 if (check_quotes && (get_char(p_in, num_bytes) != '"'))
667 return false;
668
669 char ch = get_char(p_in, num_bytes);
670
671 if (ch < 'A' || ch > 'z' || (ch > 'Z' && ch < 'a'))
672 return false;
673
674 *(p_out++) = ch;
675
676 for (int i = 1; i < NAME_LENGTH; i++) {
677 if (!check_quotes && (*p_in == ',' || *p_in == ']'))
678 break;
679
680 ch = get_char(p_in, num_bytes);
681
682 if (check_quotes && ch == '"')
683 break;
684
685 if (ch < '0' || ch > 'z' || (ch > '9' && ch < 'A') || (ch > 'Z' && ch < '_') || ch == 0x60)
686 return false;
687
688 *(p_out++) = ch;
689 }
690
691 *p_out = 0;
692
693 if (check_quotes && (ch != '"') && (get_char(p_in, num_bytes) != '"'))
694 return false;
695
696 if (check_colon) {
697 if (skip_space(p_in, num_bytes) <= 1)
698 return false;
699
700 if (get_char(p_in, num_bytes) != ':')
701 return false;
702 }
703
704 return true;
705 }
706
715 inline bool sscanf_int32(pChar &p_in, int &num_bytes, int &result) {
716 int r_len;
717
718 if (sscanf(p_in, "%i%n", &result, &r_len) > 0) {
719 p_in += r_len;
720 num_bytes -= r_len;
721
722 return num_bytes >= 0;
723 } else
724 return false;
725 }
726
735 inline bool push_int_cell(pChar cell, pChar &p_st, int * &p_out) {
736
737 if (p_st == cell) {
738 *(p_out++) = INTEGER_NA;
739
740 return true;
741 }
742 *p_st = 0;
743 p_st = cell;
744
745 if (sscanf(p_st, "%i", p_out) != 1)
746 return false;
747
748 p_out++;
749
750 return true;
751 }
752
761 inline bool push_int_cell(pChar cell, pChar &p_st, long long * &p_out) {
762
763 if (p_st == cell) {
764 *(p_out++) = LONG_INTEGER_NA;
765
766 return true;
767 }
768 *p_st = 0;
769 p_st = cell;
770
771 if (sscanf(p_st, "%lli", p_out) != 1)
772 return false;
773
774 p_out++;
775
776 return true;
777 }
778
787 inline bool push_bool_cell(pChar cell, pChar &p_st, bool * &p_out) {
788
789 if (p_st == cell) {
790 *reinterpret_cast<uint8_t *>(p_out++) = BYTE_BOOLEAN_NA;
791
792 return true;
793 }
794 *p_st = 0;
795 p_st = cell;
796
797 *(p_out++) = cell[0] == '1';
798
799 return true;
800 }
801
810 inline bool push_bool_cell(pChar cell, pChar &p_st, uint32_t * &p_out) {
811
812 if (p_st == cell) {
813 *(p_out++) = BOOLEAN_NA;
814
815 return true;
816 }
817 *p_st = 0;
818 p_st = cell;
819
820 *(p_out++) = cell[0] == '1';
821
822 return true;
823 }
824
833 inline bool push_real_cell(pChar cell, pChar &p_st, float * &p_out) {
834
835 if (p_st == cell) {
836 *(p_out++) = SINGLE_NA;
837
838 return true;
839 }
840 *p_st = 0;
841 p_st = cell;
842
843 if (sscanf(p_st, "%f", p_out) != 1)
844 return false;
845
846 p_out++;
847
848 return true;
849 }
850
859 inline bool push_real_cell(pChar cell, pChar &p_st, double * &p_out) {
860
861 if (p_st == cell) {
862 *(p_out++) = DOUBLE_NA;
863
864 return true;
865 }
866 *p_st = 0;
867 p_st = cell;
868
869 if (sscanf(p_st, "%lf", p_out) != 1)
870 return false;
871
872 p_out++;
873
874 return true;
875 }
876
886 inline bool push_time_cell(pChar cell, pChar &p_st, time_t * &p_out, pChar fmt) {
887
888 if (p_st == cell) {
889 *(p_out++) = TIME_POINT_NA;
890
891 return true;
892 }
893 *p_st = 0;
894 p_st = cell;
895
896 struct tm timeinfo = {0};
897
898 if (strptime(p_st, fmt, &timeinfo) == nullptr)
899 return false;
900
901 time_t xx = timegm(&timeinfo);
902 if (xx < 0)
903 return false;
904
905 *(p_out++) = xx;
906
907 return true;
908 }
909
910 bool get_type_and_shape (pChar &p_in, int &num_bytes, ItemHeader *item_hea, MapSI &dims);
911 bool get_shape_and_size (pChar &p_in, int &num_bytes, int cell_type, ItemHeader *item_hea);
912 bool fill_text_buffer (pChar &p_in, int &num_bytes, pChar p_out, int num_cells, int is_NA[], int hasLN[]);
913 bool fill_tensor (pChar &p_in, int &num_bytes, pBlock p_block);
914
915 int new_text_block (pTransaction &p_txn, ItemHeader &item_hea, pChar &p_in, int &num_bytes, AttributeMap *att = nullptr);
916
917 int tensor_int_as_text (pBlock p_block, pChar p_dest, pChar p_fmt);
918 int tensor_bool_as_text (pBlock p_block, pChar p_dest);
919 int tensor_float_as_text (pBlock p_block, pChar p_dest, pChar p_fmt);
920 int tensor_string_as_text(pBlock p_block, pChar p_dest);
921 int tensor_time_as_text (pBlock p_block, pChar p_dest, pChar p_fmt);
922 int tensor_tuple_as_text (pTuple p_tuple, pChar p_dest, pChar p_fmt, int item_len[]);
923 int tensor_kind_as_text (pKind p_kind, pChar p_dest);
924
930 inline void opening_brackets(int rank, pChar &p_ret) {
931 for (int i = 0; i < rank; i++)
932 *(p_ret++) = '[';
933
934 *p_ret = 0;
935 }
936
946 inline pChar as_shape(int rank, int dim[], pChar p_ret, pKind p_kind) {
947 *(p_ret++) = '[';
948
949 for (int i = 0; i < rank; i++) {
950 int k = dim[i];
951 if (k < 0) {
952 char *p_dim_name = &p_kind->p_string_buffer()->buffer[-k];
953 strcpy(p_ret, p_dim_name);
954 p_ret += strlen(p_dim_name);
955
956 } else
957 p_ret += sprintf(p_ret, "%i", k);
958
959 if (i < rank - 1) {
960 *(p_ret++) = ',';
961 *(p_ret++) = ' ';
962 }
963 }
964
965 *(p_ret++) = ']';
966
967 *p_ret = 0;
968
969 return p_ret;
970 }
971
977 inline void as_hex(pChar &p_dest, uint8_t bl) {
978 *(p_dest++) = '\\';
979 *(p_dest++) = 'x';
980 *(p_dest++) = HEX[bl >> 4];
981 *(p_dest++) = HEX[bl & 0x0f];
982 }
983
991 inline void separator(int rank_1, int dim[], int idx[], pChar &p_ret) {
992 for (int i = rank_1; i >= 0; i--) {
993 idx[i]++;
994
995 if (idx[i] == dim[i]) {
996 idx[i] = 0;
997 *(p_ret++) = ']';
998 } else {
999 *(p_ret++) = ',';
1000 *(p_ret++) = ' ';
1001
1002 for (int j = 0; j < rank_1 - i; j++)
1003 *(p_ret++) = '[';
1004
1005 break;
1006 }
1007 }
1008 *p_ret = 0;
1009 }
1010
1019 inline int separator_len(int rank_1, int dim[], int idx[]) {
1020 int ret = 0;
1021
1022 for (int i = rank_1; i >= 0; i--) {
1023 idx[i]++;
1024
1025 if (idx[i] == dim[i]) {
1026 idx[i] = 0;
1027 ret++;
1028 } else {
1029 ret += 2;
1030
1031 if (i == rank_1)
1032 return ret;
1033
1034 ret += rank_1 - i;
1035
1036 return ret;
1037 }
1038 }
1039 return ret;
1040 }
1041};
1042
1043// Instancing container, logger and config
1044// ---------------------------------------
1045
1048
1049#ifdef CATCH_TEST
1050
1051void compare_full_blocks(pBlock p_bl1, pBlock p_bl2, bool skip_value_check = false);
1052
1053extern Container CNT;
1054
1055#endif
1056
1057} // namespace jazz_elements
1058
1059#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:217
Container: A Service to manage Jazz blocks. All Jazz blocks are managed by this or a descendant of th...
Definition container.h:282
StatusCode start()
Definition container.cpp:300
bool fill_text_buffer(pChar &p_in, int &num_bytes, pChar p_out, int num_cells, int is_NA[], int hasLN[])
Definition container.cpp:2636
int tensor_float_as_text(pBlock p_block, pChar p_dest, pChar p_fmt)
Definition container.cpp:3633
bool push_bool_cell(pChar cell, pChar &p_st, uint32_t *&p_out)
Definition container.h:810
int new_text_block(pTransaction &p_txn, ItemHeader &item_hea, pChar &p_in, int &num_bytes, AttributeMap *att=nullptr)
Definition container.cpp:3294
void leave_write(pTransaction p_txn)
Definition container.cpp:433
bool get_shape_and_size(pChar &p_in, int &num_bytes, int cell_type, ItemHeader *item_hea)
Definition container.cpp:2466
char get_char(pChar &p_in, int &num_bytes)
Definition container.h:643
virtual StatusCode put(pChar p_where, pBlock p_block, int mode=WRITE_AS_BASE_DEFAULT)
Definition container.cpp:1903
int skip_space(pChar &p_in, int &num_bytes)
Definition container.h:621
int tensor_kind_as_text(pKind p_kind, pChar p_dest)
Definition container.cpp:4099
StatusCode destroy_container()
Definition container.cpp:2321
bool push_real_cell(pChar cell, pChar &p_st, double *&p_out)
Definition container.h:859
int tensor_string_as_text(pBlock p_block, pChar p_dest)
Definition container.cpp:3752
virtual StatusCode as_locator(Locator &result, pChar p_what)
Definition container.cpp:2022
virtual StatusCode remove(pChar p_where)
Definition container.cpp:1941
char HEX[16]
Hex chars.
Definition container.h:610
void unlock_container()
Definition container.h:582
void lock_container()
Definition container.h:564
bool push_bool_cell(pChar cell, pChar &p_st, bool *&p_out)
Definition container.h:787
void opening_brackets(int rank, pChar &p_ret)
Definition container.h:930
int separator_len(int rank_1, int dim[], int idx[])
Definition container.h:1019
bool get_item_name(pChar &p_in, int &num_bytes, pChar p_out, bool check_quotes=true, bool check_colon=true)
Definition container.h:662
void enter_read(pTransaction p_txn)
Definition container.cpp:347
int tensor_bool_as_text(pBlock p_block, pChar p_dest)
Definition container.cpp:3528
virtual StatusCode locate(Locator &location, pChar p_what)
Definition container.cpp:1833
virtual StatusCode new_transaction(pTransaction &p_txn)
Definition container.cpp:454
virtual StatusCode new_entity(pChar p_where)
Definition container.cpp:1922
pTransaction p_free
The free list of transactions.
Definition container.h:602
StatusCode unwrap_received(pTransaction &p_txn, pBlock p_maybe_block, int rec_size)
Definition container.h:480
int tensor_int_as_text(pBlock p_block, pChar p_dest, pChar p_fmt)
Definition container.cpp:3372
bool alloc_warning_issued
True if a warning was issued for over-allocation.
Definition container.h:603
bool sscanf_int32(pChar &p_in, int &num_bytes, int &result)
Definition container.h:715
void enter_write(pTransaction p_txn)
Definition container.cpp:376
int tensor_tuple_as_text(pTuple p_tuple, pChar p_dest, pChar p_fmt, int item_len[])
Definition container.cpp:3980
StatusCode new_container()
Definition container.cpp:2279
Lock32 _lock_
A lock for the deque of transactions.
Definition container.h:604
virtual StatusCode exec(pTransaction &p_txn, Locator &function, pTuple p_args)
Definition container.cpp:1990
void separator(int rank_1, int dim[], int idx[], pChar &p_ret)
Definition container.h:991
int max_transactions
The configured ONE_SHOT_MAX_TRANSACTIONS.
Definition container.h:597
bool push_real_cell(pChar cell, pChar &p_st, float *&p_out)
Definition container.h:833
uint64_t alloc_bytes
The current allocation in bytes.
Definition container.h:600
virtual StatusCode copy(pChar p_where, pChar p_what)
Definition container.cpp:1963
void * malloc(size_t size)
Definition container.h:527
void base_names(BaseNames &base_names)
Definition container.cpp:2272
virtual StatusCode get(pTransaction &p_txn, pChar p_what)
Definition container.cpp:1760
int from_hex(char c)
Definition container.h:593
bool push_int_cell(pChar cell, pChar &p_st, int *&p_out)
Definition container.h:735
pBlock block_malloc(size_t size)
Definition container.h:549
bool push_time_cell(pChar cell, pChar &p_st, time_t *&p_out, pChar fmt)
Definition container.h:886
bool fill_tensor(pChar &p_in, int &num_bytes, pBlock p_block)
Definition container.cpp:2782
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:573
void as_hex(pChar &p_dest, uint8_t bl)
Definition container.h:977
pTransaction p_buffer
The buffer for the transactions.
Definition container.h:601
bool push_int_cell(pChar cell, pChar &p_st, long long *&p_out)
Definition container.h:761
uint64_t fail_alloc_bytes
Taken from ONE_SHOT_ERROR_BLOCK_KBYTES.
Definition container.h:599
int tensor_time_as_text(pBlock p_block, pChar p_dest, pChar p_fmt)
Definition container.cpp:3906
pChar as_shape(int rank, int dim[], pChar p_ret, pKind p_kind)
Definition container.h:946
virtual StatusCode header(StaticBlockHeader &hea, pChar p_what)
Definition container.cpp:1854
bool get_type_and_shape(pChar &p_in, int &num_bytes, ItemHeader *item_hea, MapSI &dims)
Definition container.cpp:2352
uint64_t warn_alloc_bytes
Taken from ONE_SHOT_WARN_BLOCK_KBYTES.
Definition container.h:598
void leave_read(pTransaction p_txn)
Definition container.cpp:413
virtual StatusCode modify(Locator &function, pTuple p_args)
Definition container.cpp:2007
StatusCode shut_down()
Definition container.cpp:333
StatusCode unwrap_received(pTransaction &p_txn)
Definition container.h:429
virtual void destroy_transaction(pTransaction &p_txn)
Definition container.cpp:493
Kind: A type definition for Jazz Blocks and Tuples.
Definition kind.h:83
A simple logger.
Definition utils.h:245
A Jazz Service is a globally instanced configurable object that may allocate RAM.
Definition utils.h:285
void log(int loglevel, const char *message)
Definition utils.h:305
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:1047
struct ExtraLocator * pExtraLocator
A pointer to an ExtraLocator.
Definition container.h:174
ConfigFile CONFIG(JAZZ_DEFAULT_CONFIG_PATH)
The configuration file.
Definition container.h:1046
std::map< std::string, std::string > Index
An Index kept in RAM by Volatile implemented as an stdlib map (string, string)
Definition types.h:238
Transaction * pTransaction
A pointer to a Transaction.
Definition container.h:171
Locator * pLocator
A pointer to a Locator.
Definition container.h:194
StoredTransaction * pStoredTransaction
A pointer to a StoredTransaction.
Definition container.h:201
char * pChar
A pointer to a char buffer.
Definition types.h:185
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:183
void compile_next_state_LUT(ParseNextStateLUT lut[], int num_states, ParseStateTransition trans[])
Definition container.cpp:63
std::map< std::string, pContainer > BaseNames
A map of names for the containers (or structure engines like "map" or "tree" inside Volatile).
Definition container.h:152
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:144
class Container * pContainer
A (forward defined) pointer to a Container.
Definition container.h:148
int StatusCode
Type returned by the Service API.
Definition utils.h:141
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< std::string, int > MapSI
An internal map for managing dimension parsing.
Definition container.h:205
Header for a Movable Block (Tensor, Kind or Tuple) or a Dynamic Block (Index)
Definition types.h:242
Header for an item (of a Kind or Tuple)
Definition types.h:198
Locator: A minimal structure to define the location of resources inside a Container.
Definition container.h:184
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:185
Name entity
Another abstraction inside node.container.base, like the name of a table in a database.
Definition container.h:186
Name key
A key identifying a block inside the entity.
Definition container.h:187
int attribute
Used by API to store the attribute.
Definition container.h:190
pExtraLocator p_extra
A pointer to extend this structure with Container specific data (like URLs, cookies,...
Definition container.h:191
A lookup table for all the possible values of a char mapped into an 8-bit state.
Definition container.h:119
unsigned char next[EIGHT_BIT_LONG]
The next state for each possible char.
Definition container.h:120
A way to build constants defining the transition from one state to the next via a regex.
Definition container.h:126
int from
The state to transition from.
Definition container.h:127
char rex[MAX_TRANSITION_REGEX_LEN]
The regex that, when matched, the transition applies.
Definition container.h:129
int to
The state to transition to.
Definition container.h:128
A Binary Compatible BlockHeader without Index (and therefore constructors/destructors)
Definition types.h:265
An internal (for Container) Transaction with pointers for a deque.
Definition container.h:198
StoredTransaction * p_next
A pointer to the next StoredTransaction.
Definition container.h:199
char buffer[]
The buffer where strings are stored starting with two zeroes for STRING_NA & STRING_EMPTY.
Definition types.h:287
Transaction: A wrapper over a Block that defines the communication of a block with a Container.
Definition container.h:162
pBlockHeader p_hea
A pointer to the Block (if status == BLOCK_STATUS_READY) for Index.
Definition container.h:165
Lock32 _lock_
An atomically updated int to lock the Transaction to support modifying the Block.
Definition container.h:167
int status
The status of the block transaction.
Definition container.h:168
pBlock p_block
A pointer to the Block (if status == BLOCK_STATUS_READY) for Tensor, Kind and Tuple.
Definition container.h:164
pContainer p_owner
A pointer to the Container instance serving API calls related to this block.
Definition container.h:169