GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-d6dec75dd4
segment.h
Go to the documentation of this file.
1 #ifndef GRASS_SEGMENT_H
2 #define GRASS_SEGMENT_H
3 
4 #include <grass/gis.h>
5 
6 #ifdef HAVE_UNISTD_H
7 #include <unistd.h>
8 #endif
9 
10 #ifdef HAVE_SYS_TYPES_H
11 #include <sys/types.h>
12 #endif
13 
14 struct aq { /* age queue */
15  int cur; /* segment number */
16  struct aq *younger, *older; /* pointer to next younger and next older */
17 };
18 
19 typedef struct SEGMENT {
20  int open; /* open flag */
21  off_t nrows; /* rows in original data */
22  off_t ncols; /* cols in original data */
23  int len; /* bytes per data value */
24  int srows; /* rows in segments */
25  int scols; /* cols in segments */
26  int srowscols; /* rows x cols in segments */
27  int size; /* size in bytes of a segment */
28  int spr; /* segments per row */
29  int spill; /* cols in last segment in row */
30 
31  /* fast mode */
32  int fast_adrs; /* toggles fast address mode */
33  off_t scolbits; /* column bitshift */
34  off_t srowbits; /* row bitshift */
35  off_t segbits; /* segment bitshift */
36  int fast_seek; /* toggles fast seek mode */
37  int lenbits; /* data size bitshift */
38  int sizebits; /* segment size bitshift */
39  int (*address)(const struct SEGMENT *, off_t, off_t, int *, int *);
40  int (*seek)(const struct SEGMENT *S, int, int);
41 
42  char *fname; /* segment file name */
43  int fd; /* file descriptor to read/write segment */
44  struct scb /* control blocks */
45  {
46  char *buf; /* data buffer */
47  char dirty; /* dirty flag */
48  struct aq *age; /* pointer to position in age queue */
49  int n; /* segment number */
50  } *scb;
51  int *load_idx; /* index of loaded segments */
52  int nfreeslots; /* number of free slots */
53  int *freeslot; /* array of free slots */
54  struct aq *agequeue, /* queue of age for order of access */
55  *youngest, /* youngest in age queue */
56  *oldest; /* oldest in age queue */
57  int nseg; /* number of segments in memory */
58  int cur; /* last accessed segment */
59  int offset; /* offset of data past header */
60 
61  char *cache; /* all in memory cache */
63 
64 #include <grass/defs/segment.h>
65 
66 #endif /* GRASS_SEGMENT_H */
struct SEGMENT SEGMENT
struct aq * age
Definition: segment.h:48
char dirty
Definition: segment.h:47
char * buf
Definition: segment.h:46
int len
Definition: segment.h:23
int spill
Definition: segment.h:29
off_t nrows
Definition: segment.h:21
int * freeslot
Definition: segment.h:53
struct aq * agequeue
Definition: segment.h:54
int cur
Definition: segment.h:58
int(* address)(const struct SEGMENT *, off_t, off_t, int *, int *)
Definition: segment.h:39
off_t segbits
Definition: segment.h:35
int fast_adrs
Definition: segment.h:32
struct aq * youngest
Definition: segment.h:55
int lenbits
Definition: segment.h:37
struct aq * oldest
Definition: segment.h:56
off_t scolbits
Definition: segment.h:33
int * load_idx
Definition: segment.h:51
int spr
Definition: segment.h:28
int nfreeslots
Definition: segment.h:52
struct SEGMENT::scb * scb
off_t ncols
Definition: segment.h:22
int nseg
Definition: segment.h:57
char * cache
Definition: segment.h:61
int open
Definition: segment.h:20
int fd
Definition: segment.h:43
int srowscols
Definition: segment.h:26
int fast_seek
Definition: segment.h:36
int(* seek)(const struct SEGMENT *S, int, int)
Definition: segment.h:40
int sizebits
Definition: segment.h:38
off_t srowbits
Definition: segment.h:34
char * fname
Definition: segment.h:42
int offset
Definition: segment.h:59
int size
Definition: segment.h:27
int srows
Definition: segment.h:24
int scols
Definition: segment.h:25
Definition: segment.h:14
struct aq * younger
Definition: segment.h:16
int cur
Definition: segment.h:15
struct aq * older
Definition: segment.h:16