Skip to content

Commit bf0ff4c

Browse files
authored
Merge pull request #195 from JohnLCaron/removeBtree1
Remove BTree1, H5TiledData1, H5chunkIterator.
2 parents ce7ff5f + c1cde0e commit bf0ff4c

17 files changed

Lines changed: 131 additions & 88 deletions

File tree

cli/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
}
44

55
dependencies {
6-
implementation(project(":core"))
6+
api(project(":core"))
77

88
implementation(libs.lzf)
99
implementation(libs.lz4)
@@ -33,4 +33,4 @@ tasks.register<Jar>("uberJar") {
3333
})
3434
}
3535

36-
project.tasks["compileJava"].dependsOn(":core:allMetadataJar")
36+
// project.tasks["compileJava"].dependsOn(":core:allMetadataJar")

core/src/commonMain/kotlin/com/sunya/cdm/api/Variable.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ data class Variable<T>(
5151
return "$datatype ${fullname()}${shape.contentToString()}"
5252
}
5353

54+
override fun toString(): String {
55+
return "Variable(${nameAndShape()}, group=${group.fullname()}, nelems=$nelems, spObject=$spObject)"
56+
}
57+
5458
@InternalLibraryApi
5559
class Builder<T>(val name : String, val datatype : Datatype<T>) {
5660
val dimensions = mutableListOf<Dimension>()

core/src/commonMain/kotlin/com/sunya/cdm/array/StructureMember.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@file:OptIn(ExperimentalUnsignedTypes::class)
2+
13
package com.sunya.cdm.array
24

35
import com.sunya.cdm.api.Datatype

core/src/commonMain/kotlin/com/sunya/netchdf/hdf4/Hdf4File.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ class Hdf4File(val filename : String) : Netchdf {
4646
}
4747
}
4848

49-
override fun <T> chunkIterator(v2: Variable<T>, section: SectionPartial?, maxElements : Int?): Iterator<ArraySection<T>> {
49+
override fun <T> chunkIterator(v2: Variable<T>, wantSection: SectionPartial?, maxElements : Int?): Iterator<ArraySection<T>> {
5050
if (v2.nelems == 0L) {
5151
return listOf<ArraySection<T>>().iterator()
5252
}
53-
val wantSection = SectionPartial.fill(section, v2.shape)
53+
val section = SectionPartial.fill(wantSection, v2.shape)
5454
val vinfo = v2.spObject as Vinfo
5555

5656
return if (vinfo.isChunked) { // LOOK isLinked?
57-
H4chunkIterator(header, v2, wantSection)
57+
H4chunkIterator(header, v2, section)
5858
} else {
59-
H4maxIterator(v2, wantSection, maxElements ?: 100_000)
59+
H4maxIterator(v2, section, maxElements ?: 100_000)
6060
}
6161
}
6262

core/src/commonMain/kotlin/com/sunya/netchdf/hdf5/BTree1.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import com.sunya.cdm.iosp.OpenFileState
66
import com.sunya.cdm.layout.Tiling
77
import com.sunya.cdm.util.InternalLibraryApi
88

9-
/** B-tree, version 1, used for data (node type 1) */
9+
/** B-tree, version 1, used for data (node type 1)
1010
internal class BTree1(
1111
val h5: H5builder,
1212
val rootNodeAddress: Long,
@@ -130,7 +130,7 @@ internal class BTree1(
130130
", tile= ${tiling.tile(key.offsets).contentToString()} idx=$idx"
131131
}
132132
133-
}
133+
} */
134134

135135

136136
interface DataChunkIF {

core/src/commonMain/kotlin/com/sunya/netchdf/hdf5/BTree1data.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ internal class BTree1data(
118118
override fun chunkSize() = key.chunkSize
119119
override fun filterMask() = key.filterMask
120120

121-
override fun show(tiling : Tiling) : String = "chunkSize=${key.chunkSize}, chunkStart=${offsets().contentToString()}" +
121+
override fun show(tiling : Tiling) : String = "order=$key, chunkSize=${key.chunkSize}, chunkStart=${offsets().contentToString()}" +
122122
", tile= ${tiling.tile(offsets() ).contentToString()}"
123123

124124
fun show() = show(tiling)

core/src/commonMain/kotlin/com/sunya/netchdf/hdf5/BTree2data.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ internal class BTree2data(private val h5: H5builder, owner: String, address: Lon
306306
}
307307
}
308308

309+
// TODO this is probably not handling missing chunks correctly. See BTree1data, which iterates over tiles.
309310
fun chunkIterator() : Iterator<ChunkImpl> = ChunkIterator()
310311

311312
private inner class ChunkIterator : AbstractIterator<ChunkImpl>() {

core/src/commonMain/kotlin/com/sunya/netchdf/hdf5/H5TiledData1.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import com.sunya.cdm.layout.IndexSpace
44
import com.sunya.cdm.layout.IndexND
55
import com.sunya.cdm.layout.Tiling
66

7-
/** wraps BTree1 to handle iterating through tiled data (aka chunked data) */
7+
/** wraps BTree1 to handle iterating through tiled data (aka chunked data)
88
internal class H5TiledData1(val btree : BTree1, val varShape: LongArray, val chunkShape: LongArray) {
99
private val check = true
1010
private val debug = false
@@ -104,4 +104,4 @@ internal class H5TiledData1(val btree : BTree1, val varShape: LongArray, val chu
104104
return "TiledData(chunk=${chunkShape.contentToString()}, readHit=$readHit, readMiss=$readMiss)"
105105
}
106106
107-
}
107+
} */

core/src/commonMain/kotlin/com/sunya/netchdf/hdf5/H5cdmBuilder.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,11 @@ internal class DataContainerVariable(
280280
else -> throw RuntimeException()
281281
}
282282
}
283+
284+
override fun toString(): String {
285+
return "DataContainerVariable(mdl=$mdl, mfp=$mfp, onlyFillValue=$onlyFillValue)"
286+
}
287+
283288
}
284289

285290
internal fun getFillValue(h5 : H5builder, v5 : H5Variable, h5type: H5TypeInfo): ByteArray {

core/src/commonMain/kotlin/com/sunya/netchdf/hdf5/H5chunkIterator.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import com.sunya.cdm.layout.IndexSpace
88
import com.sunya.cdm.layout.transferMissingNelems
99
import com.sunya.cdm.util.InternalLibraryApi
1010

11-
// TODO assumes BTree1, could it include BTree2? any chunked reader ?
12-
// only used in Netchdf.readChunksConcurrent
13-
11+
/* (to be removed)
1412
@OptIn(InternalLibraryApi::class)
1513
internal class H5chunkIterator<T>(val h5 : H5builder, val v2: Variable<T>, val wantSection : Section) : AbstractIterator<ArraySection<T>>() {
1614
private val debugChunking = false
@@ -86,5 +84,5 @@ internal class H5chunkIterator<T>(val h5 : H5builder, val v2: Variable<T>, val w
8684
8785
return ArraySection(array, intersectSpace.section(v2.shape)) // LOOK use space instead of Section ??
8886
}
89-
}
87+
} */
9088

0 commit comments

Comments
 (0)