From c2fa25fdb60b5cd69a75182d8f8f74b8ebf09717 Mon Sep 17 00:00:00 2001 From: Rick Kellogg Date: Fri, 4 Sep 2015 16:55:58 -0400 Subject: [PATCH 1/4] STORM-1020 - Added Javadoc to Fields and ITuple. --- .../src/jvm/backtype/storm/tuple/Fields.java | 21 ++- .../src/jvm/backtype/storm/tuple/ITuple.java | 126 ++++++++++++++---- 2 files changed, 121 insertions(+), 26 deletions(-) diff --git a/storm-core/src/jvm/backtype/storm/tuple/Fields.java b/storm-core/src/jvm/backtype/storm/tuple/Fields.java index 9805ba6bc7a..3eed409ba65 100644 --- a/storm-core/src/jvm/backtype/storm/tuple/Fields.java +++ b/storm-core/src/jvm/backtype/storm/tuple/Fields.java @@ -25,6 +25,9 @@ import java.util.Map; import java.io.Serializable; +/** + * Collection of unique named fields using in an ITuple + */ public class Fields implements Iterable, Serializable { private List _fields; private Map _index = new HashMap(); @@ -57,10 +60,20 @@ public List toList() { return new ArrayList(_fields); } + /** + * Returns the number of fields in this collection. + */ public int size() { return _fields.size(); } + /** + * Gets the field at position index in the collection. + * + * @param index index of the field to return + * + * @throws IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()) + */ public String get(int index) { return _fields.get(index); } @@ -70,7 +83,11 @@ public Iterator iterator() { } /** - * Returns the position of the specified field. + * Returns the position of the specified named field. + * + * @param field Named field to evaluate + * + * @throws IllegalArgumentException - if field does not exist */ public int fieldIndex(String field) { Integer ret = _index.get(field); @@ -81,7 +98,7 @@ public int fieldIndex(String field) { } /** - * Returns true if this contains the specified name of the field. + * @returns true if this contains the specified name of the field. */ public boolean contains(String field) { return _index.containsKey(field); diff --git a/storm-core/src/jvm/backtype/storm/tuple/ITuple.java b/storm-core/src/jvm/backtype/storm/tuple/ITuple.java index c85848d7f56..4d6292ebab9 100644 --- a/storm-core/src/jvm/backtype/storm/tuple/ITuple.java +++ b/storm-core/src/jvm/backtype/storm/tuple/ITuple.java @@ -37,8 +37,10 @@ public interface ITuple { public Fields getFields(); /** - * Returns the position of the specified field in this tuple. - */ + * Returns the position of the specified field in this tuple. + * + * @throws IllegalArgumentException - if field does not exist + */ public int fieldIndex(String field); /** @@ -47,83 +49,161 @@ public interface ITuple { public List select(Fields selector); /** - * Gets the field at position i in the tuple. Returns object since tuples are dynamically typed. + * Gets the field at position i in the tuple. Returns object since tuples are dynamically typed. + * + * @throws IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()) */ public Object getValue(int i); /** - * Returns the String at position i in the tuple. If that field is not a String, - * you will get a runtime error. + * Returns the String at position i in the tuple. + * + * @throws ClassCastException If that field is not a String + * @throws IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()) */ public String getString(int i); /** - * Returns the Integer at position i in the tuple. If that field is not an Integer, - * you will get a runtime error. + * Returns the Integer at position i in the tuple. + * + * @throws ClassCastException If that field is not a Integer + * @throws IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()) */ public Integer getInteger(int i); /** - * Returns the Long at position i in the tuple. If that field is not a Long, - * you will get a runtime error. + * Returns the Long at position i in the tuple. + * + * @throws ClassCastException If that field is not a Long + * @throws IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()) */ public Long getLong(int i); /** - * Returns the Boolean at position i in the tuple. If that field is not a Boolean, - * you will get a runtime error. + * Returns the Boolean at position i in the tuple. + * + * @throws ClassCastException If that field is not a Boolean + * @throws IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()) */ public Boolean getBoolean(int i); /** - * Returns the Short at position i in the tuple. If that field is not a Short, - * you will get a runtime error. + * Returns the Short at position i in the tuple. + * + * @throws ClassCastException If that field is not a Short + * @throws IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()) */ public Short getShort(int i); /** - * Returns the Byte at position i in the tuple. If that field is not a Byte, - * you will get a runtime error. + * Returns the Byte at position i in the tuple. + * + * @throws ClassCastException If that field is not a Byte + * @throws IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()) */ public Byte getByte(int i); /** - * Returns the Double at position i in the tuple. If that field is not a Double, - * you will get a runtime error. + * Returns the Double at position i in the tuple. + * + * @throws ClassCastException If that field is not a Double + * @throws IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()) */ public Double getDouble(int i); /** - * Returns the Float at position i in the tuple. If that field is not a Float, - * you will get a runtime error. + * Returns the Float at position i in the tuple. + * + * @throws ClassCastException If that field is not a Float + * @throws IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()) */ public Float getFloat(int i); /** - * Returns the byte array at position i in the tuple. If that field is not a byte array, - * you will get a runtime error. + * Returns the byte array at position i in the tuple. + * + * @throws ClassCastException If that field is not a byte array + * @throws IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()) */ public byte[] getBinary(int i); - + /** + * Gets the field with a specific name. Returns object since tuples are dynamically typed. + * + * @throws IllegalArgumentException - if field does not exist + */ public Object getValueByField(String field); + /** + * Gets the String field with a specific name. + * + * @throws ClassCastException If that field is not a String + * @throws IllegalArgumentException - if field does not exist + */ public String getStringByField(String field); + /** + * Gets the Integer field with a specific name. + * + * @throws ClassCastException If that field is not an Integer + * @throws IllegalArgumentException - if field does not exist + */ public Integer getIntegerByField(String field); + /** + * Gets the Long field with a specific name. + * + * @throws ClassCastException If that field is not a Long + * @throws IllegalArgumentException - if field does not exist + */ public Long getLongByField(String field); + /** + * Gets the Boolean field with a specific name. + * + * @throws ClassCastException If that field is not a Boolean + * @throws IllegalArgumentException - if field does not exist + */ public Boolean getBooleanByField(String field); + /** + * Gets the Short field with a specific name. + * + * @throws ClassCastException If that field is not a Short + * @throws IllegalArgumentException - if field does not exist + */ public Short getShortByField(String field); + /** + * Gets the Byte field with a specific name. + * + * @throws ClassCastException If that field is not a Byte + * @throws IllegalArgumentException - if field does not exist + */ public Byte getByteByField(String field); + /** + * Gets the Double field with a specific name. + * + * @throws ClassCastException If that field is not a Double + * @throws IllegalArgumentException - if field does not exist + */ public Double getDoubleByField(String field); + /** + * Gets the Float field with a specific name. + * + * @throws ClassCastException If that field is not a Float + * @throws IllegalArgumentException - if field does not exist + */ public Float getFloatByField(String field); + /** + * Gets the Byte array field with a specific name. + * + * @throws ClassCastException If that field is not a byte array + * @throws IllegalArgumentException - if field does not exist + */ public byte[] getBinaryByField(String field); /** @@ -131,6 +211,4 @@ public interface ITuple { */ public List getValues(); - - } From ff1962af41f6b3a54e48aee761778ec9ac9c3ef0 Mon Sep 17 00:00:00 2001 From: Rick Kellogg Date: Fri, 4 Sep 2015 17:18:25 -0400 Subject: [PATCH 2/4] Force Travis rebuild --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39cd49ada0c..2533630aff5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.11.0 +## 0.11.0 * STORM-1010: Each KafkaBolt could have a specified properties. * STORM-1008: Isolate the code for metric collection and retrieval from DisruptorQueue * STORM-991: General cleanup of the generics (storm.trident.spout package) From 928ce06359f38c07e9f5f6b9e403ba55317dee43 Mon Sep 17 00:00:00 2001 From: Rick Kellogg Date: Fri, 4 Sep 2015 18:12:08 -0400 Subject: [PATCH 3/4] Force Travis rebuild. --- storm-core/src/jvm/backtype/storm/tuple/Fields.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storm-core/src/jvm/backtype/storm/tuple/Fields.java b/storm-core/src/jvm/backtype/storm/tuple/Fields.java index 3eed409ba65..5a3d5f4673b 100644 --- a/storm-core/src/jvm/backtype/storm/tuple/Fields.java +++ b/storm-core/src/jvm/backtype/storm/tuple/Fields.java @@ -26,7 +26,7 @@ import java.io.Serializable; /** - * Collection of unique named fields using in an ITuple + * Collection of unique named fields using in an ITuple */ public class Fields implements Iterable, Serializable { private List _fields; From 802f0f00a03eb7a81f868cba9d40c5dd2c2935c1 Mon Sep 17 00:00:00 2001 From: Rick Kellogg Date: Fri, 4 Sep 2015 19:12:48 -0400 Subject: [PATCH 4/4] Added STORM-1020 to CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39cd49ada0c..f6c62ea00e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ## 0.11.0 + * STORM-1020: Added Javadoc to Fields and ITuple. * STORM-1010: Each KafkaBolt could have a specified properties. * STORM-1008: Isolate the code for metric collection and retrieval from DisruptorQueue * STORM-991: General cleanup of the generics (storm.trident.spout package)