@@ -340,3 +340,162 @@ SELECT t, v FROM test_bit WHERE v % '{0,1,2,3,4,5,6,7,8,9,10}'::int4[]::bit(10)
340
340
(17 rows)
341
341
342
342
RESET anyarray.similarity_threshold;
343
+ DROP INDEX idx_test_bit;
344
+ CREATE INDEX idx_test_bit ON test_bit USING rum (v _bit_aa_ops);
345
+ SET enable_seqscan=off;
346
+ EXPLAIN (COSTS OFF) SELECT t, v FROM test_bit WHERE v && '{43,50}'::int4[]::bit(10)[] ORDER BY t;
347
+ QUERY PLAN
348
+ -----------------------------------------------------------------------
349
+ Sort
350
+ Sort Key: t
351
+ -> Bitmap Heap Scan on test_bit
352
+ Recheck Cond: (v && '{0000101011,0000110010}'::bit(10)[])
353
+ -> Bitmap Index Scan on idx_test_bit
354
+ Index Cond: (v && '{0000101011,0000110010}'::bit(10)[])
355
+ (6 rows)
356
+
357
+ EXPLAIN (COSTS OFF) SELECT t, v FROM test_bit WHERE v @> '{43,50}'::int4[]::bit(10)[] ORDER BY t;
358
+ QUERY PLAN
359
+ -----------------------------------------------------------------
360
+ Sort
361
+ Sort Key: t
362
+ -> Index Scan using idx_test_bit on test_bit
363
+ Index Cond: (v @> '{0000101011,0000110010}'::bit(10)[])
364
+ (4 rows)
365
+
366
+ EXPLAIN (COSTS OFF) SELECT t, v FROM test_bit WHERE v <@ '{0,1,2,3,4,5,6,7,8,9,10}'::int4[]::bit(10)[] ORDER BY t;
367
+ QUERY PLAN
368
+ --------------------------------------------------------------------------------------------------------------------------------------------------------------------
369
+ Sort
370
+ Sort Key: t
371
+ -> Index Scan using idx_test_bit on test_bit
372
+ Index Cond: (v <@ '{0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000,0000001001,0000001010}'::bit(10)[])
373
+ (4 rows)
374
+
375
+ EXPLAIN (COSTS OFF) SELECT t, v FROM test_bit WHERE v = '{0,1,2,3,4,5,6,7,8,9,10}'::int4[]::bit(10)[] ORDER BY t;
376
+ QUERY PLAN
377
+ -------------------------------------------------------------------------------------------------------------------------------------------------------------------
378
+ Sort
379
+ Sort Key: t
380
+ -> Index Scan using idx_test_bit on test_bit
381
+ Index Cond: (v = '{0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000,0000001001,0000001010}'::bit(10)[])
382
+ (4 rows)
383
+
384
+ EXPLAIN (COSTS OFF) SELECT t, v FROM test_bit WHERE v % '{0,1,2,3,4,5,6,7,8,9,10}'::int4[]::bit(10)[] ORDER BY t;
385
+ QUERY PLAN
386
+ -------------------------------------------------------------------------------------------------------------------------------------------------------------------
387
+ Sort
388
+ Sort Key: t
389
+ -> Index Scan using idx_test_bit on test_bit
390
+ Index Cond: (v % '{0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000,0000001001,0000001010}'::bit(10)[])
391
+ (4 rows)
392
+
393
+ SELECT t, v FROM test_bit WHERE v && '{43,50}'::int4[]::bit(10)[] ORDER BY t;
394
+ t | v
395
+ ----+----------------------------------------------------------------------------------------------------------------------------
396
+ 43 | {0000100001,0000100010,0000100011,0000100100,0000100101,0000100110,0000100111,0000101000,0000101001,0000101010,0000101011}
397
+ 44 | {0000100010,0000100011,0000100100,0000100101,0000100110,0000100111,0000101000,0000101001,0000101010,0000101011,0000101100}
398
+ 45 | {0000100011,0000100100,0000100101,0000100110,0000100111,0000101000,0000101001,0000101010,0000101011,0000101100,0000101101}
399
+ 46 | {0000100100,0000100101,0000100110,0000100111,0000101000,0000101001,0000101010,0000101011,0000101100,0000101101,0000101110}
400
+ 47 | {0000100101,0000100110,0000100111,0000101000,0000101001,0000101010,0000101011,0000101100,0000101101,0000101110,0000101111}
401
+ 48 | {0000100110,0000100111,0000101000,0000101001,0000101010,0000101011,0000101100,0000101101,0000101110,0000101111,0000110000}
402
+ 49 | {0000100111,0000101000,0000101001,0000101010,0000101011,0000101100,0000101101,0000101110,0000101111,0000110000,0000110001}
403
+ 50 | {0000101000,0000101001,0000101010,0000101011,0000101100,0000101101,0000101110,0000101111,0000110000,0000110001,0000110010}
404
+ 51 | {0000101001,0000101010,0000101011,0000101100,0000101101,0000101110,0000101111,0000110000,0000110001,0000110010,0000110011}
405
+ 52 | {0000101010,0000101011,0000101100,0000101101,0000101110,0000101111,0000110000,0000110001,0000110010,0000110011,0000110100}
406
+ 53 | {0000101011,0000101100,0000101101,0000101110,0000101111,0000110000,0000110001,0000110010,0000110011,0000110100,0000110101}
407
+ 54 | {0000101100,0000101101,0000101110,0000101111,0000110000,0000110001,0000110010,0000110011,0000110100,0000110101,0000110110}
408
+ 55 | {0000101101,0000101110,0000101111,0000110000,0000110001,0000110010,0000110011,0000110100,0000110101,0000110110,0000110111}
409
+ 56 | {0000101110,0000101111,0000110000,0000110001,0000110010,0000110011,0000110100,0000110101,0000110110,0000110111,0000111000}
410
+ 57 | {0000101111,0000110000,0000110001,0000110010,0000110011,0000110100,0000110101,0000110110,0000110111,0000111000,0000111001}
411
+ 58 | {0000110000,0000110001,0000110010,0000110011,0000110100,0000110101,0000110110,0000110111,0000111000,0000111001,0000111010}
412
+ 59 | {0000110001,0000110010,0000110011,0000110100,0000110101,0000110110,0000110111,0000111000,0000111001,0000111010,0000111011}
413
+ 60 | {0000110010,0000110011,0000110100,0000110101,0000110110,0000110111,0000111000,0000111001,0000111010,0000111011,0000111100}
414
+ (18 rows)
415
+
416
+ SELECT t, v FROM test_bit WHERE v @> '{43,50}'::int4[]::bit(10)[] ORDER BY t;
417
+ t | v
418
+ ----+----------------------------------------------------------------------------------------------------------------------------
419
+ 50 | {0000101000,0000101001,0000101010,0000101011,0000101100,0000101101,0000101110,0000101111,0000110000,0000110001,0000110010}
420
+ 51 | {0000101001,0000101010,0000101011,0000101100,0000101101,0000101110,0000101111,0000110000,0000110001,0000110010,0000110011}
421
+ 52 | {0000101010,0000101011,0000101100,0000101101,0000101110,0000101111,0000110000,0000110001,0000110010,0000110011,0000110100}
422
+ 53 | {0000101011,0000101100,0000101101,0000101110,0000101111,0000110000,0000110001,0000110010,0000110011,0000110100,0000110101}
423
+ (4 rows)
424
+
425
+ SELECT t, v FROM test_bit WHERE v <@ '{0,1,2,3,4,5,6,7,8,9,10}'::int4[]::bit(10)[] ORDER BY t;
426
+ t | v
427
+ ----+----------------------------------------------------------------------------------------------------------------------------
428
+ 1 | {0000000000,0000000001}
429
+ 2 | {0000000000,0000000001,0000000010}
430
+ 3 | {0000000000,0000000001,0000000010,0000000011}
431
+ 4 | {0000000000,0000000001,0000000010,0000000011,0000000100}
432
+ 5 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101}
433
+ 6 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110}
434
+ 7 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111}
435
+ 8 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000}
436
+ 9 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000,0000001001}
437
+ 10 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000,0000001001,0000001010}
438
+ (10 rows)
439
+
440
+ SELECT t, v FROM test_bit WHERE v = '{0,1,2,3,4,5,6,7,8,9,10}'::int4[]::bit(10)[] ORDER BY t;
441
+ t | v
442
+ ----+----------------------------------------------------------------------------------------------------------------------------
443
+ 10 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000,0000001001,0000001010}
444
+ (1 row)
445
+
446
+ SET anyarray.similarity_type=cosine;
447
+ SELECT t, v FROM test_bit WHERE v % '{0,1,2,3,4,5,6,7,8,9,10}'::int4[]::bit(10)[] ORDER BY t;
448
+ t | v
449
+ ----+----------------------------------------------------------------------------------------------------------------------------
450
+ 3 | {0000000000,0000000001,0000000010,0000000011}
451
+ 4 | {0000000000,0000000001,0000000010,0000000011,0000000100}
452
+ 5 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101}
453
+ 6 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110}
454
+ 7 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111}
455
+ 8 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000}
456
+ 9 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000,0000001001}
457
+ 10 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000,0000001001,0000001010}
458
+ 11 | {0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000,0000001001,0000001010,0000001011}
459
+ 12 | {0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000,0000001001,0000001010,0000001011,0000001100}
460
+ 13 | {0000000011,0000000100,0000000101,0000000110,0000000111,0000001000,0000001001,0000001010,0000001011,0000001100,0000001101}
461
+ 14 | {0000000100,0000000101,0000000110,0000000111,0000001000,0000001001,0000001010,0000001011,0000001100,0000001101,0000001110}
462
+ (12 rows)
463
+
464
+ SET anyarray.similarity_type=jaccard;
465
+ SELECT t, v FROM test_bit WHERE v % '{0,1,2,3,4,5,6,7,8,9,10}'::int4[]::bit(10)[] ORDER BY t;
466
+ t | v
467
+ ----+----------------------------------------------------------------------------------------------------------------------------
468
+ 6 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110}
469
+ 7 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111}
470
+ 8 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000}
471
+ 9 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000,0000001001}
472
+ 10 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000,0000001001,0000001010}
473
+ 11 | {0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000,0000001001,0000001010,0000001011}
474
+ 12 | {0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000,0000001001,0000001010,0000001011,0000001100}
475
+ (7 rows)
476
+
477
+ SET anyarray.similarity_type=overlap;
478
+ SET anyarray.similarity_threshold = 3;
479
+ SELECT t, v FROM test_bit WHERE v % '{0,1,2,3,4,5,6,7,8,9,10}'::int4[]::bit(10)[] ORDER BY t;
480
+ t | v
481
+ ----+----------------------------------------------------------------------------------------------------------------------------
482
+ 2 | {0000000000,0000000001,0000000010}
483
+ 3 | {0000000000,0000000001,0000000010,0000000011}
484
+ 4 | {0000000000,0000000001,0000000010,0000000011,0000000100}
485
+ 5 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101}
486
+ 6 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110}
487
+ 7 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111}
488
+ 8 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000}
489
+ 9 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000,0000001001}
490
+ 10 | {0000000000,0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000,0000001001,0000001010}
491
+ 11 | {0000000001,0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000,0000001001,0000001010,0000001011}
492
+ 12 | {0000000010,0000000011,0000000100,0000000101,0000000110,0000000111,0000001000,0000001001,0000001010,0000001011,0000001100}
493
+ 13 | {0000000011,0000000100,0000000101,0000000110,0000000111,0000001000,0000001001,0000001010,0000001011,0000001100,0000001101}
494
+ 14 | {0000000100,0000000101,0000000110,0000000111,0000001000,0000001001,0000001010,0000001011,0000001100,0000001101,0000001110}
495
+ 15 | {0000000101,0000000110,0000000111,0000001000,0000001001,0000001010,0000001011,0000001100,0000001101,0000001110,0000001111}
496
+ 16 | {0000000110,0000000111,0000001000,0000001001,0000001010,0000001011,0000001100,0000001101,0000001110,0000001111,0000010000}
497
+ 17 | {0000000111,0000001000,0000001001,0000001010,0000001011,0000001100,0000001101,0000001110,0000001111,0000010000,0000010001}
498
+ 18 | {0000001000,0000001001,0000001010,0000001011,0000001100,0000001101,0000001110,0000001111,0000010000,0000010001,0000010010}
499
+ (17 rows)
500
+
501
+ RESET anyarray.similarity_threshold;