-/* ------------------------------------------------\r
-Copyright 2014 AT&T Intellectual Property\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
- ------------------------------------------- */\r
-\r
-#ifndef HOST_TUPLE_H\r
-#define HOST_TUPLE_H\r
-\r
-#include <stdlib.h>\r
-#include "fta.h"\r
-\r
-\r
-/* vstring_type specifis the format in which vstirng data is stored\r
-we will use the reserved field of vstirng to store the vstring_type\r
-vstring_type desclaration should probably be in host.h\r
-*/\r
-enum vstring_type {\r
- // data immediately follows the tuple fields\r
- PACKED,\r
- // data allocated on a heap in one block\r
- // offset is interpreted as pointer to data\r
- INTERNAL,\r
- // vstring is a shallow copy of another vstring (or its part)\r
- // offset is interpreted as pointer to data\r
- SHALLOW_COPY,\r
- // data allocated on a heap as single linked list of data blocks\r
- // offset is interpreted as pointer to the head of the list\r
- // list node has the following format\r
- // {int length, node* next) followed by the data block\r
- SLIST,\r
- // data allocated on a heap as double linked list of data blocks\r
- // offset is interpreted as pointer to the head of the list\r
- // list node has the following format\r
- // {int length, node* next, node* prev) followed by the data block\r
- DLIST\r
-};\r
-\r
-struct host_tuple {\r
-\r
- size_t tuple_size; // tuple size in bytes\r
- void* data; // tuple data\r
- unsigned int channel; // input or output channel the tuple should go to\r
- bool heap_resident; // indicates whether tuple is heap or stack resident\r
-\r
- // we need to use reference counting for query plans that are DAGs\r
-#ifdef PLAN_DAG\r
- int* ref_cnt;\r
- host_tuple() {ref_cnt = NULL;}\r
-#endif\r
-\r
-\r
- inline void free_tuple() {\r
- if (heap_resident) {\r
- #ifdef PLAN_DAG\r
- if (!ref_cnt)\r
- free(data);\r
- else if (*ref_cnt == 0) {\r
- free(data);\r
- free(ref_cnt);\r
- } else {\r
- (*ref_cnt)--;\r
- }\r
- #else\r
- free(data);\r
- #endif\r
- }\r
- }\r
-\r
-};\r
-\r
-#endif // HOST_TUPLE_H\r
+/* ------------------------------------------------
+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 <stdlib.h>
+#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