|
GRASS 8 Programmer's Manual 8.6.0dev(2026)-1d1e47ad9d
|

Go to the source code of this file.
Functions | |
| int | Segment_open (SEGMENT *, char *, off_t, off_t, int, int, int, int) |
| Initialize segment structure and open segment file. | |
| int | Segment_close (SEGMENT *) |
| Free memory allocated to segment, delete temp file. | |
| int | Segment_flush (SEGMENT *) |
| Flush pending updates to disk. | |
| int | Segment_format (int, off_t, off_t, int, int, int) |
| Format a segment file. | |
| int | Segment_format_nofill (int, off_t, off_t, int, int, int) |
| Format a segment file. | |
| int | Segment_get (SEGMENT *, void *, off_t, off_t) |
| Get value from segment file. | |
| int | Segment_get_row (const SEGMENT *, void *, off_t) |
| int | Segment_init (SEGMENT *, int, int) |
| Initialize segment structure. | |
| int | Segment_put (SEGMENT *, const void *, off_t, off_t) |
| int | Segment_put_row (const SEGMENT *, const void *, off_t) |
| Write row to segment file. | |
| int | Segment_release (SEGMENT *) |
| Free memory allocated to segment. | |
Free memory allocated to segment, delete temp file.
Releases the allocated memory associated with the segment file seg and deletes the temporary file.
| [in,out] | SEG | segment |
Definition at line 32 of file segment/close.c.
References close, G_free(), NULL, Segment_release(), and unlink.
Flush pending updates to disk.
Forces all pending updates generated by Segment_put() to be written to the segment file seg. Must be called after the final Segment_put() to force all pending updates to disk. Must also be called before the first call to Segment_get_row.
| [in] | SEG | segment |
Definition at line 29 of file flush.c.
References seg_pageout().
Format a segment file.
The segmentation routines require a disk file to be used for paging segments in and out of memory. This routine formats the file open for write on file descriptor fd for use as a segment file.
A segment file must be formatted before it can be processed by other segment routines. The configuration parameters nrows, ncols, srows, scols, and len are written to the beginning of the segment file which is then filled with zeros.
The corresponding nonsegmented data matrix, which is to be transferred to the segment file, is nrows by ncols. The segment file is to be formed of segments which are srows by scols. The data items have length len bytes. For example, if the data type is int, len is sizeof(int).
| [in] | fd | file descriptor |
| [in] | nrows | number of non-segmented rows |
| [in] | ncols | number of non-segmented columns |
| [in] | srows | segment rows |
| [in] | scols | segment columns |
| [in] | len | length of data type |
Definition at line 60 of file segment/format.c.
Format a segment file.
The segmentation routines require a disk file to be used for paging segments in and out of memory. This routine formats the file open for write on file descriptor fd for use as a segment file.
A segment file must be formatted before it can be processed by other segment routines. The configuration parameters nrows, ncols, srows, scols, and len are written to the beginning of the segment file which is then filled with zeros.
The corresponding nonsegmented data matrix, which is to be transferred to the segment file, is nrows by ncols. The segment file is to be formed of segments which are srows by scols. The data items have length len bytes. For example, if the data type is int, len is sizeof(int).
Note: This version of the function does not fill in the initialized data structures with zeros.
| [in] | fd | file descriptor |
| [in] | nrows | number of non-segmented rows |
| [in] | ncols | number of non-segmented columns |
| [in] | srows | segment rows |
| [in] | scols | segment columns |
| [in] | len | length of data type |
Definition at line 97 of file segment/format.c.
Referenced by Segment_open().
Get value from segment file.
Provides random read access to the segmented data. It gets len bytes of data into buf from the segment file seg for the corresponding row and col in the original data matrix.
| [in] | SEG | segment |
| [in,out] | buf | value return buffer |
| [in] | row | |
| [in] | col |
Definition at line 36 of file segment/get.c.
References UntypedStream::buf, and seg_pagein().
Referenced by P_Read_Raster_Region_Map(), and P_Regular_Points().
Definition at line 43 of file segment/get_row.c.
References _, err(), G_warning(), read, and AMI_STREAM< T >::seek().
Initialize segment structure.
Initializes the seg structure. The file on fd is a segment file created by Segment_format() and must be open for reading and writing. The segment file configuration parameters nrows, ncols, srows, scols, and len, as written to the file by Segment_format(), are read from the file and stored in the seg structure. nsegs specifies the number of segments that will be retained in memory. The minimum value allowed is 1.
Note: The size of a segment is scols*srows*len plus a few bytes for managing each segment.
| [in,out] | SEG | segment |
| [in] | fd | file descriptor |
| [in] | nseg | number of segments to remain in memory |
Definition at line 55 of file segment/init.c.
References err(), G_warning(), and seg_setup().
Referenced by Segment_open().
| int Segment_open | ( | SEGMENT * | SEG, |
| char * | fname, | ||
| off_t | nrows, | ||
| off_t | ncols, | ||
| int | srows, | ||
| int | scols, | ||
| int | len, | ||
| int | nseg | ||
| ) |
Initialize segment structure and open segment file.
Initializes the seg structure and prepares a temporary file. This fn is a wrapper for Segment_format() and Segment_init()
Note: The file with name fname will be created anew.
| [in,out] | SEG | segment |
| [in] | fname | file name |
| [in] | nrows | number of non-segmented rows |
| [in] | ncols | number of non-segmented columns |
| [in] | srows | segment rows |
| [in] | scols | segment columns |
| [in] | len | length of data type |
| [in] | nseg | number of segments to remain in memory |
Definition at line 44 of file segment/open.c.
References _, access, close, creat, F_OK, G_calloc, G_store(), G_verbose_message(), G_warning(), NULL, open, Segment_format_nofill(), Segment_init(), and unlink.
Definition at line 42 of file segment/put.c.
References UntypedStream::buf, G_warning(), and seg_pagein().
Referenced by P_Regular_Points().
Write row to segment file.
Transfers non-segmented matrix data, row by row, into a segment file. seg is the segment structure that was configured from a call to Segment_init(). buf should contain ncols*len bytes of data to be transferred to the segment file. row specifies the row from the data matrix being transferred.
| [in,out] | SEG | segment |
| [in] | buf | data to write to segment |
| [in] | row |
Definition at line 43 of file segment/put_row.c.
References _, err(), G_warning(), AMI_STREAM< T >::seek(), and write.
Free memory allocated to segment.
Releases the allocated memory associated with the segment file seg.
Note: Does not close the file. Does not flush the data which may be pending from previous Segment_put() calls.
| [in,out] | SEG | segment |
Definition at line 33 of file segment/release.c.
References UntypedStream::buf, and G_free().
Referenced by Segment_close().