diff --git a/.gitignore b/.gitignore index 1eeec80ed7..eb8b364a58 100644 --- a/.gitignore +++ b/.gitignore @@ -49,7 +49,8 @@ camshr/cts_commands.c # vi autosave files *~ - +#vs code autosave files +*.swp # python compiled files *.pyc __pycache__/ diff --git a/_include/_ncidef.h b/_include/_ncidef.h new file mode 100644 index 0000000000..18d8178329 --- /dev/null +++ b/_include/_ncidef.h @@ -0,0 +1,19 @@ +#ifndef INTERNAL_NCIDEF_H +#define INTERNAL_NCIDEF_H +/************************************** + _NCIDEF.H - definitions of constants + used in to define compression method + names and routines. +**************************************/ + + +typedef struct compression_method { + char *name; + char *method; + char *image; +} COMPRESSION_METHOD; + +#define DEFINE_COMPRESSION_METHODS \ + static const COMPRESSION_METHOD compression_methods[] = {{"standard", NULL, NULL}, {"gzip", "gzip", "libMdsShr"}}; \ + static const size_t NUM_COMPRESSION_METHODS = sizeof(compression_methods)/sizeof(COMPRESSION_METHOD); +#endif //INTERNAL_NCIDEF_H diff --git a/include/ncidef.h b/include/ncidef.h index e37ce6986c..edcd952a3d 100644 --- a/include/ncidef.h +++ b/include/ncidef.h @@ -1,5 +1,5 @@ -#ifndef _NCIDEF_H -#define _NCIDEF_H +#ifndef NCIDEF_H +#define NCIDEF_H /************************************** NCIDEF.H - definitions of constants used in item list arguments to the @@ -38,7 +38,7 @@ TYPEDEF(4){ NciM_NID_REFERENCE = 0x00004000, NciM_INCLUDE_IN_PULSE = 0x00008000, NciM_COMPRESS_SEGMENTS = 0x00010000, -} ENDDEF(uint32_t, ncim_t); + } ENDDEF(uint32_t, ncim_t); TYPEDEF(4){ NciK_IS_CHILD = 1, NciK_IS_MEMBER = 2, @@ -84,6 +84,8 @@ TYPEDEF(4){ NciUSAGE_STR = 39, NciCLASS_STR = 40, NciVERSION = 41, + NciCOMPRESSION_METHOD = 42, + NciCOMPRESSION_METHOD_STR = 43, } ENDDEF(int16_t, nci_t); #undef TYPEDEF #undef ENDDEF diff --git a/mdsobjects/cpp/testing/MdsTreeSegments.cpp b/mdsobjects/cpp/testing/MdsTreeSegments.cpp index 3217d9d950..51caecea81 100644 --- a/mdsobjects/cpp/testing/MdsTreeSegments.cpp +++ b/mdsobjects/cpp/testing/MdsTreeSegments.cpp @@ -350,6 +350,7 @@ int main(int argc __attribute__((unused)), char *argv[] __attribute__((unused))) { setenv("t_treeseg_path", ".", 1); + TEST_TIMEOUT(100); TEST(putSegment); TEST(BlockAndRows); TEST(makeSegment); diff --git a/mdsshr/Makefile.in b/mdsshr/Makefile.in index 6c24b398f3..f05c05ac13 100644 --- a/mdsshr/Makefile.in +++ b/mdsshr/Makefile.in @@ -24,6 +24,7 @@ libShared = $(addsuffix @SHARETYPE@, $(addprefix @MAKESHLIBDIR@@LIBPRE@, $(lib_L libs = $(libStatic) $(libShared) $(IMPLIB) SOURCES = \ + gzipcompress.c \ librtl.c \ mdsmsg.c \ MDSprintf.c \ diff --git a/mdsshr/MdsCompress.c b/mdsshr/MdsCompress.c index 1406a098dd..9274313e2f 100644 --- a/mdsshr/MdsCompress.c +++ b/mdsshr/MdsCompress.c @@ -189,42 +189,44 @@ static int compress(const mdsdsc_t *const pcimage, pdat->arsize = (unsigned int)(plim - pcmp); nitems = (int)porig->arsize / (int)porig->length; - if (pcentry) + if (pcentry && pcentry->length && pcentry->pointer) { dximage = EMPTY_D; dxentry = EMPTY_D; status = LibFindImageSymbol(pcimage, pcentry, &symbol); if (STATUS_OK) - status = (*symbol)(&nitems, pwork, pdat, &bit, &dximage, &dxentry); - pdat->arsize = (bit + 7) / 8; - pd0 = (mdsdsc_t *)(pdat->pointer + pdat->arsize); - if (dximage.pointer) { - pd1 = &pd0[1] + dximage.length; - if ((char *)pd1 < (char *)plim) + status = (*symbol)(&nitems, pwork, pdat, &bit, &dximage, &dxentry); + pdat->arsize = (bit + 7) / 8; + pd0 = (mdsdsc_t *)(pdat->pointer + pdat->arsize); + if (dximage.pointer) { - prec->dscptrs[0] = pd0; - *pd0 = *(mdsdsc_t *)&dximage; - pd0->pointer = (char *)&pd0[1]; - memcpy(pd0->pointer, dximage.pointer, - dximage.length); + pd1 = &pd0[1] + dximage.length; + if ((char *)pd1 < (char *)plim) + { + prec->dscptrs[0] = pd0; + *pd0 = *(mdsdsc_t *)&dximage; + pd0->pointer = (char *)&pd0[1]; + memcpy(pd0->pointer, dximage.pointer, + dximage.length); + } + pd0 = pd1; + StrFree1Dx(&dximage); } - pd0 = pd1; - StrFree1Dx(&dximage); - } - if (dxentry.pointer) - { - pd1 = &pd0[1] + dxentry.length; - if ((char *)pd1 < (char *)plim) + if (dxentry.pointer) { - prec->dscptrs[1] = pd0; - *pd0 = *(mdsdsc_t *)&dxentry; - pd0->pointer = (char *)&pd0[1]; - memcpy(pd0->pointer, dxentry.pointer, - dxentry.length); + pd1 = &pd0[1] + dxentry.length; + if ((char *)pd1 < (char *)plim) + { + prec->dscptrs[1] = pd0; + *pd0 = *(mdsdsc_t *)&dxentry; + pd0->pointer = (char *)&pd0[1]; + memcpy(pd0->pointer, dxentry.pointer, + dxentry.length); + } + pd0 = pd1; + StrFree1Dx(&dxentry); } - pd0 = pd1; - StrFree1Dx(&dxentry); } if ((STATUS_OK) && (status != LibSTRTRU) && ((char *)pd0 < (char *)plim)) diff --git a/mdsshr/MdsSerialize.c b/mdsshr/MdsSerialize.c index d49ddf5952..0519e389b7 100644 --- a/mdsshr/MdsSerialize.c +++ b/mdsshr/MdsSerialize.c @@ -26,6 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include <_ncidef.h> #include #include @@ -52,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define FixLength(a) \ if (a.length == 0) \ MdsFixDscLength((mdsdsc_t *)&a) +#define N_ELEMENTS(a) (sizeof(a) / sizeof(a[0])) void MdsFixDscLength(mdsdsc_t *in); #ifdef WORDS_BIGENDIAN @@ -1127,12 +1129,25 @@ EXPORT int MdsSerializeDscOutZ( MdsCopyDxXdZ(in, out, 0, fixupNid, fixupNidArg, fixupPath, fixupPathArg); if (status == MdsCOMPRESSIBLE) { - if (compress) + // changed the meaning of the compress arg from boolean to: + // -1 -don't compress + // 0 - use standard delta compression + // 1.. - use the compression method with this index + if (compress != -1) { + DEFINE_COMPRESSION_METHODS + tempxd = *out; out->l_length = 0; out->pointer = 0; - status = MdsCompress(0, 0, tempxd.pointer, out); + if ((unsigned int)compress >= NUM_COMPRESSION_METHODS) + compress = 0; + DESCRIPTOR(image, compression_methods[compress].image); + DESCRIPTOR(method, compression_methods[compress].method); + status = MdsCompress((compress) ? &image : NULL, + (compress) ? &method : NULL, + tempxd.pointer, + out); MdsFree1Dx(&tempxd, NULL); compressible = 0; } @@ -1219,5 +1234,5 @@ EXPORT int MdsSerializeDscOutZ( EXPORT int MdsSerializeDscOut(mdsdsc_t const *in, mdsdsc_xd_t *out) { - return MdsSerializeDscOutZ(in, out, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + return MdsSerializeDscOutZ(in, out, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0); } diff --git a/mdsshr/gzipcompress.c b/mdsshr/gzipcompress.c new file mode 100644 index 0000000000..e9aa1fbf07 --- /dev/null +++ b/mdsshr/gzipcompress.c @@ -0,0 +1,86 @@ +#include + +#include +#include + +#include +#include +#include + +//#define DEBUG + +#define UNUSED(x) (void)(x) + +EXPORT int gzip( + const int *const nitems_ptr, + const mdsdsc_a_t *const items_dsc_ptr, + mdsdsc_a_t *const pack_dsc_ptr, + int *const bit_ptr, + mdsdsc_d_t * const pdximage, + mdsdsc_d_t * const pdxentry +) +{ + int ret; + UNUSED(nitems_ptr); + + // unsigned long maxDestinationSize = compressBound(items_dsc_ptr->length); + + unsigned long pack_length = pack_dsc_ptr->arsize; + static const DESCRIPTOR(image, "libMdsShr"); + static const DESCRIPTOR(routine, "gunzip"); + ret = compress( + (Bytef *)pack_dsc_ptr->pointer, + &pack_length, + (Bytef *)items_dsc_ptr->pointer, + items_dsc_ptr->arsize + ); + + if (ret != Z_OK) { + return LibSTRTRU; + } + +#ifdef DEBUG + printf("gzip() %u => %lu\n", pack_dsc_ptr->arsize, pack_length); +#endif + // The new compressed length, in bits (for some reason) + *bit_ptr = pack_length * 8; + + if (pdximage) { + StrCopyDx((mdsdsc_t * const)pdximage, &image); + } + + if (pdxentry) { + StrCopyDx((mdsdsc_t * const)pdxentry, &routine); + } +#ifdef DEBUG + printf("gzip() called successfully\n"); +#endif + return 1; +} +EXPORT int gunzip( + int *const nitems_ptr, + const mdsdsc_a_t *const pack_dsc_ptr, + mdsdsc_a_t *const items_dsc_ptr, + int *const bit_ptr +) +{ + int ret; + UNUSED(nitems_ptr); + UNUSED(bit_ptr); + unsigned long items_length = items_dsc_ptr->arsize; + + ret = uncompress( + (Bytef *)items_dsc_ptr->pointer, + &items_length, + (Bytef *)pack_dsc_ptr->pointer, + pack_dsc_ptr->arsize + ); + + if (ret != Z_OK) { + return LibINVSTRDES; + } +#ifdef DEBUG + printf("gunzip() called successfully\n"); +#endif + return 1; +} diff --git a/python/MDSplus/tree.py b/python/MDSplus/tree.py index 4a7a64b21a..e6cd4505b9 100644 --- a/python/MDSplus/tree.py +++ b/python/MDSplus/tree.py @@ -90,6 +90,14 @@ def __init__(self, usage): super(UsageError, self).__init__('Invalid usage "%s". Must be one of: %s' % ( str(usage), ', '.join(_usage_table.keys()))) +_compression_methods_table = {'standard': 0, 'gzip': 1} + +class CompressionMethodError(KeyError): + def __init__(self, compression_method): + super(CompressionMethodError, self).__init__('Invalid compression_method "%s". Must be one of: %s' % ( + str(compression_method), ', '.join(_compression_methods_table.keys()))) + + # ################################################### @@ -300,6 +308,8 @@ class Nci(object): USAGE_STR = (39, _C.c_char_p, 64, str) CLASS_STR = (40, _C.c_char_p, 64, str) VERSION = (41, _C.c_uint32, 4, int) + COMPRESSION_METHOD = (42, _C.c_uint8, 1, int) + COMPRESSION_METHOD_STR = (43, _C.c_char_p, 64, str) class _nci_item(_C.Structure): _fields_ = [("buflen", _C.c_ushort), @@ -1308,6 +1318,11 @@ def _getNci(self, info): return TreeNodeArray([int(ans[i]) for i in _ver.xrange(retlen//4)], self.tree) return rtype(ans.value) + def _setNci(self, code, setting): + pointer = _C.cast(_C.pointer(_C.c_uint32(setting)), _C.c_char_p) + _exc.checkStatus(_TreeShr._TreeSetNci( + self.ctx, self._nid, _C.byref(Nci._nci_item(0, code, pointer)))) + def _setNciFlag(self, mask, setting): value = 1 if setting else 2 pointer = _C.cast(_C.pointer(_C.c_uint32(mask)), _C.c_char_p) @@ -1394,6 +1409,11 @@ def _setNciFlag(self, mask, setting): Nci.TIME_INSERTED, "64-bit timestamp when data was stored") usage_str = Nci._nciProp( Nci.USAGE_STR, "formal name of the usage of this node") + compression_method = Nci._nciProp( + Nci.COMPRESSION_METHOD, "numerical code for the compression method to use for this node") + compression_method_str = Nci._nciProp( + Nci.COMPRESSION_METHOD_STR, "name of the compression algorithm to use for this node") + __children_nids = Nci._nciProp(Nci.CHILDREN_NIDS) __member_nids = Nci._nciProp(Nci.MEMBER_NIDS) @@ -1549,6 +1569,15 @@ def usage(self): @usage.setter def usage(self, usage): self.setUsage(usage) + @property + def compression_method(self): + "compression method to use for this node." + return _scr.String(str(self.compression_method_str)) + + @compression_method.setter + def compression_method(self, compression_method): + self.setCompressionMethod(compression_method) + ######################################## # End of Node Properties ######################################## @@ -2938,6 +2967,18 @@ def setUsage(self, usage): _C.c_int32(usagenum))) return self + def setCompressionMethod(self, compression_method): + """Set the usage of a node + @param compression_method: name of compression method from predfined list. + @type usage: str + @rtype: original type + """ + try: + compressionmethodnum = _compression_methods_table[compression_method.lower()] + except KeyError: + raise CompressionMethodError(compression_method) + self._setNci(Nci.COMPRESSION_METHOD[0], compressionmethodnum) + def setTree(self, tree): """Set Tree associated with this node @param tree: Tree instance to associated with this node diff --git a/tcl/tcl_directory.c b/tcl/tcl_directory.c index edf245b682..7287b5ca98 100644 --- a/tcl/tcl_directory.c +++ b/tcl/tcl_directory.c @@ -279,12 +279,18 @@ static int doFull(char **output, int nid, unsigned char nodeUsage, "text", "window", "axis", "subtree", "compound data", "unknown"}; #define MAX_USAGES (sizeof(usages) / sizeof(usages[0])) +#include <_ncidef.h> +#define UNUSED(x) (void)(x) + DEFINE_COMPRESSION_METHODS + UNUSED(NUM_COMPRESSION_METHODS); + int nciFlags; unsigned int owner; char class; char dtype; uint32_t dataLen; unsigned short conglomerate_elt; + unsigned char compression_method; int vers; NCI_ITM full_list[] = {{4, NciVERSION, &vers, 0}, {4, NciGET_FLAGS, &nciFlags, 0}, @@ -294,6 +300,7 @@ static int doFull(char **output, int nid, unsigned char nodeUsage, {1, NciDTYPE, &dtype, 0}, {4, NciLENGTH, &dataLen, 0}, {2, NciCONGLOMERATE_ELT, &conglomerate_elt, 0}, + {1, NciCOMPRESSION_METHOD, &compression_method, 0}, {0, NciEND_OF_LIST, 0, 0}}; int status; vers = version; @@ -345,7 +352,15 @@ static int doFull(char **output, int nid, unsigned char nodeUsage, strcat(msg, (nciFlags & NciM_COMPRESS_SEGMENTS) ? "," : "\n"); } if (nciFlags & NciM_COMPRESS_SEGMENTS) + { strcat(msg, "compress segments\n"); + } + if (((nciFlags & NciM_DO_NOT_COMPRESS) == 0) && (compression_method != 0)) + { + strcat(msg, " compression method = "); + strcat(msg, compression_methods[compression_method].name); + strcat(msg, "\n"); + } if (strlen(msg) > 0) { diff --git a/tcl/tcl_set_node.c b/tcl/tcl_set_node.c index c92de0b28e..d0525e6ad8 100644 --- a/tcl/tcl_set_node.c +++ b/tcl/tcl_set_node.c @@ -26,6 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #ifdef HAVE_ALLOCA_H #include #endif @@ -35,12 +36,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include <_ncidef.h> #include #include #include #include "tcl_p.h" +DEFINE_COMPRESSION_METHODS + /********************************************************************** * TCL_SET_NODE.C -- * @@ -78,6 +82,44 @@ EXPORT int TclSetNode(void *ctx, char **error, char **output) setnci[0].pointer = (unsigned char *)&statval; TreeSetNci(nid, setnci); } + if (cli_present(ctx, "COMPRESSION_METHOD")) + { + char *compression_method_str = 0; + if(cli_get_value(ctx, "COMPRESSION_METHOD", &compression_method_str) & 1) + { + unsigned int i; + unsigned char compression_method=0; + char *p = compression_method_str; + for ( ; *p; ++p) *p = tolower(*p); + for (i=0; i < NUM_COMPRESSION_METHODS; i++) + { + if(strcmp(compression_method_str, compression_methods[i].name) == 0) + { + compression_method=i; + break; + } + } + if(i < NUM_COMPRESSION_METHODS) + { + NCI_ITM setnci[] = {{sizeof(compression_method), NciCOMPRESSION_METHOD, 0, 0}, + {0, NciEND_OF_LIST, 0, 0}}; + setnci[0].pointer = (unsigned char *)&compression_method; + TreeSetNci(nid, setnci); + } + else + { + *error = malloc(strlen(nodename) + strlen(compression_method_str) + 100); + sprintf(*error, + "Error: Problem setting compression method for node %s\n" + "\t%s not a valid compression method\n", + nodename, compression_method_str); + free(compression_method_str); + goto error; + } + free(compression_method_str); + } + } + switch (cli_present(ctx, "SUBTREE")) { case MdsdclPRESENT: diff --git a/tdishr/TdiGetNci.c b/tdishr/TdiGetNci.c index 8325328518..f5d05bacfb 100644 --- a/tdishr/TdiGetNci.c +++ b/tdishr/TdiGetNci.c @@ -94,6 +94,8 @@ static const struct item {"CLASS_STR", 0, 0, NciCLASS_STR, DTYPE_T, 0}, {"COMPRESSIBLE", NciM_COMPRESSIBLE, NciM_COMPRESSIBLE, NciGET_FLAGS, DTYPE_BU, 1}, + {"COMPRESSION_METHOD", 0, 0, NciCOMPRESSION_METHOD, DTYPE_BU, 1}, + {"COMPRESSION_METHOD_STR", 0, 0, NciCOMPRESSION_METHOD_STR, DTYPE_T, 0}, {"COMPRESS_ON_PUT", NciM_COMPRESS_ON_PUT, NciM_COMPRESS_ON_PUT, NciGET_FLAGS, DTYPE_BU, 1}, {"COMPRESS_SEGMENTS", NciM_COMPRESS_SEGMENTS, NciM_COMPRESS_SEGMENTS, diff --git a/treeshr/TreeGetNci.c b/treeshr/TreeGetNci.c index bb83f3cd14..fb67e75834 100644 --- a/treeshr/TreeGetNci.c +++ b/treeshr/TreeGetNci.c @@ -31,6 +31,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include <_ncidef.h> #include #include #include @@ -43,6 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define O_RANDOM 0 #endif +DEFINE_COMPRESSION_METHODS + static inline int minInt(int a, int b) { return a < b ? a : b; } #define read_nci \ @@ -283,6 +286,12 @@ int TreeGetNci(int nid_in, struct nci_itm *nci_itm) } *(unsigned int *)itm->pointer = owner; break; + case NciCOMPRESSION_METHOD: + break_on_no_node; + read_nci; + set_retlen(sizeof(nci.compression_method)); + *(unsigned char *)itm->pointer = nci.compression_method; + break; case NciCLASS: break_on_no_node; read_nci; @@ -684,6 +693,16 @@ int TreeGetNci(int nid_in, struct nci_itm *nci_itm) break; } + case NciCOMPRESSION_METHOD_STR: + { + break_on_no_node; + read_nci; + if (nci.compression_method >= NUM_COMPRESSION_METHODS) + nci.compression_method = 0; + string = strdup(compression_methods[nci.compression_method].name); + break; + } + default: status = TreeILLEGAL_ITEM; } diff --git a/treeshr/TreePutRecord.c b/treeshr/TreePutRecord.c index 20082fa115..7dd639ab81 100644 --- a/treeshr/TreePutRecord.c +++ b/treeshr/TreePutRecord.c @@ -245,8 +245,8 @@ int _TreePutRecord(void *dbid, int nid, struct descriptor *descriptor_ptr, status = MdsSerializeDscOutZ( descriptor_ptr, info_ptr->data_file->data, tree_fixup_nid, dbid_tree, FixupPath, 0, - (compress_utility || (nci->flags & NciM_COMPRESS_ON_PUT)) && - !(nci->flags & NciM_DO_NOT_COMPRESS), + ((compress_utility || (nci->flags & NciM_COMPRESS_ON_PUT)) && + !(nci->flags & NciM_DO_NOT_COMPRESS)) ? local_nci.compression_method : -1, &compressible, &nci->length, &nci->DATA_INFO.DATA_LOCATION.record_length, &nci->dtype, &nci->class, diff --git a/treeshr/TreeSegments.c b/treeshr/TreeSegments.c index 022fc58be1..55272a5088 100644 --- a/treeshr/TreeSegments.c +++ b/treeshr/TreeSegments.c @@ -411,9 +411,10 @@ inline static int open_datafile_write1(vars_t *vars) inline static void set_compress(vars_t *vars) { - vars->compress = (vars->local_nci.flags & NciM_COMPRESS_ON_PUT) && + vars->compress = ((vars->local_nci.flags & NciM_COMPRESS_ON_PUT) && (vars->local_nci.flags & NciM_COMPRESS_SEGMENTS) && - !(vars->local_nci.flags & NciM_DO_NOT_COMPRESS); + !(vars->local_nci.flags & NciM_DO_NOT_COMPRESS)) ? + vars->local_nci.compression_method : -1; } #define NAMED_ATTRIBUTES_INDEX_SIZE \ @@ -1145,7 +1146,7 @@ static int begin_sinfo(vars_t *vars, mdsdsc_a_t *initialValue, /* If not the first segment, see if we can reuse the previous segment storage * space and compress the previous segment. */ if (((vars->shead.idx % SEGMENTS_PER_INDEX) > 0) && - (previous_length == (int64_t)vars->add_length) && vars->compress) + (previous_length == (int64_t)vars->add_length) && (vars->compress != -1)) { EMPTYXD(xd_data); EMPTYXD(xd_dim); @@ -2302,7 +2303,8 @@ int tree_put_dsc(PINO_DATABASE *dbid, TREE_INFO *tinfo, int nid_in, unsigned char tree = nid->tree; void *dbid_tree[2] = {(void *)dbid, (void *)&tree}; int status = MdsSerializeDscOutZ(dsc, &xd, tree_fixup_nid, dbid_tree, 0, 0, - compress, &compressible, &ddlen, &reclen, + compress, + &compressible, &ddlen, &reclen, &dtype, &class, 0, 0, &data_in_altbuf); if (STATUS_OK && xd.pointer && xd.pointer->class == CLASS_A && xd.pointer->pointer) @@ -2354,7 +2356,7 @@ copy_segment(TREE_INFO *tinfo_in, PINO_DATABASE *dbid_out, TREE_INFO *tinfo_out, int compress) { // used in copy_segment_index only int status = TreeSUCCESS; - if (compress) + if (compress != -1) { int length; EMPTYXD(xd); @@ -2568,17 +2570,17 @@ int TreeCopyExtended(PINO_DATABASE *dbid_in, PINO_DATABASE *dbid_out, int nid, copy_named_attributes(tinfo_in, dbid_out, tinfo_out, nid, &attr.facility_offset[NAMED_ATTRIBUTES_FACILITY], &attr.facility_length[NAMED_ATTRIBUTES_FACILITY], - compress); + (compress) ? nci->compression_method : -1); if (attr.facility_offset[SEGMENTED_RECORD_FACILITY] != -1) copy_segmented_records(tinfo_in, dbid_out, tinfo_out, nid, &attr.facility_offset[SEGMENTED_RECORD_FACILITY], &attr.facility_length[SEGMENTED_RECORD_FACILITY], - compress); + (compress) ? nci->compression_method : -1); if (attr.facility_offset[STANDARD_RECORD_FACILITY] != -1) copy_standard_record(tinfo_in, dbid_out, tinfo_out, nid, &attr.facility_offset[STANDARD_RECORD_FACILITY], &attr.facility_length[STANDARD_RECORD_FACILITY], - compress); + (compress) ? nci->compression_method : -1); RETURN_IF_NOT_OK(TreePutExtendedAttributes(tinfo_out, &attr, &offset)); SeekToRfa(offset, nci->DATA_INFO.DATA_LOCATION.rfa); int locked = 0; diff --git a/treeshr/TreeSerializeNci.c b/treeshr/TreeSerializeNci.c index fa4af32b8d..4876377cd7 100644 --- a/treeshr/TreeSerializeNci.c +++ b/treeshr/TreeSerializeNci.c @@ -39,7 +39,7 @@ void TreeSerializeNciOut(const NCI *in, char *out) putint8(&ptr, &in->class); putint8(&ptr, &in->dtype); putint32(&ptr, &in->length); - putint8(&ptr, &in->spare2); + putint8(&ptr, &in->compression_method); putint32(&ptr, &in->status); if (in->flags2 & NciM_DATA_IN_ATT_BLOCK) { @@ -71,7 +71,7 @@ void TreeSerializeNciIn(const char *in, NCI *out) getint8(&ptr, &out->class); getint8(&ptr, &out->dtype); getint32(&ptr, &out->length); - getint8(&ptr, &out->spare2); + getint8(&ptr, &out->compression_method); getint32(&ptr, &out->status); if (out->flags2 & NciM_DATA_IN_ATT_BLOCK) { diff --git a/treeshr/TreeSetNci.c b/treeshr/TreeSetNci.c index a12217bd10..0e0d77010f 100644 --- a/treeshr/TreeSetNci.c +++ b/treeshr/TreeSetNci.c @@ -232,6 +232,10 @@ int _TreeSetNci(void *dbid, int nid_in, NCI_ITM *nci_itm_ptr) status = TreeSUCCESS; break; } + case NciCOMPRESSION_METHOD: + putnci = 1; + nci.compression_method = *(unsigned char *)itm_ptr->pointer; + break; default: status = TreeILLEGAL_ITEM; break; diff --git a/treeshr/treeshrp.h b/treeshr/treeshrp.h index a6ac0682ba..79c52e2951 100644 --- a/treeshr/treeshrp.h +++ b/treeshr/treeshrp.h @@ -53,7 +53,7 @@ typedef struct nci class_t class; dtype_t dtype; l_length_t length; - unsigned char spare2; + unsigned char compression_method; unsigned int status; union { struct diff --git a/xml/tcl_commands.xml b/xml/tcl_commands.xml index 178af6087a..e6198b4c5f 100644 --- a/xml/tcl_commands.xml +++ b/xml/tcl_commands.xml @@ -1113,7 +1113,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [NO]ESSENTIAL - make this node 'essential' for DISPATCH/CHECK LOG - log node changes STATUS=n - Write a status value to a node (usually action nodes). - + COMPRESSION_METHOD={standard | gzip} - set the compression method for this node. All nodes in an MDSplus tree have a set of attributes, some are set automatically when data is stored, some are set when the nodes are first added to a tree and some are modifiable by this command. The options indicated with a '[NO]' prefix @@ -1141,6 +1141,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +