Skip to content

Instantly share code, notes, and snippets.

@alexey-milovidov
Last active September 30, 2019 23:16
Show Gist options
  • Select an option

  • Save alexey-milovidov/4139ec557f482b8a625c2670819b3277 to your computer and use it in GitHub Desktop.

Select an option

Save alexey-milovidov/4139ec557f482b8a625c2670819b3277 to your computer and use it in GitHub Desktop.
:) WITH 'It is the latest occurrence of the Southeast Asian haze, the issue that occurs in constant intensity during every wet season. It has mainly been caused by forest fires resulting from illegal slash-and-burn clearing performed on behalf of the palm oil industry in Kazakhstan, principally on the islands, which then spread quickly in the dry season.' AS str, alphaTokens(str) AS tokens, arrayMap(i -> [tokens[i], tokens[i + 1], tokens[i + 2]], arrayEnumerate(tokens)) AS shingles, arrayMap(x -> sipHash64(x, 1), shingles) AS hashes1, arrayMap(x -> sipHash64(x, 2), shingles) AS hashes2, sipHash64(arraySlice(arraySort(hashes1), 1, 5)) AS h1, sipHash64(arraySlice(arraySort(hashes2), 1, 5)) AS h2 SELECT h1, h2\G
WITH
'It is the latest occurrence of the Southeast Asian haze, the issue that occurs in constant intensity during every wet season. It has mainly been caused by forest fires resulting from illegal slash-and-burn clearing performed on behalf of the palm oil industry in Kazakhstan, principally on the islands, which then spread quickly in the dry season.' AS str,
alphaTokens(str) AS tokens,
arrayMap(i -> [tokens[i], tokens[i + 1], tokens[i + 2]], arrayEnumerate(tokens)) AS shingles,
arrayMap(x -> sipHash64(x, 1), shingles) AS hashes1,
arrayMap(x -> sipHash64(x, 2), shingles) AS hashes2,
sipHash64(arraySlice(arraySort(hashes1), 1, 5)) AS h1,
sipHash64(arraySlice(arraySort(hashes2), 1, 5)) AS h2
SELECT
h1,
h2
Row 1:
──────
h1: 4037745474664829908
h2: 18008138019670968409
WITH 'It is the latest occurrence of the Southeast European haze, the issue that occurs in constant intensity during every wet season. It has mainly been caused by forest fires resulting from illegal slash-and-burn clearing performed on behalf of the palm oil industry in Kazakhstan, principally on the islands, which then spread quickly in the dry season.' AS str, alphaTokens(str) AS tokens, arrayMap(i -> [tokens[i], tokens[i + 1], tokens[i + 2]], arrayEnumerate(tokens)) AS shingles, arrayMap(x -> sipHash64(x, 1), shingles) AS hashes1, arrayMap(x -> sipHash64(x, 2), shingles) AS hashes2, sipHash64(arraySlice(arraySort(hashes1), 1, 5)) AS h1, sipHash64(arraySlice(arraySort(hashes2), 1, 5)) AS h2 SELECT h1, h2\G
WITH
'It is the latest occurrence of the Southeast European haze, the issue that occurs in constant intensity during every wet season. It has mainly been caused by forest fires resulting from illegal slash-and-burn clearing performed on behalf of the palm oil industry in Kazakhstan, principally on the islands, which then spread quickly in the dry season.' AS str,
alphaTokens(str) AS tokens,
arrayMap(i -> [tokens[i], tokens[i + 1], tokens[i + 2]], arrayEnumerate(tokens)) AS shingles,
arrayMap(x -> sipHash64(x, 1), shingles) AS hashes1,
arrayMap(x -> sipHash64(x, 2), shingles) AS hashes2,
sipHash64(arraySlice(arraySort(hashes1), 1, 5)) AS h1,
sipHash64(arraySlice(arraySort(hashes2), 1, 5)) AS h2
SELECT
h1,
h2
Row 1:
──────
h1: 4037745474664829908
h2: 3268385572922067154
:) WITH 'It is the latest occurrence of the Southeast Asian haze, the issue that occurs in constant intensity during every wet season. It has mainly been caused by forest fires resulting from illegal slash-and-burn clearing performed on behalf of the palm oil industry in Kazakhstan, principally on the islands, which then spread quickly in the dry season.' AS str, alphaTokens(str) AS tokens, arrayMap(i -> [tokens[i], tokens[i + 1], tokens[i + 2]], arrayEnumerate(tokens)) AS shingles, arrayMap(x -> sipHash64(x, 1), shingles) AS hashes1, arrayMap(x -> sipHash64(x, 2), shingles) AS hashes2, sipHash64(arraySlice(arraySort(hashes1), 1, 5)) AS h1, sipHash64(arraySlice(arraySort(hashes2), 1, 5)) AS h2 SELECT h1, h2, arraySlice(arraySort(x -> sipHash64(x, 1), shingles), 1, 5) AS min_shingles1, arraySlice(arraySort(x -> sipHash64(x, 2), shingles), 1, 5) AS min_shingles2\G
WITH
'It is the latest occurrence of the Southeast Asian haze, the issue that occurs in constant intensity during every wet season. It has mainly been caused by forest fires resulting from illegal slash-and-burn clearing performed on behalf of the palm oil industry in Kazakhstan, principally on the islands, which then spread quickly in the dry season.' AS str,
alphaTokens(str) AS tokens,
arrayMap(i -> [tokens[i], tokens[i + 1], tokens[i + 2]], arrayEnumerate(tokens)) AS shingles,
arrayMap(x -> sipHash64(x, 1), shingles) AS hashes1,
arrayMap(x -> sipHash64(x, 2), shingles) AS hashes2,
sipHash64(arraySlice(arraySort(hashes1), 1, 5)) AS h1,
sipHash64(arraySlice(arraySort(hashes2), 1, 5)) AS h2
SELECT
h1,
h2,
arraySlice(arraySort(x -> sipHash64(x, 1), shingles), 1, 5) AS min_shingles1,
arraySlice(arraySort(x -> sipHash64(x, 2), shingles), 1, 5) AS min_shingles2
Row 1:
──────
h1: 4037745474664829908
h2: 18008138019670968409
min_shingles1: [['season','It','has'],['then','spread','quickly'],['islands','which','then'],['the','latest','occurrence'],['principally','on','the']]
min_shingles2: [['palm','oil','industry'],['slash','and','burn'],['Asian','haze','the'],['the','islands','which'],['the','palm','oil']]
1 rows in set. Elapsed: 0.012 sec.
:) WITH 'It is the latest occurrence of the Southeast Europeian haze, the issue that occurs in constant intensity during every wet season. It has mainly been caused by forest fires resulting from illegal slash-and-burn clearing performed on behalf of the palm oil industry in Kazakhstan, principally on the islands, which then spread quickly in the dry season.' AS str, alphaTokens(str) AS tokens, arrayMap(i -> [tokens[i], tokens[i + 1], tokens[i + 2]], arrayEnumerate(tokens)) AS shingles, arrayMap(x -> sipHash64(x, 1), shingles) AS hashes1, arrayMap(x -> sipHash64(x, 2), shingles) AS hashes2, sipHash64(arraySlice(arraySort(hashes1), 1, 5)) AS h1, sipHash64(arraySlice(arraySort(hashes2), 1, 5)) AS h2 SELECT h1, h2, arraySlice(arraySort(x -> sipHash64(x, 1), shingles), 1, 5) AS min_shingles1, arraySlice(arraySort(x -> sipHash64(x, 2), shingles), 1, 5) AS min_shingles2\G
WITH
'It is the latest occurrence of the Southeast Europeian haze, the issue that occurs in constant intensity during every wet season. It has mainly been caused by forest fires resulting from illegal slash-and-burn clearing performed on behalf of the palm oil industry in Kazakhstan, principally on the islands, which then spread quickly in the dry season.' AS str,
alphaTokens(str) AS tokens,
arrayMap(i -> [tokens[i], tokens[i + 1], tokens[i + 2]], arrayEnumerate(tokens)) AS shingles,
arrayMap(x -> sipHash64(x, 1), shingles) AS hashes1,
arrayMap(x -> sipHash64(x, 2), shingles) AS hashes2,
sipHash64(arraySlice(arraySort(hashes1), 1, 5)) AS h1,
sipHash64(arraySlice(arraySort(hashes2), 1, 5)) AS h2
SELECT
h1,
h2,
arraySlice(arraySort(x -> sipHash64(x, 1), shingles), 1, 5) AS min_shingles1,
arraySlice(arraySort(x -> sipHash64(x, 2), shingles), 1, 5) AS min_shingles2
Row 1:
──────
h1: 4037745474664829908
h2: 17895668912250717102
min_shingles1: [['season','It','has'],['then','spread','quickly'],['islands','which','then'],['the','latest','occurrence'],['principally','on','the']]
min_shingles2: [['palm','oil','industry'],['slash','and','burn'],['the','islands','which'],['the','palm','oil'],['been','caused','by']]
1 rows in set. Elapsed: 0.011 sec.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment