Для распределенного SQL прямое не-качественное соединение (t1.id > t2.id
) довольно дорого выполняется. Если одна сторона мала, вы выполняете широковещательную рассылку, а затем используете отсортированный индекс на каждом узле. Если обе стороны большие, вы можете выбрать один раздел и построить отсортированный индекс, а затем реплицировать другие строки в любой диапазон, который может совпадать.
Обычно у вас есть комбинационное равенство и неравное соединение, например t1.id = t2.id and t1.cost < t2.cost
. В этом случае вы можете сделать обычное распределенное хеш-соединение, а затем сохранить отсортированный список вторичных элементов для выполнения неравной части. Это то, что делает Престо.
Вы можете попробовать это:
from tkinter import Tk, scrolledtext, Menu, filedialog, END, messagebox, simpledialog, StringVar
root = Tk(className=" Text Editor")
textArea = scrolledtext.ScrolledText(root, width=100, height=80)
# --- added extra code for getting key pressed starts here --- #
word = ''
text = ''
def key(event):
# if you only need the character of the key pressed #
print("You Pressed: ", event.char)
# if you need the words after pressing ' '(space) key, or the total text #
global word, text
if event.char == ' ':
text = text + ' ' + word
print("Current Word You Entered: ", word)
print("Total Text is: ", text)
word = ''
else:
word += event.char
# binding key function to key pressed #
textArea.bind("<Key>", key)
# --- added extra code for getting key pressed ends here --- #
def newFile():
if len(textArea.get('1.0', END+'-1c')) > 0:
if messagebox.askyesno("Save ?", "Do you wish to save ?"):
saveFile()
else:
textArea.delete('1.0', END)
root.title("TEXT EDITOR")
def openFile():
textArea.delete('1.0', END)
file = filedialog.askopenfile(parent=root, mode='rb', title='Select a text file', filetypes=(("Text file", "*.txt"), ("All files", "*.*")))
if file != None:
contents = file.read()
textArea.insert('1.0', contents)
file.close()
def saveFile():
file = filedialog.asksaveasfile(mode='w')
if file != None:
data = textArea.get('1.0', END+'-1c')
file.write(data)
file.close()
menu = Menu(root)
root.config(menu=menu)
fileMenu = Menu(menu)
menu.add_cascade(label="File", menu=fileMenu)
fileMenu.add_command(label="New", command=newFile)
fileMenu.add_command(label="Open", command=openFile)
fileMenu.add_command(label="Save", command=saveFile)
fileMenu.add_command(label="Find")
fileMenu.add_separator()
fileMenu.add_command(label="Exit")
helpMenu = Menu(menu)
menu.add_cascade(label="Help")
menu.add_cascade(label="About")
textArea.pack()
root.mainloop()