BigInteger的数组函数 [英] biginteger array functions

查看:119
本文介绍了BigInteger的数组函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在与大整数工作的任何可用的功能?

我发现一个模块 intarray ,但是从这个功能模块只用整数工作,而不是 BIGINT

我错过功能从数组删除项目。就像一个减操作符提到模块中实现:


  

INT [] - INT (删除匹配从数组右边的参数项)



解决方案

更新2015年一个更好的版本。结果
你可以替换你自己的功能。这一个是相当快的:

  CREATE OR REPLACE FUNCTION arr_subtract(INT8 [],INT8 [])
  退货INT8 [] AS
$ FUNC $
选择Array(
    选择一个
    从UNNEST($ 1)用序数X(A,ORD)
    其中A<> ALL($ 2)
    ORDER BY ORD
    );
$ FUNC $语言SQL不可变的;

电话:

  SELECT arr_subtract('{} -3,5,6,7,8,9-':: INT8 [],{3,4,8}':: INT8 [] );

结果:

  {5,6,7,9}

保持阵列的原始顺序。

相关阅读:

Are there any available functions for work with big integers?

I've found a module intarray, but functions from this module only work with integer, not bigint.

I miss a function for removing an item from an array. Something like the implementation of a "minus" operator in mentioned module:

int[] - int (remove entries matching right argument from array)

解决方案

Updated 2015 with a better version.
You can substitute your own function. This one is reasonably fast:

CREATE OR REPLACE FUNCTION arr_subtract(int8[], int8[])
  RETURNS int8[] AS
$func$
SELECT ARRAY(
    SELECT a
    FROM   unnest($1) WITH ORDINALITY x(a, ord)
    WHERE  a <> ALL ($2)
    ORDER  BY ord
    );
$func$  LANGUAGE sql IMMUTABLE;

Call:

SELECT arr_subtract('{3,5,6,7,8,9}':: int8[], '{3,4,8}'::int8[]);

Result:

{5,6,7,9}

Keeps the original order of the array.

Related:

这篇关于BigInteger的数组函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆