Skip to content

Commit 836f65b

Browse files
committed
#780 Move the fixed record length record extractor to the method where other record extractors are created.
1 parent d547863 commit 836f65b

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

cobol-parser/src/main/scala/za/co/absa/cobrix/cobol/processor/CobolProcessor.scala

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616

1717
package za.co.absa.cobrix.cobol.processor
1818

19-
import za.co.absa.cobrix.cobol.parser.recordformats.RecordFormat.FixedLength
2019
import za.co.absa.cobrix.cobol.processor.impl.{ArrayOfAnyHandler, StreamProcessor}
2120
import za.co.absa.cobrix.cobol.reader.VarLenNestedReader
22-
import za.co.absa.cobrix.cobol.reader.extractors.raw.{FixedRecordLengthRawRecordExtractor, RawRecordContext, RawRecordExtractor}
21+
import za.co.absa.cobrix.cobol.reader.extractors.raw.RawRecordExtractor
2322
import za.co.absa.cobrix.cobol.reader.parameters.{CobolParametersParser, Parameters, ReaderParameters}
2423
import za.co.absa.cobrix.cobol.reader.schema.CobolSchema
2524
import za.co.absa.cobrix.cobol.reader.stream.SimpleStream
@@ -116,12 +115,6 @@ object CobolProcessor {
116115

117116
reader.recordExtractor(0, dataStream, headerStream) match {
118117
case Some(extractor) => extractor
119-
case None if readerParameters.recordFormat == FixedLength =>
120-
val dataStream = inputStream.copyStream()
121-
val ctx = RawRecordContext.builder(dataStream, getCobolSchema(readerParameters).copybook)
122-
.withReaderParams(readerParameters)
123-
.build()
124-
new FixedRecordLengthRawRecordExtractor(ctx, readerParameters.recordLength)
125118
case None =>
126119
throw new IllegalArgumentException(s"Cannot create a record extractor for the given reader parameters. " +
127120
"Please check the copybook and the reader parameters."

cobol-parser/src/main/scala/za/co/absa/cobrix/cobol/reader/VarLenNestedReader.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ class VarLenNestedReader[T: ClassTag](copybookContents: Seq[String],
8181
!readerProperties.isRecordSequence &&
8282
readerProperties.lengthFieldExpression.isEmpty =>
8383
Some(new VarOccursRecordExtractor(reParams))
84+
case None if readerProperties.recordFormat == FixedLength =>
85+
Some(new FixedRecordLengthRawRecordExtractor(reParams, readerProperties.recordLength))
8486
case None =>
8587
None
8688
}

0 commit comments

Comments
 (0)