X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=include%2Fhfta%2Fhost_tuple.h;fp=include%2Fhfta%2Fhost_tuple.h;h=146d4322b8ad612f56d44a736815e909ce5a4d12;hb=e981e864b812c938d3df8b555b6bb98bb89273e7;hp=b483f7c5ee56d25eb33fed46b15e3601131f682b;hpb=44ea17511358ebc75952066580e31cba8b38ddb8;p=com%2Fgs-lite.git diff --git a/include/hfta/host_tuple.h b/include/hfta/host_tuple.h index b483f7c..146d432 100644 --- a/include/hfta/host_tuple.h +++ b/include/hfta/host_tuple.h @@ -1,81 +1,81 @@ -/* ------------------------------------------------ -Copyright 2014 AT&T Intellectual Property - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ------------------------------------------- */ - -#ifndef HOST_TUPLE_H -#define HOST_TUPLE_H - -#include -#include "fta.h" - - -/* vstring_type specifis the format in which vstirng data is stored -we will use the reserved field of vstirng to store the vstring_type -vstring_type desclaration should probably be in host.h -*/ -enum vstring_type { - // data immediately follows the tuple fields - PACKED, - // data allocated on a heap in one block - // offset is interpreted as pointer to data - INTERNAL, - // vstring is a shallow copy of another vstring (or its part) - // offset is interpreted as pointer to data - SHALLOW_COPY, - // data allocated on a heap as single linked list of data blocks - // offset is interpreted as pointer to the head of the list - // list node has the following format - // {int length, node* next) followed by the data block - SLIST, - // data allocated on a heap as double linked list of data blocks - // offset is interpreted as pointer to the head of the list - // list node has the following format - // {int length, node* next, node* prev) followed by the data block - DLIST -}; - -struct host_tuple { - - size_t tuple_size; // tuple size in bytes - void* data; // tuple data - unsigned int channel; // input or output channel the tuple should go to - bool heap_resident; // indicates whether tuple is heap or stack resident - - // we need to use reference counting for query plans that are DAGs -#ifdef PLAN_DAG - int* ref_cnt; - host_tuple() {ref_cnt = NULL;} -#endif - - - inline void free_tuple() { - if (heap_resident) { - #ifdef PLAN_DAG - if (!ref_cnt) - free(data); - else if (*ref_cnt == 0) { - free(data); - free(ref_cnt); - } else { - (*ref_cnt)--; - } - #else - free(data); - #endif - } - } - -}; - -#endif // HOST_TUPLE_H +/* ------------------------------------------------ +Copyright 2014 AT&T Intellectual Property + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ------------------------------------------- */ + +#ifndef HOST_TUPLE_H +#define HOST_TUPLE_H + +#include +#include "fta.h" + + +/* vstring_type specifis the format in which vstirng data is stored +we will use the reserved field of vstirng to store the vstring_type +vstring_type desclaration should probably be in host.h +*/ +enum vstring_type { + // data immediately follows the tuple fields + PACKED, + // data allocated on a heap in one block + // offset is interpreted as pointer to data + INTERNAL, + // vstring is a shallow copy of another vstring (or its part) + // offset is interpreted as pointer to data + SHALLOW_COPY, + // data allocated on a heap as single linked list of data blocks + // offset is interpreted as pointer to the head of the list + // list node has the following format + // {int length, node* next) followed by the data block + SLIST, + // data allocated on a heap as double linked list of data blocks + // offset is interpreted as pointer to the head of the list + // list node has the following format + // {int length, node* next, node* prev) followed by the data block + DLIST +}; + +struct host_tuple { + + size_t tuple_size; // tuple size in bytes + void* data; // tuple data + unsigned int channel; // input or output channel the tuple should go to + bool heap_resident; // indicates whether tuple is heap or stack resident + + // we need to use reference counting for query plans that are DAGs +#ifdef PLAN_DAG + int* ref_cnt; + host_tuple() {ref_cnt = NULL;} +#endif + + + inline void free_tuple() { + if (heap_resident) { + #ifdef PLAN_DAG + if (!ref_cnt) + free(data); + else if (*ref_cnt == 0) { + free(data); + free(ref_cnt); + } else { + (*ref_cnt)--; + } + #else + free(data); + #endif + } + } + +}; + +#endif // HOST_TUPLE_H