Skip to content

Commit d2b3892

Browse files
Add MSF_SPLITISVERSION flag to control using the splitversion value
1 parent e871779 commit d2b3892

File tree

5 files changed

+58
-11
lines changed

5 files changed

+58
-11
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2025.297:
2+
- Add MSF_SPLITISVERSION flag to control using the splitversion value as the
3+
version instead the record publication version for mstl3_addmsr() and variants.
4+
15
2025.267: v3.1.9
26
- Add mstl3_pack_ppupdate_flushidle() for packing idle streams in combination
37
with the use of MSF_PPUPDATETIME during trace list additions.

fileutils.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,7 @@ _ms3_readmsr_impl (MS3FileParam **ppmsfp, MS3Record **ppmsr, const char *mspath,
506506
*
507507
* @param[in] mspath File or URL to read
508508
*
509-
* @param[in] flags Flags used to control parsing, see @ref
510-
* control-flags
509+
* @param[in] flags Flags used to control parsing, see @ref control-flags
511510
*
512511
* @param[in] verbose Controls verbosity, 0 means no diagnostic output
513512
*
@@ -662,7 +661,12 @@ ms3_readtracelist_timewin (MS3TraceList **ppmstl, const char *mspath, const MS3T
662661
* @param[in] tolerance Tolerance function pointers as ::MS3Tolerance
663662
* @param[in] selections Pointer to ::MS3Selections for limiting data
664663
* @param[in] splitversion Flag to control splitting of version/quality
665-
* @param[in] flags Flags to control reading, see ms3_readmsr_selection()
664+
* @param[in] flags
665+
* @parblock
666+
* - \c ::MSF_RECORDLIST : Build a ::MS3RecordList for each ::MS3TraceSeg
667+
* - Flags supported by msr3_parse()
668+
* - Flags supported by mstl3_addmsr()
669+
* @endparblock
666670
* @param[in] verbose Controls verbosity, 0 means no diagnostic output
667671
*
668672
* @returns ::MS_NOERROR and populates an ::MS3TraceList struct at *ppmstl

libmseed.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,6 +1559,8 @@ extern void *libmseed_memory_prealloc (void *ptr, size_t size, size_t *currentsi
15591559
#define MSF_MAINTAINMSTL 0x0200 //!< [TraceList] Do not modify a trace list when packing
15601560
#define MSF_PPUPDATETIME \
15611561
0x0400 //!< [TraceList] Store update time (as nstime_t) at ::MS3TraceSeg.prvtptr
1562+
#define MSF_SPLITISVERSION \
1563+
0x0800 //!< [TraceList] Use the splitversion value as version instead of record version
15621564
/** @} */
15631565

15641566
#ifdef __cplusplus

test/test-tracelist.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,31 @@ TEST (tracelist, read_ppupdatetime)
220220

221221
mstl3_free (&mstl, 1);
222222
}
223+
224+
TEST (tracelist, read_splitisversion)
225+
{
226+
MS3TraceList *mstl = NULL;
227+
MS3TraceID *id = NULL;
228+
uint32_t flags;
229+
int rv;
230+
231+
char *path = "data/testdata-oneseries-mixedlengths-mixedorder.mseed3";
232+
233+
/* Set bit flag to use the value of splitversion as the version
234+
* instead of the record publication version. */
235+
flags = MSF_SPLITISVERSION;
236+
237+
rv = ms3_readtracelist (&mstl, path, NULL, 99, flags, 0);
238+
239+
CHECK (rv == MS_NOERROR, "ms3_readtracelist() did not return expected MS_NOERROR");
240+
REQUIRE (mstl != NULL, "ms3_readtracelist() did not populate 'mstl'");
241+
CHECK (mstl->numtraceids == 1, "mstl->numtraceids is not expected 1");
242+
243+
id = mstl->traces.next[0];
244+
245+
REQUIRE (id != NULL, "mstl->traces.next[0] is not populated");
246+
247+
CHECK (id->pubversion == 99, "id->pubversion is not expected 99");
248+
249+
mstl3_free (&mstl, 1);
250+
}

tracelist.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ _mstl3_addmsr_impl (MS3TraceList *mstl, const MS3Record *msr, MS3RecordPtr **ppr
285285
int8_t splitversion, int8_t autoheal, uint32_t flags,
286286
const MS3Tolerance *tolerance)
287287
{
288-
(void)flags; /* Unused */
289288
MS3TraceID *id = NULL;
290289
MS3TraceID *previd[MSTRACEID_SKIPLIST_HEIGHT] = {NULL};
291290

@@ -320,8 +319,12 @@ _mstl3_addmsr_impl (MS3TraceList *mstl, const MS3Record *msr, MS3RecordPtr **ppr
320319
return NULL;
321320
}
322321

322+
/* If splitversion is true and MSF_SPLITISVERSION is set in flags, use splitversion
323+
* as the version, otherwise use msr->pubversion */
324+
int8_t pubversion = (flags & MSF_SPLITISVERSION) ? splitversion : msr->pubversion;
325+
323326
/* Search for matching trace ID */
324-
id = mstl3_findID (mstl, msr->sid, (splitversion) ? msr->pubversion : 0, previd);
327+
id = mstl3_findID (mstl, msr->sid, (splitversion) ? pubversion : 0, previd);
325328

326329
/* If no matching ID was found create new MS3TraceID and MS3TraceSeg entries */
327330
if (!id)
@@ -335,7 +338,7 @@ _mstl3_addmsr_impl (MS3TraceList *mstl, const MS3Record *msr, MS3RecordPtr **ppr
335338

336339
/* Populate MS3TraceID */
337340
memcpy (id->sid, msr->sid, sizeof (id->sid));
338-
id->pubversion = msr->pubversion;
341+
id->pubversion = pubversion;
339342
id->earliest = msr->starttime;
340343
id->latest = endtime;
341344
id->numsegments = 1;
@@ -627,8 +630,8 @@ _mstl3_addmsr_impl (MS3TraceList *mstl, const MS3Record *msr, MS3RecordPtr **ppr
627630
} /* End of searching segment list */
628631

629632
/* Track largest publication version */
630-
if (msr->pubversion > id->pubversion)
631-
id->pubversion = msr->pubversion;
633+
if (pubversion > id->pubversion)
634+
id->pubversion = pubversion;
632635

633636
/* Track earliest and latest times */
634637
if (msr->starttime < id->earliest)
@@ -707,7 +710,7 @@ _mstl3_addmsr_impl (MS3TraceList *mstl, const MS3Record *msr, MS3RecordPtr **ppr
707710
}
708711

709712
return seg;
710-
} /* End of mstl3_addmsr_recordptr() */
713+
} /* End of _mstl3_addmsr_impl() */
711714

712715
/** ************************************************************************
713716
* @brief Add data coverage from an ::MS3Record to a ::MS3TraceList
@@ -745,12 +748,18 @@ _mstl3_addmsr_impl (MS3TraceList *mstl, const MS3Record *msr, MS3RecordPtr **ppr
745748
* @param[in] msr ::MS3Record containing the data to add to list
746749
* @param[in] splitversion Flag to control splitting of version/quality
747750
* @param[in] autoheal Flag to control automatic merging of segments
748-
* @param[in] flags Flags to control optional functionality (unused)
751+
* @param[in] flags Flags to control optional functionality
752+
* @parblock
753+
* - \c ::MSF_PPUPDATETIME : Store update time (as nstime_t) at ::MS3TraceSeg.prvtptr
754+
* - \c ::MSF_SPLITISVERSION : Use \a splitversion as the version, otherwise use msr->pubversion
755+
* @endparblock
749756
* @param[in] tolerance Tolerance function pointers as ::MS3Tolerance
750757
*
751758
* @returns a pointer to the ::MS3TraceSeg updated or NULL on error.
752759
*
753-
* \sa mstl3_addmsr_recordptr() \sa mstl3_readbuffer() \sa ms3_readtracelist()
760+
* \sa mstl3_addmsr_recordptr()
761+
* \sa mstl3_readbuffer()
762+
* \sa ms3_readtracelist()
754763
*
755764
* \ref MessageOnError - this function logs a message on error
756765
***************************************************************************/

0 commit comments

Comments
 (0)