org.apache.hadoop.hbase.types
Class StructIterator

java.lang.Object
  extended by org.apache.hadoop.hbase.types.StructIterator
All Implemented Interfaces:
Iterator<Object>

@InterfaceAudience.Public
@InterfaceStability.Evolving
public class StructIterator
extends Object
implements Iterator<Object>

An Iterator over encoded Struct members.

This iterates over each serialized Struct field from the specified DataTypes<?>[] definition. It allows you to read the field or skip over its serialized bytes using next() and skip(), respectively. This is in contrast to the Struct method which allow you to Struct.decode(PositionedByteRange) or Struct.skip(PositionedByteRange) over the entire Struct at once.

This iterator may also be used to read bytes from any Struct for which the specified DataType<?>[] is a prefix. For example, if the specified Struct definition has a RawInteger and a RawStringTerminated field, you may parse the serialized output of a Struct whose fields are RawInteger, RawStringTerminated, and RawBytes. The iterator would return a number followed by a String. The trailing byte[] would be ignored.


Field Summary
protected  int idx
           
protected  PositionedByteRange src
           
protected  DataType[] types
           
 
Constructor Summary
StructIterator(PositionedByteRange src, DataType[] types)
          Construct StructIterator over the values encoded in src using the specified types definition.
 
Method Summary
 boolean hasNext()
           
 Object next()
           
 void remove()
           
 int skip()
          Bypass the next encoded value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

src

protected final PositionedByteRange src

idx

protected int idx

types

protected final DataType[] types
Constructor Detail

StructIterator

public StructIterator(PositionedByteRange src,
                      DataType[] types)
Construct StructIterator over the values encoded in src using the specified types definition.

Parameters:
src - The buffer from which to read encoded values.
types - The sequence of types to use as the schema for this Struct.
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<Object>

remove

public void remove()
Specified by:
remove in interface Iterator<Object>

next

public Object next()
Specified by:
next in interface Iterator<Object>

skip

public int skip()
Bypass the next encoded value.

Returns:
the number of bytes skipped.


Copyright © 2007–2015 The Apache Software Foundation. All rights reserved.