📄 cube.out
字号:
SELECT '(0),(1)'::cube &< '(1),(2)'::cube AS bool; bool ------ f(1 row)SELECT '(0),(1)'::cube &< '(2),(3)'::cube AS bool; bool ------ f(1 row)SELECT '0'::cube &> '1'::cube AS bool; bool ------ f(1 row)SELECT '1'::cube &> '1'::cube AS bool; bool ------ t(1 row)SELECT '2'::cube &> '1'::cube AS bool; bool ------ f(1 row)SELECT '0'::cube &> '(0),(1)'::cube AS bool; bool ------ t(1 row)SELECT '1'::cube &> '(0),(1)'::cube AS bool; bool ------ f(1 row)SELECT '(0),(0.5)' &> '(0),(1)'::cube AS bool; bool ------ t(1 row)SELECT '(0),(1)'::cube &> '(0),(1)'::cube AS bool; bool ------ t(1 row)SELECT '(0),(2)'::cube &> '(0),(1)'::cube AS bool; bool ------ t(1 row)SELECT '(1),(2)'::cube &> '(0),(1)'::cube AS bool; bool ------ f(1 row)SELECT '(2),(3)'::cube &> '(0),(1)'::cube AS bool; bool ------ f(1 row)-- "left" / "right"-- (these operators are not useful but for 1-D or 2-D cubes, but R-tree-- seems to want them defined)--SELECT '1'::cube << '0'::cube AS bool; bool ------ f(1 row)SELECT '1'::cube << '1'::cube AS bool; bool ------ f(1 row)SELECT '1'::cube << '2'::cube AS bool; bool ------ t(1 row)SELECT '(0),(1)'::cube << '0'::cube AS bool; bool ------ f(1 row)SELECT '(0),(1)'::cube << '1'::cube AS bool; bool ------ t(1 row)SELECT '(0),(1)'::cube << '(0),(0.5)'::cube AS bool; bool ------ f(1 row)SELECT '(0),(1)'::cube << '(0),(1)'::cube AS bool; bool ------ f(1 row)SELECT '(0),(1)'::cube << '(0),(2)'::cube AS bool; bool ------ f(1 row)SELECT '(0),(1)'::cube << '(1),(2)'::cube AS bool; bool ------ t(1 row)SELECT '(0),(1)'::cube << '(2),(3)'::cube AS bool; bool ------ t(1 row)SELECT '0'::cube >> '1'::cube AS bool; bool ------ f(1 row)SELECT '1'::cube >> '1'::cube AS bool; bool ------ f(1 row)SELECT '2'::cube >> '1'::cube AS bool; bool ------ t(1 row)SELECT '0'::cube >> '(0),(1)'::cube AS bool; bool ------ f(1 row)SELECT '1'::cube >> '(0),(1)'::cube AS bool; bool ------ t(1 row)SELECT '(0),(0.5)' >> '(0),(1)'::cube AS bool; bool ------ f(1 row)SELECT '(0),(1)'::cube >> '(0),(1)'::cube AS bool; bool ------ f(1 row)SELECT '(0),(2)'::cube >> '(0),(1)'::cube AS bool; bool ------ f(1 row)SELECT '(1),(2)'::cube >> '(0),(1)'::cube AS bool; bool ------ t(1 row)SELECT '(2),(3)'::cube >> '(0),(1)'::cube AS bool; bool ------ t(1 row)-- "contained in" (the left operand is the cube entirely enclosed by-- the right operand):--SELECT '0'::cube ~ '0'::cube AS bool; bool ------ t(1 row)SELECT '0,0,0'::cube ~ '0,0,0'::cube AS bool; bool ------ t(1 row)SELECT '0,0'::cube ~ '0,0,1'::cube AS bool; bool ------ t(1 row)SELECT '0,0,0'::cube ~ '0,0,1'::cube AS bool; bool ------ f(1 row)SELECT '1,0,0'::cube ~ '0,0,1'::cube AS bool; bool ------ f(1 row)SELECT '(1,0,0),(0,0,1)'::cube ~ '(1,0,0),(0,0,1)'::cube AS bool; bool ------ t(1 row)SELECT '(1,0,0),(0,0,1)'::cube ~ '(-1,-1,-1),(1,1,1)'::cube AS bool; bool ------ t(1 row)SELECT '(1,0,0),(0,0,1)'::cube ~ '(-1,-1,-1,-1),(1,1,1,1)'::cube AS bool; bool ------ t(1 row)SELECT '0'::cube ~ '(-1),(1)'::cube AS bool; bool ------ t(1 row)SELECT '1'::cube ~ '(-1),(1)'::cube AS bool; bool ------ t(1 row)SELECT '-1'::cube ~ '(-1),(1)'::cube AS bool; bool ------ t(1 row)SELECT '(-1),(1)'::cube ~ '(-1),(1)'::cube AS bool; bool ------ t(1 row)SELECT '(-1),(1)'::cube ~ '(-1,-1),(1,1)'::cube AS bool; bool ------ t(1 row)SELECT '(-2),(1)'::cube ~ '(-1),(1)'::cube AS bool; bool ------ f(1 row)SELECT '(-2),(1)'::cube ~ '(-1,-1),(1,1)'::cube AS bool; bool ------ f(1 row)-- "contains" (the left operand is the cube that entirely encloses the-- right operand)--SELECT '0'::cube @ '0'::cube AS bool; bool ------ t(1 row)SELECT '0,0,0'::cube @ '0,0,0'::cube AS bool; bool ------ t(1 row)SELECT '0,0,1'::cube @ '0,0'::cube AS bool; bool ------ t(1 row)SELECT '0,0,1'::cube @ '0,0,0'::cube AS bool; bool ------ f(1 row)SELECT '0,0,1'::cube @ '1,0,0'::cube AS bool; bool ------ f(1 row)SELECT '(1,0,0),(0,0,1)'::cube @ '(1,0,0),(0,0,1)'::cube AS bool; bool ------ t(1 row)SELECT '(-1,-1,-1),(1,1,1)'::cube @ '(1,0,0),(0,0,1)'::cube AS bool; bool ------ t(1 row)SELECT '(-1,-1,-1,-1),(1,1,1,1)'::cube @ '(1,0,0),(0,0,1)'::cube AS bool; bool ------ t(1 row)SELECT '(-1),(1)'::cube @ '0'::cube AS bool; bool ------ t(1 row)SELECT '(-1),(1)'::cube @ '1'::cube AS bool; bool ------ t(1 row)SELECT '(-1),(1)'::cube @ '-1'::cube AS bool; bool ------ t(1 row)SELECT '(-1),(1)'::cube @ '(-1),(1)'::cube AS bool; bool ------ t(1 row)SELECT '(-1,-1),(1,1)'::cube @ '(-1),(1)'::cube AS bool; bool ------ t(1 row)SELECT '(-1),(1)'::cube @ '(-2),(1)'::cube AS bool; bool ------ f(1 row)SELECT '(-1,-1),(1,1)'::cube @ '(-2),(1)'::cube AS bool; bool ------ f(1 row)-- Test of distance function--SELECT cube_distance('(0)'::cube,'(2,2,2,2)'::cube); cube_distance --------------- 4(1 row)SELECT cube_distance('(0)'::cube,'(.3,.4)'::cube); cube_distance --------------- 0.5(1 row)-- Test of cube function (text to cube)--SELECT cube('('||1||','||1.2||')'); cube ---------- (1, 1.2)(1 row)SELECT cube(NULL); cube ------ (1 row)-- Test of cube_dim function (dimensions stored in cube)--SELECT cube_dim('(0)'::cube); cube_dim ---------- 1(1 row)SELECT cube_dim('(0,0)'::cube); cube_dim ---------- 2(1 row)SELECT cube_dim('(0,0,0)'::cube); cube_dim ---------- 3(1 row)-- Test of cube_ll_coord function (retrieves LL coodinate values)--SELECT cube_ll_coord('(-1,1),(2,-2)'::cube, 1); cube_ll_coord --------------- -1(1 row)SELECT cube_ll_coord('(-1,1),(2,-2)'::cube, 2); cube_ll_coord --------------- -2(1 row)SELECT cube_ll_coord('(-1,1),(2,-2)'::cube, 3); cube_ll_coord --------------- 0(1 row)-- Test of cube_ur_coord function (retrieves UR coodinate values)--SELECT cube_ur_coord('(-1,1),(2,-2)'::cube, 1); cube_ur_coord --------------- 2(1 row)SELECT cube_ur_coord('(-1,1),(2,-2)'::cube, 2); cube_ur_coord --------------- 1(1 row)SELECT cube_ur_coord('(-1,1),(2,-2)'::cube, 3); cube_ur_coord --------------- 0(1 row)-- Test of cube_is_point--SELECT cube_is_point('(0)'::cube); cube_is_point --------------- t(1 row)SELECT cube_is_point('(0,1,2)'::cube); cube_is_point --------------- t(1 row)SELECT cube_is_point('(0,1,2),(0,1,2)'::cube); cube_is_point --------------- t(1 row)SELECT cube_is_point('(0,1,2),(-1,1,2)'::cube); cube_is_point --------------- f(1 row)SELECT cube_is_point('(0,1,2),(0,-1,2)'::cube); cube_is_point --------------- f(1 row)SELECT cube_is_point('(0,1,2),(0,1,-2)'::cube); cube_is_point --------------- f(1 row)-- Test of cube_enlarge (enlarging and shrinking cubes)--SELECT cube_enlarge('(0)'::cube, 0, 0); cube_enlarge -------------- (0)(1 row)SELECT cube_enlarge('(0)'::cube, 0, 1); cube_enlarge -------------- (0)(1 row)SELECT cube_enlarge('(0)'::cube, 0, 2); cube_enlarge -------------- (0)(1 row)SELECT cube_enlarge('(2),(-2)'::cube, 0, 4); cube_enlarge -------------- (-2),(2)(1 row)SELECT cube_enlarge('(0)'::cube, 1, 0); cube_enlarge -------------- (-1),(1)(1 row)SELECT cube_enlarge('(0)'::cube, 1, 1); cube_enlarge -------------- (-1),(1)(1 row)SELECT cube_enlarge('(0)'::cube, 1, 2); cube_enlarge ----------------- (-1, -1),(1, 1)(1 row)SELECT cube_enlarge('(2),(-2)'::cube, 1, 4); cube_enlarge ------------------------------- (-3, -1, -1, -1),(3, 1, 1, 1)(1 row)SELECT cube_enlarge('(0)'::cube, -1, 0); cube_enlarge -------------- (0)(1 row)SELECT cube_enlarge('(0)'::cube, -1, 1); cube_enlarge -------------- (0)(1 row)SELECT cube_enlarge('(0)'::cube, -1, 2); cube_enlarge -------------- (0)(1 row)SELECT cube_enlarge('(2),(-2)'::cube, -1, 4); cube_enlarge -------------- (-1),(1)(1 row)SELECT cube_enlarge('(0,0,0)'::cube, 1, 0); cube_enlarge ------------------------ (-1, -1, -1),(1, 1, 1)(1 row)SELECT cube_enlarge('(0,0,0)'::cube, 1, 2); cube_enlarge ------------------------ (-1, -1, -1),(1, 1, 1)(1 row)SELECT cube_enlarge('(2,-2),(-3,7)'::cube, 1, 2); cube_enlarge ----------------- (-4, -3),(3, 8)(1 row)SELECT cube_enlarge('(2,-2),(-3,7)'::cube, 3, 2); cube_enlarge ------------------ (-6, -5),(5, 10)(1 row)SELECT cube_enlarge('(2,-2),(-3,7)'::cube, -1, 2); cube_enlarge ----------------- (-2, -1),(1, 6)(1 row)SELECT cube_enlarge('(2,-2),(-3,7)'::cube, -3, 2); cube_enlarge --------------------- (-0.5, 1),(-0.5, 4)(1 row)-- Load some example data and build the index-- CREATE TABLE test_cube (c cube);\copy test_cube from 'data/test_cube.data'CREATE INDEX test_cube_ix ON test_cube USING gist (c);SELECT * FROM test_cube WHERE c && '(3000,1000),(0,0)'; c -------------------------- (2424, 160),(2424, 81) (759, 187),(662, 163) (1444, 403),(1346, 344) (337, 455),(240, 359) (1594, 1043),(1517, 971)(5 rows)-- Test sorting SELECT * FROM test_cube WHERE c && '(3000,1000),(0,0)' GROUP BY c; c -------------------------- (337, 455),(240, 359) (759, 187),(662, 163) (1444, 403),(1346, 344) (1594, 1043),(1517, 971) (2424, 160),(2424, 81)(5 rows)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -