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

15 can you please add support to decompress to zipoutputstream #18

Open
wants to merge 29 commits into
base: release-5.0.1
Choose a base branch
from

Conversation

kiwi1969
Copy link

Added support for gzip output file.
To do this, simple add ".gz" onto end of output file

Signed-off-by: Russell Shaw <[email protected]>
Signed-off-by: Russell Shaw <[email protected]>
Signed-off-by: Russell Shaw <[email protected]>
Signed-off-by: Russell Shaw <[email protected]>
Signed-off-by: Russell Shaw <[email protected]>
Signed-off-by: Russell Shaw <[email protected]>
Signed-off-by: Russell Shaw <[email protected]>
Signed-off-by: Russell Shaw <[email protected]>
Restored try clause.
Increased GZIP buffer size for effciency and for CryptoCards that only get used if buffer > = 8192 bytes
Set GZIP flush option to prevent corruption of file on last write

Signed-off-by: Russell Shaw <[email protected]>
Rebased upon existing 5.0.1 branch

Signed-off-by: Russell Shaw <[email protected]>
Rebased upon existing 5.0.1 branch

Signed-off-by: Russell Shaw <[email protected]>
Rebased change using existing 5.0.1 branch

Signed-off-by: Russell Shaw <[email protected]>
Rebased upon existing 5.0.1 branch

Signed-off-by: Russell Shaw <[email protected]>
Rebased using existing 5.0.1 branch

Signed-off-by: Russell Shaw <[email protected]>
Rebased using existing 5.0.1 branch.
Note this change bumps java to Java 17, and uses Shade to reduce output size

Signed-off-by: Russell Shaw <[email protected]>
trivial indentation  fix

Signed-off-by: Russell Shaw <[email protected]>
Restored maven jar plug-in

Signed-off-by: Russell Shaw <[email protected]>
Signed-off-by: Russell Shaw <[email protected]>
Signed-off-by: Russell Shaw <[email protected]>
@alexgubanow alexgubanow changed the base branch from master to release-5.0.1 March 29, 2024 17:16
.editorconfig Outdated
@@ -0,0 +1,15 @@
# Declares that this is the top-level configuration

Choose a reason for hiding this comment

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

please add .editorconfig to .gitignore too, as it is per developer to setup own

Copy link
Author

Choose a reason for hiding this comment

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

Done

Copy link
Author

Choose a reason for hiding this comment

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

Note this now means that the default tabsize when viewing in github is 8, which was what I was initially trying to correct


if (args.length == 0)
parseArgs(args);
if (args.length == 0 || (inputFileName == null && outputFileName == null) || (outputFileName == null && textMode == false) || isHelpRequested == true)

Choose a reason for hiding this comment

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

CAN BE IGNORED - check for isHelpRequested right after args.length, reasons:

  • faster in case of isHelpRequested
  • simpler to read code, as it first check simple things, later more complicated

Copy link
Author

Choose a reason for hiding this comment

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

Um, this is the other dude's change I merged with. Updated

else if (inputFileName == null) {
inputFileName = args[i];
}
// second non-flag argument is the input file name

Choose a reason for hiding this comment

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

looks like typo, should it be "second non-flag argument is the output file name" ?

Copy link
Author

Choose a reason for hiding this comment

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

I think this is part of the other guy's change I merged with. Updated now

}
else // we have more args than we know what to do with
{
isHelpRequested = true;

Choose a reason for hiding this comment

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

lets call break here, as there is no point to run more this loop

Copy link
Author

Choose a reason for hiding this comment

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

Again, this was the previous dudes change I was asked to merged with. Updated.

@@ -95,18 +103,49 @@ else if (outputFileName == null)
printUsageAndExit();
}

System.out.println("Attempting to decompress input file (" + inputFileName +") to output file (" + outputFileName +")");

Choose a reason for hiding this comment

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

Here is an example how it will be more streamlined:

Suggested change
System.out.println("Attempting to decompress input file (" + inputFileName +") to output file (" + outputFileName +")");
System.out.println("Opening output file (" + outputFileName + ")");
var outputStream = null;
try {
if (outputFileName.endsWith(".gz")) {
outputStream = new GZIPOutputStream(new FileOutputStream(outputFileName), 8192, true);
}
else {
outputStream = new FileOutputStream(outputFileName);
}
}
catch (Exception e) {
System.out.println("Got exception while opening output file (" + outputFileName + ").\nError message:\n" + e.toString());
}
System.out.println("Attempting to decompress input file (" + inputFileName + ") to output file (" + outputFileName + ")");
try (TerseDecompresser outputWriter = TerseDecompresser.create(new FileInputStream(inputFileName), outputStream)) {
outputWriter.TextFlag = textMode;
outputWriter.decode();
}
catch (Exception e) {
System.out.println("Got exception while decompressing input file (" + inputFileName + ").\nError message:\n" + e.toString());
}

Copy link
Author

Choose a reason for hiding this comment

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

Updated

Signed-off-by: Russell Shaw <[email protected]>
Signed-off-by: Russell Shaw <[email protected]>
Signed-off-by: Russell Shaw <[email protected]>
Signed-off-by: Russell Shaw <[email protected]>
Simplied, and actually still works

Signed-off-by: Russell Shaw <[email protected]>
Signed-off-by: Russell Shaw <[email protected]>
Improved outfilename suffix defaults

Signed-off-by: Russell Shaw <[email protected]>
@alexgubanow
Copy link

Hello @kiwi1969 , code looks good now.

  1. Have you ran tests? any regression?
  2. .editorconfig file still shown in PR, while you should avoid that by doing git rm, more here https://stackoverflow.com/a/53431148/6672985

@kiwi1969
Copy link
Author

FYI - using this code I was successfully able to Unterse a binary SMF110.trs file into a .gz file which is approx half the size.
The .gz file was readable by my java program that unloads SMF110 into MOLS format and JSON.

As requested

Signed-off-by: Russell Shaw <[email protected]>
updated version string and date

Signed-off-by: Russell Shaw <[email protected]>
Fix -b detection

Signed-off-by: Russell Shaw <[email protected]>
@kiwi1969 kiwi1969 requested a review from alexgubanow May 28, 2024 14:54
Copy link

@alexgubanow alexgubanow left a comment

Choose a reason for hiding this comment

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

Hello @kiwi1969 , as i mentioned before, code looks good, but the branch has conflicts:
Conflicting files
.gitignore
pom.xml
src/main/java/org/openmainframeproject/tersedecompress/TerseDecompress.java

@kiwi1969
Copy link
Author

FYI - as I do not have write access to repo, I cannot merge pull requests to resolve conflicts

@alexgubanow
Copy link

there is no need of write access to repo to resolve a merge conflict, you shall rebase your changes on top of target branch.

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.

None yet

2 participants