Thrift: getting rid of U32s for map/list/set/string lengths and field ids etc.
Summary: U32s are on the out. Make way for the I32.
Reviewed By: aditya
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664718 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/java/src/protocol/TBinaryProtocol.java b/lib/java/src/protocol/TBinaryProtocol.java
index 3aaa06b..b2e77d9 100644
--- a/lib/java/src/protocol/TBinaryProtocol.java
+++ b/lib/java/src/protocol/TBinaryProtocol.java
@@ -23,7 +23,7 @@
TField field) throws TException {
return
writeByte(out, field.type.getCode()) +
- writeU32(out, field.id);
+ writeI32(out, field.id);
}
public int writeFieldEnd (TTransport out) throws TException {
@@ -40,7 +40,7 @@
return
writeByte(out, map.keyType.getCode()) +
writeByte(out, map.valueType.getCode()) +
- writeU32(out, map.size);
+ writeI32(out, map.size);
}
public int writeMapEnd (TTransport out) throws TException {
@@ -51,7 +51,7 @@
TList list) throws TException {
return
writeByte(out, list.elemType.getCode()) +
- writeU32(out, list.size);
+ writeI32(out, list.size);
}
public int writeListEnd (TTransport out) throws TException {
@@ -62,7 +62,7 @@
TSet set) throws TException {
return
writeByte(out, set.elemType.getCode()) +
- writeU32(out, set.size);
+ writeI32(out, set.size);
}
public int writeSetEnd (TTransport out) throws TException {
@@ -102,7 +102,7 @@
public int writeString (TTransport out,
TString str) throws TException {
byte[] dat = str.value.getBytes();
- int sent = writeU32(out, new UInt32(dat.length));
+ int sent = writeI32(out, new Int32(dat.length));
out.write(dat, 0, dat.length);
return sent + dat.length;
}
@@ -129,10 +129,10 @@
recv += readByte(in, t);
field.type = TType.getType(t);
if (field.type.equals(TType.STOP)) {
- field.id = new UInt32(0);
+ field.id = new Int32(0);
return recv;
}
- recv += readU32(in, field.id);
+ recv += readI32(in, field.id);
return recv;
}
@@ -148,7 +148,7 @@
map.keyType = TType.getType(t);
recv += readByte(in, t);
map.valueType = TType.getType(t);
- recv += readU32(in, map.size);
+ recv += readI32(in, map.size);
return recv;
}
@@ -162,7 +162,7 @@
UInt8 t = new UInt8();
recv += readByte(in, t);
list.elemType = TType.getType(t);
- recv += readU32(in, list.size);
+ recv += readI32(in, list.size);
return recv;
}
@@ -176,7 +176,7 @@
UInt8 t = new UInt8();
recv += readByte(in, t);
set.elemType = TType.getType(t);
- recv += readU32(in, set.size);
+ recv += readI32(in, set.size);
return recv;
}
@@ -226,11 +226,11 @@
public int readString (TTransport in,
TString s) throws TException {
- UInt32 size = new UInt32();
- int recv = readU32(in, size);
- byte[] buf = new byte[size.toInt()];
- in.readAll(buf, 0, size.toInt());
+ Int32 size = new Int32();
+ int recv = readI32(in, size);
+ byte[] buf = new byte[size.get()];
+ in.readAll(buf, 0, size.get());
s.value = new String(buf);
- return recv + size.toInt();
+ return recv + size.get();
}
}
diff --git a/lib/java/src/protocol/TField.java b/lib/java/src/protocol/TField.java
index 83f1fc3..d758c68 100644
--- a/lib/java/src/protocol/TField.java
+++ b/lib/java/src/protocol/TField.java
@@ -11,10 +11,10 @@
public TField() {}
public TField(String n, TType t, int i) {
- this(n, t, new UInt32(i));
+ this(n, t, new Int32(i));
}
- public TField(String n, TType t, UInt32 i) {
+ public TField(String n, TType t, Int32 i) {
name = n;
type = t;
id = i;
@@ -22,5 +22,5 @@
public String name = "";
public TType type = TType.STOP;
- public UInt32 id = new UInt32();
+ public Int32 id = new Int32();
}
diff --git a/lib/java/src/protocol/TList.java b/lib/java/src/protocol/TList.java
index 6eac06b..ff76ffd 100644
--- a/lib/java/src/protocol/TList.java
+++ b/lib/java/src/protocol/TList.java
@@ -11,14 +11,14 @@
public TList() {}
public TList(TType t, int s) {
- this(t, new UInt32(s));
+ this(t, new Int32(s));
}
- public TList(TType t, UInt32 s) {
+ public TList(TType t, Int32 s) {
elemType = t;
size = s;
}
public TType elemType = TType.STOP;
- public UInt32 size = new UInt32();
+ public Int32 size = new Int32();
}
diff --git a/lib/java/src/protocol/TMap.java b/lib/java/src/protocol/TMap.java
index 84eb468..f251fa6 100644
--- a/lib/java/src/protocol/TMap.java
+++ b/lib/java/src/protocol/TMap.java
@@ -11,10 +11,10 @@
public TMap() {}
public TMap(TType k, TType v, int s) {
- this(k, v, new UInt32(s));
+ this(k, v, new Int32(s));
}
- public TMap(TType k, TType v, UInt32 s) {
+ public TMap(TType k, TType v, Int32 s) {
keyType = k;
valueType = v;
size = s;
@@ -22,5 +22,5 @@
public TType keyType = TType.STOP;
public TType valueType = TType.STOP;
- public UInt32 size = new UInt32();;
+ public Int32 size = new Int32();;
}
diff --git a/lib/java/src/protocol/TSet.java b/lib/java/src/protocol/TSet.java
index e0dcf76..fa6e24d 100644
--- a/lib/java/src/protocol/TSet.java
+++ b/lib/java/src/protocol/TSet.java
@@ -11,14 +11,14 @@
public TSet() {}
public TSet(TType t, int s) {
- this(t, new UInt32(s));
+ this(t, new Int32(s));
}
- public TSet(TType t, UInt32 s) {
+ public TSet(TType t, Int32 s) {
elemType = t;
size = s;
}
public TType elemType = TType.STOP;
- public UInt32 size = new UInt32();
+ public Int32 size = new Int32();
}