Categories
Linux Mastering Development

Editing a file based on a pattern appearance

I have a file that contains text and numbers like this: state(1, s(1,a), [s(1,b)]). state(1, s(1,b), [s(1,a)]). state(1, s(2,a), [s(2,b)]). state(1, s(2,b), [s(2,a)]). state(1, s(3,a), [s(3,b)]). state(1, s(3,b), [s(3,a)]). state(1, s(4,a), [t(1), t(2)]). state(1, s(5,a), [t(1), t(3)]). state(1, s(6,a), [s(6,b)]). state(1, s(6,b), [s(6,a)]). …so on I want the numbering with in s(x,y) to change as […]

Categories
Mastering Development

String comparison in Databricks Spark SQL

select distinct promo_name ,case when substring(promo_name,instr(promo_name, "P0"),2) = "P0" then 0 when substring(promo_name,instr(promo_name, "P1"),2) = "P1" then 1 When substring(promo_name,instr(promo_name, "P01"),3) = "P01" then 1 when substring(promo_name,instr(promo_name, "P2"),2) = "P2" then 2 When substring(promo_name,instr(promo_name, "P02"),3) = "P02" then 2 when substring(promo_name,instr(promo_name, "P3"),2) = "P3" then 3 when substring(promo_name,instr(promo_name, "P03"),3) = "P03" then 3 when substring(promo_name,instr(promo_name, […]

Categories
Mastering Development

R conditional loop to replace vallues

I am looking to conditionally replace values in a column and I think a loop is what I need. Though I know on a basic level how loops work, I have little experience using them so I struggle with wrapping my head around the order of operations. Using the dataframe df <- structure(list(player = c(“p1”, […]

Categories
Development

Time difference in execution of MySQL joins

I had a queries in which there was left joins were used and it was taking 30 seconds to complete the execution and return the dataset on mysql terminal. But when I have changed it to join its execution time has been reduced significantly from 30 to 12 seconds. I know this is too much […]

Categories
Development

Why is Entity Framework Core attempting to insert records into one of the tables from many to many relationships and NOT the join table?

Given the following set up where there are many Teams and there are many LeagueSessions. Each Team belongs to zero or more LeagueSessions but only ever one LeagueSession is active. LeagueSessions have many teams, and the teams will be repeated. Many-to-many relationship is established between Teams and LeagueSessions with a join table called TeamsSessions. Team […]

Categories
Development

alternate way to execute stored proc using simplejdbccall

Unable to execute a stored procedure by using named parameters. The SQL Server profiler for my execution showed a lengthy SQL including the null values. Is there any other way I can execute the stored procedure preferably using spring-jdbc which creates readable sql something similar to shown below under Expected? I tried to build SimpleJdbcCall […]

Categories
Development

openmp benchmarking parallel computations

I’m trying to benchmark computing f(x) while varying the number of threads with every iteration. f(x) = c * ln(x) * cos(x) n=10000000 for (int pp = 2; pp<17; pp++) { p = pp; int chunk = n/p; //acts like floor omp_set_num_threads(p); double start_parallel = omp_get_wtime(); //start parallel #pragma omp parallel shared(tt,chunk) private (i) { […]