24 Matching Annotations
  1. Jun 2021
    1. You can use jsonb_agg and jsonb_array_elements_text to flatten or unnest an array of arrays in PostgreSQL: SELECT jsonb_array_elements_text(jsonb_agg(array_of_arrays)) FROM x;
    1. As stated in the title, I am in a situation where I need to return a count of occurrences within an array, that is within a jsonb column.
    1. json_array_elements_text ( json ) → setof text jsonb_array_elements_text ( jsonb ) → setof text Expands the top-level JSON array into a set of text values. select * from json_array_elements_text('["foo", "bar"]') → value ----------- foo bar
  2. May 2021
  3. Mar 2021
  4. Sep 2020
  5. Aug 2020
  6. May 2020
    1. 通常,Arrays用于两种数据结构:queue和stack。 要了解什么queue是食品,您可以想象在食品商店中有一个普通的队列:新人们在队列的末端加入队列,而刚开始的人们则先离开队列。这就是为什么我们需要两种方法来实现的原因queue:一种在的末尾添加元素,Array而另一种在的开始处删除元素的方法queue。这两种方法是push()将一个或多个元素添加到数组的末尾并返回新的数组长度,并shift()删除数组的第零个元素并返回其值:
    2. The slice() method works only with arrays whose elements are strings, numbers, or boolean values.

      只有字符串,数字,布尔值三种类型的数组可以用 slice 操作

    3. Indexes can also be negative. If you specify a negative index in the first parameter, it will shift the end of the sequence. For example, slice(-4) call will extract the last four elements of the sequence:

      index 可以是复数,arr.slice(-4)代表从倒数第四个值到最后

    4. The slice() method does not change the source array, but returns a copy of the array

      slice()方法是个纯函数

    1. function foo { local -n data_ref=$1 echo ${data_ref[a]} ${data_ref[b]} } declare -A data data[a]="Fred Flintstone" data[b]="Barney Rubble" foo data

      best way to pass associative arrays as function argument in bash

  7. Feb 2020
    1. head(as.data.frame(nasa))#> lat long month year cloudhigh cloudlow cloudmid ozone pressure #> 1 36.20000 -113.8 1 1995 26.0 7.5 34.5 304 835 #> 2 33.70435 -113.8 1 1995 20.0 11.5 32.5 304 940 #> 3 31.20870 -113.8 1 1995 16.0 16.5 26.0 298 960 #> 4 28.71304 -113.8 1 1995 13.0 20.5 14.5 276 990 #> 5 26.21739 -113.8 1 1995 7.5 26.0 10.5 274 1000 #> 6 23.72174 -113.8 1 1995 8.0 30.0 9.5 264 1000 #> surftemp temperature #> 1 272.7 272.1 #> 2 279.5 282.2 #> 3 284.7 285.2 #> 4 289.3 290.7 #> 5 292.2 292.7 #> 6 294.1 293.6

      unrolling a tbl_cube into 2 dimensions (data.frame)

  8. Aug 2019
  9. Mar 2018
  10. Jan 2018
  11. Apr 2017
    1. array with component type int

      My only suggestion is that this should be changed to single-dimension array with component type int. As per the Encoding conventions defined by java.lang.Class#getName()'s contract.

      In other other words, the OP missed the fact that for every dimension of the array-object, an [ character is prepended to the enconding of the type contained in the array.

  12. Mar 2015