Skip to content

Commit

Permalink
Fix new lines and extra spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
luben committed Feb 11, 2023
1 parent a876ea9 commit 73a378f
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public abstract class BaseZstdBufferDecompressingStreamNoFinalizer implements Cl
protected ByteBuffer refill(ByteBuffer toRefill) {
return toRefill;
}

public boolean hasRemaining() {
return !streamEnd && (source.hasRemaining() || !finishedFrame);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/github/luben/zstd/Zstd.java
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ public static long decompressedSize(byte[] src, int srcPosition, int srcSize, bo
public static long decompressedSize(byte[] src, int srcPosition, int srcSize) {
return decompressedSize(src, srcPosition, srcSize, false);
}

/**
* Return the original size of a compressed buffer (if known)
*
Expand Down Expand Up @@ -639,7 +639,7 @@ public static long decompressedSize(byte[] src) {
* 0 if the original size is not known
*/
public static native long decompressedDirectByteBufferSize(ByteBuffer src, int srcPosition, int srcSize, boolean magicless);

/**
* Return the original size of a compressed buffer (if known)
*
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/github/luben/zstd/ZstdCompressCtx.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public ZstdCompressCtx setMagicless(boolean magiclessFlag) {
releaseSharedLock();
return this;
}

/**
* Enable or disable compression checksums
* @param checksumFlag A 32-bits checksum of content is written at end of frame, default: false
Expand Down Expand Up @@ -206,7 +206,7 @@ public ZstdFrameProgression getFrameProgression() {
return getFrameProgression0();
}
private native ZstdFrameProgression getFrameProgression0();

/**
* Clear all state and parameters from the compression context. This leaves the object in a
* state identical to a newly created compression context.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/github/luben/zstd/ZstdDecompressCtx.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public ZstdDecompressCtx setMagicless(boolean magiclessFlag) {
releaseSharedLock();
return this;
}

/**
* Load decompression dictionary
*
Expand Down
130 changes: 65 additions & 65 deletions src/main/java/com/github/luben/zstd/ZstdFrameProgression.java
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
package com.github.luben.zstd;

public class ZstdFrameProgression {
private long ingested;
private long consumed;
private long produced;
private long flushed;
private int currentJobID;
private int nbActiveWorkers;
public ZstdFrameProgression(long ingested, long consumed, long produced, long flushed, int currentJobID,
int nbActiveWorkers) {
this.ingested = ingested;
this.consumed = consumed;
this.produced = produced;
this.flushed = flushed;
this.currentJobID = currentJobID;
this.nbActiveWorkers = nbActiveWorkers;
}

/**
* The number of input bytes read and buffered.
*/
public long getIngested() {
return ingested;
}

/**
* The number of input bytes actually compressed.
* Note: ingested - consumed = amount of input data buffered internally, not yet compressed.
*/
public long getConsumed() {
return consumed;
}

/**
* The number of compressed bytes generated and buffered.
*/
public long getProduced() {
return produced;
}

/**
* The number of compressed bytes flushed.
*/
public long getFlushed() {
return flushed;
}

/**
* The last started job number. Only applicable if multi-threading is enabled.
*/
public int getCurrentJobID() {
return currentJobID;
}

/**
* The number of workers actively compressing. Only applicable if multi-threading is enabled.
*/
public int getNbActiveWorkers() {
return nbActiveWorkers;
}
}
package com.github.luben.zstd;

public class ZstdFrameProgression {

private long ingested;
private long consumed;
private long produced;
private long flushed;
private int currentJobID;
private int nbActiveWorkers;

public ZstdFrameProgression(long ingested, long consumed, long produced, long flushed, int currentJobID,
int nbActiveWorkers) {
this.ingested = ingested;
this.consumed = consumed;
this.produced = produced;
this.flushed = flushed;
this.currentJobID = currentJobID;
this.nbActiveWorkers = nbActiveWorkers;
}

/**
* The number of input bytes read and buffered.
*/
public long getIngested() {
return ingested;
}

/**
* The number of input bytes actually compressed.
* Note: ingested - consumed = amount of input data buffered internally, not yet compressed.
*/
public long getConsumed() {
return consumed;
}

/**
* The number of compressed bytes generated and buffered.
*/
public long getProduced() {
return produced;
}

/**
* The number of compressed bytes flushed.
*/
public long getFlushed() {
return flushed;
}

/**
* The last started job number. Only applicable if multi-threading is enabled.
*/
public int getCurrentJobID() {
return currentJobID;
}

/**
* The number of workers actively compressing. Only applicable if multi-threading is enabled.
*/
public int getNbActiveWorkers() {
return nbActiveWorkers;
}

}
2 changes: 1 addition & 1 deletion src/main/native/jni_fast_zstd.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ JNIEXPORT jobject JNICALL Java_com_github_luben_zstd_ZstdCompressCtx_getFramePro
(JNIEnv *env, jclass jctx) {
ZSTD_CCtx* cctx = (ZSTD_CCtx*)(intptr_t)(*env)->GetLongField(env, jctx, compress_ctx_nativePtr);
ZSTD_frameProgression native_progression = ZSTD_getFrameProgression(cctx);

jclass frame_progression_class = (*env)->FindClass(env, "com/github/luben/zstd/ZstdFrameProgression");
jmethodID frame_progression_constructor = (*env)->GetMethodID(env, frame_progression_class, "<init>", "(JJJJII)V");
return (*env)->NewObject(
Expand Down
10 changes: 5 additions & 5 deletions src/test/scala/Zstd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1099,15 +1099,15 @@ class ZstdSpec extends AnyFlatSpec with ScalaCheckPropertyChecks {
compressedBuffer.limit(compressedBuffer.position() + 1)
cctx.compressDirectByteBufferStream(compressedBuffer, inputBuffer, EndDirective.CONTINUE)
}

var frameProgression = cctx.getFrameProgression()
assert(frameProgression.getIngested() == size)
assert(frameProgression.getFlushed() == compressedBuffer.position())

compressedBuffer.limit(compressedBuffer.capacity())
val done = cctx.compressDirectByteBufferStream(compressedBuffer, inputBuffer, EndDirective.END)
assert(done)

frameProgression = cctx.getFrameProgression()
assert(frameProgression.getConsumed() == size)

Expand All @@ -1131,7 +1131,7 @@ class ZstdSpec extends AnyFlatSpec with ScalaCheckPropertyChecks {
}
}.get
}

"magicless frames" should "be magicless and roundtrip" in {
Using.Manager { use =>
val cctx = use(new ZstdCompressCtx())
Expand All @@ -1144,7 +1144,7 @@ class ZstdSpec extends AnyFlatSpec with ScalaCheckPropertyChecks {
val compressedMagicless = cctx.compress(input)
assert(compressedMagicless.length == (compressedMagic.length - 4))
assert(input.length == Zstd.decompressedSize(compressedMagicless, 0, compressedMagicless.length, true))

dctx.reset()
dctx.setMagicless(true)
val decompressed = dctx.decompress(compressedMagicless, input.length)
Expand Down

0 comments on commit 73a378f

Please sign in to comment.