Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@loaders.gl/schema

Package Overview
Dependencies
Maintainers
7
Versions
187
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@loaders.gl/schema - npm Package Compare versions

Comparing version 3.1.0-beta.1 to 3.1.0-beta.2

3

dist/category/common.d.ts

@@ -1,2 +0,2 @@

import type { RecordBatch } from 'apache-arrow';
declare type RecordBatch = any;
export declare type Field = any;

@@ -19,2 +19,3 @@ export declare type Schema = {

};
export {};
//# sourceMappingURL=common.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertMeshToColumnarTable = exports.convertMesh = void 0;
const mesh_to_arrow_table_1 = require("./mesh-to-arrow-table");
/**

@@ -14,7 +13,7 @@ * Convert a mesh to a specific shape

return convertMeshToColumnarTable(mesh);
case 'arrow-table':
return {
shape: 'arrow-table',
data: (0, mesh_to_arrow_table_1.convertMeshToArrowTable)(mesh)
};
// case 'arrow-table':
// return {
// shape: 'arrow-table',
// data: convertMeshToArrowTable(mesh)
// };
default:

@@ -21,0 +20,0 @@ throw new Error(`Unsupported shape ${options?.shape}`);

@@ -1,11 +0,1 @@

import { Table } from 'apache-arrow/Arrow.dom';
import type { Mesh } from './mesh-types';
/**
* * Convert a loaders.gl Mesh to an Apache Arrow Table
* @param mesh
* @param metadata
* @param batchSize
* @returns
*/
export declare function convertMeshToArrowTable(mesh: Mesh, batchSize?: number): Table;
//# sourceMappingURL=mesh-to-arrow-table.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertMeshToArrowTable = void 0;
const Arrow_dom_1 = require("apache-arrow/Arrow.dom");
const arrow_type_utils_1 = require("../../lib/arrow/arrow-type-utils");
const deduce_mesh_schema_1 = require("./deduce-mesh-schema");
/*
import {
Table,
Schema,
RecordBatch,
FixedSizeList,
Field,
Data,
FixedSizeListVector
} from 'apache-arrow';
import {AbstractVector} from 'apache-arrow/vector';
import {getArrowType, getArrowVector} from '../../lib/arrow/arrow-type-utils.js';
import type {Mesh} from './mesh-types.js';
import {makeMeshAttributeMetadata} from './deduce-mesh-schema.js';
/**

@@ -13,23 +23,23 @@ * * Convert a loaders.gl Mesh to an Apache Arrow Table

* @returns
*/
function convertMeshToArrowTable(mesh, batchSize) {
const vectors = [];
const fields = [];
for (const attributeKey in mesh.attributes) {
const attribute = mesh.attributes[attributeKey];
const { value, size = 1 } = attribute;
const type = (0, arrow_type_utils_1.getArrowType)(value);
const vector = (0, arrow_type_utils_1.getArrowVector)(value);
const listType = new Arrow_dom_1.FixedSizeList(size, new Arrow_dom_1.Field('value', type));
const field = new Arrow_dom_1.Field(attributeKey, listType, false, (0, deduce_mesh_schema_1.makeMeshAttributeMetadata)(attribute));
const data = new Arrow_dom_1.Data(listType, 0, value.length / size, 0, undefined, [vector]);
const listVector = new Arrow_dom_1.FixedSizeListVector(data);
vectors.push(listVector);
fields.push(field);
}
const schema = new Arrow_dom_1.Schema(fields, mesh?.schema?.metadata || new Map());
const recordBatch = new Arrow_dom_1.RecordBatch(schema, vectors[0].length, vectors);
const table = new Arrow_dom_1.Table(schema, recordBatch);
return table;
*
export function convertMeshToArrowTable(mesh: Mesh, batchSize?: number): Table {
const vectors: AbstractVector[] = [];
const fields: Field[] = [];
for (const attributeKey in mesh.attributes) {
const attribute = mesh.attributes[attributeKey];
const {value, size = 1} = attribute;
const type = getArrowType(value);
const vector = getArrowVector(value);
const listType = new FixedSizeList(size, new Field('value', type));
const field = new Field(attributeKey, listType, false, makeMeshAttributeMetadata(attribute));
const data = new Data(listType, 0, value.length / size, 0, undefined, [vector]);
const listVector = new FixedSizeListVector(data);
vectors.push(listVector);
fields.push(field);
}
const schema = new Schema(fields, mesh?.schema?.metadata || new Map<string, string>());
const recordBatch = new RecordBatch(schema, vectors[0].length, vectors);
const table = new Table(schema, recordBatch);
return table;
}
exports.convertMeshToArrowTable = convertMeshToArrowTable;
*/
import type { Schema } from '../../lib/schema/schema';
import type { Table as ApacheArrowTable, RecordBatch } from 'apache-arrow/Arrow.dom';
import type { AnyArray } from '../../types';
import type { Batch } from '../common';
declare type ApacheArrowTable = any;
declare type RecordBatch = any;
/** A general table */

@@ -76,2 +77,3 @@ export interface Table {

};
export {};
//# sourceMappingURL=table-types.d.ts.map

@@ -9,4 +9,2 @@ "use strict";

var _meshToArrowTable = require("./mesh-to-arrow-table");
function convertMesh(mesh, shape, options) {

@@ -20,8 +18,2 @@ switch (shape || 'mesh') {

case 'arrow-table':
return {
shape: 'arrow-table',
data: (0, _meshToArrowTable.convertMeshToArrowTable)(mesh)
};
default:

@@ -28,0 +20,0 @@ throw new Error("Unsupported shape ".concat(options === null || options === void 0 ? void 0 : options.shape));

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.convertMeshToArrowTable = convertMeshToArrowTable;
var _Arrow = require("apache-arrow/Arrow.dom");
var _arrowTypeUtils = require("../../lib/arrow/arrow-type-utils");
var _deduceMeshSchema = require("./deduce-mesh-schema");
function convertMeshToArrowTable(mesh, batchSize) {
var _mesh$schema;
const vectors = [];
const fields = [];
for (const attributeKey in mesh.attributes) {
const attribute = mesh.attributes[attributeKey];
const {
value,
size = 1
} = attribute;
const type = (0, _arrowTypeUtils.getArrowType)(value);
const vector = (0, _arrowTypeUtils.getArrowVector)(value);
const listType = new _Arrow.FixedSizeList(size, new _Arrow.Field('value', type));
const field = new _Arrow.Field(attributeKey, listType, false, (0, _deduceMeshSchema.makeMeshAttributeMetadata)(attribute));
const data = new _Arrow.Data(listType, 0, value.length / size, 0, undefined, [vector]);
const listVector = new _Arrow.FixedSizeListVector(data);
vectors.push(listVector);
fields.push(field);
}
const schema = new _Arrow.Schema(fields, (mesh === null || mesh === void 0 ? void 0 : (_mesh$schema = mesh.schema) === null || _mesh$schema === void 0 ? void 0 : _mesh$schema.metadata) || new Map());
const recordBatch = new _Arrow.RecordBatch(schema, vectors[0].length, vectors);
const table = new _Arrow.Table(schema, recordBatch);
return table;
}
//# sourceMappingURL=mesh-to-arrow-table.js.map
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getArrowType = getArrowType;
exports.getArrowVector = getArrowVector;
var _Arrow = require("apache-arrow/Arrow.dom");
function getArrowType(array) {
switch (array.constructor) {
case Int8Array:
return new _Arrow.Int8();
case Uint8Array:
return new _Arrow.Uint8();
case Int16Array:
return new _Arrow.Int16();
case Uint16Array:
return new _Arrow.Uint16();
case Int32Array:
return new _Arrow.Int32();
case Uint32Array:
return new _Arrow.Uint32();
case Float32Array:
return new _Arrow.Float32();
case Float64Array:
return new _Arrow.Float64();
default:
throw new Error('array type not supported');
}
}
function getArrowVector(array) {
switch (array.constructor) {
case Int8Array:
return _Arrow.Int8Vector.from(array);
case Uint8Array:
return _Arrow.Uint8Vector.from(array);
case Int16Array:
return _Arrow.Int16Vector.from(array);
case Uint16Array:
return _Arrow.Uint16Vector.from(array);
case Int32Array:
return _Arrow.Int32Vector.from(array);
case Uint32Array:
return _Arrow.Uint32Vector.from(array);
case Float32Array:
return _Arrow.Float32Vector.from(array);
case Float64Array:
return _Arrow.Float64Vector.from(array);
default:
throw new Error('array type not supported');
}
}
//# sourceMappingURL=arrow-type-utils.js.map

@@ -1,2 +0,1 @@

import { convertMeshToArrowTable } from './mesh-to-arrow-table';
export function convertMesh(mesh, shape, options) {

@@ -10,8 +9,2 @@ switch (shape || 'mesh') {

case 'arrow-table':
return {
shape: 'arrow-table',
data: convertMeshToArrowTable(mesh)
};
default:

@@ -18,0 +11,0 @@ throw new Error("Unsupported shape ".concat(options === null || options === void 0 ? void 0 : options.shape));

@@ -1,31 +0,2 @@

import { Table, Schema, RecordBatch, FixedSizeList, Field, Data, FixedSizeListVector } from 'apache-arrow/Arrow.dom';
import { getArrowType, getArrowVector } from '../../lib/arrow/arrow-type-utils';
import { makeMeshAttributeMetadata } from './deduce-mesh-schema';
export function convertMeshToArrowTable(mesh, batchSize) {
var _mesh$schema;
const vectors = [];
const fields = [];
for (const attributeKey in mesh.attributes) {
const attribute = mesh.attributes[attributeKey];
const {
value,
size = 1
} = attribute;
const type = getArrowType(value);
const vector = getArrowVector(value);
const listType = new FixedSizeList(size, new Field('value', type));
const field = new Field(attributeKey, listType, false, makeMeshAttributeMetadata(attribute));
const data = new Data(listType, 0, value.length / size, 0, undefined, [vector]);
const listVector = new FixedSizeListVector(data);
vectors.push(listVector);
fields.push(field);
}
const schema = new Schema(fields, (mesh === null || mesh === void 0 ? void 0 : (_mesh$schema = mesh.schema) === null || _mesh$schema === void 0 ? void 0 : _mesh$schema.metadata) || new Map());
const recordBatch = new RecordBatch(schema, vectors[0].length, vectors);
const table = new Table(schema, recordBatch);
return table;
}
//# sourceMappingURL=mesh-to-arrow-table.js.map

@@ -1,62 +0,2 @@

import { Float32, Float64, Int16, Int32, Int8, Uint16, Uint32, Uint8, Int8Vector, Uint8Vector, Int16Vector, Uint16Vector, Int32Vector, Uint32Vector, Float32Vector, Float64Vector } from 'apache-arrow/Arrow.dom';
export function getArrowType(array) {
switch (array.constructor) {
case Int8Array:
return new Int8();
case Uint8Array:
return new Uint8();
case Int16Array:
return new Int16();
case Uint16Array:
return new Uint16();
case Int32Array:
return new Int32();
case Uint32Array:
return new Uint32();
case Float32Array:
return new Float32();
case Float64Array:
return new Float64();
default:
throw new Error('array type not supported');
}
}
export function getArrowVector(array) {
switch (array.constructor) {
case Int8Array:
return Int8Vector.from(array);
case Uint8Array:
return Uint8Vector.from(array);
case Int16Array:
return Int16Vector.from(array);
case Uint16Array:
return Uint16Vector.from(array);
case Int32Array:
return Int32Vector.from(array);
case Uint32Array:
return Uint32Vector.from(array);
case Float32Array:
return Float32Vector.from(array);
case Float64Array:
return Float64Vector.from(array);
default:
throw new Error('array type not supported');
}
}
//# sourceMappingURL=arrow-type-utils.js.map

@@ -1,6 +0,1 @@

import type { TypedArray } from '../../types';
import { DataType } from 'apache-arrow/Arrow.dom';
import { AbstractVector } from 'apache-arrow/vector';
export declare function getArrowType(array: TypedArray): DataType;
export declare function getArrowVector(array: TypedArray): AbstractVector;
//# sourceMappingURL=arrow-type-utils.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getArrowVector = exports.getArrowType = void 0;
const Arrow_dom_1 = require("apache-arrow/Arrow.dom");
function getArrowType(array) {
switch (array.constructor) {
case Int8Array:
return new Arrow_dom_1.Int8();
case Uint8Array:
return new Arrow_dom_1.Uint8();
case Int16Array:
return new Arrow_dom_1.Int16();
case Uint16Array:
return new Arrow_dom_1.Uint16();
case Int32Array:
return new Arrow_dom_1.Int32();
case Uint32Array:
return new Arrow_dom_1.Uint32();
case Float32Array:
return new Arrow_dom_1.Float32();
case Float64Array:
return new Arrow_dom_1.Float64();
default:
throw new Error('array type not supported');
}
/*
import type {TypedArray} from '../../types.js';
import {
DataType,
Float32,
Float64,
Int16,
Int32,
Int8,
Uint16,
Uint32,
Uint8,
Int8Vector,
Uint8Vector,
Int16Vector,
Uint16Vector,
Int32Vector,
Uint32Vector,
Float32Vector,
Float64Vector
} from 'apache-arrow/Arrow.dom';
import {AbstractVector} from 'apache-arrow/vector';
export function getArrowType(array: TypedArray): DataType {
switch (array.constructor) {
case Int8Array:
return new Int8();
case Uint8Array:
return new Uint8();
case Int16Array:
return new Int16();
case Uint16Array:
return new Uint16();
case Int32Array:
return new Int32();
case Uint32Array:
return new Uint32();
case Float32Array:
return new Float32();
case Float64Array:
return new Float64();
default:
throw new Error('array type not supported');
}
}
exports.getArrowType = getArrowType;
function getArrowVector(array) {
switch (array.constructor) {
case Int8Array:
return Arrow_dom_1.Int8Vector.from(array);
case Uint8Array:
return Arrow_dom_1.Uint8Vector.from(array);
case Int16Array:
return Arrow_dom_1.Int16Vector.from(array);
case Uint16Array:
return Arrow_dom_1.Uint16Vector.from(array);
case Int32Array:
return Arrow_dom_1.Int32Vector.from(array);
case Uint32Array:
return Arrow_dom_1.Uint32Vector.from(array);
case Float32Array:
return Arrow_dom_1.Float32Vector.from(array);
case Float64Array:
return Arrow_dom_1.Float64Vector.from(array);
default:
throw new Error('array type not supported');
}
export function getArrowVector(array: TypedArray): AbstractVector {
switch (array.constructor) {
case Int8Array:
return Int8Vector.from(array);
case Uint8Array:
return Uint8Vector.from(array);
case Int16Array:
return Int16Vector.from(array);
case Uint16Array:
return Uint16Vector.from(array);
case Int32Array:
return Int32Vector.from(array);
case Uint32Array:
return Uint32Vector.from(array);
case Float32Array:
return Float32Vector.from(array);
case Float64Array:
return Float64Vector.from(array);
default:
throw new Error('array type not supported');
}
}
exports.getArrowVector = getArrowVector;
*/
{
"name": "@loaders.gl/schema",
"version": "3.1.0-beta.1",
"version": "3.1.0-beta.2",
"description": "Table format APIs for JSON, CSV, etc...",

@@ -35,6 +35,5 @@ "license": "MIT",

"dependencies": {
"@types/geojson": "^7946.0.7",
"apache-arrow": "^4.0.0"
"@types/geojson": "^7946.0.7"
},
"gitHead": "980cdefb4e8ec9ef9c951d20c78cf77777707f49"
"gitHead": "90f487e7b3f15c554d57c92497d3a12d71676818"
}

@@ -1,2 +0,3 @@

import type {RecordBatch} from 'apache-arrow';
// import type {RecordBatch} from 'apache-arrow';
type RecordBatch = any;

@@ -3,0 +4,0 @@ export type Field = any;

import type {Mesh} from './mesh-types';
import type {ColumnarTable, ArrowTable} from '../table/table-types';
import {convertMeshToArrowTable} from './mesh-to-arrow-table';
// import {convertMeshToArrowTable} from './mesh-to-arrow-table';

@@ -20,7 +20,7 @@ type TargetShape = 'mesh' | 'columnar-table' | 'arrow-table';

return convertMeshToColumnarTable(mesh);
case 'arrow-table':
return {
shape: 'arrow-table',
data: convertMeshToArrowTable(mesh)
};
// case 'arrow-table':
// return {
// shape: 'arrow-table',
// data: convertMeshToArrowTable(mesh)
// };
default:

@@ -27,0 +27,0 @@ throw new Error(`Unsupported shape ${options?.shape}`);

@@ -0,1 +1,2 @@

/*
import {

@@ -9,3 +10,3 @@ Table,

FixedSizeListVector
} from 'apache-arrow/Arrow.dom';
} from 'apache-arrow';
import {AbstractVector} from 'apache-arrow/vector';

@@ -22,3 +23,3 @@ import {getArrowType, getArrowVector} from '../../lib/arrow/arrow-type-utils';

* @returns
*/
*
export function convertMeshToArrowTable(mesh: Mesh, batchSize?: number): Table {

@@ -44,1 +45,2 @@ const vectors: AbstractVector[] = [];

}
*/
import type {Schema} from '../../lib/schema/schema';
import type {Table as ApacheArrowTable, RecordBatch} from 'apache-arrow/Arrow.dom';
import type {AnyArray} from '../../types';
import type {Batch} from '../common';
// TODO Arrow dependency causes issues
// import type {Table as ApacheArrowTable, RecordBatch} from 'apache-arrow/Arrow.dom';
type ApacheArrowTable = any;
type RecordBatch = any;

@@ -6,0 +9,0 @@ /** A general table */

@@ -0,1 +1,2 @@

/*
import type {TypedArray} from '../../types';

@@ -68,1 +69,2 @@ import {

}
*/

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc