Skip to content

Commit

Permalink
remove JSONReaderUTF8Vector and remove incubator-vector module
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Jan 19, 2025
1 parent df68b32 commit f55355f
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 549 deletions.
7 changes: 0 additions & 7 deletions benchmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@
<artifactId>fastjson2-extension</artifactId>
<version>${project.version}</version>
</dependency>
<!--
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-incubator-vector</artifactId>
<version>${project.version}</version>
</dependency>
-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public static void jackson() throws Exception {
}

public static void main(String[] args) throws Exception {
// fastjson2();
fastjson2_features();
fastjson2();
// fastjson2_features();
// dsljson();
// jackson();
}
Expand Down
21 changes: 0 additions & 21 deletions core/src/main/java/com/alibaba/fastjson2/JSONFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.function.Supplier;

import static com.alibaba.fastjson2.util.JDKUtils.VECTOR_BIT_LENGTH;

public final class JSONFactory {
public static final class Conf {
static final Properties DEFAULT_PROPERTIES;
Expand Down Expand Up @@ -92,8 +90,6 @@ public static String getProperty(String key) {
static final NameCacheEntry[] NAME_CACHE = new NameCacheEntry[8192];
static final NameCacheEntry2[] NAME_CACHE2 = new NameCacheEntry2[8192];

static final JSONReaderUTF8Creator INCUBATOR_VECTOR_READER_CREATOR_UTF8;

static int defaultDecimalMaxScale = 2048;

interface JSONReaderUTF8Creator {
Expand Down Expand Up @@ -223,23 +219,6 @@ public NameCacheEntry2(String name, long value0, long value1) {
useJacksonAnnotation = getPropertyBool(properties, "fastjson2.useJacksonAnnotation", true);
useGsonAnnotation = getPropertyBool(properties, "fastjson2.useGsonAnnotation", true);
defaultWriterAlphabetic = getPropertyBool(properties, "fastjson2.writer.alphabetic", true);

boolean readerVector = getPropertyBool(properties, "fastjson2.readerVector", false);

JSONReaderUTF8Creator readerCreatorUTF8 = null;
if (JDKUtils.VECTOR_SUPPORT) {
if (VECTOR_BIT_LENGTH >= 64) {
if (readerVector) {
try {
Class<?> factoryClass = Class.forName("com.alibaba.fastjson2.JSONReaderUTF8Vector$Factory");
readerCreatorUTF8 = (JSONReaderUTF8Creator) factoryClass.newInstance();
} catch (Throwable e) {
initErrorLast = e;
}
}
}
}
INCUBATOR_VECTOR_READER_CREATOR_UTF8 = readerCreatorUTF8;
}

private static boolean getPropertyBool(Properties properties, String name, boolean defaultValue) {
Expand Down
43 changes: 7 additions & 36 deletions core/src/main/java/com/alibaba/fastjson2/JSONReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -3257,11 +3257,7 @@ public static JSONReader of(byte[] utf8Bytes) {
return new JSONReaderASCII(context, null, utf8Bytes, 0, utf8Bytes.length);
}

if (INCUBATOR_VECTOR_READER_CREATOR_UTF8 != null) {
return INCUBATOR_VECTOR_READER_CREATOR_UTF8.create(context, null, utf8Bytes, 0, utf8Bytes.length);
} else {
return new JSONReaderUTF8(context, null, utf8Bytes, 0, utf8Bytes.length);
}
return new JSONReaderUTF8(context, null, utf8Bytes, 0, utf8Bytes.length);
}

@Deprecated
Expand All @@ -3275,11 +3271,7 @@ public static JSONReader of(Context context, byte[] utf8Bytes) {
return new JSONReaderASCII(context, null, utf8Bytes, 0, utf8Bytes.length);
}

if (INCUBATOR_VECTOR_READER_CREATOR_UTF8 != null) {
return INCUBATOR_VECTOR_READER_CREATOR_UTF8.create(context, null, utf8Bytes, 0, utf8Bytes.length);
} else {
return new JSONReaderUTF8(context, null, utf8Bytes, 0, utf8Bytes.length);
}
return new JSONReaderUTF8(context, null, utf8Bytes, 0, utf8Bytes.length);
}

public static JSONReader of(byte[] utf8Bytes, Context context) {
Expand All @@ -3292,11 +3284,7 @@ public static JSONReader of(byte[] utf8Bytes, Context context) {
return new JSONReaderASCII(context, null, utf8Bytes, 0, utf8Bytes.length);
}

if (INCUBATOR_VECTOR_READER_CREATOR_UTF8 != null) {
return INCUBATOR_VECTOR_READER_CREATOR_UTF8.create(context, null, utf8Bytes, 0, utf8Bytes.length);
} else {
return new JSONReaderUTF8(context, null, utf8Bytes, 0, utf8Bytes.length);
}
return new JSONReaderUTF8(context, null, utf8Bytes, 0, utf8Bytes.length);
}

public static JSONReader of(char[] chars) {
Expand Down Expand Up @@ -3392,11 +3380,7 @@ public static JSONReader of(byte[] bytes, int offset, int length, Charset charse
Context context = JSONFactory.createReadContext();

if (charset == StandardCharsets.UTF_8) {
if (INCUBATOR_VECTOR_READER_CREATOR_UTF8 != null) {
return INCUBATOR_VECTOR_READER_CREATOR_UTF8.create(context, null, bytes, offset, length);
} else {
return new JSONReaderUTF8(context, null, bytes, offset, length);
}
return new JSONReaderUTF8(context, null, bytes, offset, length);
}

if (charset == StandardCharsets.UTF_16) {
Expand Down Expand Up @@ -3429,11 +3413,7 @@ public static JSONReader of(byte[] bytes, int offset, int length, Charset charse
return new JSONReaderASCII(context, null, bytes, offset, length);
}

if (INCUBATOR_VECTOR_READER_CREATOR_UTF8 != null) {
return INCUBATOR_VECTOR_READER_CREATOR_UTF8.create(context, null, bytes, offset, length);
} else {
return new JSONReaderUTF8(context, null, bytes, offset, length);
}
return new JSONReaderUTF8(context, null, bytes, offset, length);
}

if (charset == StandardCharsets.UTF_16) {
Expand All @@ -3448,20 +3428,11 @@ public static JSONReader of(byte[] bytes, int offset, int length, Charset charse
}

public static JSONReader of(byte[] bytes, int offset, int length) {
Context context = createReadContext();
if (INCUBATOR_VECTOR_READER_CREATOR_UTF8 != null) {
return INCUBATOR_VECTOR_READER_CREATOR_UTF8.create(context, null, bytes, offset, length);
} else {
return new JSONReaderUTF8(context, null, bytes, offset, length);
}
return new JSONReaderUTF8(createReadContext(), null, bytes, offset, length);
}

public static JSONReader of(byte[] bytes, int offset, int length, Context context) {
if (INCUBATOR_VECTOR_READER_CREATOR_UTF8 != null) {
return INCUBATOR_VECTOR_READER_CREATOR_UTF8.create(context, null, bytes, offset, length);
} else {
return new JSONReaderUTF8(context, null, bytes, offset, length);
}
return new JSONReaderUTF8(context, null, bytes, offset, length);
}

public static JSONReader of(char[] chars, int offset, int length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ protected final void readString0() {
}

@Override
public String readString() {
public final String readString() {
if (ch == '"' || ch == '\'') {
final byte[] bytes = this.bytes;
final byte quote = (byte) ch;
Expand Down
Loading

0 comments on commit f55355f

Please sign in to comment.