October 22, 2024
Chicago 12, Melborne City, USA
java

Algorithm for partitioning an array into subsets with target sums

Example: input = [2, 3, 3, 4, 5] sumTargets = [8, 6, 3] I want an algorithm to partition the input into subsets whose elements sum to the targets, in this case 8, 6 and 3. Both input and sumTargets can be of any size and it only needs to return one possible set of

Read More
java

Error connecting to Athena Database from Metabase

I previously used two VPCs. One had an MSK cluster and an msk-athena connector, and the second was used to run Metabase on ECS. I was able to set up an Athena database in Metabase, which connected to Athena to query my MSK Kafka topic. However, when I changed my setup and used a single

Read More
java

Databricks JDBC Insert into Array field

I am trying to insert some data into a databricks table which has Array fields (field1 & field2). I am using JDBC for the connection and my POJO class looks like this public class A{ private Long id; private String[] field1; private String[] field2; } I am using jdbcTemplate.batchUpdate(String sql, final List<Object[]> batchArgs, final int[]

Read More
java

Missed signal in a Java

Can this code ever lead to missed signal? If yes, then how? private Object lock = new Object(); private boolean conditionMet = false; public void waitForCondition() throws InterruptedException { synchronized (lock) { while (!conditionMet) { lock.wait(); } // Proceed when condition is met } } public void signalCondition() { synchronized (lock) { conditionMet = true;

Read More