How to use the @apache-arrow/es5-esm/type.Dictionary function in @apache-arrow/es5-esm

To help you get started, we’ve selected a few @apache-arrow/es5-esm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github finos / perspective / packages / perspective / src / js / perspective.js View on Github external
if (type === "float") {
                const [vals, nullCount, nullArray] = this.col_to_js_typed_array(name, options);
                vectors.push(Vector.new(Data.Float(new Float64(), 0, vals.length, nullCount, nullArray, vals)));
            } else if (type === "integer") {
                const [vals, nullCount, nullArray] = this.col_to_js_typed_array(name, options);
                vectors.push(Vector.new(Data.Int(new Int32(), 0, vals.length, nullCount, nullArray, vals)));
            } else if (type === "boolean") {
                const [vals, nullCount, nullArray] = this.col_to_js_typed_array(name, options);
                vectors.push(Vector.new(Data.Bool(new Bool(), 0, vals.length, nullCount, nullArray, vals)));
            } else if (type === "date" || type === "datetime") {
                const [vals, nullCount, nullArray] = this.col_to_js_typed_array(name, options);
                vectors.push(Vector.new(Data.Timestamp(new TimestampMillisecond(), 0, vals.length / 2, nullCount, nullArray, vals)));
            } else if (type === "string") {
                const [vals, offsets, indices, nullCount, nullArray] = this.col_to_js_typed_array(name, options);
                const utf8Vector = Vector.new(Data.Utf8(new Utf8(), 0, offsets.length - 1, 0, null, offsets, vals));
                const type = new Dictionary(utf8Vector.type, new Int32(), null, null, utf8Vector);
                vectors.push(Vector.new(Data.Dictionary(type, 0, indices.length, nullCount, nullArray, indices)));
            } else {
                throw new Error(`Type ${type} not supported`);
            }
        }

        return Table.fromVectors(vectors, names.slice(start_col, end_col)).serialize("binary", false).buffer;
    };