-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Java] Add SLI(small long as int) long encoding algorithm (#942)
* design and implement SLI long encoding * add long encoding option * add long encoding config * refine testWriteSliLong * add long encoding config * using SLI encoding for fury jit/interpreter mode serialization * fix tests
- Loading branch information
1 parent
7ee2bd9
commit 96ee19f
Showing
17 changed files
with
319 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
java/fury-core/src/main/java/io/fury/config/LongEncoding.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2023 The Fury Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.fury.config; | ||
|
||
/** | ||
* Encoding option for long. Default encoding is fury SLI(Small long as int) encoding: {@link #SLI}. | ||
* | ||
* @author chaokunyang | ||
*/ | ||
public enum LongEncoding { | ||
/** | ||
* Fury SLI(Small long as int) Encoding: | ||
* <li>If long is in [0xc0000000, 0x3fffffff], encode as 4 bytes int: `| little-endian: ((int) | ||
* value) << 1 |` | ||
* <li>Otherwise write as 9 bytes: `| 0b1 | little-endian 8bytes long |`. | ||
* | ||
* <p>Faster than {@link #PVL}, but compression is not good as {@link #PVL} such as for ints | ||
* in short range. | ||
*/ | ||
SLI, | ||
/** | ||
* Fury Progressive Variable-length Long Encoding: | ||
* <li>positive long format: first bit in every byte indicate whether has next byte, then next | ||
* byte should be read util first bit is unset. | ||
* <li>Negative number will be converted to positive number by ` (v << 1) ^ (v >> 63)` to reduce | ||
* cost of small negative numbers. | ||
*/ | ||
PVL, | ||
/** Write long as little endian 8bytes, no compression. */ | ||
LE_RAW_BYTES, | ||
} |
Oops, something went wrong.