Если вы можете разделить вычисления сверхмощных операций на несколько частей или получить доступ к той части кода, которая участвует в вычислении, вы можете вставить часть выключателя. Я реализовал это в Shiny app , который прослушивает нажатие кнопки, прежде чем продолжить с остальными вычислениями. Вы можете запустить приложение из R с помощью
library(shiny)
runGitHub("romunov/shinyapps", subdir = "breaker")
или скопировать / вставить код в сервер.R и ui.R и запустить его с помощью runApp()
.
#ui.R
library(shiny)
shinyUI(fluidPage(
titlePanel("Interrupting calculation"),
sidebarLayout(
sidebarPanel(
sliderInput(inputId = "num.rows",
label = "Generate number of rows",
min = 1e1,
max = 1e7,
value = 3e3),
actionButton(inputId = "ok", label = "Stop computation")
),
mainPanel(
verbatimTextOutput("result")
)
)
))
#server.R
library(shiny)
shinyServer(function(input, output) {
initial.ok <- 0
part1 <- reactive({
nr.f <- floor(input$num.rows/2)
out1 <- data.frame(col = sample(letters[1:5], size = nr.f,
replace = TRUE),
val = runif(nr.f))
out1
})
part2 <- reactive({
nr.c <- ceiling(input$num.rows/2)
out2 <- data.frame(col = sample(letters[1:5], size = nr.c,
replace = TRUE),
val = runif(nr.c))
out2
})
output$result <- renderPrint({
out1 <- part1()
if (initial.ok < input$ok) {
initial.ok <<- initial.ok + 1
stop("Interrupted")
}
out2 <- part2()
out <- rbind(out1, out2)
print("Successful calculation")
print(str(out))
})
})
;with installed as
( select PACK from software where TAGNUM in ( select tagnum from PC where comp in ( select comp from computer where MFRNAME = 'HP')))
select * from Package p left join installed i on p.pack = i.pack
where i.pack is null
Вы можете использовать NOT EXISTS
с коррелированным подзапросом, который объединяет другие таблицы и содержит условие вашего фильтра:
select
pk.pack,
pk.packname,
pk.packv,
pk.packtype,
pk.packcost
from package pk
where not exists (
select 1
from software s
inner join pc on pc.tagnum = s.tagnum
inner join computer c on c.comp = pc.comp
where s.pack = pk.pack
and c.mfrname = 'HP'
)
order by pk.pack;
Результат
| pack | packname | packv | packtype | packcost |
|------|------------------|-------|-----------------|----------|
| AC11 | Quick Accounting | 4.1 | Accounting | 754.95 |
| AC12 | Accounting MIS | 4.0 | Accounting | 2000 |
| AC13 | Quickbook | 2005 | Accounting | 300 |
| DB11 | Manta | 1.5 | Database | 380 |
| DB13 | SQL Server | 2005 | Database | 500 |
| DB14 | My SQL | 2005 | Database | 300 |
| SS11 | Easycal | 5.5 | Spreadsheet | 225.15 |
| WP04 | Word Power | 2 | Word Processing | 118 |
| WP07 | Good Word | 3.2 | Word Processing | 35 |
| WP14 | GOOGLE | 2 | Word Processing | 118 |
[116 ] Пример SQL Fiddle