This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
public class HashJoin implements JoinStrategy { | |
@Override | |
public List<Integer> join(List<Integer> R, List<Integer> S) { | |
List<Integer> output = new ArrayList<>(); | |
HashMap<Integer, Integer> RHash = new HashMap<>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
public class SortMergeJoin implements JoinStrategy { | |
/* | |
time complexity: O(mlog(m)) + O(nlog(n)) + O(m+n), m is the size of R and n is the size of S | |
*/ | |
@Override | |
public List<Integer> join(List<Integer> R, List<Integer> S) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.List; | |
public class NestedLoopJoin implements JoinStrategy { | |
/* | |
time complexity: O(m*n), m is the size of R and n is the size of S | |
*/ | |
@Override | |
public List<Integer> join(List<Integer> R, List<Integer> S) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
SELECT DISTINCT | |
*/ | |
WITH foo (pk1, pk2) AS | |
(SELECT 1, 'a' | |
UNION ALL | |
SELECT 1, 'b' | |
UNION ALL | |
SELECT 2, 'a' | |
UNION ALL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
LEFT JOIN without filter, all tuples in foo can find a match in bar | |
*/ | |
WITH foo (id, bar_id) AS | |
( | |
SELECT 1, 1 | |
UNION ALL | |
SELECT 2, 1 | |
UNION ALL | |
SELECT 3, 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3.6 | |
import ast | |
from unittest import TestCase | |
def func1(value): | |
data = set() | |
if isinstance(value, set): | |
data |= value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import time | |
from multiprocessing import Pool as ProcessPool | |
from multiprocessing.dummy import Pool as ThreadPool | |
import pymysql | |
import psutil | |
class Timer: |