|
@@ -7,6 +7,7 @@
|
|
|
import { Column, ColumnType, createArray } from '../../column'
|
|
|
import { trimStr } from '../tokenizer'
|
|
|
import { parseIntSkipLeadingWhitespace, parseFloatSkipLeadingWhitespace } from '../number-parser'
|
|
|
+import StringPool from '../../../../utils/short-string-pool'
|
|
|
|
|
|
export interface FixedColumnInfo {
|
|
|
data: string,
|
|
@@ -28,12 +29,18 @@ function getArrayValues(value: (row: number) => any, target: any[], start: numbe
|
|
|
export function FixedColumn<T extends ColumnType>(info: FixedColumnInfo, offset: number, width: number, type: T): Column<T['@type']> {
|
|
|
const { data, lines, rowCount } = info;
|
|
|
const { kind } = type;
|
|
|
+ const pool = kind === 'pooled-str' ? StringPool.create() : void 0;
|
|
|
|
|
|
const value: Column<T['@type']>['value'] = kind === 'str' ? row => {
|
|
|
let s = lines[2 * row] + offset, e = s + width, le = lines[2 * row + 1];
|
|
|
if (s >= le) return '';
|
|
|
if (e > le) e = le;
|
|
|
return trimStr(data, s, e);
|
|
|
+ } : kind === 'pooled-str' ? row => {
|
|
|
+ let s = lines[2 * row] + offset, e = s + width, le = lines[2 * row + 1];
|
|
|
+ if (s >= le) return '';
|
|
|
+ if (e > le) e = le;
|
|
|
+ return StringPool.get(pool!, trimStr(data, s, e));
|
|
|
} : kind === 'int' ? row => {
|
|
|
const s = lines[2 * row] + offset, e = s + width;
|
|
|
return parseIntSkipLeadingWhitespace(data, s, e);
|