41#include "src/jazz_elements/utils.h"
44#ifndef INCLUDED_JAZZ_CATCH2
45#define INCLUDED_JAZZ_CATCH2
47#include "src/catch2/catch.hpp"
53#ifndef INCLUDED_JAZZ_ELEMENTS_BLOCK
54#define INCLUDED_JAZZ_ELEMENTS_BLOCK
114 rank = MAX_TENSOR_RANK;
116 for (
int i = MAX_TENSOR_RANK - 1; i > 0; i--)
117 if (p_dim[i] > 0) {
range.
dim[i] = j; j *= p_dim[i]; }
else { j = 1;
range.
dim[i] = 0;
rank = i; }
132 for (
int i = 0; i < MAX_TENSOR_RANK; i++)
144 for (
int i = 0; i <
rank; i++) {
145 if (p_idx[i] < 0 || p_idx[i]*
range.
dim[i] >= j)
return false;
167 for (
int i = 0; i <
rank; i++) j += p_idx[i]*
range.
dim[i];
177 for (
int i = 0; i <
rank; i++) { p_idx[i] = offset/
range.
dim[i]; offset -= p_idx[i]*
range.
dim[i]; }
255 if (ptk[i] == attribute_id)
272 if (all_att ==
nullptr) {
282 for (AttributeMap::iterator it = all_att->begin(); it != all_att->end(); ++it) {
340 uintptr_t gap = (uintptr_t)
this & 0x7;
341 return reinterpret_cast<int *
>(((ipt - gap + 0x7) & 0xffffFFFFffffFFF8) + gap);
382 int rows = p_block->range.dim[0];
384 if (p_block->rank < 1 || rows <= 0 ||
rank != 1)
387 rows = p_block->size/rows;
390 case CELL_TYPE_BYTE_BOOLEAN:
393 case CELL_TYPE_INTEGER:
407 bool set_hash =
true,
408 bool set_time =
true) {
409 switch (set_has_NA) {
410 case SET_HAS_NA_FALSE:
413 case SET_HAS_NA_TRUE:
428 p_start = (
void *) ((uintptr_t) p_blk + p_blk->total_bytes);
433 memset(p_start, 0, void_size);
439 created = std::chrono::steady_clock::now();
A block is a moveable BlockHeader followed by a Tensor and a StringBuffer.
Definition block.h:99
void init_string_buffer()
Definition block.h:312
void get_attributes(AttributeMap *all_att)
Definition block.h:298
bool is_a_filter()
Check (in depth) the validity of a filter.
Definition block.cpp:191
int validate_offset(int offset)
Definition block.h:157
void set_string(int offset, const char *p_str)
Definition block.h:233
void get_dimensions(int *p_dim)
Definition block.h:130
int get_string_offset(pStringBuffer psb, const char *p_str)
Definition block.cpp:128
char * get_attribute(int attribute_id)
Definition block.h:252
char * get_string(int offset)
Definition block.h:202
void get_index(int offset, int *p_idx)
Definition block.h:176
int * align64bit(uintptr_t ipt)
Align a pointer (as uintptr_t) to the next 8 byte boundary assuming the block is aligned.
Definition block.h:339
void set_dimensions(int *p_dim)
Definition block.h:113
bool can_filter(pBlock p_block)
Definition block.h:381
void set_string(int *p_idx, const char *p_str)
Definition block.h:217
pStringBuffer p_string_buffer()
Definition block.h:363
int get_offset(int *p_idx)
Definition block.h:165
bool check_hash()
Definition block.h:446
char * get_string(int *p_idx)
Definition block.h:190
int * p_attribute_keys()
Definition block.h:352
bool find_NAs_in_tensor()
Definition block.cpp:49
void close_block(int set_has_NA=SET_HAS_NA_FALSE, bool set_hash=true, bool set_time=true)
Definition block.h:406
void set_attributes(AttributeMap *all_att)
Definition block.h:268
bool validate_index(int *p_idx)
Definition block.h:142
The namespace for Jazz Utils, Blocks, Kinds, Tuples, Containers, etc.
Definition block.cpp:39
uint64_t MurmurHash64A(const void *key, int len)
MurmurHash2, 64-bit versions, by Austin Appleby.
Definition utils.cpp:250
class Block * pBlock
A (forward defined) pointer to a Block.
Definition block.h:66
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
Structure at the end of a Block, initially created with init_string_buffer()
Definition types.h:282
int last_idx
The index to the first free space after the last stored string.
Definition types.h:285
int buffer_size
The size in bytes of buffer[].
Definition types.h:286
char buffer[]
The buffer where strings are stored starting with two zeroes for STRING_NA & STRING_EMPTY.
Definition types.h:287
bool alloc_failed
A previous call to get_string_offset() failed to alloc space for a string.
Definition types.h:284
int dim[MAX_TENSOR_RANK]
Dimensions for the Tensor. The product of all * (cell_type & 0xff) < 2 Gb.
Definition types.h:193
ItemHeader cell_item[0]
.. An array of BlockHeader used by Kinds and Tuples
Definition types.h:231
int cell_int[0]
.. CELL_TYPE_INTEGER, CELL_TYPE_FACTOR, CELL_TYPE_GRADE, CELL_TYPE_BOOLEAN and CELL_TYPE_STRING
Definition types.h:223