Skip to content

Commit fdae108

Browse files
committed
remove unneeded stuff
1 parent 90b5a0f commit fdae108

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

Swift/OmFileFormat/OmFileWriter.swift

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,6 @@ public final class OmFileWriterArray<OmType: OmFileArrayDataTypeProtocol, FileHa
208208
self.scale_factor = scale_factor
209209
self.add_offset = add_offset
210210

211-
if OmType.dataTypeArray == .string_array {
212-
// string arrays need to have chunk dimensions of 1
213-
if !chunkDimensions.allSatisfy({ $0 == 1 }) {
214-
throw OmFileFormatSwiftError.omEncoder(error: "String arrays need to have chunk dimensions of 1")
215-
}
216-
}
217-
218211
// Note: The encoder keeps the pointer to `&self.dimensions`. It is important that this array is not deallocated!
219212
self.encoder = OmEncoder_t()
220213
let error = om_encoder_init(&encoder, scale_factor, add_offset, compression.toC(), OmType.dataTypeArray.toC(), &self.dimensions, &self.chunks, UInt64(dimensions.count))
@@ -428,12 +421,12 @@ public final class OmFileWriterStringArray<FileHandle: OmFileWriterBackend> {
428421
buffer.incrementWritePosition(by: lutSize)
429422

430423
return OmFileWriterArrayFinalised(
431-
scale_factor: 0, // these are fake entries we don't really need, but wasting 4 bytes is fine
432-
add_offset: 0, // these are fake entries we don't really need, but wasting 4 bytes is fine
424+
scale_factor: 0, // these are fake entries we don't need, will not be written to the file for string arrays
425+
add_offset: 0, // these are fake entries we don't need, will not be written to the file for string arrays
433426
compression: .none,
434427
datatype: .string_array,
435428
dimensions: dimensions,
436-
chunks: dimensions.map { _ in 1 }, // one string per chunk
429+
chunks: [], // this is a fake entry we don't need, will not be written to the file for string arrays
437430
lutSize: UInt64(lutSize),
438431
lutOffset: UInt64(lutOffset)
439432
)

c/src/om_common.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ uint8_t om_get_bytes_per_element(OmDataType_t data_type, OmError_t* error) {
6363
return 8;
6464

6565
case DATA_TYPE_STRING_ARRAY:
66-
return 0; // strings are variable length
67-
break;
66+
// NOTE: Strings are variable length and should not be used with this function!
67+
*error = ERROR_INVALID_DATA_TYPE;
68+
return 0;
6869

6970
case DATA_TYPE_INT8:
7071
case DATA_TYPE_UINT8:

0 commit comments

Comments
 (0)