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
create temporary table coding_interview_cash_flows( | |
flow_date DATE NOT NULL, | |
account VARCHAR (50) NOT NULL, | |
net_value NUMERIC (10, 2) NOT NULL | |
); | |
truncate table coding_interview_cash_flows; | |
insert into coding_interview_cash_flows VALUES('2021-11-23', 'COMP1_USD', -8000.00); | |
insert into coding_interview_cash_flows VALUES('2021-11-23', 'COMP2_USD', 5000); | |
insert into coding_interview_cash_flows VALUES('2021-11-24', 'COMP1_EUR', -13000); | |
insert into coding_interview_cash_flows VALUES('2021-11-25', 'COMP1_USD', 500000); |
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
private[evaluator] object NonEmptyRangesCounter { | |
def count(source: ImmutableRoaringBitmap, ranges: ImmutableRoaringBitmap): Int = { | |
val rangesIter = ranges.getIntIterator | |
val sourceIter = source.getIntIterator | |
var distinct = 0 | |
var continue = rangesIter.hasNext | |
while (continue) { |
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
class NonEmptyRangesCounterSpec extends AnyFlatSpec with Matchers { | |
it should "count map-distinct in generated test cases" in { | |
import NonEmptyRangesCounterSpec.generateTest | |
val totalRanges = 100000 | |
val totalPartitions = 14 | |
val maxPositionsPerRange = 20 | |
val numberOfTests = 10 | |
Random.setSeed(123456) | |
(0 until numberOfTests).foreach { _ => |
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
object NonEmptyRangesCounter { | |
def count(source: ImmutableRoaringBitmap, ranges: ImmutableRoaringBitmap, partitionsEnds: Seq[Long]): Seq[Int] = { | |
val rangesIter = ranges.getIntIterator | |
val sourceIter = source.getIntIterator | |
var partIdx = 0 | |
val results = Array.ofDim[Int](partitionsEnds.length) | |
var distinct = 0 | |
var continue = rangesIter.hasNext |
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
echo "FROM openjdk:14-alpine\nRUN echo \${JAVA_HOME}" > Dockerfile | |
docker build --tag my-java:latest . # No cache, Successfully built c60c9be06bcb | |
docker build --tag my-java:latest . # Fully cached, Successfully built c60c9be06bcb | |
docker rmi my-java:latest | |
docker build --tag my-java:latest . # Totally new image, Successfully built 514662e21b60 | |
docker build --no-cache --tag my-java:latest . # no-cache flag, Successfully built 364da4d3ef39 |
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
image='dckr.myrepo.com/my-org/my-app' | |
stage0=$image':stage0' | |
latest=$image':latest' | |
# Pull to bring docker images to the docker cache. | |
docker pull $stage0 || true # ||true saves from failure when image has never been published | |
docker pull $latest || true | |
# This generates Dockerfile and artifacts | |
sbt docker:stage | |
docker build \ |
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
dockerUpdateLatest := true, | |
dockerAutoremoveMultiStageIntermediateImages := false, | |
dockerBuildOptions := dockerBuildOptions.value ++ Seq( | |
"--cache-from", | |
dockerAlias.value.withTag(Some("stage0")).toString, | |
"--cache-from", | |
dockerAlias.value.withTag(Some("latest")).toString) |
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
# export DOCKER_BUILDKIT=1 | |
dockerUpdateLatest := true, | |
dockerBuildOptions := dockerBuildOptions.value ++ Seq( | |
"--progress=plain", | |
"--cache-from", | |
dockerAlias.value.withTag(Some("latest")).toString, | |
"--build-arg", | |
"BUILDKIT_INLINE_CACHE=1"), | |
dockerAutoremoveMultiStageIntermediateImages := false //breaks with Buildkit |
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
dockerLayerGrouping := { | |
val dockerBaseDirectory = (defaultLinuxInstallLocation in Docker).value | |
(path: String) => | |
{ | |
val pathInWorkdir = path.stripPrefix(dockerBaseDirectory) | |
if (pathInWorkdir.startsWith(s"/lib/${organization.value}")) | |
Some(2) | |
else if (pathInWorkdir.startsWith("/lib/")) | |
Some(1) | |
else if (pathInWorkdir.startsWith("/bin/")) |
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
FROM docker.artifactory.mycompany.com/theteam/openjre:11.0.5-0-e58ca54 as stage0 | |
LABEL snp-multi-stage="intermediate" | |
LABEL snp-multi-stage-id="8c5dc02e-39e8-42ce-9edd-2b2c153f4555" | |
WORKDIR /opt/my-project | |
COPY opt /opt | |
COPY 1/opt /1/opt | |
COPY 2/opt /2/opt | |
USER root | |
RUN ["chmod", "-R", "u=rX,g=rX", "/1/opt/my-project"] |
NewerOlder