GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-d6dec75dd4
|
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. More... | |
int | Segment_close (SEGMENT *) |
Free memory allocated to segment, delete temp file. More... | |
int | Segment_flush (SEGMENT *) |
Flush pending updates to disk. More... | |
int | Segment_format (int, off_t, off_t, int, int, int) |
Format a segment file. More... | |
int | Segment_format_nofill (int, off_t, off_t, int, int, int) |
Format a segment file. More... | |
int | Segment_get (SEGMENT *, void *, off_t, off_t) |
Get value from segment file. More... | |
int | Segment_get_row (const SEGMENT *, void *, off_t) |
int | Segment_init (SEGMENT *, int, int) |
Initialize segment structure. More... | |
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. More... | |
int | Segment_release (SEGMENT *) |
Free memory allocated to segment. More... | |
int Segment_close | ( | SEGMENT * | SEG | ) |
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 33 of file segment/close.c.
References SEGMENT::cache, SEGMENT::fd, SEGMENT::fname, G_free(), NULL, SEGMENT::open, and Segment_release().
int Segment_flush | ( | SEGMENT * | SEG | ) |
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 30 of file flush.c.
References SEGMENT::scb::dirty, SEGMENT::scb::n, SEGMENT::nseg, SEGMENT::scb, and seg_pageout().
int Segment_format | ( | int | fd, |
off_t | nrows, | ||
off_t | ncols, | ||
int | srows, | ||
int | scols, | ||
int | len | ||
) |
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 61 of file segment/format.c.
int Segment_format_nofill | ( | int | fd, |
off_t | nrows, | ||
off_t | ncols, | ||
int | srows, | ||
int | scols, | ||
int | len | ||
) |
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 99 of file segment/format.c.
int Segment_get | ( | SEGMENT * | SEG, |
void * | buf, | ||
off_t | row, | ||
off_t | col | ||
) |
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 37 of file segment/get.c.
References SEGMENT::address, SEGMENT::scb::buf, SEGMENT::cache, SEGMENT::len, SEGMENT::ncols, SEGMENT::scb, and seg_pagein().
int Segment_get_row | ( | const SEGMENT * | SEG, |
void * | buf, | ||
off_t | row | ||
) |
Definition at line 41 of file segment/get_row.c.
int Segment_init | ( | SEGMENT * | SEG, |
int | fd, | ||
int | nseg | ||
) |
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 56 of file segment/init.c.
References err(), SEGMENT::fd, G_warning(), SEGMENT::nseg, and 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 45 of file segment/open.c.
int Segment_put | ( | SEGMENT * | SEG, |
const void * | buf, | ||
off_t | row, | ||
off_t | col | ||
) |
Definition at line 43 of file segment/put.c.
References SEGMENT::address, SEGMENT::scb::buf, SEGMENT::cache, SEGMENT::scb::dirty, G_warning(), SEGMENT::len, SEGMENT::ncols, SEGMENT::scb, and seg_pagein().
int Segment_put_row | ( | const SEGMENT * | SEG, |
const void * | buf, | ||
off_t | row | ||
) |
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 41 of file segment/put_row.c.
int Segment_release | ( | SEGMENT * | SEG | ) |
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 34 of file segment/release.c.
References SEGMENT::agequeue, SEGMENT::scb::buf, SEGMENT::freeslot, G_free(), SEGMENT::load_idx, SEGMENT::nseg, SEGMENT::open, and SEGMENT::scb.
Referenced by Segment_close().