mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Use ISO_8859_1 instead of the default Charset Bytes#8
It should matter but it makes it clearer.
This commit is contained in:
@@ -41,6 +41,7 @@ import java.util.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.ISO_8859_1;
|
||||
import static java.util.Arrays.asList;
|
||||
import static net.openhft.chronicle.map.StatelessClientTest.localClient;
|
||||
import static net.openhft.chronicle.map.fromdocs.OpenJDKAndHashMapExamplesTest.parseYYYYMMDD;
|
||||
@@ -447,12 +448,12 @@ public class CHMUseCasesTest {
|
||||
.of(byte[].class, byte[][].class);
|
||||
|
||||
try (ChronicleMap<byte[], byte[][]> map = newInstance(builder)) {
|
||||
byte[] bytes1 = "value1".getBytes();
|
||||
byte[] bytes2 = "value2".getBytes();
|
||||
byte[] bytes1 = "value1".getBytes(ISO_8859_1);
|
||||
byte[] bytes2 = "value2".getBytes(ISO_8859_1);
|
||||
byte[][] value = {bytes1, bytes2};
|
||||
map.put("Key".getBytes(), value);
|
||||
map.put("Key".getBytes(ISO_8859_1), value);
|
||||
|
||||
assertEquals(value, map.get("Key".getBytes()));
|
||||
assertEquals(value, map.get("Key".getBytes(ISO_8859_1)));
|
||||
mapChecks();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.ISO_8859_1;
|
||||
import static net.openhft.chronicle.map.Alignment.*;
|
||||
import static net.openhft.chronicle.map.StatelessClientTest.localClient;
|
||||
import static org.junit.Assert.*;
|
||||
@@ -192,9 +193,9 @@ public class ChronicleMapTest {
|
||||
try (ChronicleMap<byte[], byte[]> map = ChronicleMapBuilder.of(byte[].class, byte[]
|
||||
.class).createPersistedTo(persistenceFile)) {
|
||||
|
||||
byte[] o = map.get("hello".getBytes());
|
||||
byte[] o = map.get("hello".getBytes(ISO_8859_1));
|
||||
System.out.println(o == null ? "null" : new String(o));
|
||||
map.put("hello".getBytes(), "world".getBytes());
|
||||
map.put("hello".getBytes(ISO_8859_1), "world".getBytes(ISO_8859_1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1800,10 +1801,10 @@ public class ChronicleMapTest {
|
||||
try (ChronicleMap<byte[], byte[][]> map2 = localClient(8877)) {
|
||||
|
||||
byte[] key = new byte[14];
|
||||
System.arraycopy("A".getBytes(), 0, key, 0, "A".length());
|
||||
System.arraycopy("A".getBytes(ISO_8859_1), 0, key, 0, "A".length());
|
||||
byte[][] value = {new byte[11], new byte[11]};
|
||||
System.arraycopy("A".getBytes(), 0, value[0], 0, "A".length());
|
||||
System.arraycopy("A".getBytes(), 0, value[1], 0, "A".length());
|
||||
System.arraycopy("A".getBytes(ISO_8859_1), 0, value[0], 0, "A".length());
|
||||
System.arraycopy("A".getBytes(ISO_8859_1), 0, value[1], 0, "A".length());
|
||||
|
||||
map2.put(key, value);
|
||||
Assert.assertNotNull(map2.get(key));
|
||||
|
||||
@@ -20,6 +20,8 @@ import com.google.common.hash.HashFunction;
|
||||
import com.google.common.hash.Hashing;
|
||||
import net.openhft.chronicle.hash.hashing.Hasher;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.ISO_8859_1;
|
||||
|
||||
public class HasherTest {
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -27,8 +29,8 @@ public class HasherTest {
|
||||
for (int i=0;i<10;i++)
|
||||
{
|
||||
String key = "010758403"+String.format("%06d",i)+"S-INJFIX_SLE";
|
||||
long hashCode = Hasher.hash(key.getBytes());
|
||||
long guavaHashCode = hashFunction.hashBytes(key.getBytes()).asLong();
|
||||
long hashCode = Hasher.hash(key.getBytes(ISO_8859_1));
|
||||
long guavaHashCode = hashFunction.hashBytes(key.getBytes(ISO_8859_1)).asLong();
|
||||
System.out.println("<"+key+"> => "+hashCode+" "+guavaHashCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
import static net.openhft.chronicle.map.ChronicleMapStatelessClientBuilder.*;
|
||||
import static java.nio.charset.StandardCharsets.ISO_8859_1;
|
||||
import static net.openhft.chronicle.map.ChronicleMapStatelessClientBuilder.createClientOf;
|
||||
|
||||
public class StatelessClientDuplicateKeyTest {
|
||||
|
||||
@@ -78,8 +79,8 @@ public class StatelessClientDuplicateKeyTest {
|
||||
byte[] _42 = {42};
|
||||
map.put(_42, new byte[] {1, 2, 3});
|
||||
map.put(new byte[]{1, 2, 3}, _42);
|
||||
byte[] longKey = "fooBarFooBarFooBarFooBar".getBytes();
|
||||
map.put(longKey, "bar".getBytes());
|
||||
byte[] longKey = "fooBarFooBarFooBarFooBar".getBytes(ISO_8859_1);
|
||||
map.put(longKey, "bar".getBytes(ISO_8859_1));
|
||||
|
||||
final ChronicleMap<byte[], byte[]> client =
|
||||
createClientOf(new InetSocketAddress("localhost", 8081));
|
||||
|
||||
@@ -34,6 +34,7 @@ import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.ISO_8859_1;
|
||||
import static net.openhft.chronicle.map.ChronicleMapStatelessClientBuilder.createClientOf;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -756,7 +757,7 @@ public class StatelessClientTest {
|
||||
try (ChronicleMap<byte[], CharSequence> map2 = localClient(8875)) {
|
||||
|
||||
byte[] key = new byte[14];
|
||||
System.arraycopy("A".getBytes(), 0, key, 0, "A".length());
|
||||
System.arraycopy("A".getBytes(ISO_8859_1), 0, key, 0, "A".length());
|
||||
|
||||
map2.put(key, "hello world");
|
||||
Assert.assertNotNull(map2.get(key));
|
||||
|
||||
Reference in New Issue
Block a user