forked from RoaringBitmap/RoaringBitmap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release 1.0.1.0 & Add RoaringBitmapX
- Loading branch information
Showing
25 changed files
with
2,340 additions
and
26 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# RoaringBitmapX | ||
|
||
## RBM | ||
|
||
## BBM | ||
|
||
## CBM |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
val deps: Map<String, String> by extra | ||
|
||
plugins { | ||
id("org.jetbrains.kotlin.jvm") version "1.9.10" | ||
`java-library` | ||
} | ||
|
||
tasks.withType<Test>().configureEach { | ||
useJUnitPlatform() | ||
} | ||
|
||
dependencies { | ||
implementation(project(":RoaringBitmap")) | ||
|
||
testImplementation("org.junit.jupiter:junit-jupiter-api:${deps["jupiter"]}") | ||
testImplementation("org.junit.jupiter:junit-jupiter-params:${deps["jupiter"]}") | ||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${deps["jupiter"]}") | ||
testImplementation("io.kotest:kotest-runner-junit5:5.7.2") | ||
} |
60 changes: 60 additions & 0 deletions
60
RoaringBitmapX/src/main/kotlin/org/bitlap/roaringbitmap/x/@.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2020-2023 IceMimosa, jxnu-liguobin and the Bitlap Contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.bitlap.roaringbitmap.x | ||
|
||
import java.time.Duration | ||
|
||
/** | ||
* Do [func] when [flag] is true, | ||
* if flag is false, return [t] only | ||
*/ | ||
fun <T> doIf(flag: Boolean, t: T, func: (T) -> T): T { | ||
if (flag) { | ||
return func.invoke(t) | ||
} | ||
return t | ||
} | ||
|
||
/** | ||
* see [kotlin.system.measureTimeMillis] and [kotlin.time.measureTimedValue] | ||
*/ | ||
fun <T> elapsed(block: () -> T): Pair<T, Duration> { | ||
val start = System.currentTimeMillis() | ||
return block() to Duration.ofMillis(System.currentTimeMillis() - start) | ||
} | ||
|
||
/** | ||
* like sql nvl | ||
*/ | ||
fun <T> nvl(t: T?, default: T?): T? { | ||
return t ?: default | ||
} | ||
|
||
/** | ||
* like sql coalesce | ||
*/ | ||
fun <T> coalesce(vararg t: T?): T? { | ||
return t.find { it != null } | ||
} | ||
|
||
/** | ||
* check [expr] cannot be false | ||
*/ | ||
fun checkExpression(expr: Boolean, key: String = "expr", msg: String = "$key cannot be false") { | ||
if (!expr) { | ||
throw IllegalArgumentException(msg) | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
RoaringBitmapX/src/main/kotlin/org/bitlap/roaringbitmap/x/AbsBM.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2020-2023 IceMimosa, jxnu-liguobin and the Bitlap Contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.bitlap.roaringbitmap.x | ||
|
||
import java.io.ObjectInput | ||
import java.io.ObjectOutput | ||
|
||
/** | ||
* Abstract of [BM] | ||
*/ | ||
abstract class AbsBM : BM { | ||
|
||
@Volatile | ||
@Transient | ||
protected var modified: Boolean = true | ||
protected fun <T> resetModify(func: () -> T): T { | ||
modified = true | ||
return func.invoke() | ||
} | ||
|
||
override fun writeExternal(out: ObjectOutput) { | ||
out.write(this.getBytes()) | ||
} | ||
|
||
override fun readExternal(`in`: ObjectInput) { | ||
val bytes = ByteArray(`in`.available()) | ||
`in`.readFully(bytes) | ||
this.setBytes(bytes) | ||
} | ||
} |
Oops, something went wrong.