LogLine represents a CSV text line using ASCII 30 as field separator. It implement Record.. In memory, it is kept in a format optimized for very fast parsing and low memory-consumption. The vast majority of fields are never accessed during the lifetime of an object, as a filter usually reads or wri
| 30 | // Modifications can be done through the Set() method, and can be done to any |
| 31 | // field, both those that had a parsed value, and those that were empty. |
| 32 | type LogLine struct { |
| 33 | // These next few fields handle the read-only fields that were parsed from a |
| 34 | // text logline. data is the original line in memory, while idx is the index |
| 35 | // into the original line to the separator that lies before the beginning of |
| 36 | // each field (idx[0] is always -1). meta is the metadata associated with |
| 37 | // the original input. |
| 38 | // Note that data is never modified, because it would be very slow to do it |
| 39 | // in-place, enlarging / shrinking fields as necessary; if the user code |
| 40 | // wants to modify a field through Set(), it is stored in a parallel |
| 41 | // data-structure (see wmask/wdata/wcnt below). |
| 42 | idx [LogLineNumFields + 1]int32 |
| 43 | data []byte |
| 44 | |
| 45 | // meta values can be filled in by the input to add informations on the |
| 46 | // datasource of the Logline, like timestamps, originating S3 file, |
| 47 | // debugging info or other metadata. Values can be accessed by filters or |
| 48 | // output to perform checks, transformations, etc. |
| 49 | meta Metadata |
| 50 | |
| 51 | // This triplet handles in-memory modifications to LogLines (through |
| 52 | // LogLine.Set()). |
| 53 | // wcnt is the 1-based counter of how many fields were modified; |
| 54 | // wdata is the dense storage for those modifications (so we allow for a |
| 55 | // total of 254 different fields being written to). |
| 56 | // wmask is a table indexed by each possible field index, that contains: |
| 57 | // * 0 if the field was not modified (so the current value can be fetched |
| 58 | // by idx/data) |
| 59 | // * the index into wdata were the new value for the field is stored (if |
| 60 | // the field was modified) |
| 61 | // |
| 62 | // NOTE: wdata[0] is never written to, because the index "0" in wmask is the |
| 63 | // special value to signal "no modifications". We keep it like this because |
| 64 | // we like that the zero-initialization of wmask does the right thing |
| 65 | // (i.e. indicates that no fields have been written to). |
| 66 | wmask [LogLineNumFields + NumFieldsBaker]uint8 |
| 67 | wdata [256][]byte |
| 68 | wcnt uint8 |
| 69 | |
| 70 | cache Cache |
| 71 | |
| 72 | // FieldSeparator is the byte used to separate fields value. |
| 73 | FieldSeparator byte |
| 74 | } |
| 75 | |
| 76 | // Get the value of a field (either standard or custom). |
| 77 | func (l *LogLine) Get(f FieldIndex) []byte { |
nothing calls this directly
no outgoing calls
no test coverage detected