Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pivotal # 182332696: TSV File List Serialization #571

Merged

Conversation

jhoanmanuelms
Copy link
Contributor

  • Include first list in the TSV file list serialization
  • Add file list assertions to the itests

- Include first list in the TSV file list serialization
- Add file list assertions to the itests
@jhoanmanuelms jhoanmanuelms self-assigned this May 31, 2022
@jhoanmanuelms jhoanmanuelms requested a review from Juan-EBI May 31, 2022 16:36
@@ -15,7 +15,7 @@ import java.io.OutputStream
internal class FileListTsvStreamDeserializer {
fun serializeFileList(files: Sequence<BioFile>, fileList: OutputStream) {
val writer = fileList.bufferedWriter()
writeHeaderNames(files.first(), writer)
processFirstFile(files.first(), writer)
Copy link
Contributor

@Juan-EBI Juan-EBI May 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something does not look correct, if you notice we are writing two times now the attributes values of the first file. Once in line 35 and another in line 19. That probablythe reason unit test are failing.

This does not look correct. Do I am missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the problem was coming from the .first() method taking out the first element from the sequence. Then, when it starts iterating, it'll miss it since it's already processed

- Remove extra line
- Adjust the sequence creation in the unit tests

var idx = -1
val files = object : Sequence<BioFile> {
override fun iterator(): Iterator<BioFile> = object : Iterator<BioFile> {
Copy link
Contributor

@Juan-EBI Juan-EBI Jun 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this way of creating a sequence looks overcomplex to me, why we have change previos approach (create a list and use asSequence)? . You may check https://kotlinlang.org/docs/sequences.html#construct there they mention 4 recomended ways to construct a sequence.

  1. From elements
  2. From iterable (previos appraoch)
  3. From a function
  4. From chunks

All this IMO looks way simpler that new approach.

- Fix ktlint errors
- Simplify sequence creation
Copy link
Contributor

@Juan-EBI Juan-EBI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jhoanmanuelms jhoanmanuelms merged commit abdd6fe into master Jun 1, 2022
@jhoanmanuelms jhoanmanuelms deleted the bugfix/pivotal-182332696-tsv-file-list-serialization branch June 1, 2022 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants