@nshiab/simple-data-analysis-core 2.0.8 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/class/SDAError.d.ts +6 -6
- package/esm/class/SDAError.js +6 -6
- package/esm/class/Simple.d.ts +9 -9
- package/esm/class/Simple.js +9 -9
- package/esm/class/SimpleDB.d.ts +80 -76
- package/esm/class/SimpleDB.d.ts.map +1 -1
- package/esm/class/SimpleDB.js +80 -76
- package/esm/class/SimpleTable.d.ts +2805 -1077
- package/esm/class/SimpleTable.d.ts.map +1 -1
- package/esm/class/SimpleTable.js +2777 -1077
- package/esm/helpers/appendColumnBatches.d.ts +3 -0
- package/esm/helpers/appendColumnBatches.d.ts.map +1 -0
- package/esm/helpers/appendColumnBatches.js +21 -0
- package/esm/helpers/buildApproximateMutualReachabilityMst.d.ts +45 -0
- package/esm/helpers/buildApproximateMutualReachabilityMst.d.ts.map +1 -0
- package/esm/helpers/buildApproximateMutualReachabilityMst.js +212 -0
- package/esm/helpers/buildChronologicalGraphComponentsSql.d.ts +14 -0
- package/esm/helpers/buildChronologicalGraphComponentsSql.d.ts.map +1 -0
- package/esm/helpers/buildChronologicalGraphComponentsSql.js +167 -0
- package/esm/helpers/buildExactMutualReachabilityMst.d.ts +28 -0
- package/esm/helpers/buildExactMutualReachabilityMst.d.ts.map +1 -0
- package/esm/helpers/buildExactMutualReachabilityMst.js +97 -0
- package/esm/helpers/buildGraphTemporalCostStateSql.d.ts +12 -0
- package/esm/helpers/buildGraphTemporalCostStateSql.d.ts.map +1 -0
- package/esm/helpers/buildGraphTemporalCostStateSql.js +86 -0
- package/esm/helpers/buildGraphTemporalReachabilitySql.d.ts +13 -0
- package/esm/helpers/buildGraphTemporalReachabilitySql.d.ts.map +1 -0
- package/esm/helpers/buildGraphTemporalReachabilitySql.js +70 -0
- package/esm/helpers/buildSparseMutualReachabilityMst.d.ts +10 -0
- package/esm/helpers/buildSparseMutualReachabilityMst.d.ts.map +1 -0
- package/esm/helpers/buildSparseMutualReachabilityMst.js +47 -0
- package/esm/helpers/buildUmapGraph.d.ts +21 -0
- package/esm/helpers/buildUmapGraph.d.ts.map +1 -0
- package/esm/helpers/buildUmapGraph.js +61 -0
- package/esm/helpers/buildVectorNeighbors.d.ts +45 -0
- package/esm/helpers/buildVectorNeighbors.d.ts.map +1 -0
- package/esm/helpers/buildVectorNeighbors.js +170 -0
- package/esm/helpers/buildWeakGraphComponentsSql.d.ts +3 -0
- package/esm/helpers/buildWeakGraphComponentsSql.d.ts.map +1 -0
- package/esm/helpers/buildWeakGraphComponentsSql.js +32 -0
- package/esm/helpers/cacheDatabase.d.ts.map +1 -1
- package/esm/helpers/cacheDatabase.js +2 -1
- package/esm/helpers/camelCase.d.ts +7 -5
- package/esm/helpers/camelCase.d.ts.map +1 -1
- package/esm/helpers/camelCase.js +7 -5
- package/esm/helpers/capitalize.d.ts +6 -4
- package/esm/helpers/capitalize.d.ts.map +1 -1
- package/esm/helpers/capitalize.js +6 -4
- package/esm/helpers/clusterHdbscan.d.ts +18 -0
- package/esm/helpers/clusterHdbscan.d.ts.map +1 -0
- package/esm/helpers/clusterHdbscan.js +342 -0
- package/esm/helpers/computeCovariance.d.ts +16 -0
- package/esm/helpers/computeCovariance.d.ts.map +1 -0
- package/esm/helpers/computeCovariance.js +99 -0
- package/esm/helpers/computeMahalanobisDistances.d.ts +14 -0
- package/esm/helpers/computeMahalanobisDistances.d.ts.map +1 -0
- package/esm/helpers/computeMahalanobisDistances.js +87 -0
- package/esm/helpers/createDirectory.d.ts +4 -3
- package/esm/helpers/createDirectory.d.ts.map +1 -1
- package/esm/helpers/createDirectory.js +4 -3
- package/esm/helpers/dataToArrays.d.ts +6 -4
- package/esm/helpers/dataToArrays.d.ts.map +1 -1
- package/esm/helpers/dataToArrays.js +6 -4
- package/esm/helpers/extractTypes.d.ts +1 -1
- package/esm/helpers/extractTypes.js +4 -9
- package/esm/helpers/factorCovariance.d.ts +17 -0
- package/esm/helpers/factorCovariance.d.ts.map +1 -0
- package/esm/helpers/factorCovariance.js +189 -0
- package/esm/helpers/findGeoColumn.d.ts +6 -4
- package/esm/helpers/findGeoColumn.d.ts.map +1 -1
- package/esm/helpers/findGeoColumn.js +6 -4
- package/esm/helpers/findGeoColumnFromSchema.d.ts +8 -5
- package/esm/helpers/findGeoColumnFromSchema.d.ts.map +1 -1
- package/esm/helpers/findGeoColumnFromSchema.js +8 -5
- package/esm/helpers/fitUmapCurve.d.ts +2 -0
- package/esm/helpers/fitUmapCurve.d.ts.map +1 -0
- package/esm/helpers/fitUmapCurve.js +66 -0
- package/esm/helpers/formatDate.d.ts +12 -6
- package/esm/helpers/formatDate.d.ts.map +1 -1
- package/esm/helpers/formatDate.js +12 -6
- package/esm/helpers/formatMissingTables.d.ts +8 -5
- package/esm/helpers/formatMissingTables.d.ts.map +1 -1
- package/esm/helpers/formatMissingTables.js +8 -5
- package/esm/helpers/formatNumber.d.ts +19 -10
- package/esm/helpers/formatNumber.d.ts.map +1 -1
- package/esm/helpers/formatNumber.js +32 -17
- package/esm/helpers/getGraphEdgeIdColumn.d.ts +9 -0
- package/esm/helpers/getGraphEdgeIdColumn.d.ts.map +1 -0
- package/esm/helpers/getGraphEdgeIdColumn.js +25 -0
- package/esm/helpers/getGraphEndpointColumns.d.ts +11 -0
- package/esm/helpers/getGraphEndpointColumns.d.ts.map +1 -0
- package/esm/helpers/getGraphEndpointColumns.js +160 -0
- package/esm/helpers/getGraphWeightColumn.d.ts +10 -0
- package/esm/helpers/getGraphWeightColumn.d.ts.map +1 -0
- package/esm/helpers/getGraphWeightColumn.js +40 -0
- package/esm/helpers/graphRouteResultSchema.d.ts +4 -0
- package/esm/helpers/graphRouteResultSchema.d.ts.map +1 -0
- package/esm/helpers/graphRouteResultSchema.js +12 -0
- package/esm/helpers/graphRouteResultSelect.d.ts +4 -0
- package/esm/helpers/graphRouteResultSelect.d.ts.map +1 -0
- package/esm/helpers/graphRouteResultSelect.js +22 -0
- package/esm/helpers/hasGeometryColumn.d.ts +4 -3
- package/esm/helpers/hasGeometryColumn.d.ts.map +1 -1
- package/esm/helpers/hasGeometryColumn.js +4 -3
- package/esm/helpers/initialUmapCoordinates.d.ts +2 -0
- package/esm/helpers/initialUmapCoordinates.d.ts.map +1 -0
- package/esm/helpers/initialUmapCoordinates.js +5 -0
- package/esm/helpers/inspectGraphConnectivity.d.ts +10 -0
- package/esm/helpers/inspectGraphConnectivity.d.ts.map +1 -0
- package/esm/helpers/inspectGraphConnectivity.js +55 -0
- package/esm/helpers/mergeOptions.d.ts +24 -13
- package/esm/helpers/mergeOptions.d.ts.map +1 -1
- package/esm/helpers/mergeOptions.js +24 -13
- package/esm/helpers/optimizeUmapLayout.d.ts +7 -0
- package/esm/helpers/optimizeUmapLayout.d.ts.map +1 -0
- package/esm/helpers/optimizeUmapLayout.js +93 -0
- package/esm/helpers/parseValue.d.ts +6 -4
- package/esm/helpers/parseValue.d.ts.map +1 -1
- package/esm/helpers/parseValue.js +6 -4
- package/esm/helpers/prepareGraphRouteSql.d.ts +31 -0
- package/esm/helpers/prepareGraphRouteSql.d.ts.map +1 -0
- package/esm/helpers/prepareGraphRouteSql.js +86 -0
- package/esm/helpers/prepareGraphStarts.d.ts +9 -0
- package/esm/helpers/prepareGraphStarts.d.ts.map +1 -0
- package/esm/helpers/prepareGraphStarts.js +68 -0
- package/esm/helpers/prepareGraphTemporalSql.d.ts +28 -0
- package/esm/helpers/prepareGraphTemporalSql.d.ts.map +1 -0
- package/esm/helpers/prepareGraphTemporalSql.js +154 -0
- package/esm/helpers/prepareGraphTraversal.d.ts +19 -0
- package/esm/helpers/prepareGraphTraversal.d.ts.map +1 -0
- package/esm/helpers/prepareGraphTraversal.js +79 -0
- package/esm/helpers/prepareNumericFeatures.d.ts +41 -0
- package/esm/helpers/prepareNumericFeatures.d.ts.map +1 -0
- package/esm/helpers/prepareNumericFeatures.js +210 -0
- package/esm/helpers/prepareUmapLayoutOptions.d.ts +14 -0
- package/esm/helpers/prepareUmapLayoutOptions.d.ts.map +1 -0
- package/esm/helpers/prepareUmapLayoutOptions.js +23 -0
- package/esm/helpers/prettyDuration.d.ts +14 -8
- package/esm/helpers/prettyDuration.d.ts.map +1 -1
- package/esm/helpers/prettyDuration.js +14 -8
- package/esm/helpers/printTable.d.ts +18 -13
- package/esm/helpers/printTable.d.ts.map +1 -1
- package/esm/helpers/printTable.js +18 -13
- package/esm/helpers/publishPreparedColumns.d.ts +37 -0
- package/esm/helpers/publishPreparedColumns.d.ts.map +1 -0
- package/esm/helpers/publishPreparedColumns.js +113 -0
- package/esm/helpers/queryDB.d.ts +24 -13
- package/esm/helpers/queryDB.d.ts.map +1 -1
- package/esm/helpers/queryDB.js +24 -13
- package/esm/helpers/queueAsyncBarrier.d.ts +12 -7
- package/esm/helpers/queueAsyncBarrier.d.ts.map +1 -1
- package/esm/helpers/queueAsyncBarrier.js +12 -7
- package/esm/helpers/queueGraphResult.d.ts +18 -0
- package/esm/helpers/queueGraphResult.d.ts.map +1 -0
- package/esm/helpers/queueGraphResult.js +39 -0
- package/esm/helpers/quoteIdentifier.d.ts +4 -3
- package/esm/helpers/quoteIdentifier.d.ts.map +1 -1
- package/esm/helpers/quoteIdentifier.js +4 -3
- package/esm/helpers/quoteQualifiedIdentifier.d.ts +6 -4
- package/esm/helpers/quoteQualifiedIdentifier.d.ts.map +1 -1
- package/esm/helpers/quoteQualifiedIdentifier.js +6 -4
- package/esm/helpers/readScalarNumber.d.ts +3 -0
- package/esm/helpers/readScalarNumber.d.ts.map +1 -0
- package/esm/helpers/readScalarNumber.js +4 -0
- package/esm/helpers/runQuery.d.ts.map +1 -1
- package/esm/helpers/runQuery.js +17 -3
- package/esm/helpers/selectFuzzyReplacements.d.ts +11 -0
- package/esm/helpers/selectFuzzyReplacements.d.ts.map +1 -0
- package/esm/helpers/selectFuzzyReplacements.js +124 -0
- package/esm/helpers/stabilizeCosineVectors.d.ts +14 -0
- package/esm/helpers/stabilizeCosineVectors.d.ts.map +1 -0
- package/esm/helpers/stabilizeCosineVectors.js +34 -0
- package/esm/helpers/stringToArray.d.ts +4 -3
- package/esm/helpers/stringToArray.d.ts.map +1 -1
- package/esm/helpers/stringToArray.js +4 -3
- package/esm/helpers/umapRandom.d.ts +2 -0
- package/esm/helpers/umapRandom.d.ts.map +1 -0
- package/esm/helpers/umapRandom.js +10 -0
- package/esm/helpers/updateColumnsWithJS.d.ts +12 -6
- package/esm/helpers/updateColumnsWithJS.d.ts.map +1 -1
- package/esm/helpers/updateColumnsWithJS.js +12 -6
- package/esm/helpers/validateGraphRouteResultSchema.d.ts +4 -0
- package/esm/helpers/validateGraphRouteResultSchema.d.ts.map +1 -0
- package/esm/helpers/validateGraphRouteResultSchema.js +13 -0
- package/esm/helpers/validateGraphTemporalEvents.d.ts +7 -0
- package/esm/helpers/validateGraphTemporalEvents.d.ts.map +1 -0
- package/esm/helpers/validateGraphTemporalEvents.js +47 -0
- package/esm/helpers/validateNumericalAnalysis.d.ts +10 -6
- package/esm/helpers/validateNumericalAnalysis.d.ts.map +1 -1
- package/esm/helpers/validateNumericalAnalysis.js +10 -6
- package/esm/helpers/validateVectorRowIds.d.ts +4 -0
- package/esm/helpers/validateVectorRowIds.d.ts.map +1 -0
- package/esm/helpers/validateVectorRowIds.js +16 -0
- package/esm/helpers/vectorDistanceExpression.d.ts +6 -0
- package/esm/helpers/vectorDistanceExpression.d.ts.map +1 -0
- package/esm/helpers/vectorDistanceExpression.js +11 -0
- package/esm/helpers/wrapString.d.ts +10 -7
- package/esm/helpers/wrapString.d.ts.map +1 -1
- package/esm/helpers/wrapString.js +10 -7
- package/esm/methods/addId.d.ts +5 -0
- package/esm/methods/addId.d.ts.map +1 -0
- package/esm/methods/addId.js +38 -0
- package/esm/methods/cache.js +1 -1
- package/esm/methods/commonNeighbors.d.ts +10 -0
- package/esm/methods/commonNeighbors.d.ts.map +1 -0
- package/esm/methods/commonNeighbors.js +101 -0
- package/esm/methods/connectedComponents.d.ts +9 -0
- package/esm/methods/connectedComponents.d.ts.map +1 -0
- package/esm/methods/connectedComponents.js +147 -0
- package/esm/methods/degree.d.ts +9 -0
- package/esm/methods/degree.d.ts.map +1 -0
- package/esm/methods/degree.js +135 -0
- package/esm/methods/distances.d.ts +12 -0
- package/esm/methods/distances.d.ts.map +1 -0
- package/esm/methods/distances.js +164 -0
- package/esm/methods/findCycles.d.ts +12 -0
- package/esm/methods/findCycles.d.ts.map +1 -0
- package/esm/methods/findCycles.js +330 -0
- package/esm/methods/fuzzyClean.d.ts.map +1 -1
- package/esm/methods/fuzzyClean.js +17 -136
- package/esm/methods/fuzzyJoin.js +70 -16
- package/esm/methods/getTypes.d.ts +1 -1
- package/esm/methods/hdbscan.d.ts +5 -0
- package/esm/methods/hdbscan.d.ts.map +1 -0
- package/esm/methods/hdbscan.js +208 -0
- package/esm/methods/loadArray.d.ts.map +1 -1
- package/esm/methods/loadArray.js +3 -20
- package/esm/methods/mahalanobis.d.ts +5 -0
- package/esm/methods/mahalanobis.d.ts.map +1 -0
- package/esm/methods/mahalanobis.js +92 -0
- package/esm/methods/neighbors.d.ts +9 -0
- package/esm/methods/neighbors.d.ts.map +1 -0
- package/esm/methods/neighbors.js +81 -0
- package/esm/methods/normalizeVector.d.ts +5 -0
- package/esm/methods/normalizeVector.d.ts.map +1 -0
- package/esm/methods/normalizeVector.js +132 -0
- package/esm/methods/paths.d.ts +12 -0
- package/esm/methods/paths.d.ts.map +1 -0
- package/esm/methods/paths.js +287 -0
- package/esm/methods/reachable.d.ts +11 -0
- package/esm/methods/reachable.d.ts.map +1 -0
- package/esm/methods/reachable.js +131 -0
- package/esm/methods/rowToVector.d.ts +5 -0
- package/esm/methods/rowToVector.d.ts.map +1 -0
- package/esm/methods/rowToVector.js +77 -0
- package/esm/methods/shortestPath.d.ts +12 -0
- package/esm/methods/shortestPath.d.ts.map +1 -0
- package/esm/methods/shortestPath.js +337 -0
- package/esm/methods/topologicalSort.d.ts +7 -0
- package/esm/methods/topologicalSort.d.ts.map +1 -0
- package/esm/methods/topologicalSort.js +164 -0
- package/esm/methods/umap.d.ts +5 -0
- package/esm/methods/umap.d.ts.map +1 -0
- package/esm/methods/umap.js +156 -0
- package/esm/methods/updateWithJS.js +9 -21
- package/llm.md +2170 -128
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/script/class/SDAError.d.ts +6 -6
- package/script/class/SDAError.js +6 -6
- package/script/class/Simple.d.ts +9 -9
- package/script/class/Simple.js +9 -9
- package/script/class/SimpleDB.d.ts +80 -76
- package/script/class/SimpleDB.d.ts.map +1 -1
- package/script/class/SimpleDB.js +80 -76
- package/script/class/SimpleTable.d.ts +2805 -1077
- package/script/class/SimpleTable.d.ts.map +1 -1
- package/script/class/SimpleTable.js +2777 -1077
- package/script/helpers/appendColumnBatches.d.ts +3 -0
- package/script/helpers/appendColumnBatches.d.ts.map +1 -0
- package/script/helpers/appendColumnBatches.js +24 -0
- package/script/helpers/buildApproximateMutualReachabilityMst.d.ts +45 -0
- package/script/helpers/buildApproximateMutualReachabilityMst.d.ts.map +1 -0
- package/script/helpers/buildApproximateMutualReachabilityMst.js +219 -0
- package/script/helpers/buildChronologicalGraphComponentsSql.d.ts +14 -0
- package/script/helpers/buildChronologicalGraphComponentsSql.d.ts.map +1 -0
- package/script/helpers/buildChronologicalGraphComponentsSql.js +174 -0
- package/script/helpers/buildExactMutualReachabilityMst.d.ts +28 -0
- package/script/helpers/buildExactMutualReachabilityMst.d.ts.map +1 -0
- package/script/helpers/buildExactMutualReachabilityMst.js +103 -0
- package/script/helpers/buildGraphTemporalCostStateSql.d.ts +12 -0
- package/script/helpers/buildGraphTemporalCostStateSql.d.ts.map +1 -0
- package/script/helpers/buildGraphTemporalCostStateSql.js +92 -0
- package/script/helpers/buildGraphTemporalReachabilitySql.d.ts +13 -0
- package/script/helpers/buildGraphTemporalReachabilitySql.d.ts.map +1 -0
- package/script/helpers/buildGraphTemporalReachabilitySql.js +76 -0
- package/script/helpers/buildSparseMutualReachabilityMst.d.ts +10 -0
- package/script/helpers/buildSparseMutualReachabilityMst.d.ts.map +1 -0
- package/script/helpers/buildSparseMutualReachabilityMst.js +50 -0
- package/script/helpers/buildUmapGraph.d.ts +21 -0
- package/script/helpers/buildUmapGraph.d.ts.map +1 -0
- package/script/helpers/buildUmapGraph.js +67 -0
- package/script/helpers/buildVectorNeighbors.d.ts +45 -0
- package/script/helpers/buildVectorNeighbors.d.ts.map +1 -0
- package/script/helpers/buildVectorNeighbors.js +176 -0
- package/script/helpers/buildWeakGraphComponentsSql.d.ts +3 -0
- package/script/helpers/buildWeakGraphComponentsSql.d.ts.map +1 -0
- package/script/helpers/buildWeakGraphComponentsSql.js +38 -0
- package/script/helpers/cacheDatabase.d.ts.map +1 -1
- package/script/helpers/cacheDatabase.js +2 -1
- package/script/helpers/camelCase.d.ts +7 -5
- package/script/helpers/camelCase.d.ts.map +1 -1
- package/script/helpers/camelCase.js +7 -5
- package/script/helpers/capitalize.d.ts +6 -4
- package/script/helpers/capitalize.d.ts.map +1 -1
- package/script/helpers/capitalize.js +6 -4
- package/script/helpers/clusterHdbscan.d.ts +18 -0
- package/script/helpers/clusterHdbscan.d.ts.map +1 -0
- package/script/helpers/clusterHdbscan.js +346 -0
- package/script/helpers/computeCovariance.d.ts +16 -0
- package/script/helpers/computeCovariance.d.ts.map +1 -0
- package/script/helpers/computeCovariance.js +105 -0
- package/script/helpers/computeMahalanobisDistances.d.ts +14 -0
- package/script/helpers/computeMahalanobisDistances.d.ts.map +1 -0
- package/script/helpers/computeMahalanobisDistances.js +93 -0
- package/script/helpers/createDirectory.d.ts +4 -3
- package/script/helpers/createDirectory.d.ts.map +1 -1
- package/script/helpers/createDirectory.js +4 -3
- package/script/helpers/dataToArrays.d.ts +6 -4
- package/script/helpers/dataToArrays.d.ts.map +1 -1
- package/script/helpers/dataToArrays.js +6 -4
- package/script/helpers/extractTypes.d.ts +1 -1
- package/script/helpers/extractTypes.js +4 -9
- package/script/helpers/factorCovariance.d.ts +17 -0
- package/script/helpers/factorCovariance.d.ts.map +1 -0
- package/script/helpers/factorCovariance.js +194 -0
- package/script/helpers/findGeoColumn.d.ts +6 -4
- package/script/helpers/findGeoColumn.d.ts.map +1 -1
- package/script/helpers/findGeoColumn.js +6 -4
- package/script/helpers/findGeoColumnFromSchema.d.ts +8 -5
- package/script/helpers/findGeoColumnFromSchema.d.ts.map +1 -1
- package/script/helpers/findGeoColumnFromSchema.js +8 -5
- package/script/helpers/fitUmapCurve.d.ts +2 -0
- package/script/helpers/fitUmapCurve.d.ts.map +1 -0
- package/script/helpers/fitUmapCurve.js +69 -0
- package/script/helpers/formatDate.d.ts +12 -6
- package/script/helpers/formatDate.d.ts.map +1 -1
- package/script/helpers/formatDate.js +12 -6
- package/script/helpers/formatMissingTables.d.ts +8 -5
- package/script/helpers/formatMissingTables.d.ts.map +1 -1
- package/script/helpers/formatMissingTables.js +8 -5
- package/script/helpers/formatNumber.d.ts +19 -10
- package/script/helpers/formatNumber.d.ts.map +1 -1
- package/script/helpers/formatNumber.js +32 -17
- package/script/helpers/getGraphEdgeIdColumn.d.ts +9 -0
- package/script/helpers/getGraphEdgeIdColumn.d.ts.map +1 -0
- package/script/helpers/getGraphEdgeIdColumn.js +31 -0
- package/script/helpers/getGraphEndpointColumns.d.ts +11 -0
- package/script/helpers/getGraphEndpointColumns.d.ts.map +1 -0
- package/script/helpers/getGraphEndpointColumns.js +166 -0
- package/script/helpers/getGraphWeightColumn.d.ts +10 -0
- package/script/helpers/getGraphWeightColumn.d.ts.map +1 -0
- package/script/helpers/getGraphWeightColumn.js +46 -0
- package/script/helpers/graphRouteResultSchema.d.ts +4 -0
- package/script/helpers/graphRouteResultSchema.d.ts.map +1 -0
- package/script/helpers/graphRouteResultSchema.js +18 -0
- package/script/helpers/graphRouteResultSelect.d.ts +4 -0
- package/script/helpers/graphRouteResultSelect.d.ts.map +1 -0
- package/script/helpers/graphRouteResultSelect.js +28 -0
- package/script/helpers/hasGeometryColumn.d.ts +4 -3
- package/script/helpers/hasGeometryColumn.d.ts.map +1 -1
- package/script/helpers/hasGeometryColumn.js +4 -3
- package/script/helpers/initialUmapCoordinates.d.ts +2 -0
- package/script/helpers/initialUmapCoordinates.d.ts.map +1 -0
- package/script/helpers/initialUmapCoordinates.js +11 -0
- package/script/helpers/inspectGraphConnectivity.d.ts +10 -0
- package/script/helpers/inspectGraphConnectivity.d.ts.map +1 -0
- package/script/helpers/inspectGraphConnectivity.js +58 -0
- package/script/helpers/mergeOptions.d.ts +24 -13
- package/script/helpers/mergeOptions.d.ts.map +1 -1
- package/script/helpers/mergeOptions.js +24 -13
- package/script/helpers/optimizeUmapLayout.d.ts +7 -0
- package/script/helpers/optimizeUmapLayout.d.ts.map +1 -0
- package/script/helpers/optimizeUmapLayout.js +99 -0
- package/script/helpers/parseValue.d.ts +6 -4
- package/script/helpers/parseValue.d.ts.map +1 -1
- package/script/helpers/parseValue.js +6 -4
- package/script/helpers/prepareGraphRouteSql.d.ts +31 -0
- package/script/helpers/prepareGraphRouteSql.d.ts.map +1 -0
- package/script/helpers/prepareGraphRouteSql.js +127 -0
- package/script/helpers/prepareGraphStarts.d.ts +9 -0
- package/script/helpers/prepareGraphStarts.d.ts.map +1 -0
- package/script/helpers/prepareGraphStarts.js +71 -0
- package/script/helpers/prepareGraphTemporalSql.d.ts +28 -0
- package/script/helpers/prepareGraphTemporalSql.d.ts.map +1 -0
- package/script/helpers/prepareGraphTemporalSql.js +161 -0
- package/script/helpers/prepareGraphTraversal.d.ts +19 -0
- package/script/helpers/prepareGraphTraversal.d.ts.map +1 -0
- package/script/helpers/prepareGraphTraversal.js +87 -0
- package/script/helpers/prepareNumericFeatures.d.ts +41 -0
- package/script/helpers/prepareNumericFeatures.d.ts.map +1 -0
- package/script/helpers/prepareNumericFeatures.js +217 -0
- package/script/helpers/prepareUmapLayoutOptions.d.ts +14 -0
- package/script/helpers/prepareUmapLayoutOptions.d.ts.map +1 -0
- package/script/helpers/prepareUmapLayoutOptions.js +29 -0
- package/script/helpers/prettyDuration.d.ts +14 -8
- package/script/helpers/prettyDuration.d.ts.map +1 -1
- package/script/helpers/prettyDuration.js +14 -8
- package/script/helpers/printTable.d.ts +18 -13
- package/script/helpers/printTable.d.ts.map +1 -1
- package/script/helpers/printTable.js +18 -13
- package/script/helpers/publishPreparedColumns.d.ts +37 -0
- package/script/helpers/publishPreparedColumns.d.ts.map +1 -0
- package/script/helpers/publishPreparedColumns.js +119 -0
- package/script/helpers/queryDB.d.ts +24 -13
- package/script/helpers/queryDB.d.ts.map +1 -1
- package/script/helpers/queryDB.js +24 -13
- package/script/helpers/queueAsyncBarrier.d.ts +12 -7
- package/script/helpers/queueAsyncBarrier.d.ts.map +1 -1
- package/script/helpers/queueAsyncBarrier.js +12 -7
- package/script/helpers/queueGraphResult.d.ts +18 -0
- package/script/helpers/queueGraphResult.d.ts.map +1 -0
- package/script/helpers/queueGraphResult.js +45 -0
- package/script/helpers/quoteIdentifier.d.ts +4 -3
- package/script/helpers/quoteIdentifier.d.ts.map +1 -1
- package/script/helpers/quoteIdentifier.js +4 -3
- package/script/helpers/quoteQualifiedIdentifier.d.ts +6 -4
- package/script/helpers/quoteQualifiedIdentifier.d.ts.map +1 -1
- package/script/helpers/quoteQualifiedIdentifier.js +6 -4
- package/script/helpers/readScalarNumber.d.ts +3 -0
- package/script/helpers/readScalarNumber.d.ts.map +1 -0
- package/script/helpers/readScalarNumber.js +7 -0
- package/script/helpers/runQuery.d.ts.map +1 -1
- package/script/helpers/runQuery.js +17 -3
- package/script/helpers/selectFuzzyReplacements.d.ts +11 -0
- package/script/helpers/selectFuzzyReplacements.d.ts.map +1 -0
- package/script/helpers/selectFuzzyReplacements.js +127 -0
- package/script/helpers/stabilizeCosineVectors.d.ts +14 -0
- package/script/helpers/stabilizeCosineVectors.d.ts.map +1 -0
- package/script/helpers/stabilizeCosineVectors.js +40 -0
- package/script/helpers/stringToArray.d.ts +4 -3
- package/script/helpers/stringToArray.d.ts.map +1 -1
- package/script/helpers/stringToArray.js +4 -3
- package/script/helpers/umapRandom.d.ts +2 -0
- package/script/helpers/umapRandom.d.ts.map +1 -0
- package/script/helpers/umapRandom.js +13 -0
- package/script/helpers/updateColumnsWithJS.d.ts +12 -6
- package/script/helpers/updateColumnsWithJS.d.ts.map +1 -1
- package/script/helpers/updateColumnsWithJS.js +12 -6
- package/script/helpers/validateGraphRouteResultSchema.d.ts +4 -0
- package/script/helpers/validateGraphRouteResultSchema.d.ts.map +1 -0
- package/script/helpers/validateGraphRouteResultSchema.js +19 -0
- package/script/helpers/validateGraphTemporalEvents.d.ts +7 -0
- package/script/helpers/validateGraphTemporalEvents.d.ts.map +1 -0
- package/script/helpers/validateGraphTemporalEvents.js +53 -0
- package/script/helpers/validateNumericalAnalysis.d.ts +10 -6
- package/script/helpers/validateNumericalAnalysis.d.ts.map +1 -1
- package/script/helpers/validateNumericalAnalysis.js +10 -6
- package/script/helpers/validateVectorRowIds.d.ts +4 -0
- package/script/helpers/validateVectorRowIds.d.ts.map +1 -0
- package/script/helpers/validateVectorRowIds.js +19 -0
- package/script/helpers/vectorDistanceExpression.d.ts +6 -0
- package/script/helpers/vectorDistanceExpression.d.ts.map +1 -0
- package/script/helpers/vectorDistanceExpression.js +14 -0
- package/script/helpers/wrapString.d.ts +10 -7
- package/script/helpers/wrapString.d.ts.map +1 -1
- package/script/helpers/wrapString.js +10 -7
- package/script/methods/addId.d.ts +5 -0
- package/script/methods/addId.d.ts.map +1 -0
- package/script/methods/addId.js +44 -0
- package/script/methods/cache.js +1 -1
- package/script/methods/commonNeighbors.d.ts +10 -0
- package/script/methods/commonNeighbors.d.ts.map +1 -0
- package/script/methods/commonNeighbors.js +140 -0
- package/script/methods/connectedComponents.d.ts +9 -0
- package/script/methods/connectedComponents.d.ts.map +1 -0
- package/script/methods/connectedComponents.js +186 -0
- package/script/methods/degree.d.ts +9 -0
- package/script/methods/degree.d.ts.map +1 -0
- package/script/methods/degree.js +141 -0
- package/script/methods/distances.d.ts +12 -0
- package/script/methods/distances.d.ts.map +1 -0
- package/script/methods/distances.js +203 -0
- package/script/methods/findCycles.d.ts +12 -0
- package/script/methods/findCycles.d.ts.map +1 -0
- package/script/methods/findCycles.js +369 -0
- package/script/methods/fuzzyClean.d.ts.map +1 -1
- package/script/methods/fuzzyClean.js +17 -136
- package/script/methods/fuzzyJoin.js +70 -16
- package/script/methods/getTypes.d.ts +1 -1
- package/script/methods/hdbscan.d.ts +5 -0
- package/script/methods/hdbscan.d.ts.map +1 -0
- package/script/methods/hdbscan.js +214 -0
- package/script/methods/loadArray.d.ts.map +1 -1
- package/script/methods/loadArray.js +2 -19
- package/script/methods/mahalanobis.d.ts +5 -0
- package/script/methods/mahalanobis.d.ts.map +1 -0
- package/script/methods/mahalanobis.js +98 -0
- package/script/methods/neighbors.d.ts +9 -0
- package/script/methods/neighbors.d.ts.map +1 -0
- package/script/methods/neighbors.js +120 -0
- package/script/methods/normalizeVector.d.ts +5 -0
- package/script/methods/normalizeVector.d.ts.map +1 -0
- package/script/methods/normalizeVector.js +138 -0
- package/script/methods/paths.d.ts +12 -0
- package/script/methods/paths.d.ts.map +1 -0
- package/script/methods/paths.js +326 -0
- package/script/methods/reachable.d.ts +11 -0
- package/script/methods/reachable.d.ts.map +1 -0
- package/script/methods/reachable.js +170 -0
- package/script/methods/rowToVector.d.ts +5 -0
- package/script/methods/rowToVector.d.ts.map +1 -0
- package/script/methods/rowToVector.js +83 -0
- package/script/methods/shortestPath.d.ts +12 -0
- package/script/methods/shortestPath.d.ts.map +1 -0
- package/script/methods/shortestPath.js +376 -0
- package/script/methods/topologicalSort.d.ts +7 -0
- package/script/methods/topologicalSort.d.ts.map +1 -0
- package/script/methods/topologicalSort.js +170 -0
- package/script/methods/umap.d.ts +5 -0
- package/script/methods/umap.d.ts.map +1 -0
- package/script/methods/umap.js +162 -0
- package/script/methods/updateWithJS.js +9 -21
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type SimpleTable from "../class/SimpleTable.js";
|
|
2
|
+
type TopologicalSortOptions = {
|
|
3
|
+
outputTable?: string | boolean;
|
|
4
|
+
};
|
|
5
|
+
export default function topologicalSort(simpleTable: SimpleTable, sourceColumn: string, targetColumn: string, options?: TopologicalSortOptions): SimpleTable;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=topologicalSort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topologicalSort.d.ts","sourceRoot":"","sources":["../../src/methods/topologicalSort.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAQvD,KAAK,sBAAsB,GAAG;IAC5B,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAChC,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,sBAA2B,GACnC,WAAW,CAoDb"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = topologicalSort;
|
|
7
|
+
const buildWeakGraphComponentsSql_js_1 = __importDefault(require("../helpers/buildWeakGraphComponentsSql.js"));
|
|
8
|
+
const getGraphEndpointColumns_js_1 = __importDefault(require("../helpers/getGraphEndpointColumns.js"));
|
|
9
|
+
const prepareGraphTraversal_js_1 = require("../helpers/prepareGraphTraversal.js");
|
|
10
|
+
const queueGraphResult_js_1 = __importDefault(require("../helpers/queueGraphResult.js"));
|
|
11
|
+
const queueOp_js_1 = __importDefault(require("../helpers/queueOp.js"));
|
|
12
|
+
const quoteIdentifier_js_1 = __importDefault(require("../helpers/quoteIdentifier.js"));
|
|
13
|
+
function topologicalSort(simpleTable, sourceColumn, targetColumn, options = {}) {
|
|
14
|
+
if (typeof sourceColumn !== "string") {
|
|
15
|
+
throw new TypeError("topologicalSort() sourceColumn must be a string.");
|
|
16
|
+
}
|
|
17
|
+
if (typeof targetColumn !== "string") {
|
|
18
|
+
throw new TypeError("topologicalSort() targetColumn must be a string.");
|
|
19
|
+
}
|
|
20
|
+
if (options === null || typeof options !== "object" || Array.isArray(options)) {
|
|
21
|
+
throw new TypeError("topologicalSort() options must be an object.");
|
|
22
|
+
}
|
|
23
|
+
if (options.outputTable !== undefined &&
|
|
24
|
+
typeof options.outputTable !== "string" &&
|
|
25
|
+
typeof options.outputTable !== "boolean") {
|
|
26
|
+
throw new TypeError("topologicalSort() options.outputTable must be a string or boolean.");
|
|
27
|
+
}
|
|
28
|
+
options = structuredClone(options);
|
|
29
|
+
const parameters = { sourceColumn, targetColumn, options };
|
|
30
|
+
const result = (0, queueGraphResult_js_1.default)(simpleTable, {
|
|
31
|
+
method: "topologicalSort()",
|
|
32
|
+
parameters,
|
|
33
|
+
outputTable: options.outputTable,
|
|
34
|
+
values: (schema) => {
|
|
35
|
+
validateEndpoints(schema, sourceColumn, targetColumn);
|
|
36
|
+
return [];
|
|
37
|
+
},
|
|
38
|
+
buildSelect: (input, schema) => topologicalSortSelect(input, schema, sourceColumn, targetColumn),
|
|
39
|
+
outputSchema: (schema) => ({
|
|
40
|
+
node: validateEndpoints(schema, sourceColumn, targetColumn).idType,
|
|
41
|
+
componentId: "BIGINT",
|
|
42
|
+
order: "BIGINT",
|
|
43
|
+
}),
|
|
44
|
+
});
|
|
45
|
+
// Materialize the sorting computation before downstream operations: DuckDB
|
|
46
|
+
// can otherwise discard even its terminal cycle check for LIMIT 0 or FALSE.
|
|
47
|
+
// This barrier adds no query or separate validation traversal, and upstream
|
|
48
|
+
// preparation still fuses into the sorting statement.
|
|
49
|
+
(0, queueOp_js_1.default)(result, {
|
|
50
|
+
kind: "barrier",
|
|
51
|
+
method: "topologicalSort()",
|
|
52
|
+
parameters,
|
|
53
|
+
execute: () => Promise.resolve(),
|
|
54
|
+
});
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
function validateEndpoints(schema, source, target) {
|
|
58
|
+
return (0, getGraphEndpointColumns_js_1.default)(schema, source, target, "topologicalSort()");
|
|
59
|
+
}
|
|
60
|
+
function topologicalSortSelect(input, schema, source, target) {
|
|
61
|
+
const prepared = (0, prepareGraphTraversal_js_1.prepareGraphSql)(input, schema, source, target, "topologicalSort()");
|
|
62
|
+
const relations = prepared.relationNames([
|
|
63
|
+
"graph_edges",
|
|
64
|
+
"graph_nodes",
|
|
65
|
+
"graph_topological_order",
|
|
66
|
+
"graph_topological_result",
|
|
67
|
+
"graph_component_edges",
|
|
68
|
+
"graph_component_labels",
|
|
69
|
+
"graph_component_roots",
|
|
70
|
+
"graph_ordered_nodes",
|
|
71
|
+
]);
|
|
72
|
+
const edges = relations.graph_edges;
|
|
73
|
+
const nodes = relations.graph_nodes;
|
|
74
|
+
const ordering = relations.graph_topological_order;
|
|
75
|
+
const result = relations.graph_topological_result;
|
|
76
|
+
const componentEdges = relations.graph_component_edges;
|
|
77
|
+
const labels = relations.graph_component_labels;
|
|
78
|
+
const roots = relations.graph_component_roots;
|
|
79
|
+
const orderedNodes = relations.graph_ordered_nodes;
|
|
80
|
+
const q = quoteIdentifier_js_1.default;
|
|
81
|
+
return `WITH RECURSIVE ${edges} AS (
|
|
82
|
+
${prepared.edges("outgoing")}
|
|
83
|
+
), ${nodes} AS (
|
|
84
|
+
SELECT ${q("__from")} AS ${q("node")},
|
|
85
|
+
${q("__from_key")} AS ${q("__key")}
|
|
86
|
+
FROM ${edges}
|
|
87
|
+
UNION
|
|
88
|
+
SELECT ${q("__to")} AS ${q("node")},
|
|
89
|
+
${q("__to_key")} AS ${q("__key")}
|
|
90
|
+
FROM ${edges}
|
|
91
|
+
), ${componentEdges} AS (
|
|
92
|
+
SELECT * FROM ${edges}
|
|
93
|
+
UNION ALL
|
|
94
|
+
SELECT ${q("__to")}, ${q("__from")},
|
|
95
|
+
${q("__to_key")}, ${q("__from_key")}
|
|
96
|
+
FROM ${edges}
|
|
97
|
+
), ${(0, buildWeakGraphComponentsSql_js_1.default)(componentEdges, nodes, labels, roots)},
|
|
98
|
+
${ordering}(
|
|
99
|
+
${q("node")}, ${q("__key")}, ${q("order")}, ${q("__ordered")}
|
|
100
|
+
) AS (
|
|
101
|
+
SELECT ${q("eligible")}.${q("node")},
|
|
102
|
+
${q("eligible")}.${q("__key")}, CAST(1 AS BIGINT),
|
|
103
|
+
list_value(${q("eligible")}.${q("__key")})
|
|
104
|
+
FROM (
|
|
105
|
+
SELECT ${q("candidate")}.${q("node")},
|
|
106
|
+
${q("candidate")}.${q("__key")}
|
|
107
|
+
FROM ${nodes} AS ${q("candidate")}
|
|
108
|
+
WHERE NOT EXISTS (
|
|
109
|
+
SELECT 1 FROM ${edges} AS ${q("edge")}
|
|
110
|
+
WHERE ${q("edge")}.${q("__to_key")} =
|
|
111
|
+
${q("candidate")}.${q("__key")}
|
|
112
|
+
)
|
|
113
|
+
ORDER BY ${q("candidate")}.${q("__key")}
|
|
114
|
+
LIMIT 1
|
|
115
|
+
) AS ${q("eligible")}
|
|
116
|
+
UNION ALL
|
|
117
|
+
SELECT ${q("eligible")}.${q("node")},
|
|
118
|
+
${q("eligible")}.${q("__key")},
|
|
119
|
+
${q("ordered")}.${q("order")} + 1,
|
|
120
|
+
list_append(
|
|
121
|
+
${q("ordered")}.${q("__ordered")},
|
|
122
|
+
${q("eligible")}.${q("__key")}
|
|
123
|
+
)
|
|
124
|
+
FROM ${ordering} AS ${q("ordered")}
|
|
125
|
+
CROSS JOIN LATERAL (
|
|
126
|
+
SELECT ${q("candidate")}.${q("node")},
|
|
127
|
+
${q("candidate")}.${q("__key")}
|
|
128
|
+
FROM ${nodes} AS ${q("candidate")}
|
|
129
|
+
WHERE NOT list_contains(
|
|
130
|
+
${q("ordered")}.${q("__ordered")},
|
|
131
|
+
${q("candidate")}.${q("__key")}
|
|
132
|
+
)
|
|
133
|
+
AND NOT EXISTS (
|
|
134
|
+
SELECT 1 FROM ${edges} AS ${q("edge")}
|
|
135
|
+
WHERE ${q("edge")}.${q("__to_key")} =
|
|
136
|
+
${q("candidate")}.${q("__key")}
|
|
137
|
+
AND NOT list_contains(
|
|
138
|
+
${q("ordered")}.${q("__ordered")},
|
|
139
|
+
${q("edge")}.${q("__from_key")}
|
|
140
|
+
)
|
|
141
|
+
)
|
|
142
|
+
ORDER BY ${q("candidate")}.${q("__key")}
|
|
143
|
+
LIMIT 1
|
|
144
|
+
) AS ${q("eligible")}
|
|
145
|
+
), ${result} AS (
|
|
146
|
+
SELECT CASE WHEN count(*) < (SELECT count(*) FROM ${nodes})
|
|
147
|
+
THEN error(
|
|
148
|
+
'topologicalSort() cannot order the graph because it contains a directed cycle.'
|
|
149
|
+
)
|
|
150
|
+
ELSE list(${q("node")} ORDER BY ${q("order")})
|
|
151
|
+
END AS ${q("__nodes")}
|
|
152
|
+
FROM ${ordering}
|
|
153
|
+
), ${orderedNodes} AS (
|
|
154
|
+
SELECT unnest(${q("__nodes")}) AS ${q("node")},
|
|
155
|
+
generate_subscripts(${q("__nodes")}, 1) AS ${q("__order")}
|
|
156
|
+
FROM ${result}
|
|
157
|
+
)
|
|
158
|
+
SELECT ${q("ordered")}.${q("node")}, ${q("roots")}.${q("componentId")},
|
|
159
|
+
row_number() OVER (
|
|
160
|
+
PARTITION BY ${q("roots")}.${q("componentId")}
|
|
161
|
+
ORDER BY ${q("ordered")}.${q("__order")}
|
|
162
|
+
) AS ${q("order")}
|
|
163
|
+
FROM ${orderedNodes} AS ${q("ordered")}
|
|
164
|
+
INNER JOIN ${labels} AS ${q("labels")}
|
|
165
|
+
ON ${prepared.key(`${q("ordered")}.${q("node")}`)} =
|
|
166
|
+
${q("labels")}.${q("__node_key")}
|
|
167
|
+
INNER JOIN ${roots} AS ${q("roots")}
|
|
168
|
+
ON ${q("labels")}.${q("__root_key")} = ${q("roots")}.${q("__root_key")}
|
|
169
|
+
ORDER BY ${q("componentId")}, ${q("order")}`;
|
|
170
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"umap.d.ts","sourceRoot":"","sources":["../../src/methods/umap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAavD,KAAK,OAAO,GAAG,WAAW,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/D,MAAM,CAAC,OAAO,UAAU,IAAI,CAC1B,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,OAAY,QAStB"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = umap;
|
|
7
|
+
const queueOp_js_1 = __importDefault(require("../helpers/queueOp.js"));
|
|
8
|
+
const quoteIdentifier_js_1 = __importDefault(require("../helpers/quoteIdentifier.js"));
|
|
9
|
+
const queryDB_js_1 = __importDefault(require("../helpers/queryDB.js"));
|
|
10
|
+
const mergeOptions_js_1 = __importDefault(require("../helpers/mergeOptions.js"));
|
|
11
|
+
const buildUmapGraph_js_1 = __importDefault(require("../helpers/buildUmapGraph.js"));
|
|
12
|
+
const prepareUmapLayoutOptions_js_1 = __importDefault(require("../helpers/prepareUmapLayoutOptions.js"));
|
|
13
|
+
const readScalarNumber_js_1 = __importDefault(require("../helpers/readScalarNumber.js"));
|
|
14
|
+
const optimizeUmapLayout_js_1 = __importDefault(require("../helpers/optimizeUmapLayout.js"));
|
|
15
|
+
const initialUmapCoordinates_js_1 = __importDefault(require("../helpers/initialUmapCoordinates.js"));
|
|
16
|
+
const appendColumnBatches_js_1 = __importDefault(require("../helpers/appendColumnBatches.js"));
|
|
17
|
+
const node_api_1 = require("@duckdb/node-api");
|
|
18
|
+
function umap(table, column, options = {}) {
|
|
19
|
+
const settings = structuredClone(options);
|
|
20
|
+
(0, queueOp_js_1.default)(table, {
|
|
21
|
+
kind: "barrier",
|
|
22
|
+
method: "umap()",
|
|
23
|
+
parameters: { column, options: settings },
|
|
24
|
+
execute: () => execute(table, column, settings),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async function execute(table, column, options) {
|
|
28
|
+
const { neighbors = 15, metric = "euclidean" } = options;
|
|
29
|
+
if (!Number.isSafeInteger(neighbors) || neighbors < 2) {
|
|
30
|
+
throw new Error("neighbors must be a safe integer of at least 2.");
|
|
31
|
+
}
|
|
32
|
+
const layoutOptions = (0, prepareUmapLayoutOptions_js_1.default)(options);
|
|
33
|
+
if (!["euclidean", "cosine"].includes(metric)) {
|
|
34
|
+
throw new Error("metric must be euclidean or cosine.");
|
|
35
|
+
}
|
|
36
|
+
const types = await table.getTypes();
|
|
37
|
+
const columns = Object.keys(types);
|
|
38
|
+
const resolve = (name) => {
|
|
39
|
+
const found = columns.find((c) => c.toLowerCase() === name.toLowerCase());
|
|
40
|
+
if (found === undefined)
|
|
41
|
+
throw new Error(`Column ${name} does not exist.`);
|
|
42
|
+
return found;
|
|
43
|
+
};
|
|
44
|
+
const vector = resolve(column);
|
|
45
|
+
if (columns.some((c) => ["umapx", "umapy"].includes(c.toLowerCase()))) {
|
|
46
|
+
throw new Error("UMAP output columns umapX and umapY must not already exist.");
|
|
47
|
+
}
|
|
48
|
+
if (!/^(FLOAT|DOUBLE|TINYINT|SMALLINT|INTEGER|BIGINT|HUGEINT|UTINYINT|USMALLINT|UINTEGER|UBIGINT|UHUGEINT|DECIMAL\(\d+,\d+\))\[\d*\]$/
|
|
49
|
+
.test(types[vector])) {
|
|
50
|
+
throw new Error("UMAP requires a one-dimensional numeric LIST or ARRAY column.");
|
|
51
|
+
}
|
|
52
|
+
const connection = table.connection;
|
|
53
|
+
const [sourceOid, sourceTemporary] = (await connection.runAndReadAll(`SELECT table_oid,temporary FROM duckdb_tables()
|
|
54
|
+
WHERE lower(table_name)=lower($1) AND schema_name=current_schema()
|
|
55
|
+
AND database_name IN (current_database(),'temp')
|
|
56
|
+
ORDER BY temporary DESC LIMIT 1`, [table.name])).getRowsJS()[0] ?? [];
|
|
57
|
+
if (typeof sourceOid !== "number" && typeof sourceOid !== "bigint") {
|
|
58
|
+
throw new Error("UMAP requires a materialized source table.");
|
|
59
|
+
}
|
|
60
|
+
const q = quoteIdentifier_js_1.default;
|
|
61
|
+
const suffix = crypto.randomUUID().replaceAll("-", "");
|
|
62
|
+
const name = (part) => `__sda_umap_${suffix}_${part}`;
|
|
63
|
+
const ordinal = q(name("ordinal"));
|
|
64
|
+
const source = q(table.name), snapshot = q(name("snapshot"));
|
|
65
|
+
const layoutName = name("layout"), layout = q(layoutName);
|
|
66
|
+
const names = {
|
|
67
|
+
rows: q(name("rows")),
|
|
68
|
+
knn: q(name("knn")),
|
|
69
|
+
search: q(name("search")),
|
|
70
|
+
hnsw: q(name("hnsw")),
|
|
71
|
+
candidates: q(name("candidates")),
|
|
72
|
+
scales: q(name("scales")),
|
|
73
|
+
directed: q(name("directed")),
|
|
74
|
+
graph: q(name("graph")),
|
|
75
|
+
};
|
|
76
|
+
const scratch = [
|
|
77
|
+
snapshot,
|
|
78
|
+
layout,
|
|
79
|
+
...Object.entries(names)
|
|
80
|
+
.filter(([key]) => key !== "hnsw").map(([, value]) => value),
|
|
81
|
+
];
|
|
82
|
+
try {
|
|
83
|
+
// Retain payloads in native DuckDB types. A private ordinal distinguishes
|
|
84
|
+
// duplicate rows and is independent of any user column named rowid.
|
|
85
|
+
await connection.run(`CREATE TEMP TABLE ${snapshot} AS
|
|
86
|
+
SELECT *, row_number() OVER () - 1 AS ${ordinal} FROM ${source}`);
|
|
87
|
+
const count = await (0, readScalarNumber_js_1.default)(connection, `SELECT count(*) FROM ${snapshot}`);
|
|
88
|
+
if (count < 3 || count > 0x7fffffff) {
|
|
89
|
+
throw new Error("UMAP requires between 3 and 2147483647 rows.");
|
|
90
|
+
}
|
|
91
|
+
if (await (0, readScalarNumber_js_1.default)(connection, `SELECT count(*) FROM ${snapshot}
|
|
92
|
+
WHERE ${q(vector)} IS NULL OR len(${q(vector)})=0
|
|
93
|
+
OR list_count(${q(vector)}) != len(${q(vector)})
|
|
94
|
+
OR NOT list_bool_and(list_transform(${q(vector)}, x -> isfinite(x::DOUBLE)))`)) {
|
|
95
|
+
throw new Error("Vectors must be nonempty, non-null and contain finite numbers only.");
|
|
96
|
+
}
|
|
97
|
+
if (await (0, readScalarNumber_js_1.default)(connection, `SELECT count(DISTINCT len(${q(vector)})) FROM ${snapshot}`) !== 1) {
|
|
98
|
+
throw new Error("Vectors must have equal dimensions.");
|
|
99
|
+
}
|
|
100
|
+
const dimensions = await (0, readScalarNumber_js_1.default)(connection, `SELECT len(${q(vector)}) FROM ${snapshot} LIMIT 1`);
|
|
101
|
+
await connection.run(`CREATE TEMP TABLE ${names.rows} AS
|
|
102
|
+
SELECT (row_number() OVER (ORDER BY ${ordinal})-1)::INTEGER AS vertex,
|
|
103
|
+
${ordinal} AS ordinal, ${q(vector)}::DOUBLE[${dimensions}] AS vec FROM ${snapshot}`);
|
|
104
|
+
if (await (0, readScalarNumber_js_1.default)(connection, `SELECT count(*) FROM ${names.rows}
|
|
105
|
+
WHERE NOT isfinite(array_inner_product(vec,vec)) OR array_inner_product(vec,vec)>1e300
|
|
106
|
+
${metric === "cosine" ? "OR array_inner_product(vec,vec)=0" : ""}`)) {
|
|
107
|
+
throw new Error("Vector norms overflow, or cosine distance received a zero vector.");
|
|
108
|
+
}
|
|
109
|
+
const graph = await (0, buildUmapGraph_js_1.default)(connection, {
|
|
110
|
+
count,
|
|
111
|
+
dimensions,
|
|
112
|
+
neighbors: Math.min(neighbors, count - 1),
|
|
113
|
+
}, {
|
|
114
|
+
metric,
|
|
115
|
+
search: count <= 1000 ? "exact" : "hnsw",
|
|
116
|
+
}, names);
|
|
117
|
+
// Release index and vector scratch before allocating optimizer state.
|
|
118
|
+
for (const relation of [
|
|
119
|
+
names.search,
|
|
120
|
+
names.candidates,
|
|
121
|
+
names.knn,
|
|
122
|
+
names.directed,
|
|
123
|
+
names.scales,
|
|
124
|
+
names.graph,
|
|
125
|
+
]) {
|
|
126
|
+
await connection.run(`DROP TABLE IF EXISTS ${relation}`);
|
|
127
|
+
}
|
|
128
|
+
await connection.run(`ALTER TABLE ${names.rows} DROP COLUMN vec`);
|
|
129
|
+
const coordinates = (0, optimizeUmapLayout_js_1.default)(graph, (0, initialUmapCoordinates_js_1.default)(count, layoutOptions.seed), layoutOptions);
|
|
130
|
+
await connection.run(`CREATE TEMP TABLE ${layout} (vertex INTEGER,x DOUBLE,y DOUBLE)`);
|
|
131
|
+
await (0, appendColumnBatches_js_1.default)(connection, layoutName, [node_api_1.INTEGER, node_api_1.DOUBLE, node_api_1.DOUBLE], count, (column, start, end) => Array.from({ length: end - start }, (_, row) => column === 0
|
|
132
|
+
? start + row
|
|
133
|
+
: coordinates[2 * (start + row) + column - 1]));
|
|
134
|
+
// Publish in one statement: failed fits never add partial columns. Existing
|
|
135
|
+
// native indexes must be restored because CREATE OR REPLACE drops them.
|
|
136
|
+
const indexes = (await connection.runAndReadAll("SELECT sql FROM duckdb_indexes() WHERE table_oid=$1", [sourceOid])).getRowsJS().map((row) => String(row[0]));
|
|
137
|
+
await connection.run("BEGIN TRANSACTION");
|
|
138
|
+
try {
|
|
139
|
+
await (0, queryDB_js_1.default)(table, `CREATE OR REPLACE ${sourceTemporary ? "TEMP " : ""}TABLE ${source} AS
|
|
140
|
+
SELECT ${columns.map((c) => `s.${q(c)}`).join(",")}, l.x AS "umapX", l.y AS "umapY"
|
|
141
|
+
FROM ${snapshot} s JOIN ${names.rows} r ON s.${ordinal}=r.ordinal
|
|
142
|
+
JOIN ${layout} l ON r.vertex=l.vertex ORDER BY s.${ordinal}`, (0, mergeOptions_js_1.default)(table, {
|
|
143
|
+
table: table.name,
|
|
144
|
+
method: "umap()",
|
|
145
|
+
parameters: { column, options },
|
|
146
|
+
noClean: true,
|
|
147
|
+
}));
|
|
148
|
+
for (const sql of indexes)
|
|
149
|
+
await connection.run(sql);
|
|
150
|
+
await connection.run("COMMIT");
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
await connection.run("ROLLBACK");
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
for (const relation of scratch) {
|
|
159
|
+
await connection.run(`DROP TABLE IF EXISTS ${relation}`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -10,7 +10,7 @@ const quoteIdentifier_js_1 = __importDefault(require("../helpers/quoteIdentifier
|
|
|
10
10
|
const tableRegistry_js_1 = require("../helpers/tableRegistry.js");
|
|
11
11
|
const queueOp_js_1 = __importDefault(require("../helpers/queueOp.js"));
|
|
12
12
|
const loadArray_js_1 = require("./loadArray.js");
|
|
13
|
-
const
|
|
13
|
+
const appendColumnBatches_js_1 = __importDefault(require("../helpers/appendColumnBatches.js"));
|
|
14
14
|
const readMutationRows_js_1 = __importDefault(require("../helpers/readMutationRows.js"));
|
|
15
15
|
const parseDuckDBType_js_1 = __importDefault(require("../helpers/parseDuckDBType.js"));
|
|
16
16
|
function updateWithJS(simpleTable, dataModifier, options = {}) {
|
|
@@ -139,26 +139,14 @@ async function executeUpdateWithJS(simpleTable, dataModifier, options) {
|
|
|
139
139
|
(0, parseDuckDBType_js_1.default)(added.types[newKeys.indexOf(key)]));
|
|
140
140
|
await simpleTable.sdb.customQuery(`CREATE OR REPLACE TABLE ${(0, quoteIdentifier_js_1.default)(scratch.name)} (${keys.map((key, i) => `${(0, quoteIdentifier_js_1.default)(key)} ${columnTypes[i]}`)
|
|
141
141
|
.join(", ")})`);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
? geometryData.get(key).slice(start, end)
|
|
151
|
-
: source.types.has(key)
|
|
152
|
-
? modified.slice(start, end).map((row) => source.toNative(row[key], columnTypes[i]))
|
|
153
|
-
: added.columnsData[newKeys.indexOf(key)].slice(start, end));
|
|
154
|
-
}
|
|
155
|
-
appender.appendDataChunk(chunk);
|
|
156
|
-
}
|
|
157
|
-
appender.flushSync();
|
|
158
|
-
}
|
|
159
|
-
finally {
|
|
160
|
-
appender.closeSync();
|
|
161
|
-
}
|
|
142
|
+
await (0, appendColumnBatches_js_1.default)(simpleTable.connection, scratch.name, columnTypes, modified.length, (column, start, end) => {
|
|
143
|
+
const key = keys[column];
|
|
144
|
+
return outputGeometry.includes(key)
|
|
145
|
+
? geometryData.get(key).slice(start, end)
|
|
146
|
+
: source.types.has(key)
|
|
147
|
+
? modified.slice(start, end).map((row) => source.toNative(row[key], columnTypes[column]))
|
|
148
|
+
: added.columnsData[newKeys.indexOf(key)].slice(start, end);
|
|
149
|
+
});
|
|
162
150
|
const projection = keys.map((key) => outputGeometry.includes(key)
|
|
163
151
|
? `${(0, geometryFromJSON_js_1.default)((0, quoteIdentifier_js_1.default)(key))} AS ${(0, quoteIdentifier_js_1.default)(key)}`
|
|
164
152
|
: outputJSON.includes(key)
|