signature:
public class ImmutableMultimapSerializer { /** * Creates a new { @ link ImmutableMultimapSerializer } and registers its serializer
 * for the several ImmutableMultimap related classes .
 * @ param kryo the { @ link Kryo } instance to set the serializer on */
public static void registerSerializers ( final Kryo kryo ) { } }

implementation:
// ImmutableMap is used by ImmutableMultimap . However ,
// we already have a separate serializer class for ImmutableMap ,
// ImmutableMapSerializer . If it is not already being used , register it .
Serializer immutableMapSerializer = getSerializer ( kryo , ImmutableMap . class ) ; if ( ! ( immutableMapSerializer instanceof ImmutableMapSerializer ) ) { ImmutableMapSerializer . registerSerializers ( kryo ) ; } // ImmutableList is used by ImmutableListMultimap . However ,
// we already have a separate serializer class for ImmutableList ,
// ImmutableListSerializer . If it is not already being used , register it .
Serializer immutableListSerializer = getSerializer ( kryo , ImmutableList . class ) ; if ( ! ( immutableListSerializer instanceof ImmutableListSerializer ) ) { ImmutableListSerializer . registerSerializers ( kryo ) ; } // ImmutableSet is used by ImmutableSetMultimap . However ,
// we already have a separate serializer class for ImmutableSet ,
// ImmutableSetSerializer . If it is not already being used , register it .
Serializer immutableSetSerializer = getSerializer ( kryo , ImmutableSet . class ) ; if ( ! ( immutableSetSerializer instanceof ImmutableSetSerializer ) ) { ImmutableSetSerializer . registerSerializers ( kryo ) ; } final ImmutableMultimapSerializer serializer = new ImmutableMultimapSerializer ( ) ; // ImmutableMultimap ( abstract class )
// + - EmptyImmutableListMultimap
// + - ImmutableListMultimap
// + - EmptyImmutableSetMultimap
// + - ImmutableSetMultimap
kryo . register ( ImmutableMultimap . class , serializer ) ; kryo . register ( ImmutableListMultimap . of ( ) . getClass ( ) , serializer ) ; kryo . register ( ImmutableListMultimap . of ( "A" , "B" ) . getClass ( ) , serializer ) ; kryo . register ( ImmutableSetMultimap . of ( ) . getClass ( ) , serializer ) ; kryo . register ( ImmutableSetMultimap . of ( "A" , "B" ) . getClass ( ) , serializer ) ;


signature:
public class UnicodeBlockSerializer { /** * { @ inheritDoc } */
@ Override public void write ( final Kryo kryo , final Output output , final UnicodeBlock obj ) { } }

implementation: output . writeAscii ( BLOCK_NAMES . get ( obj ) ) ;


signature:
public class HashBasedTableSerializer { /** * Creates a new { @ link HashBasedTableSerializer } and registers its serializer .
 * @ param kryo the { @ link Kryo } instance to set the serializer on */
public static void registerSerializers ( final Kryo kryo ) { } }

implementation: final HashBasedTableSerializer serializer = new HashBasedTableSerializer ( ) ; kryo . register ( HashBasedTable . class , serializer ) ;


signature:
public class ImmutableSortedSetSerializer { /** * Creates a new { @ link ImmutableSortedSetSerializer } and registers its serializer
 * for the several ImmutableSortedSet related classes .
 * @ param kryo the { @ link Kryo } instance to set the serializer on */
public static void registerSerializers ( final Kryo kryo ) { } }

implementation:
// ImmutableSortedSet ( abstract class )
// + - EmptyImmutableSortedSet
// + - RegularImmutableSortedSet
// + - DescendingImmutableSortedSet
final ImmutableSortedSetSerializer serializer = new ImmutableSortedSetSerializer ( ) ; kryo . register ( ImmutableSortedSet . class , serializer ) ; kryo . register ( ImmutableSortedSet . of ( ) . getClass ( ) , serializer ) ; kryo . register ( ImmutableSortedSet . of ( "" ) . getClass ( ) , serializer ) ; kryo . register ( ImmutableSortedSet . of ( ) . descendingSet ( ) . getClass ( ) , serializer ) ;


signature:
public class TreeBasedTableSerializer { /** * Creates a new { @ link TreeBasedTableSerializer } and registers its serializer .
 * @ param kryo the { @ link Kryo } instance to set the serializer on */
public static void registerSerializers ( final Kryo kryo ) { } }

implementation: final TreeBasedTableSerializer serializer = new TreeBasedTableSerializer ( ) ; kryo . register ( TreeBasedTable . class , serializer ) ;


signature:
public class KryoReflectionFactorySupport { /** * { @ inheritDoc } */
@ Override @ SuppressWarnings ( "unchecked" ) public < T > T newInstance ( final Class < T > type ) { } }

implementation: if ( type == null ) { throw new IllegalArgumentException ( "type cannot be null." ) ; } Constructor < ? > constructor = _constructors . get ( type ) ; if ( constructor == null ) { constructor = getNoArgsConstructor ( type ) ; if ( constructor == null ) { constructor = newConstructorForSerialization ( type ) ; } _constructors . put ( type , constructor ) ; } return ( T ) newInstanceFrom ( constructor ) ;


signature:
public class UnmodifiableNavigableSetSerializer { /** * Creates a new { @ link UnmodifiableNavigableSetSerializer } and registers its serializer
 * for the UnmodifiableNavigableSetSerializer related class .
 * @ param kryo the { @ link Kryo } instance to set the serializer on */
public static void registerSerializers ( final Kryo kryo ) { } }

implementation:
// UnmodifiableNavigableSetSerializer ( private class )
final UnmodifiableNavigableSetSerializer serializer = new UnmodifiableNavigableSetSerializer ( ) ; kryo . register ( Sets . unmodifiableNavigableSet ( new TreeSet < Object > ( ) ) . getClass ( ) , serializer ) ;


signature:
public class FieldAnnotationAwareSerializer { /** * Adds an annotation to the annotations that are considered by this serializer .
 * < b > Important < / b > : This will not have an effect if the serializer was configured
 * to exclusively serialize annotated fields by setting { @ code disregarding } to
 * { @ code false } . This is similar to the contract of this serializer ' s superclass
 * { @ link FieldSerializer } which does not allow to add fields that were formerly
 * removed . If this was possible , instances that were serialized before this field
 * was added could not longer be properly deserialized . In order to make this contract
 * break explicit , you need to create a new instance of this serializer if you want to
 * include new fields to a serializer that exclusively serializes annotated fields .
 * @ param clazz The annotation class to be added .
 * @ return { @ code true } if the method call had an effect . */
public boolean addAnnotation ( final Class < ? extends Annotation > clazz ) { } }

implementation: if ( disregarding && marked . add ( clazz ) ) { initializeCachedFields ( ) ; return true ; } return false ;


signature:
public class FieldAnnotationAwareSerializer { /** * Removes an annotation to the annotations that are considered by this serializer .
 * < b > Important < / b > : This will not have an effect if the serializer was configured
 * to not serialize annotated fields by setting { @ code disregarding } to
 * { @ code true } . This is similar to the contract of this serializer ' s superclass
 * { @ link FieldSerializer } which does not allow to add fields that were formerly
 * removed . If this was possible , instances that were serialized before this field
 * was added could not longer be properly deserialized . In order to make this contract
 * break explicit , you need to create a new instance of this serializer if you want to
 * include new fields to a serializer that ignores annotated fields for serialization .
 * @ param clazz The annotation class to be removed .
 * @ return { @ code true } if the method call had an effect . */
public boolean removeAnnotation ( final Class < ? extends Annotation > clazz ) { } }

implementation: if ( ! disregarding && marked . remove ( clazz ) ) { initializeCachedFields ( ) ; return true ; } return false ;


signature:
public class ArrayTableSerializer { /** * Creates a new { @ link ArrayTableSerializer } and registers its serializer .
 * @ param kryo the { @ link Kryo } instance to set the serializer on */
public static void registerSerializers ( final Kryo kryo ) { } }

implementation:
// ImmutableList is used by ArrayTable . However ,
// we already have a separate serializer class for ImmutableList ,
// ImmutableListSerializer . If it is not already being used , register it .
Serializer immutableListSerializer = getSerializer ( kryo , ImmutableList . class ) ; if ( ! ( immutableListSerializer instanceof ImmutableListSerializer ) ) { ImmutableListSerializer . registerSerializers ( kryo ) ; } final ArrayTableSerializer serializer = new ArrayTableSerializer ( ) ; kryo . register ( ArrayTable . class , serializer ) ;


signature:
public class ImmutableMapSerializer { /** * Creates a new { @ link ImmutableMapSerializer } and registers its serializer
 * for the several ImmutableMap related classes .
 * @ param kryo the { @ link Kryo } instance to set the serializer on */
public static void registerSerializers ( final Kryo kryo ) { } }

implementation:
// we ' re writing a HashMap , therefore we should register it
kryo . register ( java . util . HashMap . class ) ; final ImmutableMapSerializer serializer = new ImmutableMapSerializer ( ) ; // ImmutableMap ( abstract class )
// + - EmptyImmutableBiMap
// + - SingletonImmutableBiMap
// + - RegularImmutableMap
// + - ImmutableEnumMap
// + - RowMap from DenseImmutableTable
// + - Row from DenseImmutableTable
// + - ColumnMap from DenseImmutableTable
// + - Column from DenseImmutableTable
kryo . register ( ImmutableMap . class , serializer ) ; kryo . register ( ImmutableMap . of ( ) . getClass ( ) , serializer ) ; Object o1 = new Object ( ) ; Object o2 = new Object ( ) ; kryo . register ( ImmutableMap . of ( o1 , o1 ) . getClass ( ) , serializer ) ; kryo . register ( ImmutableMap . of ( o1 , o1 , o2 , o2 ) . getClass ( ) , serializer ) ; Map < DummyEnum , Object > enumMap = new EnumMap < DummyEnum , Object > ( DummyEnum . class ) ; for ( DummyEnum e : DummyEnum . values ( ) ) { enumMap . put ( e , o1 ) ; } kryo . register ( ImmutableMap . copyOf ( enumMap ) . getClass ( ) , serializer ) ; ImmutableTable < Object , Object , Object > denseImmutableTable = ImmutableTable . builder ( ) . put ( "a" , 1 , 1 ) . put ( "b" , 1 , 1 ) . build ( ) ; kryo . register ( denseImmutableTable . rowMap ( ) . getClass ( ) , serializer ) ; // RowMap
kryo . register ( denseImmutableTable . rowMap ( ) . get ( "a" ) . getClass ( ) , serializer ) ; // Row
kryo . register ( denseImmutableTable . columnMap ( ) . getClass ( ) , serializer ) ; // ColumnMap
kryo . register ( denseImmutableTable . columnMap ( ) . get ( 1 ) . getClass ( ) , serializer ) ; // Column


signature:
public class ListSerializer { /** * Creates a new { @ link ImmutableListSerializer } and registers its serializer
 * @ param kryo the { @ link Kryo } instance to set the serializer on */
public static void registerSerializers ( final Kryo kryo ) { } }

implementation:
final ListSerializer serializer = new ListSerializer ( ) ; kryo . register ( List . class , serializer ) ; // Note :
// Only registering above is good enough for serializing / deserializing .
// but if using Kryo # copy , following is required .
kryo . register ( IndexedLists . of ( ) . getClass ( ) , serializer ) ; kryo . register ( IndexedLists . of ( 1 ) . getClass ( ) , serializer ) ; kryo . register ( IndexedLists . of ( 1 , 2 ) . getClass ( ) , serializer ) ; kryo . register ( IndexedLists . of ( 1 , 2 , 3 ) . getClass ( ) , serializer ) ; kryo . register ( IndexedLists . of ( 1 , 2 , 3 , 4 ) . getClass ( ) , serializer ) ; kryo . register ( IndexedLists . of ( 1 , 2 , 3 , 4 , 5 ) . getClass ( ) , serializer ) ; kryo . register ( IndexedLists . of ( 1 , 2 , 3 , 4 , 5 , 6 ) . getClass ( ) , serializer ) ; kryo . register ( IndexedLists . of ( 1 , 2 , 3 , 4 , 5 , 6 , 7 ) . getClass ( ) , serializer ) ; kryo . register ( IndexedLists . of ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ) . getClass ( ) , serializer ) ; kryo . register ( IndexedLists . of ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ) . getClass ( ) , serializer ) ; kryo . register ( IndexedLists . of ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 10 ) . getClass ( ) , serializer ) ; kryo . register ( IndexedLists . of ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 10 , 11 ) . getClass ( ) , serializer ) ;


signature:
public class MapSerializer { /** * Creates a new { @ link ImmutableMapSerializer } and registers its serializer
 * for the several ImmutableMap related classes .
 * @ param kryo the { @ link Kryo } instance to set the serializer on */
public static void registerSerializers ( final Kryo kryo ) { } }

implementation: final MapSerializer serializer = new MapSerializer ( ) ; kryo . register ( Map . class , serializer ) ; kryo . register ( Maps . of ( ) . getClass ( ) , serializer ) ; Object o1 = new Object ( ) ; Object o2 = new Object ( ) ; Object o3 = new Object ( ) ; Object o4 = new Object ( ) ; Object o5 = new Object ( ) ; kryo . register ( Maps . of ( o1 , o1 ) . getClass ( ) , serializer ) ; kryo . register ( Maps . of ( o1 , o1 , o2 , o2 ) . getClass ( ) , serializer ) ; kryo . register ( Maps . of ( o1 , o1 , o2 , o2 , o3 , o3 ) . getClass ( ) , serializer ) ; kryo . register ( Maps . of ( o1 , o1 , o2 , o2 , o3 , o3 , o4 , o4 ) . getClass ( ) , serializer ) ; kryo . register ( Maps . of ( o1 , o1 , o2 , o2 , o3 , o3 , o4 , o4 , o5 , o5 ) . getClass ( ) , serializer ) ;


signature:
public class TreeMultimapSerializer { /** * Creates a new { @ link TreeMultimapSerializer } and registers its serializer .
 * @ param kryo the { @ link Kryo } instance to set the serializer on */
public static void registerSerializers ( final Kryo kryo ) { } }

implementation: final TreeMultimapSerializer serializer = new TreeMultimapSerializer ( ) ; kryo . register ( TreeMultimap . class , serializer ) ;


signature:
public class SubListSerializers { /** * Obtain a serializer for the given sublist type . If the type is not supported
 * < code > null < / code > is returned .
 * @ param type the class of the sublist .
 * @ return a serializer instance or < code > null < / code > . */
@ SuppressWarnings ( "rawtypes" ) public static Serializer < List < ? > > createFor ( final Class type ) { } }

implementation: if ( ArrayListSubListSerializer . canSerialize ( type ) ) return new ArrayListSubListSerializer ( ) ; if ( JavaUtilSubListSerializer . canSerialize ( type ) ) return new JavaUtilSubListSerializer ( ) ; return null ;


signature:
public class SubListSerializers { /** * Adds appropriate sublist serializers as default serializers . */
public static Kryo addDefaultSerializers ( Kryo kryo ) { } }

implementation: ArrayListSubListSerializer . addDefaultSerializer ( kryo ) ; AbstractListSubListSerializer . addDefaultSerializer ( kryo ) ; JavaUtilSubListSerializer . addDefaultSerializer ( kryo ) ; return kryo ;


signature:
public class ImmutableSortedMapSerializer { /** * Creates a new { @ link ImmutableSortedMapSerializer } and registers its serializer
 * for the several ImmutableMap related classes .
 * @ param kryo the { @ link Kryo } instance to set the serializer on */
public static void registerSerializers ( final Kryo kryo ) { } }

implementation:
// we ' re writing a TreeMap , therefore we should register it
kryo . register ( java . util . TreeMap . class ) ; final ImmutableSortedMapSerializer serializer = new ImmutableSortedMapSerializer ( ) ; kryo . register ( ImmutableSortedMap . class , serializer ) ; kryo . register ( ImmutableSortedMap . of ( ) . getClass ( ) , serializer ) ; final Comparable < Object > k1 = new Comparable < Object > ( ) { @ Override public int compareTo ( Object o ) { return o == this ? 0 : - 1 ; } } ; final Comparable < Object > k2 = new Comparable < Object > ( ) { @ Override public int compareTo ( Object o ) { return o == this ? 0 : 1 ; } } ; final Object v1 = new Object ( ) ; final Object v2 = new Object ( ) ; kryo . register ( ImmutableSortedMap . of ( k1 , v1 ) . getClass ( ) , serializer ) ; kryo . register ( ImmutableSortedMap . of ( k1 , v1 , k2 , v2 ) . getClass ( ) , serializer ) ; Map < DummyEnum , Object > enumMap = new EnumMap < DummyEnum , Object > ( DummyEnum . class ) ; for ( DummyEnum e : DummyEnum . values ( ) ) { enumMap . put ( e , v1 ) ; } kryo . register ( ImmutableSortedMap . copyOf ( enumMap ) . getClass ( ) , serializer ) ;


signature:
public class ImmutableSetSerializer { /** * Creates a new { @ link ImmutableSetSerializer } and registers its serializer
 * for the several ImmutableSet related classes .
 * @ param kryo the { @ link Kryo } instance to set the serializer on */
public static void registerSerializers ( final Kryo kryo ) { } }

implementation:
// ImmutableList ( abstract class )
// + - EmptyImmutableSet
// | EmptyImmutableSet
// + - SingletonImmutableSet
// | Optimized for Set with only 1 element .
// + - RegularImmutableSet
// | RegularImmutableList
// + - EnumImmutableSet
// | EnumImmutableSet
final ImmutableSetSerializer serializer = new ImmutableSetSerializer ( ) ; kryo . register ( ImmutableSet . class , serializer ) ; // Note :
// Only registering above is good enough for serializing / deserializing .
// but if using Kryo # copy , following is required .
kryo . register ( ImmutableSet . of ( ) . getClass ( ) , serializer ) ; kryo . register ( ImmutableSet . of ( 1 ) . getClass ( ) , serializer ) ; kryo . register ( ImmutableSet . of ( 1 , 2 , 3 ) . getClass ( ) , serializer ) ; kryo . register ( Sets . immutableEnumSet ( SomeEnum . A , SomeEnum . B , SomeEnum . C ) . getClass ( ) , serializer ) ;


signature:
public class HashMultimapSerializer { /** * Creates a new { @ link HashMultimapSerializer } and registers its serializer .
 * @ param kryo the { @ link Kryo } instance to set the serializer on */
public static void registerSerializers ( final Kryo kryo ) { } }

implementation: final HashMultimapSerializer serializer = new HashMultimapSerializer ( ) ; kryo . register ( HashMultimap . class , serializer ) ;


signature:
public class UnmodifiableCollectionsSerializer { /** * Creates a new { @ link UnmodifiableCollectionsSerializer } and registers its serializer
 * for the several unmodifiable Collections that can be created via { @ link Collections } ,
 * including { @ link Map } s .
 * @ param kryo the { @ link Kryo } instance to set the serializer on .
 * @ see Collections # unmodifiableCollection ( Collection )
 * @ see Collections # unmodifiableList ( List )
 * @ see Collections # unmodifiableSet ( Set )
 * @ see Collections # unmodifiableSortedSet ( SortedSet )
 * @ see Collections # unmodifiableMap ( Map )
 * @ see Collections # unmodifiableSortedMap ( SortedMap ) */
public static void registerSerializers ( final Kryo kryo ) { } }

implementation: final UnmodifiableCollectionsSerializer serializer = new UnmodifiableCollectionsSerializer ( ) ; UnmodifiableCollection . values ( ) ; for ( final UnmodifiableCollection item : UnmodifiableCollection . values ( ) ) { kryo . register ( item . type , serializer ) ; }


signature:
public class ImmutableListSerializer { /** * Creates a new { @ link ImmutableListSerializer } and registers its serializer
 * for the several ImmutableList related classes .
 * @ param kryo the { @ link Kryo } instance to set the serializer on */
public static void registerSerializers ( final Kryo kryo ) { } }

implementation:
// ImmutableList ( abstract class )
// + - RegularImmutableList
// | RegularImmutableList
// + - SingletonImmutableList
// | Optimized for List with only 1 element .
// + - SubList
// | Representation for part of ImmutableList
// + - ReverseImmutableList
// | For iterating in reverse order
// + - StringAsImmutableList
// | Used by Lists # charactersOf
// + - Values ( ImmutableTable values )
// Used by return value of # values ( ) when there are multiple cells
final ImmutableListSerializer serializer = new ImmutableListSerializer ( ) ; kryo . register ( ImmutableList . class , serializer ) ; // Note :
// Only registering above is good enough for serializing / deserializing .
// but if using Kryo # copy , following is required .
kryo . register ( ImmutableList . of ( ) . getClass ( ) , serializer ) ; kryo . register ( ImmutableList . of ( 1 ) . getClass ( ) , serializer ) ; kryo . register ( ImmutableList . of ( 1 , 2 , 3 , 4 ) . subList ( 1 , 3 ) . getClass ( ) , serializer ) ; kryo . register ( ImmutableList . of ( 1 , 2 ) . reverse ( ) . getClass ( ) , serializer ) ; kryo . register ( Lists . charactersOf ( "KryoRocks" ) . getClass ( ) , serializer ) ; Table < Integer , Integer , Integer > baseTable = HashBasedTable . create ( ) ; baseTable . put ( 1 , 2 , 3 ) ; baseTable . put ( 4 , 5 , 6 ) ; Table < Integer , Integer , Integer > table = ImmutableTable . copyOf ( baseTable ) ; kryo . register ( table . values ( ) . getClass ( ) , serializer ) ;


signature:
public class SetSerializer { /** * Creates a new { @ link ImmutableSetSerializer } and registers its serializer
 * for the several ImmutableSet related classes .
 * @ param kryo the { @ link Kryo } instance to set the serializer on */
public static void registerSerializers ( final Kryo kryo ) { } }

implementation:
final SetSerializer serializer = new SetSerializer ( ) ; kryo . register ( Set . class , serializer ) ; // Note :
// Only registering above is good enough for serializing / deserializing .
// but if using Kryo # copy , following is required .
kryo . register ( Sets . of ( ) . getClass ( ) , serializer ) ; kryo . register ( Sets . of ( 1 ) . getClass ( ) , serializer ) ; kryo . register ( Sets . of ( 1 , 2 , 3 ) . getClass ( ) , serializer ) ; kryo . register ( Sets . of ( 1 , 2 , 3 , 4 ) . getClass ( ) , serializer ) ; kryo . register ( Sets . of ( 1 , 2 , 3 , 4 , 5 ) . getClass ( ) , serializer ) ; kryo . register ( Sets . of ( 1 , 2 , 3 , 4 , 5 , 6 ) . getClass ( ) , serializer ) ; kryo . register ( Sets . of ( 1 , 2 , 3 , 4 , 5 , 6 , 7 ) . getClass ( ) , serializer ) ; kryo . register ( Sets . of ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ) . getClass ( ) , serializer ) ; kryo . register ( Sets . of ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ) . getClass ( ) , serializer ) ; kryo . register ( Sets . of ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ) . getClass ( ) , serializer ) ; kryo . register ( Sets . of ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 ) . getClass ( ) , serializer ) ;


signature:
public class DateSerializer { /** * { @ inheritDoc } */
@ Override public Date read ( final Kryo kryo , final Input input , final Class < ? extends Date > type ) { } }

implementation: try { return _constructor . newInstance ( input . readLong ( true ) ) ; } catch ( final Exception e ) { throw new RuntimeException ( e ) ; }


signature:
public class DateSerializer { /** * { @ inheritDoc } */
@ Override public void write ( final Kryo kryo , final Output output , final Date obj ) { } }

implementation: output . writeLong ( obj . getTime ( ) , true ) ;


signature:
public class LinkedHashMultimapSerializer { /** * Creates a new { @ link LinkedHashMultimapSerializer } and registers its serializer .
 * @ param kryo the { @ link Kryo } instance to set the serializer on */
public static void registerSerializers ( final Kryo kryo ) { } }

implementation: final LinkedHashMultimapSerializer serializer = new LinkedHashMultimapSerializer ( ) ; kryo . register ( LinkedHashMultimap . class , serializer ) ;


signature:
public class ImmutableTableSerializer { /** * Creates a new { @ link ImmutableTableSerializer } and registers its serializer .
 * @ param kryo the { @ link Kryo } instance to set the serializer on */
public static void registerSerializers ( final Kryo kryo ) { } }

implementation:
// ImmutableTable ( abstract class )
// + - SparseImmutableTable
// | SparseImmutableTable
// + - DenseImmutableTable
// | Used when more than half of the cells have values
// + - SingletonImmutableTable
// | Optimized for Table with only 1 element .
final ImmutableTableSerializer serializer = new ImmutableTableSerializer ( ) ; kryo . register ( ImmutableTable . class , serializer ) ; // ImmutableTable
kryo . register ( ImmutableTable . of ( ) . getClass ( ) , serializer ) ; // SparseImmutableTable
kryo . register ( ImmutableTable . of ( 1 , 2 , 3 ) . getClass ( ) , serializer ) ; // SingletonImmutableTable
kryo . register ( ImmutableTable . builder ( ) . put ( "a" , 1 , 1 ) . put ( "b" , 1 , 1 ) . build ( ) . getClass ( ) , serializer ) ; // DenseImmutableTable


signature:
public class ProtobufSerializer { /** * Caches method reflection lookup
 * @ throws NoSuchMethodException */
private Method getParseFromMethod ( Class < ? extends T > type ) throws NoSuchMethodException { } }

implementation: if ( parseFromMethod == null ) { parseFromMethod = type . getMethod ( "parseFrom" , byte [ ] . class ) ; } return parseFromMethod ;


signature:
public class ArrayListMultimapSerializer { /** * Creates a new { @ link ArrayListMultimapSerializer } and registers its serializer .
 * @ param kryo the { @ link Kryo } instance to set the serializer on */
public static void registerSerializers ( final Kryo kryo ) { } }

implementation: final ArrayListMultimapSerializer serializer = new ArrayListMultimapSerializer ( ) ; kryo . register ( ArrayListMultimap . class , serializer ) ;


signature:
public class LinkedListMultimapSerializer { /** * Creates a new { @ link LinkedListMultimapSerializer } and registers its serializer .
 * @ param kryo the { @ link Kryo } instance to set the serializer on */
public static void registerSerializers ( final Kryo kryo ) { } }

implementation: final LinkedListMultimapSerializer serializer = new LinkedListMultimapSerializer ( ) ; kryo . register ( LinkedListMultimap . class , serializer ) ;


signature:
public class RisonParser { /** * Method called to release internal buffers owned by the base
 * reader . This may be called along with { @ link # _ closeInput } ( for
 * example , when explicitly closing this reader instance ) , or
 * separately ( if need be ) . */
@ Override protected void _releaseBuffers ( ) throws IOException { } }

implementation: super . _releaseBuffers ( ) ; char [ ] buf = _inputBuffer ; if ( buf != null ) { _inputBuffer = null ; _ioContext . releaseTokenBuffer ( buf ) ; }


signature:
public class RisonParser { /** * Method for accessing textual representation of the current event ;
 * if no current event ( before first call to { @ link # nextToken } , or
 * after encountering end - of - input ) , returns null .
 * Method can be called for any event . */
@ Override public String getText ( ) throws IOException , JsonParseException { } }

implementation:
JsonToken t = _currToken ; if ( t == JsonToken . VALUE_STRING ) { if ( _tokenIncomplete ) { _tokenIncomplete = false ; _finishString ( ) ; // only strings can be incomplete
} return _textBuffer . contentsAsString ( ) ; } return _getText2 ( t ) ;


signature:
public class RisonParser { /** * note : identical to one in Utf8StreamParser */
@ Override public String nextTextValue ( ) throws IOException , JsonParseException { } }

implementation:
if ( _currToken == JsonToken . FIELD_NAME ) { // mostly copied from ' _ nextAfterName '
_nameCopied = false ; JsonToken t = _nextToken ; _nextToken = null ; _currToken = t ; if ( t == JsonToken . VALUE_STRING ) { if ( _tokenIncomplete ) { _tokenIncomplete = false ; _finishString ( ) ; } return _textBuffer . contentsAsString ( ) ; } if ( t == JsonToken . START_ARRAY ) { _parsingContext = _parsingContext . createChildArrayContext ( _tokenInputRow , _tokenInputCol ) ; } else if ( t == JsonToken . START_OBJECT ) { _parsingContext = _parsingContext . createChildObjectContext ( _tokenInputRow , _tokenInputCol ) ; } return null ; } // ! ! ! TODO : optimize this case as well
return ( nextToken ( ) == JsonToken . VALUE_STRING ) ? getText ( ) : null ;


signature:
public class RisonParser { /** * note : identical to one in Utf8StreamParser */
@ Override public int nextIntValue ( int defaultValue ) throws IOException , JsonParseException { } }

implementation:
if ( _currToken == JsonToken . FIELD_NAME ) { _nameCopied = false ; JsonToken t = _nextToken ; _nextToken = null ; _currToken = t ; if ( t == JsonToken . VALUE_NUMBER_INT ) { return getIntValue ( ) ; } if ( t == JsonToken . START_ARRAY ) { _parsingContext = _parsingContext . createChildArrayContext ( _tokenInputRow , _tokenInputCol ) ; } else if ( t == JsonToken . START_OBJECT ) { _parsingContext = _parsingContext . createChildObjectContext ( _tokenInputRow , _tokenInputCol ) ; } return defaultValue ; } // ! ! ! TODO : optimize this case as well
return ( nextToken ( ) == JsonToken . VALUE_NUMBER_INT ) ? getIntValue ( ) : defaultValue ;


signature:
public class RisonParser { /** * note : identical to one in Utf8StreamParser */
@ Override public Boolean nextBooleanValue ( ) throws IOException , JsonParseException { } }

implementation:
if ( _currToken == JsonToken . FIELD_NAME ) { // mostly copied from ' _ nextAfterName '
_nameCopied = false ; JsonToken t = _nextToken ; _nextToken = null ; _currToken = t ; if ( t == JsonToken . VALUE_TRUE ) { return Boolean . TRUE ; } if ( t == JsonToken . VALUE_FALSE ) { return Boolean . FALSE ; } if ( t == JsonToken . START_ARRAY ) { _parsingContext = _parsingContext . createChildArrayContext ( _tokenInputRow , _tokenInputCol ) ; } else if ( t == JsonToken . START_OBJECT ) { _parsingContext = _parsingContext . createChildObjectContext ( _tokenInputRow , _tokenInputCol ) ; } return null ; } switch ( nextToken ( ) ) { case VALUE_TRUE : return Boolean . TRUE ; case VALUE_FALSE : return Boolean . FALSE ; } return null ;


signature:
public class RisonParser { /** * Initial parsing method for number values . It needs to be able
 * to parse enough input to be able to determine whether the
 * value is to be considered a simple integer value , or a more
 * generic decimal value : latter of which needs to be expressed
 * as a floating point number . The basic rule is that if the number
 * has no fractional or exponential part , it is an integer ; otherwise
 * a floating point number .
 * Because much of input has to be processed in any case , no partial
 * parsing is done : all input text will be stored for further
 * processing . However , actual numeric value conversion will be
 * deferred , since it is usually the most complicated and costliest
 * part of processing . */
protected JsonToken parseNumberText ( int ch ) throws IOException , JsonParseException { } }

implementation:
/* Although we will always be complete with respect to textual
 * representation ( that is , all characters will be parsed ) ,
 * actual conversion to a number is deferred . Thus , need to
 * note that no representations are valid yet */
boolean negative = ( ch == INT_MINUS ) ; int ptr = _inputPtr ; int startPtr = ptr - 1 ; // to include sign / digit already read
final int inputLen = _inputEnd ; dummy_loop : do { // dummy loop , to be able to break out
if ( negative ) { // need to read the next digit
if ( ptr >= _inputEnd ) { break dummy_loop ; } ch = _inputBuffer [ ptr ++ ] ; // First check : must have a digit to follow minus sign
if ( ch > INT_9 || ch < INT_0 ) { _inputPtr = ptr ; return _handleInvalidNumberStart ( ch , true ) ; } /* ( note : has been checked for non - negative already , in
 * the dispatching code that determined it should be
 * a numeric value ) */
} // One special case , leading zero ( es ) :
if ( ch == INT_0 ) { break dummy_loop ; } /* First , let ' s see if the whole number is contained within
 * the input buffer unsplit . This should be the common case ;
 * and to simplify processing , we will just reparse contents
 * in the alternative case ( number split on buffer boundary ) */
int intLen = 1 ; // already got one
// First let ' s get the obligatory integer part :
int_loop : while ( true ) { if ( ptr >= _inputEnd ) { break dummy_loop ; } ch = ( int ) _inputBuffer [ ptr ++ ] ; if ( ch < INT_0 || ch > INT_9 ) { break int_loop ; } ++ intLen ; } int fractLen = 0 ; // And then see if we get other parts
if ( ch == '.' ) { // yes , fraction
fract_loop : while ( true ) { if ( ptr >= inputLen ) { break dummy_loop ; } ch = ( int ) _inputBuffer [ ptr ++ ] ; if ( ch < INT_0 || ch > INT_9 ) { break fract_loop ; } ++ fractLen ; } // must be followed by sequence of ints , one minimum
if ( fractLen == 0 ) { reportUnexpectedNumberChar ( ch , "Decimal point not followed by a digit" ) ; } } int expLen = 0 ; if ( ch == INT_e || ch == INT_E ) { // and / or exponent
if ( ptr >= inputLen ) { break dummy_loop ; } // Sign indicator ?
ch = ( int ) _inputBuffer [ ptr ++ ] ; if ( ch == INT_MINUS || ch == INT_PLUS ) { // yup , skip for now
if ( ptr >= inputLen ) { break dummy_loop ; } ch = ( int ) _inputBuffer [ ptr ++ ] ; } while ( ch <= INT_9 && ch >= INT_0 ) { ++ expLen ; if ( ptr >= inputLen ) { break dummy_loop ; } ch = ( int ) _inputBuffer [ ptr ++ ] ; } // must be followed by sequence of ints , one minimum
if ( expLen == 0 ) { reportUnexpectedNumberChar ( ch , "Exponent indicator not followed by a digit" ) ; } } // Got it all : let ' s add to text buffer for parsing , access
-- ptr ; // need to push back following separator
_inputPtr = ptr ; int len = ptr - startPtr ; _textBuffer . resetWithShared ( _inputBuffer , startPtr , len ) ; return reset ( negative , intLen , fractLen , expLen ) ; } while ( false ) ; _inputPtr = negative ? ( startPtr + 1 ) : startPtr ; return parseNumberText2 ( negative ) ;


signature:
public class RisonParser { /** * Method called to parse a number , when the primary parse
 * method has failed to parse it , due to it being split on
 * buffer boundary . As a result code is very similar , except
 * that it has to explicitly copy contents to the text buffer
 * instead of just sharing the main input buffer . */
private JsonToken parseNumberText2 ( boolean negative ) throws IOException , JsonParseException { } }

implementation:
char [ ] outBuf = _textBuffer . emptyAndGetCurrentSegment ( ) ; int outPtr = 0 ; // Need to prepend sign ?
if ( negative ) { outBuf [ outPtr ++ ] = '-' ; } // This is the place to do leading - zero check ( s ) too :
int intLen = 0 ; char c = ( _inputPtr < _inputEnd ) ? _inputBuffer [ _inputPtr ++ ] : getNextChar ( "No digit following minus sign" ) ; if ( c == '0' ) { c = _verifyNoLeadingZeroes ( ) ; } boolean eof = false ; // Ok , first the obligatory integer part :
int_loop : while ( c >= '0' && c <= '9' ) { ++ intLen ; if ( outPtr >= outBuf . length ) { outBuf = _textBuffer . finishCurrentSegment ( ) ; outPtr = 0 ; } outBuf [ outPtr ++ ] = c ; if ( _inputPtr >= _inputEnd && ! loadMore ( ) ) { // EOF is legal for main level int values
c = CHAR_NULL ; eof = true ; break int_loop ; } c = _inputBuffer [ _inputPtr ++ ] ; } // Also , integer part is not optional
if ( intLen == 0 ) { reportInvalidNumber ( "Missing integer part (next char " + _getCharDesc ( c ) + ")" ) ; } int fractLen = 0 ; // And then see if we get other parts
if ( c == '.' ) { // yes , fraction
outBuf [ outPtr ++ ] = c ; fract_loop : while ( true ) { if ( _inputPtr >= _inputEnd && ! loadMore ( ) ) { eof = true ; break fract_loop ; } c = _inputBuffer [ _inputPtr ++ ] ; if ( c < INT_0 || c > INT_9 ) { break fract_loop ; } ++ fractLen ; if ( outPtr >= outBuf . length ) { outBuf = _textBuffer . finishCurrentSegment ( ) ; outPtr = 0 ; } outBuf [ outPtr ++ ] = c ; } // must be followed by sequence of ints , one minimum
if ( fractLen == 0 ) { reportUnexpectedNumberChar ( c , "Decimal point not followed by a digit" ) ; } } int expLen = 0 ; if ( c == 'e' || c == 'E' ) { // exponent ?
if ( outPtr >= outBuf . length ) { outBuf = _textBuffer . finishCurrentSegment ( ) ; outPtr = 0 ; } outBuf [ outPtr ++ ] = c ; // Not optional , can require that we get one more char
c = ( _inputPtr < _inputEnd ) ? _inputBuffer [ _inputPtr ++ ] : getNextChar ( "expected a digit for number exponent" ) ; // Sign indicator ?
if ( c == '-' || c == '+' ) { if ( outPtr >= outBuf . length ) { outBuf = _textBuffer . finishCurrentSegment ( ) ; outPtr = 0 ; } outBuf [ outPtr ++ ] = c ; // Likewise , non optional :
c = ( _inputPtr < _inputEnd ) ? _inputBuffer [ _inputPtr ++ ] : getNextChar ( "expected a digit for number exponent" ) ; } exp_loop : while ( c <= INT_9 && c >= INT_0 ) { ++ expLen ; if ( outPtr >= outBuf . length ) { outBuf = _textBuffer . finishCurrentSegment ( ) ; outPtr = 0 ; } outBuf [ outPtr ++ ] = c ; if ( _inputPtr >= _inputEnd && ! loadMore ( ) ) { eof = true ; break exp_loop ; } c = _inputBuffer [ _inputPtr ++ ] ; } // must be followed by sequence of ints , one minimum
if ( expLen == 0 ) { reportUnexpectedNumberChar ( c , "Exponent indicator not followed by a digit" ) ; } } // Ok ; unless we hit end - of - input , need to push last char read back
if ( ! eof ) { -- _inputPtr ; } _textBuffer . setCurrentLength ( outPtr ) ; // And there we have it !
return reset ( negative , intLen , fractLen , expLen ) ;


signature:
public class RisonParser { /** * Method called when we have seen one zero , and want to ensure
 * it is not followed by another */
private char _verifyNoLeadingZeroes ( ) throws IOException , JsonParseException { } }

implementation:
// Ok to have plain " 0"
if ( _inputPtr >= _inputEnd && ! loadMore ( ) ) { return '0' ; } char ch = _inputBuffer [ _inputPtr ] ; // if not followed by a number ( probably ' . ' ) ; return zero as is , to be included
if ( ch < '0' || ch > '9' ) { return '0' ; } if ( ! isEnabled ( JsonParser . Feature . ALLOW_NUMERIC_LEADING_ZEROS ) ) { reportInvalidNumber ( "Leading zeroes not allowed" ) ; } // if so , just need to skip either all zeroes ( if followed by number ) ; or all but one ( if non - number )
++ _inputPtr ; // Leading zero to be skipped
if ( ch == INT_0 ) { while ( _inputPtr < _inputEnd || loadMore ( ) ) { ch = _inputBuffer [ _inputPtr ] ; if ( ch < '0' || ch > '9' ) { // followed by non - number ; retain one zero
return '0' ; } ++ _inputPtr ; // skip previous zero
if ( ch != '0' ) { // followed by other number ; return
break ; } } } return ch ;


signature:
public class RisonParser { /** * Method called if expected numeric value ( due to leading sign ) does not
 * look like a number */
protected JsonToken _handleInvalidNumberStart ( int ch , boolean negative ) throws IOException , JsonParseException { } }

implementation: if ( ch == 'I' ) { if ( _inputPtr >= _inputEnd ) { if ( ! loadMore ( ) ) { _reportInvalidEOFInValue ( ) ; } } ch = _inputBuffer [ _inputPtr ++ ] ; if ( ch == 'N' ) { String match = negative ? "-INF" : "+INF" ; _matchToken ( match , 3 ) ; if ( isEnabled ( JsonParser . Feature . ALLOW_NON_NUMERIC_NUMBERS ) ) { return resetAsNaN ( match , negative ? Double . NEGATIVE_INFINITY : Double . POSITIVE_INFINITY ) ; } _reportError ( "Non-standard token '" + match + "': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow" ) ; } else if ( ch == 'n' ) { String match = negative ? "-Infinity" : "+Infinity" ; _matchToken ( match , 3 ) ; if ( isEnabled ( JsonParser . Feature . ALLOW_NON_NUMERIC_NUMBERS ) ) { return resetAsNaN ( match , negative ? Double . NEGATIVE_INFINITY : Double . POSITIVE_INFINITY ) ; } _reportError ( "Non-standard token '" + match + "': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow" ) ; } } reportUnexpectedNumberChar ( ch , "expected digit (0-9) to follow minus sign, for valid numeric value" ) ; return null ;


signature:
public class RisonParser { /** * / * Internal methods , secondary parsing */
protected String _parseFieldName ( int i ) throws IOException , JsonParseException { } }

implementation:
/* First : let ' s try to see if we have a simple name : one that does
 * not cross input buffer boundary , and does not contain escape
 * sequences . */
int ptr = _inputPtr ; int hash = 0 ; final int inputLen = _inputEnd ; if ( ptr < inputLen ) { do { int ch = _inputBuffer [ ptr ] ; if ( ch == INT_APOSTROPHE ) { int start = _inputPtr ; _inputPtr = ptr + 1 ; // to skip the quote
return _symbols . findSymbol ( _inputBuffer , start , ptr - start , hash ) ; } else if ( ch == '!' ) { break ; // escape , can ' t take the fast path
} hash = ( hash * 31 ) + ch ; ++ ptr ; } while ( ptr < inputLen ) ; } int start = _inputPtr ; _inputPtr = ptr ; return _parseFieldName2 ( start , hash , INT_APOSTROPHE ) ;


signature:
public class RisonParser { /** * Method called when we see non - white space character other
 * than double quote , when expecting a field name .
 * In standard mode will just throw an expection ; but
 * in non - standard modes may be able to parse name . */
protected String _parseUnquotedFieldName ( int i ) throws IOException , JsonParseException { } }

implementation:
// Also : first char must be a valid name char , but NOT be number
boolean firstOk = IdentifierUtils . isIdStartLenient ( i ) ; if ( ! firstOk ) { _reportUnexpectedChar ( i , "was expecting either valid name character (for unquoted name) or single-quote (for quoted) to start field name" ) ; } int ptr = _inputPtr ; int hash = 0 ; final int inputLen = _inputEnd ; if ( ptr < inputLen ) { do { int ch = _inputBuffer [ ptr ] ; if ( ! IdentifierUtils . isIdCharLenient ( ch ) ) { int start = _inputPtr - 1 ; // -1 to bring back first char
_inputPtr = ptr ; return _symbols . findSymbol ( _inputBuffer , start , ptr - start , hash ) ; } hash = ( hash * 31 ) + ch ; ++ ptr ; } while ( ptr < inputLen ) ; } int start = _inputPtr - 1 ; _inputPtr = ptr ; return _parseUnquotedFieldName2 ( start , hash ) ;


signature:
public class RisonParser { /** * Method for handling cases where first non - space character
 * of an expected value token is not legal for standard JSON content . */
protected JsonToken _handleUnexpectedValue ( int i ) throws IOException , JsonParseException { } }

implementation:
// Most likely an error , unless we are to allow single - quote - strings
switch ( i ) { case 'N' : _matchToken ( "NaN" , 1 ) ; if ( isEnabled ( JsonParser . Feature . ALLOW_NON_NUMERIC_NUMBERS ) ) { return resetAsNaN ( "NaN" , Double . NaN ) ; } _reportError ( "Non-standard token 'NaN': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow" ) ; break ; case '+' : // note : ' - ' is taken as number
if ( _inputPtr >= _inputEnd ) { if ( ! loadMore ( ) ) { _reportInvalidEOFInValue ( ) ; } } return _handleInvalidNumberStart ( _inputBuffer [ _inputPtr ++ ] , false ) ; } _reportUnexpectedChar ( i , "expected a valid value (number, String, array, object, 'true', 'false' or 'null')" ) ; return null ;


signature:
public class RisonParser { /** * Method called to skim through rest of unparsed String value ,
 * if it is not needed . This can be done bit faster if contents
 * need not be stored for future access . */
protected void _skipString ( ) throws IOException , JsonParseException { } }

implementation: _tokenIncomplete = false ; int inputPtr = _inputPtr ; int inputLen = _inputEnd ; char [ ] inputBuffer = _inputBuffer ; while ( true ) { if ( inputPtr >= inputLen ) { _inputPtr = inputPtr ; if ( ! loadMore ( ) ) { _reportInvalidEOF ( ": was expecting closing quote for a string value" ) ; } inputPtr = _inputPtr ; inputLen = _inputEnd ; } char c = inputBuffer [ inputPtr ++ ] ; if ( c == INT_APOSTROPHE ) { _inputPtr = inputPtr ; break ; } else if ( c == '!' ) { _inputPtr = inputPtr ; _decodeEscaped ( ) ; inputPtr = _inputPtr ; inputLen = _inputEnd ; } }


signature:
public class RisonParser { /** * / * Internal methods , other parsing */
private int _nextCh ( ) throws IOException , JsonParseException { } }

implementation: if ( _inputPtr < _inputEnd || loadMore ( ) ) { return _inputBuffer [ _inputPtr ++ ] ; } throw _constructError ( "Unexpected end-of-input within/between " + _parsingContext . getTypeDesc ( ) + " entries" ) ;


signature:
public class RisonParser { /** * Helper method for checking whether input matches expected token */
protected void _matchToken ( String matchStr , int i ) throws IOException , JsonParseException { } }

implementation:
final int len = matchStr . length ( ) ; do { if ( _inputPtr >= _inputEnd ) { if ( ! loadMore ( ) ) { _reportInvalidEOFInValue ( ) ; } } if ( _inputBuffer [ _inputPtr ] != matchStr . charAt ( i ) ) { _reportInvalidToken ( matchStr . substring ( 0 , i ) , "'null', 'true', 'false' or NaN" ) ; } ++ _inputPtr ; } while ( ++ i < len ) ; // but let ' s also ensure we either get EOF , or non - alphanum char . . .
if ( _inputPtr >= _inputEnd ) { if ( ! loadMore ( ) ) { return ; } } char c = _inputBuffer [ _inputPtr ] ; if ( c < '0' || c == ')' ) { // expected / allowed chars
return ; } // if letter , it ' s a problem tho
if ( IdentifierUtils . isIdCharLenient ( c ) ) { _reportInvalidToken ( matchStr . substring ( 0 , i ) , "'null', 'true', 'false' or NaN" ) ; }


signature:
public class RisonParser { /** * Efficient handling for incremental parsing of base64 - encoded
 * textual content . */
protected byte [ ] _decodeBase64 ( Base64Variant b64variant ) throws IOException , JsonParseException { } }

implementation:
ByteArrayBuilder builder = _getByteArrayBuilder ( ) ; // main _ loop :
while ( true ) { // first , we ' ll skip preceding white space , if any
char ch ; do { if ( _inputPtr >= _inputEnd ) { loadMoreGuaranteed ( ) ; } ch = _inputBuffer [ _inputPtr ++ ] ; } while ( ch <= INT_SPACE ) ; int bits = b64variant . decodeBase64Char ( ch ) ; if ( bits < 0 ) { if ( ch == INT_APOSTROPHE ) { // reached the end , fair and square ?
return builder . toByteArray ( ) ; } bits = _decodeBase64Escape2 ( b64variant , ch , 0 ) ; if ( bits < 0 ) { // white space to skip
continue ; } } int decodedData = bits ; // then second base64 char ; can ' t get padding yet , nor ws
if ( _inputPtr >= _inputEnd ) { loadMoreGuaranteed ( ) ; } ch = _inputBuffer [ _inputPtr ++ ] ; bits = b64variant . decodeBase64Char ( ch ) ; if ( bits < 0 ) { bits = _decodeBase64Escape2 ( b64variant , ch , 1 ) ; } decodedData = ( decodedData << 6 ) | bits ; // third base64 char ; can be padding , but not ws
if ( _inputPtr >= _inputEnd ) { loadMoreGuaranteed ( ) ; } ch = _inputBuffer [ _inputPtr ++ ] ; bits = b64variant . decodeBase64Char ( ch ) ; // First branch : can get padding ( - > 1 byte )
if ( bits < 0 ) { if ( bits != Base64Variant . BASE64_VALUE_PADDING ) { // as per [ JACKSON - 631 ] , could also just be ' missing ' padding
if ( ch == INT_APOSTROPHE && ! b64variant . usesPadding ( ) ) { decodedData >>= 4 ; builder . append ( decodedData ) ; return builder . toByteArray ( ) ; } bits = _decodeBase64Escape2 ( b64variant , ch , 2 ) ; } if ( bits == Base64Variant . BASE64_VALUE_PADDING ) { // Ok , must get more padding chars , then
if ( _inputPtr >= _inputEnd ) { loadMoreGuaranteed ( ) ; } ch = _inputBuffer [ _inputPtr ++ ] ; if ( ! b64variant . usesPaddingChar ( ch ) ) { throw reportInvalidBase64Char ( b64variant , ch , 3 , "expected padding character '" + b64variant . getPaddingChar ( ) + "'" ) ; } // Got 12 bits , only need 8 , need to shift
decodedData >>= 4 ; builder . append ( decodedData ) ; continue ; } // otherwise we got escaped other char , to be processed below
} // Nope , 2 or 3 bytes
decodedData = ( decodedData << 6 ) | bits ; // fourth and last base64 char ; can be padding , but not ws
if ( _inputPtr >= _inputEnd ) { loadMoreGuaranteed ( ) ; } ch = _inputBuffer [ _inputPtr ++ ] ; bits = b64variant . decodeBase64Char ( ch ) ; if ( bits < 0 ) { if ( bits != Base64Variant . BASE64_VALUE_PADDING ) { // as per [ JACKSON - 631 ] , could also just be ' missing ' padding
if ( ch == INT_APOSTROPHE && ! b64variant . usesPadding ( ) ) { decodedData >>= 2 ; builder . appendTwoBytes ( decodedData ) ; return builder . toByteArray ( ) ; } bits = _decodeBase64Escape2 ( b64variant , ch , 3 ) ; } if ( bits == Base64Variant . BASE64_VALUE_PADDING ) { // With padding we only get 2 bytes ; but we have
// to shift it a bit so it is identical to triplet
// case with partial output .
// 3 chars gives 3x6 = = 18 bits , of which 2 are
// dummies , need to discard :
decodedData >>= 2 ; builder . appendTwoBytes ( decodedData ) ; continue ; } // otherwise we got escaped other char , to be processed below
} // otherwise , our triplet is now complete
decodedData = ( decodedData << 6 ) | bits ; builder . appendThreeBytes ( decodedData ) ; }


signature:
public class RisonParser { /** * / * Error reporting */
protected void _reportInvalidToken ( String matchedPart , String msg ) throws IOException , JsonParseException { } }

implementation:
StringBuilder sb = new StringBuilder ( matchedPart ) ; /* Let ' s just try to find what appears to be the token , using
 * regular Java identifier character rules . It ' s just a heuristic ,
 * nothing fancy here . */
while ( true ) { if ( _inputPtr >= _inputEnd ) { if ( ! loadMore ( ) ) { break ; } } char c = _inputBuffer [ _inputPtr ] ; if ( ! IdentifierUtils . isIdCharLenient ( c ) ) { break ; } ++ _inputPtr ; sb . append ( c ) ; } _reportError ( "Unrecognized token '" + sb . toString ( ) + "': was expecting " ) ;


signature:
public class IdentifierUtils { /** * Returns true if a string does not need to be quoted when serialized .
 * Uses the strict definition described in the Rison specification , appropriate for encoding . */
public static boolean isIdStrict ( String string ) { } }

implementation: int len = string . length ( ) ; if ( len == 0 ) { return false ; } if ( ! isIdStartStrict ( string . charAt ( 0 ) ) ) { return false ; } for ( int i = 1 ; i < len ; i ++ ) { if ( ! isIdCharStrict ( string . charAt ( i ) ) ) { return false ; } } return true ;


signature:
public class IdentifierUtils { /** * Returns true if the string represented by the specified character array does not
 * Uses the strict definition described in the Rison specification , appropriate for encoding . */
public static boolean isIdStrict ( char [ ] chars , int offset , int len ) { } }

implementation: if ( len == 0 ) { return false ; } int end = offset + len ; if ( ! isIdStartStrict ( chars [ offset ++ ] ) ) { return false ; } while ( offset < end ) { if ( ! isIdCharStrict ( chars [ offset ++ ] ) ) { return false ; } } return true ;


signature:
public class IdentifierUtils { /** * Encodes a set of ASCII characters ( < 127 ) as a bitset of 4 32 - bit values . */
private static int [ ] toIdSet ( boolean includeAlphaCharacters , String nonAlphaCharacters ) { } }

implementation:
int [ ] bits = new int [ 4 ] ; // 4*32 = 128 which covers all ASCII
if ( includeAlphaCharacters ) { for ( int ch = 'A' ; ch <= 'Z' ; ch ++ ) { bits [ ch >>> 5 ] |= ( 1 << ( ch & 31 ) ) ; } for ( int ch = 'a' ; ch <= 'z' ; ch ++ ) { bits [ ch >>> 5 ] |= ( 1 << ( ch & 31 ) ) ; } } for ( int i = 0 ; i < nonAlphaCharacters . length ( ) ; i ++ ) { int ch = nonAlphaCharacters . charAt ( i ) ; if ( ch >= 128 ) { throw new AssertionError ( ) ; // out of range
} bits [ ch >>> 5 ] |= ( 1 << ( ch & 31 ) ) ; } return bits ;


signature:
public class RisonGenerator { /** * / * Output method implementations , base64 - encoded binary */
@ Override public void writeBinary ( Base64Variant b64variant , byte [ ] data , int offset , int len ) throws IOException , JsonGenerationException { } }

implementation:
_verifyValueWrite ( "write binary value" ) ; // Starting quotes
if ( _outputTail >= _outputEnd ) { _flushBuffer ( ) ; } _outputBuffer [ _outputTail ++ ] = '\'' ; _writeBinary ( b64variant , data , offset , offset + len ) ; // and closing quotes
if ( _outputTail >= _outputEnd ) { _flushBuffer ( ) ; } _outputBuffer [ _outputTail ++ ] = '\'' ;


signature:
public class RisonGenerator { /** * / * Implementations for other methods */
@ Override protected final void _verifyValueWrite ( String typeMsg ) throws IOException , JsonGenerationException { } }

implementation: int status = _writeContext . writeValue ( ) ; if ( status == JsonWriteContext . STATUS_EXPECT_NAME ) { _reportError ( "Can not " + typeMsg + ", expecting field name" ) ; } char c ; switch ( status ) { case JsonWriteContext . STATUS_OK_AFTER_COMMA : c = ',' ; break ; case JsonWriteContext . STATUS_OK_AFTER_COLON : c = ':' ; break ; case JsonWriteContext . STATUS_OK_AFTER_SPACE : if ( _rootValueSeparator != null ) { _writeRaw ( _rootValueSeparator . getValue ( ) ) ; } return ; case JsonWriteContext . STATUS_OK_AS_IS : default : return ; } if ( _outputTail >= _outputEnd ) { _flushBuffer ( ) ; } _outputBuffer [ _outputTail ++ ] = c ;


signature:
public class RisonGenerator { /** * / * Internal methods , low - level writing ; text , default */
private void _writeRaw ( String text ) throws IOException , JsonGenerationException { } }

implementation:
// Nothing to check , can just output as is
int len = text . length ( ) ; int room = _outputEnd - _outputTail ; if ( room == 0 ) { _flushBuffer ( ) ; room = _outputEnd - _outputTail ; } // But would it nicely fit in ? If yes , it ' s easy
if ( room >= len ) { text . getChars ( 0 , len , _outputBuffer , _outputTail ) ; _outputTail += len ; } else { _writeRawLong ( text ) ; }


signature:
public class RisonGenerator { /** * Method called to output textual context which has been copied
 * to the output buffer prior to call . If any escaping is needed ,
 * it will also be handled by the method .
 * Note : when called , textual content to write is within output
 * buffer , right after buffered content ( if any ) . That ' s why only
 * length of that text is passed , as buffer and offset are implied . */
private void _writeSegment ( int end ) throws IOException , JsonGenerationException { } }

implementation:
int ptr = 0 ; int start = ptr ; output_loop : while ( ptr < end ) { // Fast loop for chars not needing escaping
char c ; while ( true ) { c = _outputBuffer [ ptr ] ; if ( c == '!' || c == '\'' ) { break ; } if ( ++ ptr >= end ) { break ; } } // Ok , bumped into something that needs escaping .
/* First things first : need to flush the buffer .
 * Inlined , as we don ' t want to lose tail pointer */
int flushLen = ( ptr - start ) ; if ( flushLen > 0 ) { _writer . write ( _outputBuffer , start , flushLen ) ; if ( ptr >= end ) { break output_loop ; } } // So ; either try to prepend ( most likely ) , or write directly :
start = _prependOrWrite ( _outputBuffer , ptr , '!' ) ; ptr ++ ; // advance past the char - to - be - escaped
// Flush the last 1 or 2 characters if this is the last time though the loop
if ( ptr == end ) { _writer . write ( _outputBuffer , start , ptr - start ) ; break output_loop ; } }


signature:
public class RisonGenerator { /** * This method called when the string content is already in
 * a char buffer , and need not be copied for processing . */
private void _writeString ( char [ ] text , int offset , int len ) throws IOException , JsonGenerationException { } }

implementation:
/* Let ' s just find longest spans of non - escapable
 * content , and for each see if it makes sense
 * to copy them , or write through */
len += offset ; // - > len marks the end from now on
while ( offset < len ) { int start = offset ; while ( true ) { char c = text [ offset ] ; if ( c == '!' || c == '\'' ) { break ; } if ( ++ offset >= len ) { break ; } } // Short span ? Better just copy it to buffer first :
int newAmount = offset - start ; if ( newAmount < SHORT_WRITE ) { // Note : let ' s reserve room for escaped char ( up to 6 chars )
if ( ( _outputTail + newAmount ) > _outputEnd ) { _flushBuffer ( ) ; } if ( newAmount > 0 ) { System . arraycopy ( text , start , _outputBuffer , _outputTail , newAmount ) ; _outputTail += newAmount ; } } else { // Nope : better just write through
_flushBuffer ( ) ; _writer . write ( text , start , newAmount ) ; } // Was this the end ?
if ( offset >= len ) { // yup
break ; } // Nope , need to escape the char .
char c = text [ offset ++ ] ; _appendCharacterEscape ( '!' , c ) ; }


signature:
public class RisonGenerator { /** * / * Internal methods , low - level writing ; binary */
protected void _writeBinary ( Base64Variant b64variant , byte [ ] input , int inputPtr , final int inputEnd ) throws IOException , JsonGenerationException { } }

implementation:
// Encoding is by chunks of 3 input , 4 output chars , so :
int safeInputEnd = inputEnd - 3 ; // Let ' s also reserve room for possible lf char each round
int safeOutputEnd = _outputEnd - 6 ; int chunksBeforeLF = b64variant . getMaxLineLength ( ) >> 2 ; // Ok , first we loop through all full triplets of data :
while ( inputPtr <= safeInputEnd ) { if ( _outputTail > safeOutputEnd ) { // need to flush
_flushBuffer ( ) ; } // First , mash 3 bytes into lsb of 32 - bit int
int b24 = ( ( int ) input [ inputPtr ++ ] ) << 8 ; b24 |= ( ( int ) input [ inputPtr ++ ] ) & 0xFF ; b24 = ( b24 << 8 ) | ( ( ( int ) input [ inputPtr ++ ] ) & 0xFF ) ; _outputTail = b64variant . encodeBase64Chunk ( b24 , _outputBuffer , _outputTail ) ; if ( -- chunksBeforeLF <= 0 ) { // note : RISON does not escape newlines
_outputBuffer [ _outputTail ++ ] = '\n' ; chunksBeforeLF = b64variant . getMaxLineLength ( ) >> 2 ; } } // And then we may have 1 or 2 leftover bytes to encode
int inputLeft = inputEnd - inputPtr ; // 0 , 1 or 2
if ( inputLeft > 0 ) { // yes , but do we have room for output ?
if ( _outputTail > safeOutputEnd ) { // don ' t really need 6 bytes but . . .
_flushBuffer ( ) ; } int b24 = ( ( int ) input [ inputPtr ++ ] ) << 16 ; if ( inputLeft == 2 ) { b24 |= ( ( ( int ) input [ inputPtr ] ) & 0xFF ) << 8 ; } _outputTail = b64variant . encodeBase64Partial ( b24 , inputLeft , _outputBuffer , _outputTail ) ; }


signature:
public class RisonGenerator { /** * Method called to try to either prepend character escape at front of
 * given buffer ; or if not possible , to write it out directly .
 * @ return Pointer to start of prepended entity ( if prepended ) ; or ' ptr '
 * if not . */
private int _prependOrWrite ( char [ ] buffer , int ptr , char esc ) throws IOException , JsonGenerationException { } }

implementation:
if ( ptr > 0 ) { // fits , just prepend
buffer [ -- ptr ] = esc ; } else { // won ' t fit , write
_writer . write ( esc ) ; } return ptr ;


signature:
public class RisonGenerator { /** * Method called to append escape sequence for given character , at the
 * end of standard output buffer ; or if not possible , write out directly . */
private void _appendCharacterEscape ( char esc , char ch ) throws IOException , JsonGenerationException { } }

implementation: if ( ( _outputTail + 1 ) >= _outputEnd ) { _flushBuffer ( ) ; } _outputBuffer [ _outputTail ++ ] = esc ; _outputBuffer [ _outputTail ++ ] = ch ;


signature:
public class ThriftToPig { /** * Set the flags that can be used by the conversion .
 * @ param conf usually the Hadoop job conf */
public static void setConversionProperties ( Configuration conf ) { } }

implementation: if ( conf != null ) { useEnumId = conf . getBoolean ( USE_ENUM_ID_CONF_KEY , false ) ; LOG . debug ( "useEnumId is set to " + useEnumId ) ; }


signature:
public class ThriftToPig { /** * TType . STRING is a mess in Thrift . It could be byte [ ] , ByteBuffer ,
 * or even a String ! . */
private static Object stringTypeToPig ( Object value ) { } }

implementation: if ( value instanceof String ) { return value ; } if ( value instanceof byte [ ] ) { byte [ ] buf = ( byte [ ] ) value ; return new DataByteArray ( Arrays . copyOf ( buf , buf . length ) ) ; } if ( value instanceof ByteBuffer ) { ByteBuffer bin = ( ByteBuffer ) value ; byte [ ] buf = new byte [ bin . remaining ( ) ] ; bin . mark ( ) ; bin . get ( buf ) ; bin . reset ( ) ; return new DataByteArray ( buf ) ; } return null ;


signature:
public class ThriftToPig { /** * return { @ link FieldSchema } for a given field . */
private static FieldSchema singleFieldToFieldSchema ( String fieldName , Field field ) throws FrontendException { } }

implementation:
// TODO we should probably implement better naming , the current system is pretty nonsensical now
switch ( field . getType ( ) ) { case TType . STRUCT : return new FieldSchema ( fieldName , toSchema ( field . gettStructDescriptor ( ) ) , DataType . TUPLE ) ; case TType . LIST : return new FieldSchema ( fieldName , singleFieldToTupleSchema ( fieldName + "_tuple" , field . getListElemField ( ) ) , DataType . BAG ) ; case TType . SET : return new FieldSchema ( fieldName , singleFieldToTupleSchema ( fieldName + "_tuple" , field . getSetElemField ( ) ) , DataType . BAG ) ; case TType . MAP : if ( field . getMapKeyField ( ) . getType ( ) != TType . STRING && field . getMapKeyField ( ) . getType ( ) != TType . ENUM ) { LOG . warn ( "Using a map with non-string key for field " + field . getName ( ) + ". while converting to PIG Tuple, toString() is used for the key." + " It could result in incorrect maps." ) ; } return new FieldSchema ( fieldName , new Schema ( singleFieldToFieldSchema ( null , field . getMapValueField ( ) ) ) , DataType . MAP ) ; default : return new FieldSchema ( fieldName , null , getPigDataType ( field ) ) ; }


signature:
public class ThriftToPig { /** * A helper function which wraps a Schema in a tuple ( for Pig bags ) if our version of pig makes it necessary */
private static Schema wrapInTupleIfPig9 ( Schema schema ) throws FrontendException { } }

implementation: if ( PigUtil . Pig9orNewer ) { return new Schema ( new FieldSchema ( "t" , schema , DataType . TUPLE ) ) ; } else { return schema ; }


signature:
public class ThriftToPig { /** * Returns a schema with single tuple ( for Pig bags ) . */
private static Schema singleFieldToTupleSchema ( String fieldName , Field field ) throws FrontendException { } }

implementation: switch ( field . getType ( ) ) { case TType . STRUCT : return wrapInTupleIfPig9 ( toSchema ( field . gettStructDescriptor ( ) ) ) ; case TType . LIST : case TType . SET : case TType . MAP : return wrapInTupleIfPig9 ( new Schema ( singleFieldToFieldSchema ( fieldName , field ) ) ) ; default : return wrapInTupleIfPig9 ( new Schema ( new FieldSchema ( fieldName , null , getPigDataType ( field ) ) ) ) ; }


signature:
public class ThriftToPig { /** * Turn a Thrift Struct into a loading schema for a pig script . */
public static String toPigScript ( Class < ? extends TBase < ? , ? > > thriftClass , Class < ? extends LoadFunc > pigLoader ) { } }

implementation:
StringBuilder sb = new StringBuilder ( ) ; /* we are commenting out explicit schema specification . The schema is
 * included mainly to help the readers of the pig script . Pig learns the
 * schema directly from the loader .
 * If explicit schema is not commented , we might have surprising results
 * when a Thrift class ( possibly in control of another team ) changes ,
 * but the Pig script is not updated . Commenting it out avoids this . */
StringBuilder prefix = new StringBuilder ( "       --  " ) ; sb . append ( "raw_data = load '$INPUT_FILES' using " ) . append ( pigLoader . getName ( ) ) . append ( "('" ) . append ( thriftClass . getName ( ) ) . append ( "');\n" ) . append ( prefix ) . append ( "as " ) ; prefix . append ( "   " ) ; try { stringifySchema ( sb , toSchema ( thriftClass ) , DataType . TUPLE , prefix ) ; } catch ( FrontendException e ) { throw new RuntimeException ( e ) ; } sb . append ( "\n" ) ; return sb . toString ( ) ;


signature:
public class ThriftToPig { /** * type can only be BAG or TUPLE */
public static void stringifySchema ( StringBuilder sb , Schema schema , byte type , StringBuilder prefix ) throws FrontendException { } }

implementation:
// this is a modified version of { @ link Schema # stringifySchema ( StringBuilder , Schema , byte ) }
if ( type == DataType . TUPLE ) { sb . append ( "(" ) ; } else if ( type == DataType . BAG ) { sb . append ( "{" ) ; } prefix . append ( "  " ) ; sb . append ( "\n" ) . append ( prefix ) ; if ( schema == null ) { sb . append ( "null" ) ; } else { boolean isFirst = true ; for ( int i = 0 ; i < schema . size ( ) ; i ++ ) { if ( ! isFirst ) { sb . append ( ",\n" ) . append ( prefix ) ; } else { isFirst = false ; } FieldSchema fs = schema . getField ( i ) ; if ( fs == null ) { sb . append ( "null" ) ; continue ; } if ( fs . alias != null ) { sb . append ( fs . alias ) ; sb . append ( ": " ) ; } if ( DataType . isAtomic ( fs . type ) ) { sb . append ( DataType . findTypeName ( fs . type ) ) ; } else if ( ( fs . type == DataType . TUPLE ) || ( fs . type == DataType . BAG ) ) { // safety net
if ( schema != fs . schema ) { stringifySchema ( sb , fs . schema , fs . type , prefix ) ; } else { throw new AssertionError ( "Schema refers to itself " + "as inner schema" ) ; } } else if ( fs . type == DataType . MAP ) { sb . append ( DataType . findTypeName ( fs . type ) + "[" ) ; if ( fs . schema != null ) stringifySchema ( sb , fs . schema , fs . type , prefix ) ; sb . append ( "]" ) ; } else { sb . append ( DataType . findTypeName ( fs . type ) ) ; } } } prefix . setLength ( prefix . length ( ) - 2 ) ; sb . append ( "\n" ) . append ( prefix ) ; if ( type == DataType . TUPLE ) { sb . append ( ")" ) ; } else if ( type == DataType . BAG ) { sb . append ( "}" ) ; }


signature:
public class LuceneIndexRecordReader { /** * Open an index stored in path
 * Override if you want more control over how indexes are opened
 * @ param path path to the index
 * @ param conf job conf
 * @ return an IndexReader of the index in path
 * @ throws IOException */
protected IndexReader openIndex ( Path path , Configuration conf ) throws IOException { } }

implementation: return DirectoryReader . open ( new LuceneHdfsDirectory ( path , path . getFileSystem ( conf ) ) ) ;


signature:
public class LuceneIndexRecordReader { /** * This is sort of an approximation of progress .
 * It splits the progress equally among all indexes , then among all queries for that index .
 * So it won ' t move linearly , since we don ' t know how many hits there will be per query */
@ Override public float getProgress ( ) { } }

implementation: if ( numIndexes < 1 ) { return 1.0f ; } float indexProgress = ( float ) currentIndexPathIter . previousIndex ( ) / ( float ) numIndexes ; float queriesProgress = 1.0f ; if ( queries . size ( ) > 0 ) { queriesProgress = ( float ) currentQueryIter . previousIndex ( ) / ( float ) queries . size ( ) ; } queriesProgress *= 1.0f / numIndexes ; return indexProgress + queriesProgress ;


signature:
public class ProtobufToPig { /** * Turn a generic message into a Tuple . Individual fields that are enums
 * are converted into their string equivalents . Fields that are not filled
 * out in the protobuf are set to null , unless there is a default field value in
 * which case that is used instead .
 * @ param msg the protobuf message
 * @ return a pig tuple representing the message . */
public Tuple toTuple ( Message msg ) { } }

implementation:
if ( msg == null ) { // Pig tuples deal gracefully with nulls .
// Also , we can be called with null here in recursive calls .
return null ; } Descriptor msgDescriptor = msg . getDescriptorForType ( ) ; Tuple tuple = tupleFactory_ . newTuple ( msgDescriptor . getFields ( ) . size ( ) ) ; int curField = 0 ; try { // Walk through all the possible fields in the message .
for ( FieldDescriptor fieldDescriptor : msgDescriptor . getFields ( ) ) { // Get the set value , or the default value , or null .
Object fieldValue = msg . getField ( fieldDescriptor ) ; if ( fieldDescriptor . getType ( ) == FieldDescriptor . Type . MESSAGE ) { tuple . set ( curField ++ , messageToTuple ( fieldDescriptor , fieldValue ) ) ; } else { tuple . set ( curField ++ , singleFieldToTuple ( fieldDescriptor , fieldValue ) ) ; } } } catch ( ExecException e ) { LOG . warn ( "Could not convert msg " + msg + " to tuple" , e ) ; } return tuple ;


signature:
public class ProtobufToPig { /** * Returns either { @ link # messageToTuple ( FieldDescriptor , Object ) }
 * or { @ link # singleFieldToTuple ( FieldDescriptor , Object ) } depending
 * on whether the field is a Message or a simple field . */
public Object fieldToPig ( FieldDescriptor fieldDescriptor , Object fieldValue ) { } }

implementation:
if ( fieldValue == null ) { // protobufs unofficially ensures values are not null . just in case :
return null ; } if ( fieldDescriptor . getType ( ) == FieldDescriptor . Type . MESSAGE ) { return messageToTuple ( fieldDescriptor , fieldValue ) ; } else { return singleFieldToTuple ( fieldDescriptor , fieldValue ) ; }


signature:
public class ProtobufToPig { /** * Translate a nested message to a tuple . If the field is repeated , it walks the list and adds each to a bag .
 * Otherwise , it just adds the given one .
 * @ param fieldDescriptor the descriptor object for the given field .
 * @ param fieldValue the object representing the value of this field , possibly null .
 * @ return the object representing fieldValue in Pig - - either a bag or a tuple . */
@ SuppressWarnings ( "unchecked" ) protected Object messageToTuple ( FieldDescriptor fieldDescriptor , Object fieldValue ) { } }

implementation:
if ( fieldValue == null ) { // protobufs unofficially ensures values are not null . just in case :
return null ; } assert fieldDescriptor . getType ( ) == FieldDescriptor . Type . MESSAGE : "messageToTuple called with field of type " + fieldDescriptor . getType ( ) ; if ( fieldDescriptor . isRepeated ( ) ) { // The protobuf contract is that if the field is repeated , then the object returned is actually a List
// of the underlying datatype , which in this case is a nested message .
List < Message > messageList = ( List < Message > ) ( fieldValue != null ? fieldValue : Lists . newArrayList ( ) ) ; DataBag bag = new NonSpillableDataBag ( messageList . size ( ) ) ; for ( Message m : messageList ) { bag . add ( new ProtobufTuple ( m ) ) ; } return bag ; } else { return new ProtobufTuple ( ( Message ) fieldValue ) ; }


signature:
public class ProtobufToPig { /** * Translate a single field to a tuple . If the field is repeated , it walks the list and adds each to a bag .
 * Otherwise , it just adds the given one .
 * @ param fieldDescriptor the descriptor object for the given field .
 * @ param fieldValue the object representing the value of this field , possibly null .
 * @ return the object representing fieldValue in Pig - - either a bag or a single field .
 * @ throws ExecException if Pig decides to . Shouldn ' t happen because we won ' t walk off the end of a tuple ' s field set . */
@ SuppressWarnings ( "unchecked" ) protected Object singleFieldToTuple ( FieldDescriptor fieldDescriptor , Object fieldValue ) { } }

implementation:
assert fieldDescriptor . getType ( ) != FieldDescriptor . Type . MESSAGE : "messageToFieldSchema called with field of type " + fieldDescriptor . getType ( ) ; if ( fieldDescriptor . isRepeated ( ) ) { // The protobuf contract is that if the field is repeated , then the object returned is actually a List
// of the underlying datatype , which in this case is a " primitive " like int , float , String , etc .
// We have to make a single - item tuple out of it to put it in the bag .
List < Object > fieldValueList = ( List < Object > ) ( fieldValue != null ? fieldValue : Collections . emptyList ( ) ) ; DataBag bag = new NonSpillableDataBag ( fieldValueList . size ( ) ) ; for ( Object singleFieldValue : fieldValueList ) { Object nonEnumFieldValue = coerceToPigTypes ( fieldDescriptor , singleFieldValue ) ; Tuple innerTuple = tupleFactory_ . newTuple ( 1 ) ; try { innerTuple . set ( 0 , nonEnumFieldValue ) ; } catch ( ExecException e ) { // not expected
throw new RuntimeException ( e ) ; } bag . add ( innerTuple ) ; } return bag ; } else { return coerceToPigTypes ( fieldDescriptor , fieldValue ) ; }


signature:
public class ProtobufToPig { /** * If the given field value is an enum , translate it to the enum ' s name as a string , since Pig cannot handle enums .
 * Also , if the given field value is a bool , translate it to 0 or 1 to avoid Pig bools , which can be sketchy .
 * @ param fieldDescriptor the descriptor object for the given field .
 * @ param fieldValue the object representing the value of this field , possibly null .
 * @ return the object , unless it was from an enum field , in which case we return the name of the enum field . */
private Object coerceToPigTypes ( FieldDescriptor fieldDescriptor , Object fieldValue ) { } }

implementation: if ( fieldDescriptor . getType ( ) == FieldDescriptor . Type . ENUM && fieldValue != null ) { EnumValueDescriptor enumValueDescriptor = ( EnumValueDescriptor ) fieldValue ; return enumValueDescriptor . getName ( ) ; } else if ( fieldDescriptor . getType ( ) == FieldDescriptor . Type . BOOL && fieldValue != null ) { Boolean boolValue = ( Boolean ) fieldValue ; return new Integer ( boolValue ? 1 : 0 ) ; } else if ( fieldDescriptor . getType ( ) == FieldDescriptor . Type . BYTES && fieldValue != null ) { ByteString bsValue = ( ByteString ) fieldValue ; return new DataByteArray ( bsValue . toByteArray ( ) ) ; } return fieldValue ;


signature:
public class ProtobufToPig { /** * Turn a generic message descriptor into a Schema . Individual fields that are enums
 * are converted into their string equivalents .
 * @ param msgDescriptor the descriptor for the given message type .
 * @ return a pig schema representing the message . */
public Schema toSchema ( Descriptor msgDescriptor ) { } }

implementation:
Schema schema = new Schema ( ) ; try { // Walk through all the possible fields in the message .
for ( FieldDescriptor fieldDescriptor : msgDescriptor . getFields ( ) ) { if ( fieldDescriptor . getType ( ) == FieldDescriptor . Type . MESSAGE ) { schema . add ( messageToFieldSchema ( fieldDescriptor ) ) ; } else { schema . add ( singleFieldToFieldSchema ( fieldDescriptor ) ) ; } } } catch ( FrontendException e ) { LOG . warn ( "Could not convert descriptor " + msgDescriptor + " to schema" , e ) ; } return schema ;


signature:
public class ProtobufToPig { /** * Turn a nested message into a Schema object . For repeated nested messages , it generates a schema for a bag of
 * tuples . For non - repeated nested messages , it just generates a schema for the tuple itself .
 * @ param fieldDescriptor the descriptor object for the given field .
 * @ return the Schema for the nested message .
 * @ throws FrontendException if Pig decides to . */
private FieldSchema messageToFieldSchema ( FieldDescriptor fieldDescriptor ) throws FrontendException { } }

implementation: assert fieldDescriptor . getType ( ) == FieldDescriptor . Type . MESSAGE : "messageToFieldSchema called with field of type " + fieldDescriptor . getType ( ) ; Schema innerSchema = toSchema ( fieldDescriptor . getMessageType ( ) ) ; if ( fieldDescriptor . isRepeated ( ) ) { Schema tupleSchema = new Schema ( ) ; tupleSchema . add ( new FieldSchema ( fieldDescriptor . getName ( ) + "_tuple" , innerSchema , DataType . TUPLE ) ) ; return new FieldSchema ( fieldDescriptor . getName ( ) , tupleSchema , DataType . BAG ) ; } else { return new FieldSchema ( fieldDescriptor . getName ( ) , innerSchema , DataType . TUPLE ) ; }


signature:
public class ProtobufToPig { /** * Turn a single field into a Schema object . For repeated single fields , it generates a schema for a bag of single - item tuples .
 * For non - repeated fields , it just generates a standard field schema .
 * @ param fieldDescriptor the descriptor object for the given field .
 * @ return the Schema for the nested message .
 * @ throws FrontendException if Pig decides to . */
private FieldSchema singleFieldToFieldSchema ( FieldDescriptor fieldDescriptor ) throws FrontendException { } }

implementation: assert fieldDescriptor . getType ( ) != FieldDescriptor . Type . MESSAGE : "singleFieldToFieldSchema called with field of type " + fieldDescriptor . getType ( ) ; if ( fieldDescriptor . isRepeated ( ) ) { Schema itemSchema = new Schema ( ) ; itemSchema . add ( new FieldSchema ( fieldDescriptor . getName ( ) , null , getPigDataType ( fieldDescriptor ) ) ) ; Schema itemTupleSchema = new Schema ( ) ; itemTupleSchema . add ( new FieldSchema ( fieldDescriptor . getName ( ) + "_tuple" , itemSchema , DataType . TUPLE ) ) ; return new FieldSchema ( fieldDescriptor . getName ( ) + "_bag" , itemTupleSchema , DataType . BAG ) ; } else { return new FieldSchema ( fieldDescriptor . getName ( ) , null , getPigDataType ( fieldDescriptor ) ) ; }


signature:
public class ProtobufToPig { /** * Translate between protobuf ' s datatype representation and Pig ' s datatype representation .
 * @ param fieldDescriptor the descriptor object for the given field .
 * @ return the byte representing the pig datatype for the given field type . */
private byte getPigDataType ( FieldDescriptor fieldDescriptor ) { } }

implementation:
switch ( fieldDescriptor . getType ( ) ) { case INT32 : case UINT32 : case SINT32 : case FIXED32 : case SFIXED32 : case BOOL : // We convert booleans to ints for pig output .
return DataType . INTEGER ; case INT64 : case UINT64 : case SINT64 : case FIXED64 : case SFIXED64 : return DataType . LONG ; case FLOAT : return DataType . FLOAT ; case DOUBLE : return DataType . DOUBLE ; case STRING : case ENUM : // We convert enums to strings for pig output .
return DataType . CHARARRAY ; case BYTES : return DataType . BYTEARRAY ; case MESSAGE : throw new IllegalArgumentException ( "getPigDataType called on field " + fieldDescriptor . getFullName ( ) + " of type message." ) ; default : throw new IllegalArgumentException ( "Unexpected field type. " + fieldDescriptor . toString ( ) + " " + fieldDescriptor . getFullName ( ) + " " + fieldDescriptor . getType ( ) ) ; }


signature:
public class ProtobufToPig { /** * Turn a generic message descriptor into a loading schema for a pig script .
 * @ param msgDescriptor the descriptor for the given message type .
 * @ param loaderClassName the fully qualified classname of the pig loader to use . Not
 * passed a < code > Class < ? extends LoadFunc > < / code > because in many situations that class
 * is being generated as well , and so doesn ' t exist in compiled form .
 * @ return a pig script that can load the given message . */
public String toPigScript ( Descriptor msgDescriptor , String loaderClassName ) { } }

implementation: StringBuffer sb = new StringBuffer ( ) ; final int initialTabOffset = 3 ; sb . append ( "raw_data = load '$INPUT_FILES' using " + loaderClassName + "()" ) . append ( "\n" ) ; sb . append ( tabs ( initialTabOffset ) ) . append ( "as (" ) . append ( "\n" ) ; sb . append ( toPigScriptInternal ( msgDescriptor , initialTabOffset ) ) ; sb . append ( tabs ( initialTabOffset ) ) . append ( ");" ) . append ( "\n" ) . append ( "\n" ) ; return sb . toString ( ) ;


signature:
public class ProtobufToPig { /** * Turn a generic message descriptor into a loading schema for a pig script . Individual fields that are enums
 * are converted into their string equivalents .
 * @ param msgDescriptor the descriptor for the given message type .
 * @ param numTabs the tab depth at the current point in the recursion , for pretty printing .
 * @ return a pig schema representing the message . */
private StringBuffer toPigScriptInternal ( Descriptor msgDescriptor , int numTabs ) { } }

implementation:
StringBuffer sb = new StringBuffer ( ) ; try { // Walk through all the possible fields in the message .
for ( FieldDescriptor fieldDescriptor : msgDescriptor . getFields ( ) ) { // We have to add a comma after every line EXCEPT for the last , or Pig gets mad .
boolean isLast = ( fieldDescriptor == msgDescriptor . getFields ( ) . get ( msgDescriptor . getFields ( ) . size ( ) - 1 ) ) ; if ( fieldDescriptor . getType ( ) == FieldDescriptor . Type . MESSAGE ) { sb . append ( messageToPigScript ( fieldDescriptor , numTabs + 1 , isLast ) ) ; } else { sb . append ( singleFieldToPigScript ( fieldDescriptor , numTabs + 1 , isLast ) ) ; } } } catch ( FrontendException e ) { LOG . warn ( "Could not convert descriptor " + msgDescriptor + " to pig script" , e ) ; } return sb ;


signature:
public class ProtobufToPig { /** * Turn a nested message into a pig script load string . For repeated nested messages , it generates a string for a bag of
 * tuples . For non - repeated nested messages , it just generates a string for the tuple itself .
 * @ param fieldDescriptor the descriptor object for the given field .
 * @ param numTabs the tab depth at the current point in the recursion , for pretty printing .
 * @ return the pig script load schema for the nested message .
 * @ throws FrontendException if Pig decides to . */
private StringBuffer messageToPigScript ( FieldDescriptor fieldDescriptor , int numTabs , boolean isLast ) throws FrontendException { } }

implementation: assert fieldDescriptor . getType ( ) == FieldDescriptor . Type . MESSAGE : "messageToPigScript called with field of type " + fieldDescriptor . getType ( ) ; if ( fieldDescriptor . isRepeated ( ) ) { return new StringBuffer ( ) . append ( tabs ( numTabs ) ) . append ( fieldDescriptor . getName ( ) ) . append ( ": bag {" ) . append ( "\n" ) . append ( tabs ( numTabs + 1 ) ) . append ( fieldDescriptor . getName ( ) ) . append ( "_tuple: tuple (" ) . append ( "\n" ) . append ( toPigScriptInternal ( fieldDescriptor . getMessageType ( ) , numTabs + 2 ) ) . append ( tabs ( numTabs + 1 ) ) . append ( ")" ) . append ( "\n" ) . append ( tabs ( numTabs ) ) . append ( "}" ) . append ( isLast ? "" : "," ) . append ( "\n" ) ; } else { return new StringBuffer ( ) . append ( tabs ( numTabs ) ) . append ( fieldDescriptor . getName ( ) ) . append ( ": tuple (" ) . append ( "\n" ) . append ( toPigScriptInternal ( fieldDescriptor . getMessageType ( ) , numTabs + 1 ) ) . append ( tabs ( numTabs ) ) . append ( ")" ) . append ( isLast ? "" : "," ) . append ( "\n" ) ; }


signature:
public class ProtobufToPig { /** * Turn a single field into a pig script load string . For repeated single fields , it generates a string for a bag of single - item tuples .
 * For non - repeated fields , it just generates a standard single - element string .
 * @ param fieldDescriptor the descriptor object for the given field .
 * @ param numTabs the tab depth at the current point in the recursion , for pretty printing .
 * @ return the pig script load string for the nested message .
 * @ throws FrontendException if Pig decides to . */
private StringBuffer singleFieldToPigScript ( FieldDescriptor fieldDescriptor , int numTabs , boolean isLast ) throws FrontendException { } }

implementation: assert fieldDescriptor . getType ( ) != FieldDescriptor . Type . MESSAGE : "singleFieldToPigScript called with field of type " + fieldDescriptor . getType ( ) ; if ( fieldDescriptor . isRepeated ( ) ) { return new StringBuffer ( ) . append ( tabs ( numTabs ) ) . append ( fieldDescriptor . getName ( ) ) . append ( "_bag: bag {" ) . append ( "\n" ) . append ( tabs ( numTabs + 1 ) ) . append ( fieldDescriptor . getName ( ) ) . append ( "_tuple: tuple (" ) . append ( "\n" ) . append ( tabs ( numTabs + 2 ) ) . append ( fieldDescriptor . getName ( ) ) . append ( ": " ) . append ( getPigScriptDataType ( fieldDescriptor ) ) . append ( "\n" ) . append ( tabs ( numTabs + 1 ) ) . append ( ")" ) . append ( "\n" ) . append ( tabs ( numTabs ) ) . append ( "}" ) . append ( isLast ? "" : "," ) . append ( "\n" ) ; } else { return new StringBuffer ( ) . append ( tabs ( numTabs ) ) . append ( fieldDescriptor . getName ( ) ) . append ( ": " ) . append ( getPigScriptDataType ( fieldDescriptor ) ) . append ( isLast ? "" : "," ) . append ( "\n" ) ; }


signature:
public class ProtobufToPig { /** * Translate between protobuf ' s datatype representation and Pig ' s datatype representation .
 * @ param fieldDescriptor the descriptor object for the given field .
 * @ return the byte representing the pig datatype for the given field type . */
private String getPigScriptDataType ( FieldDescriptor fieldDescriptor ) { } }

implementation:
switch ( fieldDescriptor . getType ( ) ) { case INT32 : case UINT32 : case SINT32 : case FIXED32 : case SFIXED32 : case BOOL : // We convert booleans to ints for pig output .
return "int" ; case INT64 : case UINT64 : case SINT64 : case FIXED64 : case SFIXED64 : return "long" ; case FLOAT : return "float" ; case DOUBLE : return "double" ; case STRING : case ENUM : // We convert enums to strings for pig output .
return "chararray" ; case BYTES : return "bytearray" ; case MESSAGE : throw new IllegalArgumentException ( "getPigScriptDataType called on field " + fieldDescriptor . getFullName ( ) + " of type message." ) ; default : throw new IllegalArgumentException ( "Unexpected field type. " + fieldDescriptor . toString ( ) + " " + fieldDescriptor . getFullName ( ) + " " + fieldDescriptor . getType ( ) ) ; }


signature:
public class TStructDescriptor { /** * Creates a descriptor for a Thrift class */
public static TStructDescriptor getInstance ( Class < ? extends TBase < ? , ? > > tClass ) { } }

implementation: synchronized ( structMap ) { TStructDescriptor desc = structMap . get ( tClass ) ; if ( desc == null ) { desc = new TStructDescriptor ( ) ; desc . tClass = tClass ; structMap . put ( tClass , desc ) ; desc . build ( tClass ) ; } return desc ; }


signature:
public class TStructDescriptor { /** * returns ' enum name - > enum object ' mapping .
 * Currently used for converting Tuple to a Thrift object . */
static private Map < String , TEnum > extractEnumMap ( Class < ? extends TEnum > enumClass ) { } }

implementation: ImmutableMap . Builder < String , TEnum > builder = ImmutableMap . builder ( ) ; for ( TEnum e : enumClass . getEnumConstants ( ) ) { builder . put ( e . toString ( ) , e ) ; } return builder . build ( ) ;


signature:
public class TStructDescriptor { /** * Derives Thrift TType from java { @ link Type } of a thrift field */
private static byte getTTypeFromJavaType ( Type jType ) { } }

implementation:
// check primitive types and final classes
if ( jType == Boolean . TYPE || jType == Boolean . class ) return TType . BOOL ; if ( jType == Byte . TYPE || jType == Byte . class ) return TType . BYTE ; if ( jType == Short . TYPE || jType == Short . class ) return TType . I16 ; if ( jType == Integer . TYPE || jType == Integer . class ) return TType . I32 ; if ( jType == Long . TYPE || jType == Long . class ) return TType . I64 ; if ( jType == Double . TYPE || jType == Double . class ) return TType . DOUBLE ; if ( jType == String . class ) return TType . STRING ; if ( jType == byte [ ] . class ) return TType . STRING ; // buffer
if ( jType == Void . class ) return TType . VOID ; // non - generic simple classes
if ( jType instanceof Class ) { Class < ? > klass = ( Class < ? > ) jType ; if ( TEnum . class . isAssignableFrom ( klass ) ) return TType . ENUM ; if ( ByteBuffer . class . isAssignableFrom ( klass ) ) return TType . STRING ; // buffer ( ByteBuffer )
if ( TBase . class . isAssignableFrom ( klass ) ) return TType . STRUCT ; } // generic types
if ( jType instanceof ParameterizedType ) { Class < ? > klass = ( Class < ? > ) ( ( ParameterizedType ) jType ) . getRawType ( ) ; if ( Map . class . isAssignableFrom ( klass ) ) return TType . MAP ; if ( Set . class . isAssignableFrom ( klass ) ) return TType . SET ; if ( List . class . isAssignableFrom ( klass ) ) return TType . LIST ; } throw new IllegalArgumentException ( "cannot convert java type '" + jType + "'  to thrift type" ) ;


signature:
public class LuceneIndexOutputFormat { /** * Creates a path filter that accepts non - hidden directories that start with " index - "
 * This is what the indexes created by this output format look like ,
 * so this is useful for finding them when traversing the file system */
public static PathFilter newIndexDirFilter ( Configuration conf ) { } }

implementation: return new PathFilters . CompositePathFilter ( PathFilters . newExcludeFilesFilter ( conf ) , PathFilters . EXCLUDE_HIDDEN_PATHS_FILTER , new PathFilter ( ) { @ Override public boolean accept ( Path path ) { return path . getName ( ) . startsWith ( "index-" ) ; } } ) ;


signature:
public class Protobufs { /** * For a configured protoClass , should the message be dynamic or is it a pre - generated Message class ? If protoClass is
 * null or set to DynamicMessage . class , then the configurer intends for a dynamically generated protobuf to be used . */
public static boolean useDynamicProtoMessage ( Class < ? > protoClass ) { } }

implementation: return protoClass == null || protoClass . getCanonicalName ( ) . equals ( DynamicMessage . class . getCanonicalName ( ) ) ;


signature:
public class Protobufs { /** * Returns a Message { @ link Descriptor } for a dynamically generated
 * DescriptorProto .
 * @ param descProto
 * @ throws DescriptorValidationException */
public static Descriptor makeMessageDescriptor ( DescriptorProto descProto ) throws DescriptorValidationException { } }

implementation: DescriptorProtos . FileDescriptorProto fileDescP = DescriptorProtos . FileDescriptorProto . newBuilder ( ) . addMessageType ( descProto ) . build ( ) ; Descriptors . FileDescriptor [ ] fileDescs = new Descriptors . FileDescriptor [ 0 ] ; Descriptors . FileDescriptor dynamicDescriptor = Descriptors . FileDescriptor . buildFrom ( fileDescP , fileDescs ) ; return dynamicDescriptor . findMessageTypeByName ( descProto . getName ( ) ) ;


signature:
public class Protobufs { /** * { " a " = > " A " , " c " = > " IGNORE " } , then you ' ll end up with A , b */
public static List < String > getMessageFieldNames ( Class < ? extends Message > protoClass , Map < String , String > fieldNameTranslations ) { } }

implementation: return getMessageFieldNames ( getMessageDescriptor ( protoClass ) , fieldNameTranslations ) ;


signature:
public class Protobufs { /** * Returns typeref for a Protobuf class */
public static < M extends Message > TypeRef < M > getTypeRef ( String protoClassName ) { } }

implementation: return new TypeRef < M > ( getProtobufClass ( protoClassName ) ) { } ;


signature:
public class Protobufs { /** * Returns TypeRef for the Protobuf class that was set using setClass ( jobConf ) ; */
public static < M extends Message > TypeRef < M > getTypeRef ( Configuration jobConf , Class < ? > genericClass ) { } }

implementation: String className = jobConf . get ( CLASS_CONF_PREFIX + genericClass . getName ( ) ) ; if ( className == null ) { throw new RuntimeException ( CLASS_CONF_PREFIX + genericClass . getName ( ) + " is not set" ) ; } return new TypeRef < M > ( getProtobufClass ( jobConf , className ) ) { } ;


signature:
public class Protobufs { /** * Serializes a single field . All the native fields are serialized using
 * " NoTag " methods in { @ link CodedOutputStream }
 * e . g . < code > writeInt32NoTag ( ) < / code > . The field index is not written .
 * @ param output
 * @ param fd
 * @ param value
 * @ throws IOException */
public static void writeFieldNoTag ( CodedOutputStream output , FieldDescriptor fd , Object value ) throws IOException { } }

implementation: if ( value == null ) { return ; } if ( fd . isRepeated ( ) ) { @ SuppressWarnings ( "unchecked" ) List < Object > values = ( List < Object > ) value ; for ( Object obj : values ) { writeSingleFieldNoTag ( output , fd , obj ) ; } } else { writeSingleFieldNoTag ( output , fd , value ) ; }


signature:
public class Protobufs { /** * Wrapper around { @ link # readFieldNoTag ( CodedInputStream , FieldDescriptor , Builder ) } . < br >
 * same as < br > < code >
 * builder . setField ( fd , readFieldNoTag ( input , fd , builder ) ) ; < / code > */
public static void setFieldValue ( CodedInputStream input , FieldDescriptor fd , Builder builder ) throws IOException { } }


signature:
public class Protobufs { /** * Deserializer for protobuf objects written with
 * { @ link # writeFieldNoTag ( CodedOutputStream , FieldDescriptor , Object ) } .
 * @ param input
 * @ param fd
 * @ param enclosingBuilder required to create a builder when the field
 * is a message
 * @ throws IOException */
public static Object readFieldNoTag ( CodedInputStream input , FieldDescriptor fd , Builder enclosingBuilder ) throws IOException { } }

implementation:
if ( ! fd . isRepeated ( ) ) { return readSingleFieldNoTag ( input , fd , enclosingBuilder ) ; } // repeated field
List < Object > values = Lists . newArrayList ( ) ; while ( ! input . isAtEnd ( ) ) { values . add ( readSingleFieldNoTag ( input , fd , enclosingBuilder ) ) ; } return values ;


signature:
public class LzoRecordReader { /** * Get the progress within the split . */
@ Override public float getProgress ( ) { } }

implementation: if ( start_ == end_ ) { return 0.0f ; } else { return Math . min ( 1.0f , ( pos_ - start_ ) / ( float ) ( end_ - start_ ) ) ; }


signature:
public class LzoInputFormat { /** * Add lzo file ( s ) . If recursive is set , traverses the directories .
 * @ param results
 * The List to store all files .
 * @ param fs
 * The FileSystem .
 * @ param pathStat
 * The input path .
 * @ param recursive
 * Traverse in to directory
 * @ throws IOException */
protected void addInputPath ( List < FileStatus > results , FileSystem fs , FileStatus pathStat , boolean recursive ) throws IOException { } }

implementation: Path path = pathStat . getPath ( ) ; if ( pathStat . isDir ( ) ) { if ( recursive ) { for ( FileStatus stat : fs . listStatus ( path , hiddenPathFilter ) ) { addInputPath ( results , fs , stat , recursive ) ; } } } else if ( visibleLzoFilter . accept ( path ) ) { results . add ( pathStat ) ; lzoSplitStatus ( path ) . lzoFileStatus = pathStat ; } else if ( lzoIndexFilter . accept ( path ) ) { final String lzoIndexName = path . getName ( ) ; final String lzoName = lzoIndexName . substring ( 0 , lzoIndexName . length ( ) - LzoIndex . LZO_INDEX_SUFFIX . length ( ) ) ; final Path lzoPath = new Path ( path . getParent ( ) , lzoName ) ; lzoSplitStatus ( lzoPath ) . lzoIndexFileStatus = pathStat ; }


signature:
public class LzoUtils { /** * Creates an lzop output stream . The index for the lzop is
 * also written to another at the same time if
 * < code > elephantbird . lzo . output . index < / code > is set in configuration . < p >
 * If the file size at closing is not larger than a single block ,
 * the index file is deleted ( in line with { @ link LzoIndexer } behavior ) . */
public static DataOutputStream getIndexedLzoOutputStream ( Configuration conf , Path path ) throws IOException { } }

implementation:
LzopCodec codec = new LzopCodec ( ) ; codec . setConf ( conf ) ; final Path file = path ; final FileSystem fs = file . getFileSystem ( conf ) ; FSDataOutputStream fileOut = fs . create ( file , false ) ; FSDataOutputStream indexOut = null ; if ( conf . getBoolean ( LZO_OUTPUT_INDEX , false ) ) { if ( isLzopIndexSupported ) { Path indexPath = file . suffix ( LzoIndex . LZO_TMP_INDEX_SUFFIX ) ; indexOut = fs . create ( indexPath , false ) ; } else { LOG . warn ( "elephantbird.lzo.output.index is enabled, but LzopCodec " + "does not have createIndexedOutputStream method. " + "Please upgrade hadoop-lzo." ) ; } } final boolean isIndexed = indexOut != null ; final long minIndexableSize = conf . getLong ( LZO_OUTPUT_INDEXABLE_MINSIZE , - 1L ) ; OutputStream out = ( isIndexed ? codec . createIndexedOutputStream ( fileOut , indexOut ) : codec . createOutputStream ( fileOut ) ) ; return new DataOutputStream ( out ) { // override close ( ) to handle renaming index file .
public void close ( ) throws IOException { super . close ( ) ; if ( isIndexed ) { // rename or remove the index file based on file size .
Path tmpPath = file . suffix ( LzoIndex . LZO_TMP_INDEX_SUFFIX ) ; FileStatus stat = fs . getFileStatus ( file ) ; final long minSizeToIndex = minIndexableSize < 0 ? stat . getBlockSize ( ) : minIndexableSize ; if ( stat . getLen ( ) <= minSizeToIndex ) { fs . delete ( tmpPath , false ) ; } else { fs . rename ( tmpPath , file . suffix ( LzoIndex . LZO_INDEX_SUFFIX ) ) ; } } } } ;


signature:
public class BinaryWritable { /** * Returns the current object . Subsequent calls to get ( ) may not return the
 * same object , but in stead might return a new object deserialized from same
 * set of bytes . As a result , multiple calls to get ( ) should be avoided , and
 * modifications to an object returned by get ( ) may not
 * reflect even if this writable is serialized later . < br >
 * Please use set ( ) to be certain of what object is serialized . < br > < br >
 * The deserialization of the actual Protobuf / Thrift object is often delayed
 * till the first call to this method . < br >
 * In some cases the the parameterized proto class may not be known yet
 * ( in case of default construction . see { @ link # setConverter ( Class ) } ) ,
 * and this will throw an { @ link IllegalStateException } . */
public M get ( ) { } }

implementation:
// may be we should rename this method . the contract would be less
// confusing with a different name .
if ( message == null && messageBytes != null ) { checkConverter ( ) ; try { return converter . fromBytes ( messageBytes ) ; } catch ( DecodeException e ) { throw new IllegalStateException ( "Converter failed to deserialize" , e ) ; } } return message ;


signature:
public class BinaryWritable { /** * Converts the message to raw bytes , and caches the converted value .
 * @ return converted value , which may be null in case of null message or error . */
private byte [ ] serialize ( ) { } }

implementation:
if ( messageBytes == null && message != null ) { checkConverter ( ) ; messageBytes = converter . toBytes ( message ) ; if ( messageBytes == null ) { // should we throw an IOException instead ?
LOG . warn ( "Could not serialize " + message . getClass ( ) ) ; } else { message = null ; // so that message and messageBytes don ' t go out of
// sync .
} } return messageBytes ;


signature:
public class DeprecatedInputFormatWrapper { /** * Sets jobs input format to { @ link DeprecatedInputFormatWrapper } and stores
 * supplied real { @ link InputFormat } class name in job configuration .
 * This configuration is read on the remote tasks to instantiate actual
 * InputFormat correctly . */
public static void setInputFormat ( Class < ? > realInputFormatClass , JobConf jobConf ) { } }

implementation: jobConf . setInputFormat ( DeprecatedInputFormatWrapper . class ) ; HadoopUtils . setClassConf ( jobConf , CLASS_CONF_KEY , realInputFormatClass ) ;


signature:
public class DeprecatedInputFormatWrapper { /** * For cases where we need to set hadoop1 input format in a hadoop2 Configuration object . */
public static void setInputFormat ( Class < ? > realInputFormatClass , Configuration conf ) { } }

implementation: conf . setClass ( "mapred.input.format.class" , DeprecatedInputFormatWrapper . class , org . apache . hadoop . mapred . InputFormat . class ) ; HadoopUtils . setClassConf ( conf , CLASS_CONF_KEY , realInputFormatClass ) ;


signature:
public class LuceneIndexLoader { /** * THIS INVOLVES AN UNCHECKED CAST
 * Pig gives us a raw type for the RecordReader unfortunately .
 * However , because { @ link # getInputFormat ( ) } is final and delegates
 * to { @ link # getLuceneIndexInputFormat ( ) } we can be reasonably sure
 * that this record reader is actually a LuceneIndexRecordReader < T > */
@ Override @ SuppressWarnings ( "unchecked" ) public void prepareToRead ( RecordReader reader , PigSplit split ) { } }

implementation: this . reader = ( LuceneIndexRecordReader < T > ) reader ;