Decoder that performs type-resolution between the reader's and
writer's schemas.
When resolving schemas, this class will return the values of fields in
_writer's_ order, not the reader's order. (However, it returns _only_ the
reader's fields, not any extra fields the writer may have written.) To help
clients handle fields that appear to be coming out of order, this class
defines the method readFieldOrder.
See the parser documentation for information on how this works.
| Modifier and Type | Field and Description |
|---|---|
| private Decoder |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| private | ResolvingDecoder(Object
The resolver to use. resolver, Decoder The underlying decoder. in)Constructs a ResolvingDecoder using the given resolver. |
| Modifier and Type | Method and Description |
|---|---|
| public Symbol | doAction(Symbol
The input symbol from the caller of advance input, Symbol The symbol at the top the stack. top)Overrides org. Implements org. |
| public final void | drain()
Consume any more data that has been written by the writer but not needed by the reader so that the the underlying decoder is in proper shape for the next record. |
| public ByteBuffer | readBytes(ByteBuffer old)
Overrides org. Encoder#writeBytes.
|
| public double | readDouble()
Overrides org. Encoder#writeDouble.
|
| public int | |
| public final Schema. | readFieldOrder()
Returns the actual order in which the reader's fields will be returned to the reader. |
| public final Schema. | readFieldOrderIfDiff()
Same as |
| public float | readFloat()
Overrides org. Encoder#writeFloat.
|
| public int | readIndex()
Overrides org. Encoder#writeIndex.
|
| public long | readLong()
Overrides org. Encoder#writeLong.
|
| public Utf8 | readString(Utf8 old)
Overrides org. Encoder#writeString.
|
| public String | readString()
Overrides org. Encoder#writeString.
|
| public static Object | Returns: The opaque resolver.The writer's schema. Cannot be null. writer, Schema The reader's schema. Cannot be null. reader)Produces an opaque resolver that can be used to construct a new
|
| public void | skipAction()
Overrides org. Implements org. |
| public void | skipBytes()
Overrides org. Encoder#writeBytes.
|
| public void | skipString()
Overrides org. Encoder#writeString.
|
| backup | back to summary |
|---|---|
| private Decoder backup | |
| ResolvingDecoder | back to summary |
|---|---|
| pack-priv ResolvingDecoder(Schema writer, Schema reader, Decoder in) throws IOException | |
| ResolvingDecoder | back to summary |
|---|---|
| private ResolvingDecoder(Object resolver, Decoder in) throws IOException Constructs a ResolvingDecoder using the given resolver. The resolver
must have been returned by a previous call to
| |
| doAction | back to summary |
|---|---|
| public Symbol doAction(Symbol input, Symbol top) throws IOException Overrides org. Implements org. Doc from org. Handle the action symbol top when the input is sought to be taken off the stack. | |
| drain | back to summary |
|---|---|
| public final void drain() throws IOException Consume any more data that has been written by the writer but not needed by the reader so that the the underlying decoder is in proper shape for the next record. This situation happens when, for example, the writer writes a record with two fields and the reader needs only the first field. This function should be called after completely decoding an object but before next object can be decoded from the same underlying decoder either directly or through another resolving decoder. If the same resolving decoder is used for the next object as well, calling this method is optional; the state of this resolving decoder ensures that any leftover portions are consumed before the next object is decoded. | |
| readBytes | back to summary |
|---|---|
| public ByteBuffer readBytes(ByteBuffer old) throws IOException Overrides org. Doc from org. Reads a byte-string written by
| |
| readDouble | back to summary |
|---|---|
| public double readDouble() throws IOException Overrides org. Doc from org. Reads a double written by
| |
| readEnum | back to summary |
|---|---|
| public int readEnum() throws IOException Overrides org. Doc from org. Reads an enumeration.
| |
| readFieldOrder | back to summary |
|---|---|
| public final Schema. Returns the actual order in which the reader's fields will be returned to the
reader.
This method is useful because
Schema.Fields[] fieldOrder = in.readFieldOrder();
for (int i = 0; i < 3; i++) {
switch (fieldOrder[i].pos()) {
case 1:
foo(in.readLong());
break;
case 2:
someVariable = in.readString();
break;
case 3:
bar(in); // The code of "bar" will read an array-of-int
break;
}
Note that ResolvingDecoder will return only the fields expected by
the reader, not other fields that may have been written by the writer. Thus,
the iteration-count of "3" in the above loop will always be correct.
Throws a runtime exception if we're not just about to read the first field of
a record. (If the client knows the order of incoming fields, then the client
does not need to call this method but rather can just start reading
the field values.)
| |
| readFieldOrderIfDiff | back to summary |
|---|---|
| public final Schema. Same as | |
| readFloat | back to summary |
|---|---|
| public float readFloat() throws IOException Overrides org. Doc from org. Reads a float written by
| |
| readIndex | back to summary |
|---|---|
| public int readIndex() throws IOException Overrides org. Doc from org. Reads the tag of a union written by
| |
| readLong | back to summary |
|---|---|
| public long readLong() throws IOException Overrides org. Doc from org. Reads a long written by
| |
| readString | back to summary |
|---|---|
| public Utf8 readString(Utf8 old) throws IOException Overrides org. Doc from org. Reads a char-string written by
| |
| readString | back to summary |
|---|---|
| public String readString() throws IOException Overrides org. Doc from org. Reads a char-string written by
| |
| resolve | back to summary |
|---|---|
| public static Object resolve(Schema writer, Schema reader) throws IOException Produces an opaque resolver that can be used to construct a new
| |
| skipAction | back to summary |
|---|---|
| public void skipAction() throws IOException Overrides org. Implements org. Doc from org. Skips the action at the top of the stack.
| |
| skipBytes | back to summary |
|---|---|
| public void skipBytes() throws IOException Overrides org. Doc from org. Discards a byte-string written by
| |
| skipString | back to summary |
|---|---|
| public void skipString() throws IOException Overrides org. Doc from org. Discards a char-string written by
| |