Merge remote-tracking branch 'origin/master'

Conflicts:
	src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java
	src/test/java/eg/BGChronicleTest.java
This commit is contained in:
Peter Lawrey
2014-12-06 00:06:51 +02:00
13 changed files with 1821 additions and 254 deletions
@@ -0,0 +1,45 @@
package eg;
import net.openhft.lang.model.constraints.MaxSize;
/**
* Created by Vanitha on 12/5/2014.
*/
public interface TestIntrumentVOInterface {
public int getSizeOfInstrumentIDArray();
public void setSizeOfInstrumentIDArray(int sizeOfInstrumentIDArray);
public String getSymbol();
public void setSymbol(@MaxSize(20) String symbol);
public String getCurrencyCode();
public void setCurrencyCode(@MaxSize(4) String currencyCode);
public void setInstrumentIDAt(@MaxSize(2) int location, TestInstrumentIDVOInterface instrumentID);
public TestInstrumentIDVOInterface getInstrumentIDAt(int location);
interface TestInstrumentIDVOInterface {
public String getIdSource();
public void setIdSource(@MaxSize(6) String idSource);
public String getSecurityId();
public void setSecurityId(@MaxSize(100) String securityId);
}
}
@@ -0,0 +1,110 @@
package eg;
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import net.openhft.chronicle.map.ChronicleMap;
import net.openhft.chronicle.map.ChronicleMapBuilder;
import net.openhft.lang.model.DataValueClasses;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import java.net.InetSocketAddress;
import java.util.concurrent.TimeUnit;
/**
* Created by Vanitha on 12/5/2014.
*/
public class TestNesterInterfaceMarshal {
/**
* Test that both maps are created first and then populated the first map so that second will get the contents
* @throws Exception
*/
@Test
public void testReplicatedMap() throws Exception {
ChronicleMap<CharSequence,TestIntrumentVOInterface> map =createReplicatedMap1();
ChronicleMap<CharSequence,TestIntrumentVOInterface> replicatedMap=createReplicatedMap2();
//Store some data into MAP1
TestIntrumentVOInterface intrumentVOInterface= DataValueClasses.newDirectInstance(TestIntrumentVOInterface.class);
intrumentVOInterface.setSymbol("FIXFlyer");
intrumentVOInterface.setCurrencyCode("USA");
intrumentVOInterface.setSizeOfInstrumentIDArray(2);
TestIntrumentVOInterface.TestInstrumentIDVOInterface instrumentIDVOInterface= intrumentVOInterface.getInstrumentIDAt(0);
instrumentIDVOInterface.setIdSource("CUSIP");
instrumentIDVOInterface.setSecurityId("TEST");
intrumentVOInterface.setInstrumentIDAt(0,instrumentIDVOInterface);
map.put("KEY1",intrumentVOInterface);
Assert.assertNotNull(map);
Assert.assertNotNull(replicatedMap);
int t = 0;
for (; t < 5000; t++) {
if (map.equals(replicatedMap))
break;
Thread.sleep(1);
}
Assert.assertEquals(map, replicatedMap);
Assert.assertTrue(!replicatedMap.isEmpty());
System.out.println(map.get("KEY1"));
System.out.println(replicatedMap.get("KEY1"));
map.close();
replicatedMap.close();
}
protected ChronicleMap createReplicatedMap1() {
ChronicleMap chronicleMap = null;
TcpTransportAndNetworkConfig tcpTransportAndNetworkConfig=TcpTransportAndNetworkConfig.of(8076).heartBeatInterval(1L, TimeUnit.SECONDS);
try {
ChronicleMapBuilder builder = ChronicleMapBuilder.of(CharSequence.class, TestIntrumentVOInterface.class)
.entries(5000L).entrySize(2000)
.replication((byte) 1, tcpTransportAndNetworkConfig);
chronicleMap = builder.create();
} catch (Exception e) {
System.out.println("Error(s) creating instrument cache: " + e);
}
return chronicleMap;
}
protected ChronicleMap createReplicatedMap2() {
ChronicleMap chronicleMap = null;
TcpTransportAndNetworkConfig tcpTransportAndNetworkConfig=TcpTransportAndNetworkConfig.of(8077,new InetSocketAddress("127.0.0.1",8076)).heartBeatInterval(1L, TimeUnit.SECONDS);
try {
ChronicleMapBuilder builder = ChronicleMapBuilder.of(CharSequence.class, TestIntrumentVOInterface.class)
.putReturnsNull(true)
.removeReturnsNull(true)
.entries(5000L).entrySize(2000)
.replication((byte)2,tcpTransportAndNetworkConfig) ;
chronicleMap = builder.create();
} catch (Exception e) {
System.out.println("*********************Error(s) creating launcher instrument cache: " + e);
}
return chronicleMap;
}
}
@@ -0,0 +1,56 @@
/*
* Copyright 2014 Higher Frequency Trading http://www.higherfrequencytrading.com
*
* 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 net.openhft.chronicle.map;
import net.openhft.lang.model.Byteable;
import net.openhft.lang.model.DataValueClasses;
import net.openhft.lang.values.IntValue;
import net.openhft.lang.values.LongValue;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class DataKeyValueTest {
@Test
public void dataKeyValueTest() {
ChronicleMap<IntValue, LongValue> map =
OnHeapUpdatableChronicleMapBuilder.of(IntValue.class, LongValue.class)
.entries(1000).create();
IntValue heapKey = DataValueClasses.newInstance(IntValue.class);
IntValue directKey = DataValueClasses.newDirectInstance(IntValue.class);
LongValue heapValue = DataValueClasses.newInstance(LongValue.class);
LongValue directValue = DataValueClasses.newDirectInstance(LongValue.class);
heapKey.setValue(1);
heapValue.setValue(1);
map.put(heapKey, heapValue);
assertEquals(1, map.get(heapKey).getValue());
assertEquals(1, map.getUsing(heapKey, directValue).getValue());
((Byteable) directValue).bytes(null, 0L);
directKey.setValue(1);
map.getUsing(directKey, directValue).addValue(1);
assertEquals(2, map.getUsing(directKey, heapValue).getValue());
directKey.setValue(2);
heapValue.setValue(3);
map.put(directKey, heapValue);
assertEquals(3, map.get(directKey).getValue());
}
}
@@ -26,7 +26,8 @@ import org.junit.Test;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -507,6 +508,21 @@ public class StatelessClientTest {
}
}
@Test(timeout = 10000)
public void testGetAndEntryWeDontHave() throws IOException,
InterruptedException, ExecutionException {
try (ChronicleMap<Integer, CharSequence> serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
.replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) {
try (ChronicleMap<Integer, CharSequence> statelessMap = ChronicleMapBuilder.of(Integer
.class, CharSequence.class)
.statelessClient(new InetSocketAddress("localhost", 8056)).create()) {
assertEquals(null, statelessMap.get(3));
}
}
}
@Test(timeout = 10000)
public void testEquals() throws IOException, InterruptedException {
@@ -547,4 +563,99 @@ public class StatelessClientTest {
serverMap1.close();
serverMap2.close();
}
}
@Test
public void testThreadSafeness() throws IOException, InterruptedException {
int nThreads = 1;
final ExecutorService executorService = Executors.newFixedThreadPool(nThreads);
int count = 1000;
final CountDownLatch latch = new CountDownLatch(count * 2);
final AtomicInteger got = new AtomicInteger();
long startTime = System.currentTimeMillis();
// server
try (ChronicleMap<Integer, Integer> server = ChronicleMapBuilder.of(Integer.class, Integer.class)
.putReturnsNull(true)
.replication((byte) 1, TcpTransportAndNetworkConfig.of(8059)).create()) {
// stateless client
try (ChronicleMap<Integer, Integer> client = ChronicleMapBuilder.of(Integer.class,
Integer.class)
.statelessClient(new InetSocketAddress("localhost", 8059)).create()) {
for (int i = 0; i < count; i++) {
final int j = i;
executorService.submit(new Runnable() {
@Override
public void run() {
try {
client.put(j, j);
latch.countDown();
} catch (Error | Exception e) {
e.printStackTrace();
System.exit(0);
}
}
});
}
for (int i = 0; i < count; i++) {
final int j = i;
executorService.submit(new Runnable() {
@Override
public void run() {
try {
Integer result = client.get(j);
if (result == null) {
executorService.submit(this);
return;
}
if (result.equals(j)) {
got.incrementAndGet();
} else {
System.out.println("expected j=" + j + " but got back=" + result);
}
latch.countDown();
} catch (Error | Exception e) {
e.printStackTrace();
System.exit(0);
}
}
});
}
latch.await();
System.out.println("" + count + " messages took " +
TimeUnit.MILLISECONDS.toSeconds(System
.currentTimeMillis() - startTime) + " seconds, using " + nThreads + "" +
" threads");
assertEquals(count, got.get());
}
} finally {
executorService.shutdownNow();
executorService.awaitTermination(100, TimeUnit.SECONDS);
}
}
}
@@ -0,0 +1,174 @@
/*
* Copyright 2014 Higher Frequency Trading http://www.higherfrequencytrading.com
*
* 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 net.openhft.chronicle.map.fromdocs;
import static net.openhft.lang.Compare.*;
import java.io.IOException;
import net.openhft.chronicle.map.fromdocs.BondVOInterface;
import net.openhft.chronicle.map.fromdocs.BondVOInterface.MarketPx;
import net.openhft.lang.io.Bytes;
import net.openhft.lang.io.serialization.BytesMarshallable;
import net.openhft.lang.model.Copyable;
public class BondVOInterface$$Heap implements BondVOInterface, BytesMarshallable, Copyable<net.openhft.chronicle.map.fromdocs.BondVOInterface> {
private double _coupon;
private long _issueDate;
private long _maturityDate;
private int _entry;
private net.openhft.chronicle.map.fromdocs.BondVOInterface.MarketPx[] _marketPxIntraDayHistory = new net.openhft.chronicle.map.fromdocs.BondVOInterface.MarketPx[7];
{
for (int i = 0; i < _marketPxIntraDayHistory.length; i++)
_marketPxIntraDayHistory[i] = new net.openhft.chronicle.map.fromdocs.BondVOInterface$MarketPx$$Heap();
} private java.lang.String _symbol;
public void setCoupon(double $) {
_coupon = $;
}
public double getCoupon() {
return _coupon;
}
public synchronized double addAtomicCoupon(double $) {
return _coupon += $;
}
public synchronized boolean compareAndSwapCoupon(double _1, double _2) {
if (_coupon == _1) {
_coupon = _2;
return true;
}
return false;
}
public void setIssueDate(long $) {
_issueDate = $;
}
public long getIssueDate() {
return _issueDate;
}
public void setMaturityDate(long $) {
_maturityDate = $;
}
public long getMaturityDate() {
return _maturityDate;
}
public synchronized long addAtomicMaturityDate(long $) {
return _maturityDate += $;
}
public void unlockEntry() {
throw new UnsupportedOperationException();
} public void busyLockEntry() {
throw new UnsupportedOperationException();
} public void setMarketPxIntraDayHistoryAt(int i, net.openhft.chronicle.map.fromdocs.BondVOInterface.MarketPx $) {
if(i<0) throw new ArrayIndexOutOfBoundsException(i + " must be greater than 0");
if(i>=7) throw new ArrayIndexOutOfBoundsException(i + " must be less than 7");
_marketPxIntraDayHistory[i] = $;
}
public net.openhft.chronicle.map.fromdocs.BondVOInterface.MarketPx getMarketPxIntraDayHistoryAt(int i) {
if(i<0) throw new ArrayIndexOutOfBoundsException(i + " must be greater than 0");
if(i>=7) throw new ArrayIndexOutOfBoundsException(i + " must be less than 7");
return _marketPxIntraDayHistory[i];
}
public void setSymbol(java.lang.String $) {
_symbol = $;
}
public java.lang.String getSymbol() {
return _symbol;
}
@SuppressWarnings("unchecked")
public void copyFrom(net.openhft.chronicle.map.fromdocs.BondVOInterface from) {
setCoupon(from.getCoupon());
setIssueDate(from.getIssueDate());
setMaturityDate(from.getMaturityDate());
for (int i = 0; i < 7; i++){
setMarketPxIntraDayHistoryAt(i, from.getMarketPxIntraDayHistoryAt(i));
}
setSymbol(from.getSymbol());
}
public void writeMarshallable(Bytes out) {
out.writeDouble(getCoupon());
out.writeLong(getIssueDate());
out.writeLong(getMaturityDate());
for (int i = 0; i < 7; i++){
out.writeObject(getMarketPxIntraDayHistoryAt(i));
}
out.writeUTFΔ(getSymbol());
}
public void readMarshallable(Bytes in) {
_coupon = in.readDouble();
_issueDate = in.readLong();
_maturityDate = in.readLong();
_entry = in.readInt();
for (int i = 0; i < 7; i++){
_marketPxIntraDayHistory[i] = in.readObject(net.openhft.chronicle.map.fromdocs.BondVOInterface.MarketPx.class);
}
_symbol = in.readUTFΔ();
}
public long longHashCode_marketPxIntraDayHistory() {
long hc = 0;
for (int i = 0; i < 7; i++) {
hc += calcLongHashCode(getMarketPxIntraDayHistoryAt(i));
}
return hc;
}
public int hashCode() {
long lhc = longHashCode();
return (int) ((lhc >>> 32) ^ lhc);
}
public long longHashCode() {
return ((((calcLongHashCode(getCoupon())) * 10191 +
calcLongHashCode(getIssueDate())) * 10191 +
calcLongHashCode(getMaturityDate())) * 10191 +
longHashCode_marketPxIntraDayHistory()) * 10191 +
calcLongHashCode(getSymbol());
}
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof BondVOInterface)) return false;
BondVOInterface that = (BondVOInterface) o;
if(!isEqual(getCoupon(), that.getCoupon())) return false;
if(!isEqual(getIssueDate(), that.getIssueDate())) return false;
if(!isEqual(getMaturityDate(), that.getMaturityDate())) return false;
for (int i = 0; i <7; i++) {
if(!isEqual(getMarketPxIntraDayHistoryAt(i), that.getMarketPxIntraDayHistoryAt(i))) return false;
}
if(!isEqual(getSymbol(), that.getSymbol())) return false;
return true;
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("BondVOInterface{ ");
sb.append(" }");
return sb.toString();
}
}
@@ -0,0 +1,203 @@
/*
* Copyright 2014 Higher Frequency Trading http://www.higherfrequencytrading.com
*
* 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 net.openhft.chronicle.map.fromdocs;
import net.openhft.lang.io.Bytes;
import net.openhft.lang.io.serialization.BytesMarshallable;
import net.openhft.lang.model.Byteable;
import net.openhft.lang.model.Copyable;
import static net.openhft.lang.Compare.calcLongHashCode;
import static net.openhft.lang.Compare.isEqual;
public class BondVOInterface$$Native
implements BondVOInterface, BytesMarshallable, Byteable,
Copyable<BondVOInterface> {
private static final int COUPON = 0;
private static final int ISSUEDATE = 8;
private static final int MATURITYDATE = 16;
private static final int ENTRY = 24;
private static final int MARKETPXINTRADAYHISTORY = 28;
private final BondVOInterface$MarketPx$$Native _marketPxIntraDayHistory[] =
new BondVOInterface$MarketPx$$Native[7];
{
for (int i = 0; i < 7; i++)
_marketPxIntraDayHistory[i] = new BondVOInterface$MarketPx$$Native();
}
private static final int SYMBOL = 308;
private Bytes _bytes;
private long _offset;
public void setCoupon(double $) {
_bytes.writeDouble(_offset + COUPON, $);
}
public double getCoupon() {
return _bytes.readDouble(_offset + COUPON);
}
public double addAtomicCoupon(double $) {
return _bytes.addAtomicDouble(_offset + COUPON, $);
} public boolean compareAndSwapCoupon(double _1, double _2) {
return _bytes.compareAndSwapDouble(_offset + COUPON, _1, _2);
}
public void setIssueDate(long $) {
_bytes.writeLong(_offset + ISSUEDATE, $);
}
public long getIssueDate() {
return _bytes.readLong(_offset + ISSUEDATE);
}
public void setMaturityDate(long $) {
_bytes.writeLong(_offset + MATURITYDATE, $);
}
public long getMaturityDate() {
return _bytes.readLong(_offset + MATURITYDATE);
}
public long addAtomicMaturityDate(long $) {
return _bytes.addAtomicLong(_offset + MATURITYDATE, $);
} public void unlockEntry() {
_bytes.unlockInt(_offset + ENTRY);
} public void busyLockEntry() throws InterruptedException {
_bytes.busyLockInt(_offset + ENTRY);
} public void setMarketPxIntraDayHistoryAt(int i, BondVOInterface.MarketPx $) {
_marketPxIntraDayHistory[i].copyFrom($);
}
public BondVOInterface.MarketPx getMarketPxIntraDayHistoryAt(int i) {
return _marketPxIntraDayHistory[i];
}
public void setSymbol(java.lang.String $) {
_bytes.writeUTFΔ(_offset + SYMBOL, 20, $);
}
public java.lang.String getSymbol() {
return _bytes.readUTFΔ(_offset + SYMBOL);
}
@Override
public void copyFrom(BondVOInterface from) {
setCoupon(from.getCoupon());
setIssueDate(from.getIssueDate());
setMaturityDate(from.getMaturityDate());
for (int i = 0; i < 7; i++){
setMarketPxIntraDayHistoryAt(i, from.getMarketPxIntraDayHistoryAt(i));
}
setSymbol(from.getSymbol());
}
@Override
public void writeMarshallable(Bytes out) {
out.writeDouble(getCoupon());
out.writeLong(getIssueDate());
out.writeLong(getMaturityDate());
for (int i = 0; i < 7; i++){
_marketPxIntraDayHistory[i].writeMarshallable(out);
}
out.writeUTFΔ(getSymbol());
}
@Override
public void readMarshallable(Bytes in) {
setCoupon(in.readDouble());
setIssueDate(in.readLong());
setMaturityDate(in.readLong());
for (int i = 0; i < 7; i++){
_marketPxIntraDayHistory[i].readMarshallable(in);
}
setSymbol(in.readUTFΔ());
}
@Override
public void bytes(Bytes bytes, long offset) {
this._bytes = bytes;
this._offset = offset;
for (int i = 0; i < 7; i++){
((Byteable) _marketPxIntraDayHistory[i]).bytes(bytes,
_offset + MARKETPXINTRADAYHISTORY + (i * 40));
}
}
@Override
public Bytes bytes() {
return _bytes;
}
@Override
public long offset() {
return _offset;
}
@Override
public int maxSize() {
return 328;
}
public long longHashCode_marketPxIntraDayHistory() {
long hc = 0;
for (int i = 0; i < 7; i++) {
hc += calcLongHashCode(getMarketPxIntraDayHistoryAt(i));
}
return hc;
}
public int hashCode() {
long lhc = longHashCode();
return (int) ((lhc >>> 32) ^ lhc);
}
public long longHashCode() {
return ((((calcLongHashCode(getCoupon())) * 10191 +
calcLongHashCode(getIssueDate())) * 10191 +
calcLongHashCode(getMaturityDate())) * 10191 +
longHashCode_marketPxIntraDayHistory()) * 10191 +
calcLongHashCode(getSymbol());
}
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof BondVOInterface)) return false;
BondVOInterface that = (BondVOInterface) o;
if(!isEqual(getCoupon(), that.getCoupon())) return false;
if(!isEqual(getIssueDate(), that.getIssueDate())) return false;
if(!isEqual(getMaturityDate(), that.getMaturityDate())) return false;
for (int i = 0; i <7; i++) {
if(!isEqual(getMarketPxIntraDayHistoryAt(i), that.getMarketPxIntraDayHistoryAt(i)))
return false;
}
if(!isEqual(getSymbol(), that.getSymbol())) return false;
return true;
}
public String toString() {
if (_bytes == null) return "bytes is null";
StringBuilder sb = new StringBuilder();
sb.append("BondVOInterface{ ");
sb.append(" }");
return sb.toString();
}
}
@@ -0,0 +1,128 @@
/*
* Copyright 2014 Higher Frequency Trading http://www.higherfrequencytrading.com
*
* 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 net.openhft.chronicle.map.fromdocs;
import static net.openhft.lang.Compare.*;
import java.io.IOException;
import net.openhft.chronicle.map.fromdocs.BondVOInterface.MarketPx;
import net.openhft.lang.io.Bytes;
import net.openhft.lang.io.serialization.BytesMarshallable;
import net.openhft.lang.model.Copyable;
public class BondVOInterface$MarketPx$$Heap implements MarketPx, BytesMarshallable, Copyable<net.openhft.chronicle.map.fromdocs.BondVOInterface.MarketPx> {
private double _askPx;
private double _bidPx;
private double _callPx;
private double _maturityPx;
private double _parPx;
public void setAskPx(double $) {
_askPx = $;
}
public double getAskPx() {
return _askPx;
}
public void setBidPx(double $) {
_bidPx = $;
}
public double getBidPx() {
return _bidPx;
}
public void setCallPx(double $) {
_callPx = $;
}
public double getCallPx() {
return _callPx;
}
public void setMaturityPx(double $) {
_maturityPx = $;
}
public double getMaturityPx() {
return _maturityPx;
}
public void setParPx(double $) {
_parPx = $;
}
public double getParPx() {
return _parPx;
}
@SuppressWarnings("unchecked")
public void copyFrom(net.openhft.chronicle.map.fromdocs.BondVOInterface.MarketPx from) {
setAskPx(from.getAskPx());
setBidPx(from.getBidPx());
setCallPx(from.getCallPx());
setMaturityPx(from.getMaturityPx());
setParPx(from.getParPx());
}
public void writeMarshallable(Bytes out) {
out.writeDouble(getAskPx());
out.writeDouble(getBidPx());
out.writeDouble(getCallPx());
out.writeDouble(getMaturityPx());
out.writeDouble(getParPx());
}
public void readMarshallable(Bytes in) {
_askPx = in.readDouble();
_bidPx = in.readDouble();
_callPx = in.readDouble();
_maturityPx = in.readDouble();
_parPx = in.readDouble();
}
public int hashCode() {
long lhc = longHashCode();
return (int) ((lhc >>> 32) ^ lhc);
}
public long longHashCode() {
return ((((calcLongHashCode(getAskPx())) * 10191 +
calcLongHashCode(getBidPx())) * 10191 +
calcLongHashCode(getCallPx())) * 10191 +
calcLongHashCode(getMaturityPx())) * 10191 +
calcLongHashCode(getParPx());
}
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof BondVOInterface.MarketPx)) return false;
BondVOInterface.MarketPx that = (BondVOInterface.MarketPx) o;
if(!isEqual(getAskPx(), that.getAskPx())) return false;
if(!isEqual(getBidPx(), that.getBidPx())) return false;
if(!isEqual(getCallPx(), that.getCallPx())) return false;
if(!isEqual(getMaturityPx(), that.getMaturityPx())) return false;
if(!isEqual(getParPx(), that.getParPx())) return false;
return true;
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("BondVOInterface.MarketPx{ ");
sb.append(" }");
return sb.toString();
}
}
@@ -0,0 +1,165 @@
/*
* Copyright 2014 Higher Frequency Trading http://www.higherfrequencytrading.com
*
* 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 net.openhft.chronicle.map.fromdocs;
import net.openhft.lang.io.Bytes;
import net.openhft.lang.io.serialization.BytesMarshallable;
import net.openhft.lang.model.Byteable;
import net.openhft.lang.model.Copyable;
import static net.openhft.lang.Compare.calcLongHashCode;
import static net.openhft.lang.Compare.isEqual;
public class BondVOInterface$MarketPx$$Native
implements BondVOInterface.MarketPx, BytesMarshallable, Byteable,
Copyable<BondVOInterface.MarketPx> {
private static final int ASKPX = 0;
private static final int BIDPX = 8;
private static final int CALLPX = 16;
private static final int MATURITYPX = 24;
private static final int PARPX = 32;
private Bytes _bytes;
private long _offset;
public void setAskPx(double $) {
_bytes.writeDouble(_offset + ASKPX, $);
}
public double getAskPx() {
return _bytes.readDouble(_offset + ASKPX);
}
public void setBidPx(double $) {
_bytes.writeDouble(_offset + BIDPX, $);
}
public double getBidPx() {
return _bytes.readDouble(_offset + BIDPX);
}
public void setCallPx(double $) {
_bytes.writeDouble(_offset + CALLPX, $);
}
public double getCallPx() {
return _bytes.readDouble(_offset + CALLPX);
}
public void setMaturityPx(double $) {
_bytes.writeDouble(_offset + MATURITYPX, $);
}
public double getMaturityPx() {
return _bytes.readDouble(_offset + MATURITYPX);
}
public void setParPx(double $) {
_bytes.writeDouble(_offset + PARPX, $);
}
public double getParPx() {
return _bytes.readDouble(_offset + PARPX);
}
@Override
public void copyFrom(BondVOInterface.MarketPx from) {
setAskPx(from.getAskPx());
setBidPx(from.getBidPx());
setCallPx(from.getCallPx());
setMaturityPx(from.getMaturityPx());
setParPx(from.getParPx());
}
@Override
public void writeMarshallable(Bytes out) {
out.writeDouble(getAskPx());
out.writeDouble(getBidPx());
out.writeDouble(getCallPx());
out.writeDouble(getMaturityPx());
out.writeDouble(getParPx());
}
@Override
public void readMarshallable(Bytes in) {
setAskPx(in.readDouble());
setBidPx(in.readDouble());
setCallPx(in.readDouble());
setMaturityPx(in.readDouble());
setParPx(in.readDouble());
}
@Override
public void bytes(Bytes bytes, long offset) {
this._bytes = bytes;
this._offset = offset;
}
@Override
public Bytes bytes() {
return _bytes;
}
@Override
public long offset() {
return _offset;
}
@Override
public int maxSize() {
return 40;
}
public int hashCode() {
long lhc = longHashCode();
return (int) ((lhc >>> 32) ^ lhc);
}
public long longHashCode() {
return ((((calcLongHashCode(getAskPx())) * 10191 +
calcLongHashCode(getBidPx())) * 10191 +
calcLongHashCode(getCallPx())) * 10191 +
calcLongHashCode(getMaturityPx())) * 10191 +
calcLongHashCode(getParPx());
}
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof BondVOInterface.MarketPx)) return false;
BondVOInterface.MarketPx that = (BondVOInterface.MarketPx) o;
if(!isEqual(getAskPx(), that.getAskPx())) return false;
if(!isEqual(getBidPx(), that.getBidPx())) return false;
if(!isEqual(getCallPx(), that.getCallPx())) return false;
if(!isEqual(getMaturityPx(), that.getMaturityPx())) return false;
if(!isEqual(getParPx(), that.getParPx())) return false;
return true;
}
public String toString() {
if (_bytes == null) return "bytes is null";
StringBuilder sb = new StringBuilder();
sb.append("BondVOInterface.MarketPx{ ");
sb.append(" }");
return sb.toString();
}
}