This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fury.git
The following commit(s) were added to refs/heads/main by this push:
new 7b6e9ed5 chore(java): rename copyTrackingRef to copyRef (#1748)
7b6e9ed5 is described below
commit 7b6e9ed5b5472f37bfcaf92ac517ade81c6d7a82
Author: Shawn Yang <[email protected]>
AuthorDate: Wed Jul 24 20:20:43 2024 +0800
chore(java): rename copyTrackingRef to copyRef (#1748)
## What does this PR do?
rename copyTrackingRef to copyRef
## Related issues
#1679
#1747
## Does this PR introduce any user-facing change?
<!--
If any user-facing interface changes, please [open an
issue](https://github.com/apache/fury/issues/new/choose) describing the
need to do so and update the document if necessary.
-->
- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
## Benchmark
<!--
When the PR has an impact on performance (if you don't know whether the
PR will have an impact on performance, you can submit the PR first, and
if it will have impact on performance, the code reviewer will explain
it), be sure to attach a benchmark data here.
-->
---
.../src/main/java/org/apache/fury/Fury.java | 2 +-
.../src/main/java/org/apache/fury/config/Config.java | 20 ++++++++++++++------
.../java/org/apache/fury/config/FuryBuilder.java | 15 +++++++++++----
.../src/test/java/org/apache/fury/FuryCopyTest.java | 6 +++---
4 files changed, 29 insertions(+), 14 deletions(-)
diff --git a/java/fury-core/src/main/java/org/apache/fury/Fury.java
b/java/fury-core/src/main/java/org/apache/fury/Fury.java
index 9f3e84e1..bb2aa87e 100644
--- a/java/fury-core/src/main/java/org/apache/fury/Fury.java
+++ b/java/fury-core/src/main/java/org/apache/fury/Fury.java
@@ -134,7 +134,7 @@ public final class Fury implements BaseFury {
config = new Config(builder);
this.language = config.getLanguage();
this.refTracking = config.trackingRef();
- this.copyRefTracking = config.copyTrackingRef();
+ this.copyRefTracking = config.copyRef();
this.shareMeta = config.isMetaShareEnabled();
compressInt = config.compressInt();
longEncoding = config.longEncoding();
diff --git a/java/fury-core/src/main/java/org/apache/fury/config/Config.java
b/java/fury-core/src/main/java/org/apache/fury/config/Config.java
index e783044f..fad9d395 100644
--- a/java/fury-core/src/main/java/org/apache/fury/config/Config.java
+++ b/java/fury-core/src/main/java/org/apache/fury/config/Config.java
@@ -38,7 +38,7 @@ public class Config implements Serializable {
private final boolean basicTypesRefIgnored;
private final boolean stringRefIgnored;
private final boolean timeRefIgnored;
- private final boolean copyTrackingRef;
+ private final boolean copyRef;
private final boolean codeGenEnabled;
private final boolean checkClassVersion;
private final CompatibleMode compatibleMode;
@@ -66,7 +66,7 @@ public class Config implements Serializable {
basicTypesRefIgnored = !trackingRef || builder.basicTypesRefIgnored;
stringRefIgnored = !trackingRef || builder.stringRefIgnored;
timeRefIgnored = !trackingRef || builder.timeRefIgnored;
- copyTrackingRef = builder.copyTrackingRef;
+ copyRef = builder.copyRef;
compressString = builder.compressString;
compressInt = builder.compressInt;
longEncoding = builder.longEncoding;
@@ -101,8 +101,16 @@ public class Config implements Serializable {
return trackingRef;
}
- public boolean copyTrackingRef() {
- return copyTrackingRef;
+ /**
+ * Returns true if copy value by ref, and false copy by value.
+ *
+ * <p>If this option is false, shared reference will be copied into
different object, and circular
+ * reference copy will raise stack overflow exception.
+ *
+ * <p>If this option is enabled, the copy performance will be slower.
+ */
+ public boolean copyRef() {
+ return copyRef;
}
public boolean isBasicTypesRefIgnored() {
@@ -253,7 +261,7 @@ public class Config implements Serializable {
&& basicTypesRefIgnored == config.basicTypesRefIgnored
&& stringRefIgnored == config.stringRefIgnored
&& timeRefIgnored == config.timeRefIgnored
- && copyTrackingRef == config.copyTrackingRef
+ && copyRef == config.copyRef
&& codeGenEnabled == config.codeGenEnabled
&& checkClassVersion == config.checkClassVersion
&& checkJdkClassSerializable == config.checkJdkClassSerializable
@@ -283,7 +291,7 @@ public class Config implements Serializable {
basicTypesRefIgnored,
stringRefIgnored,
timeRefIgnored,
- copyTrackingRef,
+ copyRef,
codeGenEnabled,
checkClassVersion,
compatibleMode,
diff --git
a/java/fury-core/src/main/java/org/apache/fury/config/FuryBuilder.java
b/java/fury-core/src/main/java/org/apache/fury/config/FuryBuilder.java
index 2080dca6..4d5c9686 100644
--- a/java/fury-core/src/main/java/org/apache/fury/config/FuryBuilder.java
+++ b/java/fury-core/src/main/java/org/apache/fury/config/FuryBuilder.java
@@ -59,7 +59,7 @@ public final class FuryBuilder {
boolean checkClassVersion = false;
Language language = Language.JAVA;
boolean trackingRef = false;
- boolean copyTrackingRef = false;
+ boolean copyRef = false;
boolean basicTypesRefIgnored = true;
boolean stringRefIgnored = true;
boolean timeRefIgnored = true;
@@ -99,9 +99,16 @@ public final class FuryBuilder {
return this;
}
- /** Whether track {@link Fury#copy(Object)} circular references. */
- public FuryBuilder withCopyRefTracking(boolean copyTrackingRef) {
- this.copyTrackingRef = copyTrackingRef;
+ /**
+ * Whether track {@link Fury#copy(Object)} shared or circular references.
+ *
+ * <p>If this option is false, shared reference will be copied into
different object, and circular
+ * reference copy will raise stack overflow exception.
+ *
+ * <p>If this option is enabled, the copy performance will be slower.
+ */
+ public FuryBuilder withRefCopy(boolean copyRef) {
+ this.copyRef = copyRef;
return this;
}
diff --git a/java/fury-core/src/test/java/org/apache/fury/FuryCopyTest.java
b/java/fury-core/src/test/java/org/apache/fury/FuryCopyTest.java
index b86fe07a..213e82e9 100644
--- a/java/fury-core/src/test/java/org/apache/fury/FuryCopyTest.java
+++ b/java/fury-core/src/test/java/org/apache/fury/FuryCopyTest.java
@@ -86,7 +86,7 @@ import org.testng.annotations.Test;
public class FuryCopyTest extends FuryTestBase {
- private final Fury fury =
builder().withCopyRefTracking(true).withCodegen(false).build();
+ private final Fury fury =
builder().withRefCopy(true).withCodegen(false).build();
@Test
public void immutableObjectCopyTest() {
@@ -131,7 +131,7 @@ public class FuryCopyTest extends FuryTestBase {
ExecutorService executor = Executors.newSingleThreadExecutor();
AtomicReference<Throwable> ex = new AtomicReference<>();
ThreadLocalFury threadLocalFury =
-
builder().withCodegen(false).withCopyRefTracking(true).buildThreadLocalFury();
+ builder().withCodegen(false).withRefCopy(true).buildThreadLocalFury();
threadLocalFury.register(BeanA.class);
assetEqualsButNotSame(threadLocalFury.copy(beanA));
executor.execute(
@@ -151,7 +151,7 @@ public class FuryCopyTest extends FuryTestBase {
AtomicBoolean flag = new AtomicBoolean(false);
ThreadSafeFury threadSafeFury =
builder()
- .withCopyRefTracking(true)
+ .withRefCopy(true)
.withCodegen(false)
.withAsyncCompilation(true)
.buildThreadSafeFuryPool(5, 10);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]