Comments (19)
You have typo here:
this.key = wire.read(() -> "ket").text();
Regards
On Fri, Feb 12, 2016 at 10:41 AM, Gadi [email protected] wrote:
public class WireModel implements Marshallable {
private long id;
private int revision;
private String key;public WireModel(long id, int revision, String key) {
this.id = id;
this.revision = revision;
this.key = key;
}@OverRide
public void readMarshallable(@NotNull WireIn wire) throws IllegalStateException {
this.id = wire.read(() -> "id").int64();
this.revision = wire.read(() -> "revision").int32();
this.key = wire.read(() -> "ket").text();
}@OverRide
public void writeMarshallable(WireOut wire) {
wire
.write(() -> "id").int64(id)
.write(() -> "revision").int32(revision)
.write(() -> "key").text(key);
}what an I doing wrong here?
keep getting same error regardless of read or write I tried.testMultipleReads0 http://...WireModelTest: Unordered fields not
supported yet, Expected=id was: ''
testMultipleReads1 http://...WireModelTest: Unsupported type '3'—
Reply to this email directly or view it on GitHub
#15.
from chronicle-wire.
Thank you , good catch, but I am afraid this is still same error on the first field "id"
--- !!meta-data #binary
312313424
12
"1625d931-8220-4f5c-8bc1-1a11be5a8201"
--- !!meta-data
"id":312313424,"revision":,"key":"46fecdb7-96d2-4c97-8e9b-2cdb682f612e"
Tests run: 5, Failures: 1, Errors: 4, Skipped: 0, Time elapsed: 0.18 sec <<< FAILURE!
testMultipleReads0 Time elapsed: 0.159 sec <<< ERROR!
java.lang.UnsupportedOperationException: Unordered fields not supported yet, Expected=id was: ''
here is my test class
Bytes bytes = Bytes.elasticByteBuffer();
Wire wire = wireType.apply(bytes);
wire.writeDocument(true, model1);
System.out.println(Wires.fromSizePrefixedBlobs(bytes));
StringBuilder sb = new StringBuilder();
WireModel results1 = new WireModel();
wire.read(sb).marshallable(results1);
assertEquals(model1.getId(), results1.getId());
assertEquals(model1.getRevision(), results1.getRevision());
assertEquals(model1.getKey(), results1.getKey());
from chronicle-wire.
A writeDocument should be matched by a readDocument:
Also note how in the code below I've used enums to avoid any possible typos
:)
Hope you find this useful.
package test;
import net.openhft.chronicle.bytes.Bytes;
import net.openhft.chronicle.wire.*;
import org.jetbrains.annotations.NotNull;
import java.util.function.Function;
import static org.junit.Assert.assertEquals;
import static test.WireModel.Values.*;
public class WireModel implements Marshallable {
enum Values implements WireKey {ID, REVISION, KEY}
private long id;
private int revision;
private String key;
public WireModel(){
}
public WireModel(long id, int revision, String key) {
this.id = id;
this.revision = revision;
this.key = key;
}
@Override
public void readMarshallable(@NotNull WireIn wire) throws
IllegalStateException {
this.id = wire.read(ID).int64();
this.revision = wire.read(REVISION).int32();
this.key = wire.read(KEY).text();
}
@Override
public void writeMarshallable(WireOut wire) {
wire.write(ID).int64(id)
.write(REVISION).int32(revision)
.write(KEY).text(key);
}
@Override
public String toString() {
return "test.WireModel{" +
"id=" + id +
", revision=" + revision +
", key='" + key + '\'' +
'}';
}
public static void main(String[] args) {
WireModel model1 = new WireModel(10, 9, "test");
Function<Bytes, Wire> wireType = bytes -> new TextWire(bytes);
Bytes bytes = Bytes.elasticByteBuffer();
Wire wire = wireType.apply(bytes);
wire.writeDocument(true, model1);
System.out.println(Wires.fromSizePrefixedBlobs(bytes));
WireModel results1 = new WireModel();
wire.readDocument(results1, null);
assertEquals(model1.toString(), results1.toString());
}
}
On Fri, Feb 12, 2016 at 11:16 AM, Gadi [email protected] wrote:
Thank you , good catch, but I am afraid this is still same error on the
first field "id"--- !!meta-data #binary
312313424
12
"1625d931-8220-4f5c-8bc1-1a11be5a8201"--- !!meta-data
"id":312313424,"revision":,"key":"46fecdb7-96d2-4c97-8e9b-2cdb682f612e"Tests run: 5, Failures: 1, Errors: 4, Skipped: 0, Time elapsed: 0.18 sec
<<< FAILURE!
testMultipleReads0 http://wire.tests.WireModelTest Time elapsed: 0.159
sec <<< ERROR!
java.lang.UnsupportedOperationException: Unordered fields not supported
yet, Expected=id was: ''here is my test class
Bytes bytes = Bytes.elasticByteBuffer(); Wire wire = wireType.apply(bytes); wire.writeDocument(true, model1); System.out.println(Wires.fromSizePrefixedBlobs(bytes)); StringBuilder sb = new StringBuilder(); WireModel results1 = new WireModel(); wire.read(sb).marshallable(results1); assertEquals(model1.getId(), results1.getId()); assertEquals(model1.getRevision(), results1.getRevision()); assertEquals(model1.getKey(), results1.getKey());
—
Reply to this email directly or view it on GitHub
#15 (comment)
.
from chronicle-wire.
Awesome! Your suggestion fixed it, good idea.
The only WireType that doesn't work is JSON but its not important for now.
from chronicle-wire.
The latest version of wire (from 1.3.x) should support unordered fields,
and in any case doesn't have this error message.
Peter.
On 12 February 2016 at 07:13, Gadi [email protected] wrote:
Awesome! Your suggestion fixed it, good idea.
The only WireType that doesn't work is JSON but its not important for now.—
Reply to this email directly or view it on GitHub
#15 (comment)
.
from chronicle-wire.
Not sure which version of Wire you're using but I can confirm that JSONWire
works on the latest snapshot.
On Fri, Feb 12, 2016 at 12:13 PM, Gadi [email protected] wrote:
Awesome! Your suggestion fixed it, good idea.
The only WireType that doesn't work is JSON but its not important for now.—
Reply to this email directly or view it on GitHub
#15 (comment)
.
from chronicle-wire.
thank you both, I used 1.2.0. will upgrade and test again shortly.
I created this test project to help explore my options before using it, this is generic composition of objects, hope it can help someone else https://github.com/gadieichhorn/chronicle-wire-tests/blob/master/src/main/java/com/rds/chronicle/wire/tests/WireCollection.java
I struggle to find the way to wire nested collections and hashmaps like in this example.
from looking in the README or the tests libs I couldn't find any example that works for my case. Appreciate any help :)
from chronicle-wire.
Can you provide an example? Do you mean
Map<String, WiredType>
On 12 February 2016 at 11:43, Gadi [email protected] wrote:
thank you both, I used 1.2.0. will upgrade and test again shortly.
I created this test project to help explore my options before using it,
this is generic composition of objects, hope it can help someone else
https://github.com/gadieichhorn/chronicle-wire-tests/blob/master/src/main/java/com/rds/chronicle/wire/tests/WireCollection.javaI struggle to find the way to wire nested collections and hashmaps like in
this example.
from looking in the README or the tests libs I couldn't find any example
that works for my case. Appreciate any help :)—
Reply to this email directly or view it on GitHub
#15 (comment)
.
from chronicle-wire.
Yes, please
List and HashMap
WireProperty & WireCollection are both Marshallable
WireCollection contain other nested Marshallable as below
private List<WireProperty> properties = new ArrayList<>();
private Map<String, WireCollection> collections = new HashMap<>();
The 1.3.2-snapshot will not compile. I will stay with 1.2.0 and use the read/write I used so far.
from chronicle-wire.
The release version is 1.3.4 and the next snapshot is 1.3.5-SNAPSHOT
http://search.maven.org/#artifactdetails%7Cnet.openhft%7Cchronicle-wire%7C1.3.4%7Cbundle
You can use
properties = wireIn.read(() -> "properties").list(WireProperty.class);
collections = wireIn.read(() -> "collections").marshallableAsMap(
WireCollection.class);
I suspect your properties should be just a map.
On 12 February 2016 at 12:32, Gadi [email protected] wrote:
Yes, please
List and HashMapWireProperty & WireCollection are both Marshallable
WireCollection contain other nested Marshallable as belowprivate List properties = new ArrayList<>();
private Map<String, WireCollection> collections = new HashMap<>();The 1.3.2-snapshot will not compile. I will stay with 1.2.0 and use the
read/write I used so far.—
Reply to this email directly or view it on GitHub
#15 (comment)
.
from chronicle-wire.
Thank you, that works after the upgrade, I was missing the new methods.
Have a small issue with the WIreType.
WireType.TEXT
WireType.BINARY
These are the only working WireTypes with the nested collections, it seemed to not get the right number of elements back or the map key is not correctly set to match the source.
The following compare the size of the return collection
assertEquals(a.getCollections().size(), b.getCollections().size());
assertEquals(a.getProperties().size(), b.getProperties().size());
This test check if the results contains the original elements (I use reference as key). I suspect some WireType implement a different map key and that is why it fails.
a.getProperties().values().forEach(c -> {
if (b.getProperties().containsKey(c.getReference())) {
compareWireProperty(c, b.getProperties().get(c.getReference()));
} else {
Assert.fail("Cannot match property child element WireProperty");
}
});
if you like to see my tests you can have a look here. https://github.com/gadieichhorn/chronicle-wire-tests
from chronicle-wire.
Can you provide a unit test to replicate this? I suspect this has been
fixed in newer versions but it would be good to check.
On 12 February 2016 at 16:55, Gadi [email protected] wrote:
Thank you, that works after the upgrade, I was missing the new methods.
Have a small issue with the WIreType.
WireType.TEXT
WireType.BINARYThese are the only working WireTypes with the nested collections, it
seemed to not get the right number of elements back or the map key is not
correctly set to match the source.The following compare the size of the return collection
assertEquals(a.getCollections().size(), b.getCollections().size()); assertEquals(a.getProperties().size(), b.getProperties().size());
This test check if the results contains the original elements (I use
reference as key). I suspect some WireType implement a different map key
and that is why it fails.a.getProperties().values().forEach(c -> { if (b.getProperties().containsKey(c.getReference())) { compareWireProperty(c, b.getProperties().get(c.getReference())); } else { Assert.fail("Cannot match property child element WireProperty"); } });
if you like to see my tests you can have a look here.
https://github.com/gadieichhorn/chronicle-wire-tests—
Reply to this email directly or view it on GitHub
#15 (comment)
.
from chronicle-wire.
I created a pull request.
Failed tests:
WireCollectionTest.testMultipleReads:59 Cannot match property child element WireProperty
WireCollectionTest.testMultipleReads:59 expected:<3> but was:<1>
let me know what you think.
On a different note:
If the collection is empty you still get an empty array in the wire. SO I created this check before to eliminate the extra empty collection writing
if (properties.size() > 0) {
wire.write(WireCollection.Values.PROPERTIES).marshallableAsMap(properties);
}
if (collections.size() > 0) {
wire.write(WireCollection.Values.COLLECTIONS).marshallableAsMap(collections);
}
in some cases the class name appears in the wire, I guess this is necessary in case there are polymorphic classes and the collection can have different specific types under the hood. ANy suggestions to clean this up?
][
!net.openhft.chronicle.wire.reuse.WireCollection [
8426082448332188729,
!int -47647815,
"2c791eb9-753b-4c72-ad23-63bdf66ae3f4",
reference3,
"@:3",
name3[
Thanks again for your support.
from chronicle-wire.
Hello Gabi,
Thank you for the unit test. I was able to find the bug quite quickly
(and have committed a fix)
The output for numbered fields now looks like.
--- !!meta-data #binary
"0": 234234234
"1": 23
"8": "38432228-f85c-4a43-9499-c5636c94de3d"
"4": reference
"5": @
"6": name
"2": [
reference7: !WireProperty [
"0": -2473783008384263129,
"1": 996207328,
"8": "2fa10878-f87d-4a6a-9378-2d7899acfaaf",
"4": reference7,
"5": "@:7",
"6": name7,
"7": "7567ca01b7b7435b80cba2b25c54180d"
]
reference8: !WireProperty [
"0": 7813252551544261374,
"1": !int -1455156808,
"8": b04cd400-9266-4cb5-9a59-f1512366f8c9,
"4": reference8,
"5": "@:8",
"6": name8,
"7": aa362e2e3ff346a7b0a7c45c6eb89133
]
reference9: !WireProperty [
"0": -4078949010835680613,
"1": 241021037,
"8": "74933db6-adbe-4d96-8734-230e64724fb6",
"4": reference9,
"5": "@:9",
"6": name9,
"7": cb0f73f2da2e450fa10db4d138075269
]
reference3: !WireProperty [
"0": -3447705347187420950,
"1": !int -243598213,
"8": d4750faa-dbb8-4e2b-bc73-470e295ac1aa,
"4": reference3,
"5": "@:3",
"6": name3,
"7": fd460c7c0ccf44cea8c22a791a52de1e
]
reference4: !WireProperty [
"0": 8493808251427423191,
"1": 648409363,
"8": "08db865f-95ff-4e76-872f-9af001ef593e",
"4": reference4,
"5": "@:4",
"6": name4,
"7": "1afd8d5f88dc4b57b7ff45bdc52dd3cd"
]
reference5: !WireProperty [
"0": -1958360471934516811,
"1": !int -1847639601,
"8": "50af4f11-cd86-4d66-baf5-bce083646182",
"4": reference5,
"5": "@:5",
"6": name5,
"7": "520f02f33c0a464d9fd9de4a0789cd12"
]
reference6: !WireProperty [
"0": 2956160254387511097,
"1": !int -325989312,
"8": d78f6930-badb-4d44-9a9e-76e0b7f0014d,
"4": reference6,
"5": "@:6",
"6": name6,
"7": f53821258f9f4236a0a92255d9bca8b2
]
reference1: !WireProperty [
"0": 1920184879057585000,
"1": 672916719,
"8": "1afca66b-0c43-4ea5-8d7e-f3a106129846",
"4": reference1,
"5": "@:1",
"6": name1,
"7": ea7673d93830443bb3ee08d03bb09d51
]
reference2: !WireProperty [
"0": 3685197974110234027,
"1": 1708461762,
"8": "03838103-e0cb-4ead-b8b6-980f5110a418",
"4": reference2,
"5": "@:2",
"6": name2,
"7": "6596e4da49584a4eae2cb21eec248b9d"
]
]
The output for named fields now looks like
--- !!meta-data
id: 234234234
revision: 23
key: "20617f19-1781-4f40-98c9-61ffa5dba21e"
reference: reference
path: @
name: name
properties: {
reference7: !WireProperty { id: 9020901677846458544, revision: 679950018,
key: "6c606d4e-71a9-4b17-8523-1dcb9c088d23", reference: reference7, path:
"@:7", name: name7, value: "63f20cbc33f0481b8234930d69a09520" },
reference8: !WireProperty { id: -6735319603169159958, revision:
862355910, key: "3fe7ad73-7f8a-45b6-af4e-435bc8fd0b1d", reference:
reference8, path: "@:8", name: name8, value:
"2afe3c88364041c8acaa56f4b35bc53b" },
reference9: !WireProperty { id: 2239969738209127675, revision:
-279215100, key: "7fae7281-7c18-4487-a2f5-4e3499f525ae", reference:
reference9, path: "@:9", name: name9, value:
"554fcb098c024e2da135186bea0a5ba3" },
reference3: !WireProperty { id: 8390695552422707165, revision:
-147514553, key: "926e552c-e395-4c2f-80e6-5d6de1f84b7b", reference:
reference3, path: "@:3", name: name3, value:
a4da0ad3ed684003949e971fa8699d27 },
reference4: !WireProperty { id: -978531391916948535, revision: 524865454,
key: dd8d9eef-ce7d-4423-a781-06605e37b011, reference: reference4, path:
"@:4", name: name4, value: bec03d70d0e6482e81b7bb0e357f3d92 },
reference5: !WireProperty { id: 3374944958029627633, revision:
-398086406, key: "0a1e056e-e6e7-4e11-b303-c293c6fdf5f3", reference:
reference5, path: "@:5", name: name5, value:
"69813084c39d4936b69b0dde0f0c0ed5" },
reference6: !WireProperty { id: -8433021096891598682, revision:
-736117722, key: "776461da-264a-4827-aeea-3a4d2ef5a8ba", reference:
reference6, path: "@:6", name: name6, value:
"3367fa70b0e14aed80abc5172414134c" },
reference1: !WireProperty { id: -142490954081820345, revision:
-318848728, key: "2205a065-a732-40c1-a635-b421f8f8cba6", reference:
reference1, path: "@:1", name: name1, value:
"6fafe5346ddc4ec18d80f45104332eac" },
reference2: !WireProperty { id: 2991033472590306421, revision:
1566613018, key: d8f3385b-c268-4d0c-88bd-d9883ca31ab4, reference:
reference2, path: "@:2", name: name2, value:
"74641a3b78b64837a67433a30b40016f" }
}
the output for field less now looks like, this is the most difficult to
read as it has the least information. If you wanted to make it readable,
you would parse the data, and print the parsed data (note I added a
toString()) method for you.
--- !!meta-data #binary
234234234
23
f4a93b1e-9c86-4fc3-8c8e-529a034a506e
reference
@
name
[
reference7: !WireProperty [
115906392025424068,
154486320,
"22711f61-923c-41fc-92b3-0e2ca5c3f6a8",
reference7,
"@:7",
name7,
"6c63fa3a28894b0ca770af1688ad8fb6"
]
reference8: !WireProperty [
6431574489447352160,
1976658183,
"6d23c6dd-91b8-4c8c-bcca-4516c4b42313",
reference8,
"@:8",
name8,
a68645912c6f4556afebaa1c1a9c8572
]
reference9: !WireProperty [
3357362923123882492,
!int -731973258,
a7d80411-8184-4e6e-80eb-a494ffb39b7e,
reference9,
"@:9",
name9,
"792d1edb686041e397246862887b331f"
]
reference3: !WireProperty [
7741702624161412808,
!int -1298385948,
"324e6e71-aa05-4871-b0ba-d70d931e2ea6",
reference3,
"@:3",
name3,
d7b7bb14f1e6438585c2ea9118c9ce6f
]
On 13 February 2016 at 03:32, Gadi [email protected] wrote:
I created a pull request.
Failed tests:
WireCollectionTest.testMultipleReads:59 Cannot match property child
element WireProperty
WireCollectionTest.testMultipleReads:59 expected:<3> but was:<1>let me know what you think.
On a different note:
If the collection is empty you still get an empty array in the wire. SO I
created this check before to eliminate the extra empty collection writingif (properties.size() > 0) { wire.write(WireCollection.Values.PROPERTIES).marshallableAsMap(properties); } if (collections.size() > 0) { wire.write(WireCollection.Values.COLLECTIONS).marshallableAsMap(collections); }
in some cases the class name appears in the wire, I guess this is
necessary in case there are polymorphic classes and the collection can have
different specific types under the hood. ANy suggestions to clean this up?][
!net.openhft.chronicle.wire.reuse.WireCollection [
8426082448332188729,
!int -47647815,
"2c791eb9-753b-4c72-ad23-63bdf66ae3f4",
reference3,
"@:3",
name3[Thanks again for your support.
—
Reply to this email directly or view it on GitHub
#15 (comment)
.
from chronicle-wire.
To add toString, equals, hashCode you just need to add the following
methods and as long as the writeMarshallable methods are up to date, this
will be correct.
@OverRide
public int hashCode() {
return HashWire.hash32(this);
}
@OverRide
public boolean equals(Object obj) {
return obj instanceof WriteMarshallable &&
obj.toString().equals(toString());
}
@OverRide
public String toString() {
return WireType.TEXT.asString(this);
}
On 13 February 2016 at 08:24, Peter Lawrey [email protected]
wrote:
Hello Gabi,
Thank you for the unit test. I was able to find the bug quite quickly
(and have committed a fix)The output for numbered fields now looks like.
--- !!meta-data #binary
"0": 234234234
"1": 23
"8": "38432228-f85c-4a43-9499-c5636c94de3d"
"4": reference
"5": @
"6": name
"2": [
reference7: !WireProperty [
"0": -2473783008384263129,
"1": 996207328,
"8": "2fa10878-f87d-4a6a-9378-2d7899acfaaf",
"4": reference7,
"5": "@:7",
"6": name7,
"7": "7567ca01b7b7435b80cba2b25c54180d"
]
reference8: !WireProperty [
"0": 7813252551544261374,
"1": !int -1455156808,
"8": b04cd400-9266-4cb5-9a59-f1512366f8c9,
"4": reference8,
"5": "@:8",
"6": name8,
"7": aa362e2e3ff346a7b0a7c45c6eb89133
]
reference9: !WireProperty [
"0": -4078949010835680613,
"1": 241021037,
"8": "74933db6-adbe-4d96-8734-230e64724fb6",
"4": reference9,
"5": "@:9",
"6": name9,
"7": cb0f73f2da2e450fa10db4d138075269
]
reference3: !WireProperty [
"0": -3447705347187420950,
"1": !int -243598213,
"8": d4750faa-dbb8-4e2b-bc73-470e295ac1aa,
"4": reference3,
"5": "@:3",
"6": name3,
"7": fd460c7c0ccf44cea8c22a791a52de1e
]
reference4: !WireProperty [
"0": 8493808251427423191,
"1": 648409363,
"8": "08db865f-95ff-4e76-872f-9af001ef593e",
"4": reference4,
"5": "@:4",
"6": name4,
"7": "1afd8d5f88dc4b57b7ff45bdc52dd3cd"
]
reference5: !WireProperty [
"0": -1958360471934516811,
"1": !int -1847639601,
"8": "50af4f11-cd86-4d66-baf5-bce083646182",
"4": reference5,
"5": "@:5",
"6": name5,
"7": "520f02f33c0a464d9fd9de4a0789cd12"
]
reference6: !WireProperty [
"0": 2956160254387511097,
"1": !int -325989312,
"8": d78f6930-badb-4d44-9a9e-76e0b7f0014d,
"4": reference6,
"5": "@:6",
"6": name6,
"7": f53821258f9f4236a0a92255d9bca8b2
]
reference1: !WireProperty [
"0": 1920184879057585000,
"1": 672916719,
"8": "1afca66b-0c43-4ea5-8d7e-f3a106129846",
"4": reference1,
"5": "@:1",
"6": name1,
"7": ea7673d93830443bb3ee08d03bb09d51
]
reference2: !WireProperty [
"0": 3685197974110234027,
"1": 1708461762,
"8": "03838103-e0cb-4ead-b8b6-980f5110a418",
"4": reference2,
"5": "@:2",
"6": name2,
"7": "6596e4da49584a4eae2cb21eec248b9d"
]
]The output for named fields now looks like
--- !!meta-data
id: 234234234
revision: 23
key: "20617f19-1781-4f40-98c9-61ffa5dba21e"
reference: reference
path: @
name: name
properties: {
reference7: !WireProperty { id: 9020901677846458544, revision:
679950018, key: "6c606d4e-71a9-4b17-8523-1dcb9c088d23", reference:
reference7, path: "@:7", name: name7, value:
"63f20cbc33f0481b8234930d69a09520" },
reference8: !WireProperty { id: -6735319603169159958, revision:
862355910, key: "3fe7ad73-7f8a-45b6-af4e-435bc8fd0b1d", reference:
reference8, path: "@:8", name: name8, value:
"2afe3c88364041c8acaa56f4b35bc53b" },
reference9: !WireProperty { id: 2239969738209127675, revision:
-279215100, key: "7fae7281-7c18-4487-a2f5-4e3499f525ae", reference:
reference9, path: "@:9", name: name9, value:
"554fcb098c024e2da135186bea0a5ba3" },
reference3: !WireProperty { id: 8390695552422707165, revision:
-147514553, key: "926e552c-e395-4c2f-80e6-5d6de1f84b7b", reference:
reference3, path: "@:3", name: name3, value:
a4da0ad3ed684003949e971fa8699d27 },
reference4: !WireProperty { id: -978531391916948535, revision:
524865454, key: dd8d9eef-ce7d-4423-a781-06605e37b011, reference:
reference4, path: "@:4", name: name4, value:
bec03d70d0e6482e81b7bb0e357f3d92 },
reference5: !WireProperty { id: 3374944958029627633, revision:
-398086406, key: "0a1e056e-e6e7-4e11-b303-c293c6fdf5f3", reference:
reference5, path: "@:5", name: name5, value:
"69813084c39d4936b69b0dde0f0c0ed5" },
reference6: !WireProperty { id: -8433021096891598682, revision:
-736117722, key: "776461da-264a-4827-aeea-3a4d2ef5a8ba", reference:
reference6, path: "@:6", name: name6, value:
"3367fa70b0e14aed80abc5172414134c" },
reference1: !WireProperty { id: -142490954081820345, revision:
-318848728, key: "2205a065-a732-40c1-a635-b421f8f8cba6", reference:
reference1, path: "@:1", name: name1, value:
"6fafe5346ddc4ec18d80f45104332eac" },
reference2: !WireProperty { id: 2991033472590306421, revision:
1566613018, key: d8f3385b-c268-4d0c-88bd-d9883ca31ab4, reference:
reference2, path: "@:2", name: name2, value:
"74641a3b78b64837a67433a30b40016f" }
}the output for field less now looks like, this is the most difficult to
read as it has the least information. If you wanted to make it readable,
you would parse the data, and print the parsed data (note I added a
toString()) method for you.--- !!meta-data #binary
234234234
23
f4a93b1e-9c86-4fc3-8c8e-529a034a506e
reference
@
name
[
reference7: !WireProperty [
115906392025424068,
154486320,
"22711f61-923c-41fc-92b3-0e2ca5c3f6a8",
reference7,
"@:7",
name7,
"6c63fa3a28894b0ca770af1688ad8fb6"
]
reference8: !WireProperty [
6431574489447352160,
1976658183,
"6d23c6dd-91b8-4c8c-bcca-4516c4b42313",
reference8,
"@:8",
name8,
a68645912c6f4556afebaa1c1a9c8572
]
reference9: !WireProperty [
3357362923123882492,
!int -731973258,
a7d80411-8184-4e6e-80eb-a494ffb39b7e,
reference9,
"@:9",
name9,
"792d1edb686041e397246862887b331f"
]
reference3: !WireProperty [
7741702624161412808,
!int -1298385948,
"324e6e71-aa05-4871-b0ba-d70d931e2ea6",
reference3,
"@:3",
name3,
d7b7bb14f1e6438585c2ea9118c9ce6f
]On 13 February 2016 at 03:32, Gadi [email protected] wrote:
I created a pull request.
Failed tests:
WireCollectionTest.testMultipleReads:59 Cannot match property child
element WireProperty
WireCollectionTest.testMultipleReads:59 expected:<3> but was:<1>let me know what you think.
On a different note:
If the collection is empty you still get an empty array in the wire. SO I
created this check before to eliminate the extra empty collection writingif (properties.size() > 0) { wire.write(WireCollection.Values.PROPERTIES).marshallableAsMap(properties); } if (collections.size() > 0) { wire.write(WireCollection.Values.COLLECTIONS).marshallableAsMap(collections); }
in some cases the class name appears in the wire, I guess this is
necessary in case there are polymorphic classes and the collection can have
different specific types under the hood. ANy suggestions to clean this up?][
!net.openhft.chronicle.wire.reuse.WireCollection [
8426082448332188729,
!int -47647815,
"2c791eb9-753b-4c72-ad23-63bdf66ae3f4",
reference3,
"@:3",
name3[Thanks again for your support.
—
Reply to this email directly or view it on GitHub
#15 (comment)
.
from chronicle-wire.
The toString for the random WireCollection now looks like
id: 234234234
revision: 23
key: "6cbb88a5-b24c-4144-87ca-df1dc05faf58"
reference: reference
path: @
name: name
properties: {
reference7: { id: -1378134787947258651, revision: -860625809, key:
"231f4fff-c6ec-4e41-a375-e6096a9c1f62", reference: reference7, path: "@:7",
name: name7, value: "8360f68ecf474b3bb017aff65d10b0ae" },
reference8: { id: 3796602193238203700, revision: -1117270406, key:
ae5fff3a-cde9-42a2-8f13-381e080b3e94, reference: reference8, path: "@:8",
name: name8, value: cff987dcfe2548729a3f49c9571f51c7 },
reference9: { id: 4093892018757645835, revision: 1300709420, key:
"348d8b5c-8cca-4d4c-a87f-ef614ada31d7", reference: reference9, path: "@:9",
name: name9, value: "8afcdd9a08d9417ab3940790efb8fedf" },
reference3: { id: 3703192364200711998, revision: 824693184, key:
"05b6d19f-bdec-40ea-93ac-f9a32cc4cd23", reference: reference3, path: "@:3",
name: name3, value: "18bc49f502e14457b7f00638c011f813" },
reference4: { id: 7633232404783378963, revision: -1014084408, key:
"5894cd04-44d4-4f8d-9156-992ef60e99b3", reference: reference4, path: "@:4",
name: name4, value: c869fe39952a4c01be2aff1d3a2d7593 },
reference5: { id: -654517402135093390, revision: 1275967644, key:
"3b50718a-9af5-4ab7-98cb-c3dd858bb3d9", reference: reference5, path: "@:5",
name: name5, value: e736ac9afef94efbae2aed1da23a5b02 },
reference6: { id: -1663295654902626957, revision: 279328039, key:
"3bf89d95-d76f-4df6-bf81-a33fbe833e2d", reference: reference6, path: "@:6",
name: name6, value: "1d8c43b9c9a54fa3b1f27005a73c5ba0" },
reference1: { id: 329865317752132836, revision: -1200820035, key:
abc116a7-04a2-40d0-b89a-65a334c1c18c, reference: reference1, path: "@:1",
name: name1, value: d0338c4a6b4b4b1b90bc0d94c446bf83 },
reference2: { id: 113453255235637683, revision: 84305237, key:
"4e83a8c7-c799-4aae-8930-ee0389ea8bce", reference: reference2, path: "@:2",
name: name2, value: b2e2c6ce061546c2bd4d18183dec29c4 }
}
collections: {
reference3: {
id: 3845722779839431780,
revision: -412869519,
key: "710e32ba-13a4-4943-b83d-a82dcf24e99e",
reference: reference3,
path: "@:3",
name: name3,
properties: {
reference3: { id: -8291590071434083652, revision: 1845562311, key:
"96911884-024b-43a7-a446-10bc6e9e991d", reference: reference3, path:
"@:3-3", name: name3, value: "0ce9e850c9de49338255530416e8413c" },
reference1: { id: -4212377675553044477, revision: 365285698, key:
de9ad2bf-176c-441d-9938-33581c69f326, reference: reference1, path: "@:3-1",
name: name1, value: "5c01ce52ac384be6962c9095e6fd068b" },
reference2: { id: 1799532890313653854, revision: -96717494, key:
"0b560e1e-157c-4dd9-ab71-b2567b15d5e5", reference: reference2, path:
"@:3-2", name: name2, value: "3496afa0745540eeba578aa190bfde8e" }
}
},
reference1: {
id: 6891895605267261644,
revision: -1170165399,
key: "6922eab3-604a-478d-9c96-9cf49ca8100b",
reference: reference1,
path: "@:1",
name: name1,
properties: {
reference3: { id: -344787303413512347, revision: 699991691, key:
"2d8bcb29-d94e-4d4c-a363-e05ce852d5b8", reference: reference3, path:
"@:1-3", name: name3, value: b1408862ad62413c855c1421210a1d22 },
reference1: { id: -2453672433290944896, revision: 1589198342, key:
"387ec1ce-cbc9-429c-a502-30934a6a92a8", reference: reference1, path:
"@:1-1", name: name1, value: df5d7116fc1e454d84089c95ed447a4f },
reference2: { id: 3870629044623399982, revision: 1735308014, key:
ce383d21-8155-4200-b268-e9c8eae067be, reference: reference2, path: "@:1-2",
name: name2, value: "4278c4a72b944d6e9231741a67af2c02" }
}
},
reference2: {
id: 5049260818097187356,
revision: 176543070,
key: "2751f943-c4e3-4f82-b500-f9e9471c217a",
reference: reference2,
path: "@:2",
name: name2,
properties: {
reference3: { id: -691621033846215588, revision: -452178485, key:
a25ed756-cd3d-4f43-ba92-a7d8dfb25df2, reference: reference3, path: "@:2-3",
name: name3, value: "50c4992b85614757a8ea18eca8b038ee" },
reference1: { id: -5444529600601341973, revision: -1827346947, key:
afbb71c1-1a9b-4b9e-b0c1-b878d5a0494c, reference: reference1, path: "@:2-1",
name: name1, value: c453e796b6cc47c5b6201c1dbc97764f },
reference2: { id: -6573994050202780983, revision: -754379721, key:
"99f6edff-dc5d-49a9-afef-51e72dd9dafc", reference: reference2, path:
"@:2-2", name: name2, value: e1b821a030a6497883a18fd0f6e4694f }
}
}
}
On 13 February 2016 at 08:28, Peter Lawrey [email protected]
wrote:
To add toString, equals, hashCode you just need to add the following
methods and as long as the writeMarshallable methods are up to date, this
will be correct.@OverRide
public int hashCode() {
return HashWire.hash32(this);
}@OverRide
public boolean equals(Object obj) {
return obj instanceof WriteMarshallable &&
obj.toString().equals(toString());
}@OverRide
public String toString() {
return WireType.TEXT.asString(this);
}On 13 February 2016 at 08:24, Peter Lawrey <
[email protected]> wrote:Hello Gabi,
Thank you for the unit test. I was able to find the bug quite quickly
(and have committed a fix)The output for numbered fields now looks like.
--- !!meta-data #binary
"0": 234234234
"1": 23
"8": "38432228-f85c-4a43-9499-c5636c94de3d"
"4": reference
"5": @
"6": name
"2": [
reference7: !WireProperty [
"0": -2473783008384263129,
"1": 996207328,
"8": "2fa10878-f87d-4a6a-9378-2d7899acfaaf",
"4": reference7,
"5": "@:7",
"6": name7,
"7": "7567ca01b7b7435b80cba2b25c54180d"
]
reference8: !WireProperty [
"0": 7813252551544261374,
"1": !int -1455156808,
"8": b04cd400-9266-4cb5-9a59-f1512366f8c9,
"4": reference8,
"5": "@:8",
"6": name8,
"7": aa362e2e3ff346a7b0a7c45c6eb89133
]
reference9: !WireProperty [
"0": -4078949010835680613,
"1": 241021037,
"8": "74933db6-adbe-4d96-8734-230e64724fb6",
"4": reference9,
"5": "@:9",
"6": name9,
"7": cb0f73f2da2e450fa10db4d138075269
]
reference3: !WireProperty [
"0": -3447705347187420950,
"1": !int -243598213,
"8": d4750faa-dbb8-4e2b-bc73-470e295ac1aa,
"4": reference3,
"5": "@:3",
"6": name3,
"7": fd460c7c0ccf44cea8c22a791a52de1e
]
reference4: !WireProperty [
"0": 8493808251427423191,
"1": 648409363,
"8": "08db865f-95ff-4e76-872f-9af001ef593e",
"4": reference4,
"5": "@:4",
"6": name4,
"7": "1afd8d5f88dc4b57b7ff45bdc52dd3cd"
]
reference5: !WireProperty [
"0": -1958360471934516811,
"1": !int -1847639601,
"8": "50af4f11-cd86-4d66-baf5-bce083646182",
"4": reference5,
"5": "@:5",
"6": name5,
"7": "520f02f33c0a464d9fd9de4a0789cd12"
]
reference6: !WireProperty [
"0": 2956160254387511097,
"1": !int -325989312,
"8": d78f6930-badb-4d44-9a9e-76e0b7f0014d,
"4": reference6,
"5": "@:6",
"6": name6,
"7": f53821258f9f4236a0a92255d9bca8b2
]
reference1: !WireProperty [
"0": 1920184879057585000,
"1": 672916719,
"8": "1afca66b-0c43-4ea5-8d7e-f3a106129846",
"4": reference1,
"5": "@:1",
"6": name1,
"7": ea7673d93830443bb3ee08d03bb09d51
]
reference2: !WireProperty [
"0": 3685197974110234027,
"1": 1708461762,
"8": "03838103-e0cb-4ead-b8b6-980f5110a418",
"4": reference2,
"5": "@:2",
"6": name2,
"7": "6596e4da49584a4eae2cb21eec248b9d"
]
]The output for named fields now looks like
--- !!meta-data
id: 234234234
revision: 23
key: "20617f19-1781-4f40-98c9-61ffa5dba21e"
reference: reference
path: @
name: name
properties: {
reference7: !WireProperty { id: 9020901677846458544, revision:
679950018, key: "6c606d4e-71a9-4b17-8523-1dcb9c088d23", reference:
reference7, path: "@:7", name: name7, value:
"63f20cbc33f0481b8234930d69a09520" },
reference8: !WireProperty { id: -6735319603169159958, revision:
862355910, key: "3fe7ad73-7f8a-45b6-af4e-435bc8fd0b1d", reference:
reference8, path: "@:8", name: name8, value:
"2afe3c88364041c8acaa56f4b35bc53b" },
reference9: !WireProperty { id: 2239969738209127675, revision:
-279215100, key: "7fae7281-7c18-4487-a2f5-4e3499f525ae", reference:
reference9, path: "@:9", name: name9, value:
"554fcb098c024e2da135186bea0a5ba3" },
reference3: !WireProperty { id: 8390695552422707165, revision:
-147514553, key: "926e552c-e395-4c2f-80e6-5d6de1f84b7b", reference:
reference3, path: "@:3", name: name3, value:
a4da0ad3ed684003949e971fa8699d27 },
reference4: !WireProperty { id: -978531391916948535, revision:
524865454, key: dd8d9eef-ce7d-4423-a781-06605e37b011, reference:
reference4, path: "@:4", name: name4, value:
bec03d70d0e6482e81b7bb0e357f3d92 },
reference5: !WireProperty { id: 3374944958029627633, revision:
-398086406, key: "0a1e056e-e6e7-4e11-b303-c293c6fdf5f3", reference:
reference5, path: "@:5", name: name5, value:
"69813084c39d4936b69b0dde0f0c0ed5" },
reference6: !WireProperty { id: -8433021096891598682, revision:
-736117722, key: "776461da-264a-4827-aeea-3a4d2ef5a8ba", reference:
reference6, path: "@:6", name: name6, value:
"3367fa70b0e14aed80abc5172414134c" },
reference1: !WireProperty { id: -142490954081820345, revision:
-318848728, key: "2205a065-a732-40c1-a635-b421f8f8cba6", reference:
reference1, path: "@:1", name: name1, value:
"6fafe5346ddc4ec18d80f45104332eac" },
reference2: !WireProperty { id: 2991033472590306421, revision:
1566613018, key: d8f3385b-c268-4d0c-88bd-d9883ca31ab4, reference:
reference2, path: "@:2", name: name2, value:
"74641a3b78b64837a67433a30b40016f" }
}the output for field less now looks like, this is the most difficult to
read as it has the least information. If you wanted to make it readable,
you would parse the data, and print the parsed data (note I added a
toString()) method for you.--- !!meta-data #binary
234234234
23
f4a93b1e-9c86-4fc3-8c8e-529a034a506e
reference
@
name
[
reference7: !WireProperty [
115906392025424068,
154486320,
"22711f61-923c-41fc-92b3-0e2ca5c3f6a8",
reference7,
"@:7",
name7,
"6c63fa3a28894b0ca770af1688ad8fb6"
]
reference8: !WireProperty [
6431574489447352160,
1976658183,
"6d23c6dd-91b8-4c8c-bcca-4516c4b42313",
reference8,
"@:8",
name8,
a68645912c6f4556afebaa1c1a9c8572
]
reference9: !WireProperty [
3357362923123882492,
!int -731973258,
a7d80411-8184-4e6e-80eb-a494ffb39b7e,
reference9,
"@:9",
name9,
"792d1edb686041e397246862887b331f"
]
reference3: !WireProperty [
7741702624161412808,
!int -1298385948,
"324e6e71-aa05-4871-b0ba-d70d931e2ea6",
reference3,
"@:3",
name3,
d7b7bb14f1e6438585c2ea9118c9ce6f
]On 13 February 2016 at 03:32, Gadi [email protected] wrote:
I created a pull request.
Failed tests:
WireCollectionTest.testMultipleReads:59 Cannot match property child
element WireProperty
WireCollectionTest.testMultipleReads:59 expected:<3> but was:<1>let me know what you think.
On a different note:
If the collection is empty you still get an empty array in the wire. SO
I created this check before to eliminate the extra empty collection writingif (properties.size() > 0) { wire.write(WireCollection.Values.PROPERTIES).marshallableAsMap(properties); } if (collections.size() > 0) { wire.write(WireCollection.Values.COLLECTIONS).marshallableAsMap(collections); }
in some cases the class name appears in the wire, I guess this is
necessary in case there are polymorphic classes and the collection can have
different specific types under the hood. ANy suggestions to clean this up?][
!net.openhft.chronicle.wire.reuse.WireCollection [
8426082448332188729,
!int -47647815,
"2c791eb9-753b-4c72-ad23-63bdf66ae3f4",
reference3,
"@:3",
name3[Thanks again for your support.
—
Reply to this email directly or view it on GitHub
#15 (comment)
.
from chronicle-wire.
Thank you! yes, looking very concise.
Is it a must to have all the keys in the same enum?
from chronicle-wire.
It's not a must, but it does reduce duplication. You don't have to use
enums at all provided the reader will accept the fields written. enums is
just a simple way to a) ensure that the writer and reader use the same
names b) define the code() to use if you have numbered fields.
On 13 February 2016 at 12:07, Gadi [email protected] wrote:
Thank you! yes, looking very concise.
Is it a must to have all the keys in the same enum?—
Reply to this email directly or view it on GitHub
#15 (comment)
.
from chronicle-wire.
Released in Chronicle-Wire-2.20.101, BOM-2.20.134
from chronicle-wire.
Related Issues (20)
- ServiceCfg fails to read it's own YAML HOT 3
- The classloader complains about jdk.xxx packages being sealed when testing is running concurrently on Java 17+ HOT 1
- Add sub-sequence parse() to LongConverter HOT 1
- Marshallable.copyTo should not validate destination object HOT 2
- Wire does not use overridden ClassLookup for Classes HOT 2
- Flatten the call stack for Method Readers HOT 2
- Trivially copyable issues on Mac M1 JDK 17+ HOT 1
- WireType.JSON_ONLY incorrectly parses nested maps
- BinaryWire.text(CharSequence) with long strings inefficiently calls findUtf8Length() twice HOT 4
- Improve efficiency of writing MessageHistory as bytes HOT 1
- Support SizeLongConvertor for K, M, G, T suffix sizes HOT 1
- Add README Documentation for the different supported LongConverters
- commentListener is called multiple times when TextWire saves and reads unexpected fields HOT 1
- Investigate unsafe reuse of StringBuilder in YamlWireOut
- Fix MessageHistoryTest to run with history.as.bytes=true on mac
- JSONWire to parse doubles/ints surrounded by quotes HOT 2
- SelfDescribingTriviallyCopyable fails on Mac with Java17 or newer
- examples in documentation need to be updated to latest version of code
- Wire MethodReader fails to clear List before populating HOT 4
- Anchor is ignored and alias is not found when dealing with text fields HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chronicle-wire.