Initial commit
This commit is contained in:
Generated
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
import { VariableSizeVector } from "../variableSizeVector";
|
||||
import type BitVector from "../flat/bitVector";
|
||||
export declare class StringFsstDictionaryVector extends VariableSizeVector<Uint8Array, string> {
|
||||
private readonly indexBuffer;
|
||||
private readonly symbolOffsetBuffer;
|
||||
private readonly symbolTableBuffer;
|
||||
private symbolLengthBuffer;
|
||||
private decodedDictionary;
|
||||
constructor(name: string, indexBuffer: Uint32Array, offsetBuffer: Uint32Array, dictionaryBuffer: Uint8Array, symbolOffsetBuffer: Uint32Array, symbolTableBuffer: Uint8Array, nullabilityBuffer: BitVector);
|
||||
protected getValueFromBuffer(index: number): string;
|
||||
private offsetToLengthBuffer;
|
||||
}
|
||||
Generated
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
import { VariableSizeVector } from "../variableSizeVector";
|
||||
import { decodeFsst } from "../../decoding/fsstDecoder";
|
||||
import { decodeString } from "../../decoding/decodingUtils";
|
||||
export class StringFsstDictionaryVector extends VariableSizeVector {
|
||||
constructor(name, indexBuffer, offsetBuffer, dictionaryBuffer, symbolOffsetBuffer, symbolTableBuffer, nullabilityBuffer) {
|
||||
super(name, offsetBuffer, dictionaryBuffer, nullabilityBuffer);
|
||||
this.indexBuffer = indexBuffer;
|
||||
this.symbolOffsetBuffer = symbolOffsetBuffer;
|
||||
this.symbolTableBuffer = symbolTableBuffer;
|
||||
}
|
||||
getValueFromBuffer(index) {
|
||||
if (this.decodedDictionary == null) {
|
||||
if (this.symbolLengthBuffer == null) {
|
||||
// TODO: change FsstEncoder to take offsets instead of length to get rid of this conversion
|
||||
this.symbolLengthBuffer = this.offsetToLengthBuffer(this.symbolOffsetBuffer);
|
||||
}
|
||||
this.decodedDictionary = decodeFsst(this.symbolTableBuffer, this.symbolLengthBuffer, this.dataBuffer);
|
||||
}
|
||||
const offset = this.indexBuffer[index];
|
||||
const start = this.offsetBuffer[offset];
|
||||
const end = this.offsetBuffer[offset + 1];
|
||||
return decodeString(this.decodedDictionary, start, end);
|
||||
}
|
||||
// TODO: get rid of that conversion
|
||||
offsetToLengthBuffer(offsetBuffer) {
|
||||
const lengthBuffer = new Uint32Array(offsetBuffer.length - 1);
|
||||
let previousOffset = offsetBuffer[0];
|
||||
for (let i = 1; i < offsetBuffer.length; i++) {
|
||||
const offset = offsetBuffer[i];
|
||||
lengthBuffer[i - 1] = offset - previousOffset;
|
||||
previousOffset = offset;
|
||||
}
|
||||
return lengthBuffer;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=stringFsstDictionaryVector.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"stringFsstDictionaryVector.js","sourceRoot":"","sources":["../../../src/vector/fsst-dictionary/stringFsstDictionaryVector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,MAAM,OAAO,0BAA2B,SAAQ,kBAAsC;IAKlF,YACI,IAAY,EACK,WAAwB,EACzC,YAAyB,EACzB,gBAA4B,EACX,kBAA+B,EAC/B,iBAA6B,EAC9C,iBAA4B;QAE5B,KAAK,CAAC,IAAI,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;QAP9C,gBAAW,GAAX,WAAW,CAAa;QAGxB,uBAAkB,GAAlB,kBAAkB,CAAa;QAC/B,sBAAiB,GAAjB,iBAAiB,CAAY;IAIlD,CAAC;IAES,kBAAkB,CAAC,KAAa;QACtC,IAAI,IAAI,CAAC,iBAAiB,IAAI,IAAI,EAAE,CAAC;YACjC,IAAI,IAAI,CAAC,kBAAkB,IAAI,IAAI,EAAE,CAAC;gBAClC,2FAA2F;gBAC3F,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACjF,CAAC;YAED,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC1G,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACvC,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACxC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC1C,OAAO,YAAY,CAAC,IAAI,CAAC,iBAAiB,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IAC5D,CAAC;IAED,mCAAmC;IAC3B,oBAAoB,CAAC,YAAyB;QAClD,MAAM,YAAY,GAAG,IAAI,WAAW,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC9D,IAAI,cAAc,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3C,MAAM,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;YAC/B,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,GAAG,cAAc,CAAC;YAC9C,cAAc,GAAG,MAAM,CAAC;QAC5B,CAAC;QAED,OAAO,YAAY,CAAC;IACxB,CAAC;CACJ","sourcesContent":["import { VariableSizeVector } from \"../variableSizeVector\";\nimport type BitVector from \"../flat/bitVector\";\nimport { decodeFsst } from \"../../decoding/fsstDecoder\";\nimport { decodeString } from \"../../decoding/decodingUtils\";\n\nexport class StringFsstDictionaryVector extends VariableSizeVector<Uint8Array, string> {\n // TODO: extend from StringVector\n private symbolLengthBuffer: Uint32Array;\n private decodedDictionary: Uint8Array;\n\n constructor(\n name: string,\n private readonly indexBuffer: Uint32Array,\n offsetBuffer: Uint32Array,\n dictionaryBuffer: Uint8Array,\n private readonly symbolOffsetBuffer: Uint32Array,\n private readonly symbolTableBuffer: Uint8Array,\n nullabilityBuffer: BitVector,\n ) {\n super(name, offsetBuffer, dictionaryBuffer, nullabilityBuffer);\n }\n\n protected getValueFromBuffer(index: number): string {\n if (this.decodedDictionary == null) {\n if (this.symbolLengthBuffer == null) {\n // TODO: change FsstEncoder to take offsets instead of length to get rid of this conversion\n this.symbolLengthBuffer = this.offsetToLengthBuffer(this.symbolOffsetBuffer);\n }\n\n this.decodedDictionary = decodeFsst(this.symbolTableBuffer, this.symbolLengthBuffer, this.dataBuffer);\n }\n\n const offset = this.indexBuffer[index];\n const start = this.offsetBuffer[offset];\n const end = this.offsetBuffer[offset + 1];\n return decodeString(this.decodedDictionary, start, end);\n }\n\n // TODO: get rid of that conversion\n private offsetToLengthBuffer(offsetBuffer: Uint32Array): Uint32Array {\n const lengthBuffer = new Uint32Array(offsetBuffer.length - 1);\n let previousOffset = offsetBuffer[0];\n for (let i = 1; i < offsetBuffer.length; i++) {\n const offset = offsetBuffer[i];\n lengthBuffer[i - 1] = offset - previousOffset;\n previousOffset = offset;\n }\n\n return lengthBuffer;\n }\n}\n"]}
|
||||
Reference in New Issue
Block a user