signature:
public class HollowFilterConfig { /** * Parse a HollowFilterConfig from the specified String . The String should contain multiple lines .
 * The first line should be either " EXCLUDE " or " INCLUDE " . Subsequent lines should be one of the following :
 * < ul >
 * < li > & lt ; typeName & gt ; < / li >
 * < li > & lt ; typeName & gt ; . & lt ; fieldName & gt ; < / li >
 * < / ul >
 * @ param conf the configuration as a string
 * @ return the filter configuration */
public static HollowFilterConfig fromString ( String conf ) { } }

implementation: String lines [ ] = conf . split ( "\n" ) ; HollowFilterConfig config = new HollowFilterConfig ( "EXCLUDE" . equals ( lines [ 0 ] ) ) ; for ( int i = 1 ; i < lines . length ; i ++ ) { int delimiterIdx = lines [ i ] . indexOf ( '.' ) ; if ( delimiterIdx == - 1 ) { config . addType ( lines [ i ] ) ; } else { String type = lines [ i ] . substring ( 0 , delimiterIdx ) ; String field = lines [ i ] . substring ( delimiterIdx + 1 ) ; config . addField ( type , field ) ; } } return config ;


signature:
public class HollowTypeReadState { /** * Add a { @ link HollowTypeStateListener } to this type .
 * @ param listener the listener to add */
public void addListener ( HollowTypeStateListener listener ) { } }

implementation: HollowTypeStateListener [ ] newListeners = Arrays . copyOf ( stateListeners , stateListeners . length + 1 ) ; newListeners [ newListeners . length - 1 ] = listener ; stateListeners = newListeners ;


signature:
public class HollowTypeReadState { /** * Remove a specific { @ link HollowTypeStateListener } from this type .
 * @ param listener the listener to remove */
public void removeListener ( HollowTypeStateListener listener ) { } }

implementation: if ( stateListeners . length == 0 ) return ; stateListeners = Stream . of ( stateListeners ) . filter ( l -> l != listener ) . toArray ( HollowTypeStateListener [ ] :: new ) ;


signature:
public class HollowSchemaSorter { /** * Dependency types come before dependent types
 * @ param schemas the schema
 * @ return the dependent schema */
public static List < HollowSchema > dependencyOrderedSchemaList ( Collection < HollowSchema > schemas ) { } }

implementation: DependencyIndex idx = new DependencyIndex ( ) ; Map < String , HollowSchema > schemaMap = new HashMap < String , HollowSchema > ( ) ; for ( HollowSchema schema : schemas ) { schemaMap . put ( schema . getName ( ) , schema ) ; idx . indexSchema ( schema , schemas ) ; } List < HollowSchema > orderedSchemas = new ArrayList < HollowSchema > ( ) ; while ( idx . hasMoreTypes ( ) ) orderedSchemas . add ( schemaMap . get ( idx . getNextType ( ) ) ) ; return orderedSchemas ;


signature:
public class CodeGeneratorConfig { /** * Make it easier to automatically use defaults for next major version */
public void initWithNextMajorVersionDefaults_V3 ( ) { } }

implementation: usePackageGrouping = true ; useBooleanFieldErgonomics = true ; reservePrimaryKeyIndexForTypeWithPrimaryKey = true ; useHollowPrimitiveTypes = true ; restrictApiToFieldType = true ; useVerboseToString = true ;


signature:
public class GrowingSegmentedLongArray { /** * Set the byte at the given index to the specified value
 * @ param index the index
 * @ param value the byte */
public void set ( long index , long value ) { } }

implementation: int segmentIndex = ( int ) ( index >> log2OfSegmentSize ) ; if ( segmentIndex >= segments . length ) { int nextPowerOfTwo = 1 << ( 32 - Integer . numberOfLeadingZeros ( segmentIndex ) ) ; segments = Arrays . copyOf ( segments , nextPowerOfTwo ) ; } if ( segments [ segmentIndex ] == null ) { segments [ segmentIndex ] = memoryRecycler . getLongArray ( ) ; } int longInSegment = ( int ) ( index & bitmask ) ; segments [ segmentIndex ] [ longInSegment ] = value ;


signature:
public class GrowingSegmentedLongArray { /** * Get the value of the byte at the specified index .
 * @ param index the index
 * @ return the byte value */
public long get ( long index ) { } }

implementation: int segmentIndex = ( int ) ( index >> log2OfSegmentSize ) ; if ( segmentIndex >= segments . length || segments [ segmentIndex ] == null ) return 0 ; int longInSegment = ( int ) ( index & bitmask ) ; return segments [ segmentIndex ] [ longInSegment ] ;


signature:
public class HollowFieldMatchQuery { /** * Match any records which include a field with the provided fieldName and value .
 * @ param fieldName the field name
 * @ param fieldValue the field value as a string that will be parsed as the type of the field to match .
 * @ return the matching records */
public Map < String , BitSet > findMatchingRecords ( String fieldName , String fieldValue ) { } }

implementation: Map < String , BitSet > matches = new HashMap < String , BitSet > ( ) ; for ( HollowTypeReadState typeState : readEngine . getTypeStates ( ) ) { augmentMatchingRecords ( typeState , fieldName , fieldValue , matches ) ; } return matches ;


signature:
public class HollowFieldMatchQuery { /** * Match any records of the specified type , which have the specified field set to the specified value .
 * @ param typeName the type name
 * @ param fieldName the field name
 * @ param fieldValue the field value as a string that will be parsed as the type of the field to match .
 * @ return the matching records */
public Map < String , BitSet > findMatchingRecords ( String typeName , String fieldName , String fieldValue ) { } }

implementation: Map < String , BitSet > matches = new HashMap < String , BitSet > ( ) ; HollowTypeReadState typeState = readEngine . getTypeState ( typeName ) ; if ( typeState != null ) augmentMatchingRecords ( typeState , fieldName , fieldValue , matches ) ; return matches ;


signature:
public class HollowSpecificDiff { /** * Set the paths for which we will inspect differences across the two states
 * @ param paths the paths for inspection */
public void setElementMatchPaths ( String ... paths ) { } }

implementation: resetResults ( ) ; this . elementPaths = paths ; this . elementKeyPaths = null ; this . elementNonKeyPaths = null ;


signature:
public class HollowSpecificDiff { /** * Optionally specify paths for which we will match records within an individual type ' s hierarchy
 * @ param paths the paths for matching */
public void setElementKeyPaths ( String ... paths ) { } }

implementation: resetResults ( ) ; elementKeyPaths = new BitSet ( elementPaths . length ) ; for ( int i = 0 ; i < paths . length ; i ++ ) { int elementPathIdx = getElementPathIdx ( paths [ i ] ) ; if ( elementPathIdx == - 1 ) throw new IllegalArgumentException ( "Key path must have been specified as an element match path.  Offending path: " + paths [ i ] ) ; elementKeyPaths . set ( elementPathIdx ) ; } elementNonKeyPaths = new BitSet ( elementPaths . length ) ; elementNonKeyPaths . set ( 0 , elementPaths . length ) ; elementNonKeyPaths . andNot ( elementKeyPaths ) ;


signature:
public class HollowSpecificDiff { /** * Calculate the differences */
public void calculate ( ) { } }

implementation: resetResults ( ) ; SimultaneousExecutor executor = new SimultaneousExecutor ( getClass ( ) , "calculate" ) ; final int numThreads = executor . getCorePoolSize ( ) ; for ( int i = 0 ; i < numThreads ; i ++ ) { final int threadNumber = i ; executor . execute ( new Runnable ( ) { public void run ( ) { HollowIndexerValueTraverser fromTraverser = new HollowIndexerValueTraverser ( from , type , elementPaths ) ; HollowIndexerValueTraverser toTraverser = new HollowIndexerValueTraverser ( to , type , elementPaths ) ; int hashedResults [ ] = new int [ 16 ] ; for ( int i = threadNumber ; i < matcher . getMatchedOrdinals ( ) . size ( ) ; i += numThreads ) { long ordinalPair = matcher . getMatchedOrdinals ( ) . get ( i ) ; int fromOrdinal = ( int ) ( ordinalPair >>> 32 ) ; int toOrdinal = ( int ) ordinalPair ; fromTraverser . traverse ( fromOrdinal ) ; toTraverser . traverse ( toOrdinal ) ; if ( fromTraverser . getNumMatches ( ) * 2 > hashedResults . length ) hashedResults = new int [ hashTableSize ( fromTraverser . getNumMatches ( ) ) ] ; populateHashTable ( fromTraverser , hashedResults ) ; countMatches ( fromTraverser , toTraverser , hashedResults ) ; } for ( int i = threadNumber ; i < matcher . getExtraInFrom ( ) . size ( ) ; i += numThreads ) { fromTraverser . traverse ( matcher . getExtraInFrom ( ) . get ( i ) ) ; totalUnmatchedFromElements . addAndGet ( fromTraverser . getNumMatches ( ) ) ; } for ( int i = threadNumber ; i < matcher . getExtraInTo ( ) . size ( ) ; i += numThreads ) { toTraverser . traverse ( matcher . getExtraInTo ( ) . get ( i ) ) ; totalUnmatchedToElements . addAndGet ( toTraverser . getNumMatches ( ) ) ; } } } ) ; } try { executor . awaitSuccessfulCompletion ( ) ; } catch ( Exception ex ) { throw new RuntimeException ( ex ) ; }


signature:
public class HollowFieldDiff { /** * Should be called exclusively from the { @ link HollowDiff } - - not intended for external consumption
 * @ param fromOrdinal the from ordinal
 * @ param toOrdinal the to ordinal
 * @ param score the score */
public void addDiff ( int fromOrdinal , int toOrdinal , int score ) { } }

implementation: if ( isSameDiffAsLastAdd ( fromOrdinal , toOrdinal ) ) { int scoreIdx = diffPairScores . size ( ) - 1 ; diffPairScores . set ( scoreIdx , diffPairScores . get ( scoreIdx ) + score ) ; } else { diffFromOrdinals . add ( fromOrdinal ) ; diffToOrdinals . add ( toOrdinal ) ; diffPairScores . add ( score ) ; } totalDiffScore += score ;


signature:
public class HollowFieldDiff { /** * This should be called exclusively from the { @ link HollowDiff } . Not for external consumption .
 * @ param otherFieldDiff the field diff to add */
public void addResults ( HollowFieldDiff otherFieldDiff ) { } }

implementation: for ( int i = 0 ; i < otherFieldDiff . getNumDiffs ( ) ; i ++ ) { addDiff ( otherFieldDiff . getFromOrdinal ( i ) , otherFieldDiff . getToOrdinal ( i ) , otherFieldDiff . getPairScore ( i ) ) ; }


signature:
public class HollowFieldDiff { /** * Comparison is based on the totalDiffScore ( ) . */
@ Override public int compareTo ( HollowFieldDiff o ) { } }

implementation: if ( o . getTotalDiffScore ( ) > totalDiffScore ) return 1 ; else if ( o . getTotalDiffScore ( ) < totalDiffScore ) return - 1 ; return 0 ;


signature:
public class HollowConsumer { /** * Triggers a refresh to the latest version specified by the { @ link HollowConsumer . AnnouncementWatcher } .
 * If already on the latest version , this operation is a no - op .
 * If a { @ link HollowConsumer . AnnouncementWatcher } is not present , this call trigger a refresh to the
 * latest version available in the blob store .
 * This is a blocking call . */
public void triggerRefresh ( ) { } }

implementation: refreshLock . writeLock ( ) . lock ( ) ; try { updater . updateTo ( announcementWatcher == null ? Long . MAX_VALUE : announcementWatcher . getLatestVersion ( ) ) ; } catch ( Error | RuntimeException e ) { throw e ; } catch ( Throwable t ) { throw new RuntimeException ( t ) ; } finally { refreshLock . writeLock ( ) . unlock ( ) ; }


signature:
public class HollowConsumer { /** * Triggers async refresh after the specified number of milliseconds has passed .
 * Any subsequent calls for async refresh will not begin until after the specified delay
 * has completed .
 * @ param delayMillis the delay , in millseconds , before triggering the refresh */
public void triggerAsyncRefreshWithDelay ( int delayMillis ) { } }

implementation:
final long targetBeginTime = System . currentTimeMillis ( ) + delayMillis ; refreshExecutor . execute ( ( ) -> { try { long delay = targetBeginTime - System . currentTimeMillis ( ) ; if ( delay > 0 ) Thread . sleep ( delay ) ; } catch ( InterruptedException e ) { // Interrupting , such as shutting down the executor pool ,
// cancels the trigger
LOG . log ( Level . INFO , "Async refresh interrupted before trigger, refresh cancelled" , e ) ; return ; } try { triggerRefresh ( ) ; } catch ( Error | RuntimeException e ) { // Ensure exceptions are propagated to the executor
LOG . log ( Level . SEVERE , "Async refresh failed" , e ) ; throw e ; } } ) ;


signature:
public class HollowConsumer { /** * If a { @ link HollowConsumer . AnnouncementWatcher } is not specified , then this method will attempt to update
 * to the specified version , and if the specified version does not exist then to a different version as specified
 * by functionality in the { @ code BlobRetriever } .
 * Otherwise , an UnsupportedOperationException will be thrown .
 * This is a blocking call .
 * @ param version the version to refresh to */
public void triggerRefreshTo ( long version ) { } }

implementation: if ( announcementWatcher != null ) throw new UnsupportedOperationException ( "Cannot trigger refresh to specified version when a HollowConsumer.AnnouncementWatcher is present" ) ; try { updater . updateTo ( version ) ; } catch ( Error | RuntimeException e ) { throw e ; } catch ( Throwable t ) { throw new RuntimeException ( t ) ; }


signature:
public class HollowConsumer { /** * Equivalent to calling { @ link # getAPI ( ) } and casting to the specified API .
 * @ param apiClass the class of the API
 * @ param < T > the type of the API
 * @ return the API which wraps the underlying dataset */
public < T extends HollowAPI > T getAPI ( Class < T > apiClass ) { } }

implementation: return apiClass . cast ( updater . getAPI ( ) ) ;


signature:
public class StateEngineRoundTripper { /** * Populate the provided { @ link HollowReadStateEngine } with the dataset currently in the provided { @ link HollowWriteStateEngine }
 * @ param writeEngine the write state engine
 * @ param readEngine the read state engine
 * @ throws IOException if the round trip from write to read state failed */
public static void roundTripSnapshot ( HollowWriteStateEngine writeEngine , HollowReadStateEngine readEngine ) throws IOException { } }

implementation: roundTripSnapshot ( writeEngine , readEngine , null ) ;


signature:
public class StateEngineRoundTripper { /** * Populate the provided { @ link HollowReadStateEngine } with the dataset currently in the provided { @ link HollowWriteStateEngine } .
 * Apply the provided { @ link HollowFilterConfig } .
 * @ param writeEngine the write state engine
 * @ param readEngine the read state engine
 * @ param filter the filter configuration
 * @ throws IOException if the round trip from write to read state failed */
public static void roundTripSnapshot ( HollowWriteStateEngine writeEngine , HollowReadStateEngine readEngine , HollowFilterConfig filter ) throws IOException { } }

implementation: ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; HollowBlobWriter writer = new HollowBlobWriter ( writeEngine ) ; writer . writeSnapshot ( baos ) ; writeEngine . prepareForNextCycle ( ) ; HollowBlobReader reader = new HollowBlobReader ( readEngine ) ; InputStream is = new ByteArrayInputStream ( baos . toByteArray ( ) ) ; if ( filter == null ) reader . readSnapshot ( is ) ; else reader . readSnapshot ( is , filter ) ;


signature:
public class StateEngineRoundTripper { /** * Update the provided { @ link HollowReadStateEngine } with the new state currently available in the { @ link HollowWriteStateEngine } .
 * It is assumed that the readEngine is currently populated with the prior state from the writeEngine .
 * @ param writeEngine the write state engine
 * @ param readEngine the read state engine
 * @ throws IOException if the round trip from write to read state failed */
public static void roundTripDelta ( HollowWriteStateEngine writeEngine , HollowReadStateEngine readEngine ) throws IOException { } }

implementation: ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; HollowBlobWriter writer = new HollowBlobWriter ( writeEngine ) ; writer . writeDelta ( baos ) ; HollowBlobReader reader = new HollowBlobReader ( readEngine ) ; reader . applyDelta ( new ByteArrayInputStream ( baos . toByteArray ( ) ) ) ; writeEngine . prepareForNextCycle ( ) ;


signature:
public class HollowHistoricalStateCreator { /** * Create a { @ link HollowDataAccess } for the prior state of the supplied { @ link HollowReadStateEngine } after a delta
 * has been applied .
 * @ param version The state ' s version
 * @ param stateEngine The current { @ link HollowReadStateEngine } to which a delta has been applied .
 * @ return a data access for history */
public HollowHistoricalStateDataAccess createBasedOnNewDelta ( long version , HollowReadStateEngine stateEngine ) { } }

implementation: IntMapOrdinalRemapper typeRemovedOrdinalMapping = new IntMapOrdinalRemapper ( ) ; List < HollowTypeReadState > historicalTypeStates = new ArrayList < HollowTypeReadState > ( stateEngine . getTypeStates ( ) . size ( ) ) ; for ( HollowTypeReadState typeState : stateEngine . getTypeStates ( ) ) { createDeltaHistoricalTypeState ( typeRemovedOrdinalMapping , historicalTypeStates , typeState ) ; } HollowHistoricalStateDataAccess dataAccess = new HollowHistoricalStateDataAccess ( totalHistory , version , stateEngine , historicalTypeStates , typeRemovedOrdinalMapping , Collections . < String , HollowHistoricalSchemaChange > emptyMap ( ) ) ; dataAccess . setNextState ( stateEngine ) ; return dataAccess ;


signature:
public class HollowHistoricalStateCreator { /** * Create a { @ link HollowDataAccess } for a { @ link HollowHistory } . Remap ordinal spaces for all prior historical
 * versions in the { @ link HollowHistory } for consistency .
 * @ param version the version
 * @ param previous the prior read state
 * @ return the data access for a history */
public HollowHistoricalStateDataAccess createConsistentOrdinalHistoricalStateFromDoubleSnapshot ( long version , HollowReadStateEngine previous ) { } }

implementation: return new HollowHistoricalStateDataAccess ( totalHistory , version , previous , IdentityOrdinalRemapper . INSTANCE , Collections . < String , HollowHistoricalSchemaChange > emptyMap ( ) ) ;


signature:
public class HollowHistoricalStateCreator { /** * Create a { @ link HollowDataAccess } for a historical state after a double snapshot occurs , without a { @ link HollowHistory } .
 * @ param version the version
 * @ param previous the previous state
 * @ param current the current state
 * @ param ordinalRemapper the ordinal remapper
 * @ return the data access for a history */
public HollowHistoricalStateDataAccess createHistoricalStateFromDoubleSnapshot ( long version , HollowReadStateEngine previous , HollowReadStateEngine current , DiffEqualityMappingOrdinalRemapper ordinalRemapper ) { } }

implementation: HollowWriteStateEngine writeEngine = HollowWriteStateCreator . createWithSchemas ( schemasWithoutKeys ( previous . getSchemas ( ) ) ) ; IntMapOrdinalRemapper typeRemovedOrdinalLookupMaps = new IntMapOrdinalRemapper ( ) ; for ( HollowSchema previousSchema : HollowSchemaSorter . dependencyOrderedSchemaList ( previous ) ) { HollowTypeReadState previousTypeState = previous . getTypeState ( previousSchema . getName ( ) ) ; String typeName = previousTypeState . getSchema ( ) . getName ( ) ; IntMap ordinalLookupMap ; if ( current . getTypeState ( typeName ) == null ) { ordinalLookupMap = copyAllRecords ( previousTypeState , ordinalRemapper , writeEngine ) ; } else { HollowTypeReadState currentTypeState = current . getTypeState ( typeName ) ; BitSet currentlyPopulatedOrdinals = currentTypeState . getListener ( PopulatedOrdinalListener . class ) . getPopulatedOrdinals ( ) ; ordinalLookupMap = copyUnmatchedRecords ( previousTypeState , ordinalRemapper , currentlyPopulatedOrdinals , writeEngine ) ; } typeRemovedOrdinalLookupMaps . addOrdinalRemapping ( typeName , ordinalLookupMap ) ; } Map < String , HollowHistoricalSchemaChange > schemaChanges = calculateSchemaChanges ( previous , current , ordinalRemapper . getDiffEqualityMapping ( ) ) ; return new HollowHistoricalStateDataAccess ( totalHistory , version , roundTripStateEngine ( writeEngine ) , typeRemovedOrdinalLookupMaps , schemaChanges ) ;


signature:
public class HollowIncrementalProducer { /** * Initializes the data model and restores from existing state . */
public void restoreFromLastState ( ) { } }

implementation: producer . initializeDataModel ( dataModel ) ; long latestAnnouncedVersion = announcementWatcher . getLatestVersion ( ) ; if ( latestAnnouncedVersion == HollowFilesystemAnnouncementWatcher . NO_ANNOUNCEMENT_AVAILABLE || latestAnnouncedVersion < 0 ) { return ; } restore ( latestAnnouncedVersion , blobRetriever ) ;


signature:
public class HollowIncrementalProducer { /** * Runs a Hollow Cycle , if successful , cleans the mutations map .
 * @ return the version of the cycle if successful , otherwise the { @ link # FAILED _ VERSION }
 * @ since 2.9.9 */
public long runCycle ( ) { } }

implementation:
long recordsRemoved = countRecordsToRemove ( ) ; long recordsAddedOrModified = this . mutations . values ( ) . size ( ) - recordsRemoved ; try { long version = producer . runCycle ( populator ) ; if ( version == lastSucessfulCycle ) { return version ; } listeners . fireIncrementalCycleComplete ( version , recordsAddedOrModified , recordsRemoved , new HashMap < String , Object > ( cycleMetadata ) ) ; // Only clean changes when the version is new .
clearChanges ( ) ; lastSucessfulCycle = version ; return version ; } catch ( Exception e ) { listeners . fireIncrementalCycleFail ( e , recordsAddedOrModified , recordsRemoved , new HashMap < String , Object > ( cycleMetadata ) ) ; return FAILED_VERSION ; } finally { clearCycleMetadata ( ) ; }


signature:
public class HollowIncrementalProducer { /** * Parallel execution . Modifies the mutation ConcurrentHashMap in parallel based on a Callback .
 * Note : This could be replaced with Java 8 parallelStream and lambadas instead of Callback interface
 * @ param objList
 * @ param callback */
private void executeInParallel ( Collection < Object > objList , String description , final Callback callback ) { } }

implementation: SimultaneousExecutor executor = new SimultaneousExecutor ( threadsPerCpu , getClass ( ) , description ) ; for ( final Object obj : objList ) { executor . execute ( ( ) -> callback . call ( obj ) ) ; } try { executor . awaitSuccessfulCompletion ( ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; }


signature:
public class HollowCombinerExcludePrimaryKeysCopyDirector { /** * Exclude the record which matches the specified key .
 * @ param idx the index in which to query for the key
 * @ param key the key */
public void excludeKey ( HollowPrimaryKeyIndex idx , Object ... key ) { } }

implementation: int excludeOrdinal = idx . getMatchingOrdinal ( key ) ; if ( excludeOrdinal >= 0 ) { BitSet excludedOrdinals = this . excludedOrdinals . get ( idx . getTypeState ( ) ) ; if ( excludedOrdinals == null ) { excludedOrdinals = new BitSet ( idx . getTypeState ( ) . maxOrdinal ( ) + 1 ) ; this . excludedOrdinals . put ( idx . getTypeState ( ) , excludedOrdinals ) ; } excludedOrdinals . set ( excludeOrdinal ) ; }


signature:
public class HollowCombinerExcludePrimaryKeysCopyDirector { /** * Exclude any objects which are referenced by excluded objects . */
public void excludeReferencedObjects ( ) { } }

implementation: Set < HollowReadStateEngine > stateEngines = new HashSet < HollowReadStateEngine > ( ) ; for ( Map . Entry < HollowTypeReadState , BitSet > entry : excludedOrdinals . entrySet ( ) ) stateEngines . add ( entry . getKey ( ) . getStateEngine ( ) ) ; for ( HollowReadStateEngine stateEngine : stateEngines ) { Map < String , BitSet > typeBitSetsForStateEngine = new HashMap < String , BitSet > ( ) ; for ( Map . Entry < HollowTypeReadState , BitSet > entry : excludedOrdinals . entrySet ( ) ) { if ( entry . getKey ( ) . getStateEngine ( ) == stateEngine ) { String type = entry . getKey ( ) . getSchema ( ) . getName ( ) ; typeBitSetsForStateEngine . put ( type , BitSet . valueOf ( entry . getValue ( ) . toLongArray ( ) ) ) ; } } TransitiveSetTraverser . addTransitiveMatches ( stateEngine , typeBitSetsForStateEngine ) ; for ( Map . Entry < String , BitSet > entry : typeBitSetsForStateEngine . entrySet ( ) ) excludedOrdinals . put ( stateEngine . getTypeState ( entry . getKey ( ) ) , entry . getValue ( ) ) ; }


signature:
public class HollowBlobHeaderWriter { /** * Write the header to the data output stream
 * @ param header the blob header
 * @ param dos the data output stream to write the blov header
 * @ throws IOException if the blob header could not be written */
public void writeHeader ( HollowBlobHeader header , DataOutputStream dos ) throws IOException { } }

implementation:
// / save 4 bytes to indicate FastBlob version header . This will be changed to indicate backwards incompatibility .
dos . writeInt ( HollowBlobHeader . HOLLOW_BLOB_VERSION_HEADER ) ; // / Write randomized tag data - - every state gets a random 64 - bit tag .
// / When attempting to apply a delta , the originating state ' s random 64 - bit tag is compared against the current 64 - bit tag .
// / This prevents deltas from being applied to incorrect states .
dos . writeLong ( header . getOriginRandomizedTag ( ) ) ; dos . writeLong ( header . getDestinationRandomizedTag ( ) ) ; // / write the schemas contained in this blob to the stream in the pre v2.2.0 backwards compatibility envelope
ByteArrayOutputStream schemasStream = new ByteArrayOutputStream ( ) ; VarInt . writeVInt ( schemasStream , header . getSchemas ( ) . size ( ) ) ; for ( HollowSchema schema : header . getSchemas ( ) ) schema . writeTo ( schemasStream ) ; byte [ ] schemasData = schemasStream . toByteArray ( ) ; VarInt . writeVInt ( dos , schemasData . length + 1 ) ; // plus one byte for new backwards compatibility envelope .
dos . write ( schemasData ) ; // / backwards compatibility - - new data can be added here by first indicating number of bytes used , will be skipped by existing readers .
VarInt . writeVInt ( dos , 0 ) ; // / write the header tags - - intended to include input source data versions
dos . writeShort ( header . getHeaderTags ( ) . size ( ) ) ; for ( Map . Entry < String , String > headerTag : header . getHeaderTags ( ) . entrySet ( ) ) { dos . writeUTF ( headerTag . getKey ( ) ) ; dos . writeUTF ( headerTag . getValue ( ) ) ; }


signature:
public class HollowObjectTypeReadStateShard { /** * Warning : Not thread - safe . Should only be called within the update thread . */
public int bitsRequiredForField ( String fieldName ) { } }

implementation: int fieldIndex = schema . getPosition ( fieldName ) ; return fieldIndex == - 1 ? 0 : currentDataVolatile . bitsPerField [ fieldIndex ] ;


signature:
public class HollowMetrics { /** * Calculates the memory heap footprint and populated ordinals per type and total
 * @ param hollowReadStateEngine */
void calculateTypeMetrics ( HollowReadStateEngine hollowReadStateEngine ) { } }

implementation: Collection < HollowTypeReadState > typeStates = hollowReadStateEngine . getTypeStates ( ) ; if ( typeStates == null ) return ; totalHeapFootprint = 0L ; totalPopulatedOrdinals = 0 ; for ( HollowTypeReadState typeState : typeStates ) { long heapCost = typeState . getApproximateHeapFootprintInBytes ( ) ; totalHeapFootprint += heapCost ; int populatedOrdinals = typeState . getPopulatedOrdinals ( ) . cardinality ( ) ; totalPopulatedOrdinals += populatedOrdinals ; String type = typeState . getSchema ( ) . getName ( ) ; typeHeapFootprint . put ( type , heapCost ) ; typePopulatedOrdinals . put ( type , populatedOrdinals ) ; }


signature:
public class HollowCombiner { /** * When provided , a set of { @ link PrimaryKey } will ensure that no duplicate records are added to the destination state .
 * If multiple records exist in the inputs matching a single value for any of the supplied primary keys , then only one such record
 * will be copied to the destination . The specific record which is copied will be the record from the input which was supplied first in the constructor
 * of this HollowCombiner .
 * Further , if any record < i > references < / i > another record which was omitted because it would have been duplicate based on this rule , then that reference is
 * remapped in the destination state to the matching record which was chosen to be included .
 * @ param newKeys the new primary keys */
public void setPrimaryKeys ( PrimaryKey ... newKeys ) { } }

implementation:
Objects . requireNonNull ( newKeys ) ; if ( newKeys . length == 0 ) { return ; } if ( inputs . length == 1 ) { return ; } // / deduplicate new keys with existing keys
// process existing ones first
Map < String , PrimaryKey > keysByType = new HashMap < > ( ) ; for ( PrimaryKey primaryKey : primaryKeys ) { keysByType . put ( primaryKey . getType ( ) , primaryKey ) ; } // allow override
for ( PrimaryKey primaryKey : newKeys ) { keysByType . put ( primaryKey . getType ( ) , primaryKey ) ; } this . primaryKeys = sortPrimaryKeys ( new ArrayList < > ( keysByType . values ( ) ) ) ;


signature:
public class HollowCombiner { /** * Perform the combine operation . */
public void combine ( ) { } }

implementation:
SimultaneousExecutor executor = new SimultaneousExecutor ( getClass ( ) , "combine" ) ; final int numThreads = executor . getCorePoolSize ( ) ; createOrdinalRemappers ( ) ; createHashOrderIndependentOrdinalMaps ( ) ; final Set < String > processedTypes = new HashSet < > ( ) ; final Set < PrimaryKey > processedPrimaryKeys = new HashSet < > ( ) ; final Set < PrimaryKey > selectedPrimaryKeys = new HashSet < > ( ) ; while ( processedTypes . size ( ) < output . getOrderedTypeStates ( ) . size ( ) ) { // / find the next primary keys
for ( PrimaryKey key : primaryKeys ) { if ( ! processedPrimaryKeys . contains ( key ) && ! ignoredTypes . contains ( key . getType ( ) ) ) { if ( ! isAnySelectedPrimaryKeyADependencyOf ( key . getType ( ) , selectedPrimaryKeys ) ) { selectedPrimaryKeys . add ( key ) ; } } } final Set < String > typesToProcessThisIteration = new HashSet < > ( ) ; final Map < String , HollowPrimaryKeyIndex [ ] > primaryKeyIndexes = new HashMap < > ( ) ; final HollowCombinerExcludePrimaryKeysCopyDirector primaryKeyCopyDirector = new HollowCombinerExcludePrimaryKeysCopyDirector ( copyDirector ) ; for ( HollowSchema schema : output . getSchemas ( ) ) { if ( ! processedTypes . contains ( schema . getName ( ) ) && ! ignoredTypes . contains ( schema . getName ( ) ) ) { if ( selectedPrimaryKeys . isEmpty ( ) || isAnySelectedPrimaryKeyDependentOn ( schema . getName ( ) , selectedPrimaryKeys ) ) { for ( PrimaryKey pk : selectedPrimaryKeys ) { if ( pk . getType ( ) . equals ( schema . getName ( ) ) ) { HollowPrimaryKeyIndex [ ] indexes = new HollowPrimaryKeyIndex [ inputs . length ] ; for ( int i = 0 ; i < indexes . length ; i ++ ) { if ( inputs [ i ] . getTypeState ( pk . getType ( ) ) != null ) indexes [ i ] = new HollowPrimaryKeyIndex ( inputs [ i ] , pk ) ; } for ( int i = 0 ; i < indexes . length ; i ++ ) { HollowTypeReadState typeState = inputs [ i ] . getTypeState ( pk . getType ( ) ) ; if ( typeState != null ) { BitSet populatedOrdinals = typeState . getListener ( PopulatedOrdinalListener . class ) . getPopulatedOrdinals ( ) ; int ordinal = populatedOrdinals . nextSetBit ( 0 ) ; while ( ordinal != - 1 ) { if ( primaryKeyCopyDirector . shouldCopy ( typeState , ordinal ) ) { Object [ ] recordKey = indexes [ i ] . getRecordKey ( ordinal ) ; for ( int j = i + 1 ; j < indexes . length ; j ++ ) { primaryKeyCopyDirector . excludeKey ( indexes [ j ] , recordKey ) ; } } ordinal = populatedOrdinals . nextSetBit ( ordinal + 1 ) ; } } } primaryKeyIndexes . put ( pk . getType ( ) , indexes ) ; } } typesToProcessThisIteration . add ( schema . getName ( ) ) ; } } } if ( typesToProcessThisIteration . isEmpty ( ) ) break ; for ( int i = 0 ; i < numThreads ; i ++ ) { final int threadNumber = i ; executor . execute ( ( ) -> { for ( int i1 = 0 ; i1 < inputs . length ; i1 ++ ) { HollowCombinerCopyDirector copyDirector = selectedPrimaryKeys . isEmpty ( ) ? HollowCombiner . this . copyDirector : primaryKeyCopyDirector ; HollowReadStateEngine inputEngine = inputs [ i1 ] ; OrdinalRemapper ordinalRemapper = selectedPrimaryKeys . isEmpty ( ) ? ordinalRemappers [ i1 ] : new HollowCombinerPrimaryKeyOrdinalRemapper ( ordinalRemappers , primaryKeyIndexes , i1 ) ; Map < String , HollowCombinerCopier > copierMap = new HashMap < > ( ) ; List < HollowCombinerCopier > copierList = new ArrayList < > ( ) ; for ( String typeName : typesToProcessThisIteration ) { HollowTypeReadState readState = inputEngine . getTypeState ( typeName ) ; HollowTypeWriteState writeState = output . getTypeState ( typeName ) ; if ( readState != null && writeState != null ) { HollowCombinerCopier copier = new HollowCombinerCopier ( readState , writeState , ordinalRemapper ) ; copierList . add ( copier ) ; copierMap . put ( typeName , copier ) ; } } for ( String typeName : processedTypes ) { HollowTypeReadState readState = inputEngine . getTypeState ( typeName ) ; HollowTypeWriteState writeState = output . getTypeState ( typeName ) ; if ( readState != null && writeState != null ) { HollowCombinerCopier copier = new HollowCombinerCopier ( readState , writeState , ordinalRemappers [ i1 ] ) ; copierMap . put ( typeName , copier ) ; } } copiersPerType . set ( copierMap ) ; int currentOrdinal = threadNumber ; while ( ! copierList . isEmpty ( ) ) { copyOrdinalForAllStates ( currentOrdinal , copierList , ordinalRemapper , copyDirector ) ; currentOrdinal += numThreads ; } } } ) ; } try { executor . awaitSuccessfulCompletionOfCurrentTasks ( ) ; } catch ( Throwable th ) { throw new RuntimeException ( th ) ; } processedTypes . addAll ( typesToProcessThisIteration ) ; processedPrimaryKeys . addAll ( selectedPrimaryKeys ) ; selectedPrimaryKeys . clear ( ) ; } executor . shutdown ( ) ;


signature:
public class HollowObjectWriteRecord { /** * Concatenates all fields , in order , to the ByteDataBuffer supplied . This concatenation is the
 * verbatim serialized representation in the FastBlob .
 * @ param buf the data buffer to write data to */
public void writeDataTo ( ByteDataBuffer buf ) { } }

implementation: for ( int i = 0 ; i < fieldData . length ; i ++ ) { writeField ( buf , i ) ; }


signature:
public class HollowObjectWriteRecord { /** * Returns the buffer which should be used to serialize the data for the field at the given position in the schema . < p >
 * This is used by the FastBlobFrameworkSerializer when writing the data for a specific field .
 * @ param field
 * @ return */
private ByteDataBuffer getFieldBuffer ( int fieldPosition ) { } }

implementation: isNonNull [ fieldPosition ] = true ; fieldData [ fieldPosition ] . reset ( ) ; return fieldData [ fieldPosition ] ;


signature:
public class HollowObjectWriteRecord { /** * Write 4 consecutive bytes */
private static void writeFixedLengthInt ( ByteDataBuffer fieldBuffer , int intBits ) { } }

implementation: fieldBuffer . write ( ( byte ) ( intBits >>> 24 ) ) ; fieldBuffer . write ( ( byte ) ( intBits >>> 16 ) ) ; fieldBuffer . write ( ( byte ) ( intBits >>> 8 ) ) ; fieldBuffer . write ( ( byte ) ( intBits ) ) ;


signature:
public class HollowObjectWriteRecord { /** * Write 8 consecutive bytes */
private static void writeFixedLengthLong ( ByteDataBuffer fieldBuffer , long intBits ) { } }

implementation: fieldBuffer . write ( ( byte ) ( intBits >>> 56 ) ) ; fieldBuffer . write ( ( byte ) ( intBits >>> 48 ) ) ; fieldBuffer . write ( ( byte ) ( intBits >>> 40 ) ) ; fieldBuffer . write ( ( byte ) ( intBits >>> 32 ) ) ; fieldBuffer . write ( ( byte ) ( intBits >>> 24 ) ) ; fieldBuffer . write ( ( byte ) ( intBits >>> 16 ) ) ; fieldBuffer . write ( ( byte ) ( intBits >>> 8 ) ) ; fieldBuffer . write ( ( byte ) ( intBits ) ) ;


signature:
public class HollowHashIndexResult { /** * Returns a stream of matching ordinals .
 * The ordinals may be used with a generated API or the Generic Object API to inspect
 * the matched records .
 * @ return an { @ code IntStream } of matching ordinals */
public IntStream stream ( ) { } }

implementation:
Spliterator . OfInt si = new Spliterator . OfInt ( ) { final long endBucket = selectTableStartPointer + selectTableBuckets ; long currentBucket = selectTableStartPointer ; @ Override public OfInt trySplit ( ) { // @ @ @ Supporting splitting and therefore enable parallelism
return null ; } @ Override public boolean tryAdvance ( IntConsumer action ) { while ( currentBucket < endBucket ) { int selectOrdinal = ( int ) hashIndexState . getSelectHashArray ( ) . getElementValue ( ( currentBucket ++ ) * hashIndexState . getBitsPerSelectHashEntry ( ) , hashIndexState . getBitsPerSelectHashEntry ( ) ) - 1 ; if ( selectOrdinal != - 1 ) { action . accept ( selectOrdinal ) ; return true ; } } return false ; } @ Override public long estimateSize ( ) { return 0 ; } @ Override public int characteristics ( ) { // @ @ @ ordinals are distinct ?
return 0 ; } } ; return StreamSupport . intStream ( si , false ) ;


signature:
public class FreeOrdinalTracker { /** * Return an ordinal to the pool after the object to which it was assigned is discarded .
 * @ param ordinal the ordinal */
public void returnOrdinalToPool ( int ordinal ) { } }

implementation: if ( size == freeOrdinals . length ) { freeOrdinals = Arrays . copyOf ( freeOrdinals , freeOrdinals . length * 3 / 2 ) ; } freeOrdinals [ size ] = ordinal ; size ++ ;


signature:
public class FreeOrdinalTracker { /** * Ensure that all future ordinals are returned in ascending order . */
public void sort ( ) { } }

implementation:
Arrays . sort ( freeOrdinals , 0 , size ) ; // / reverse the ordering
int midpoint = size / 2 ; for ( int i = 0 ; i < midpoint ; i ++ ) { int temp = freeOrdinals [ i ] ; freeOrdinals [ i ] = freeOrdinals [ size - i - 1 ] ; freeOrdinals [ size - i - 1 ] = temp ; }


signature:
public class SetMapKeyHasher { /** * Hash a key
 * @ param key the key
 * @ param fieldType the respective FieldTypes of each key .
 * @ return the hash code */
public static int hash ( Object key [ ] , FieldType fieldType [ ] ) { } }

implementation: int hash = 0 ; for ( int i = 0 ; i < key . length ; i ++ ) { hash *= 31 ; hash ^= hash ( key [ i ] , fieldType [ i ] ) ; } return hash ;


signature:
public class SetMapKeyHasher { /** * Hash a single key field
 * @ param key the key
 * @ param fieldType the FieldType of the key .
 * @ return the hash code */
public static int hash ( Object key , FieldType fieldType ) { } }

implementation: switch ( fieldType ) { case INT : return HashCodes . hashInt ( ( ( Integer ) key ) . intValue ( ) ) ; case LONG : long longVal = ( ( Long ) key ) . longValue ( ) ; return HashCodes . hashInt ( ( int ) ( longVal ^ ( longVal >>> 32 ) ) ) ; case REFERENCE : return HashCodes . hashInt ( ( ( Integer ) key ) . intValue ( ) ) ; case BYTES : return HashCodes . hashInt ( HashCodes . hashCode ( ( byte [ ] ) key ) ) ; case STRING : return HashCodes . hashInt ( key . hashCode ( ) ) ; case BOOLEAN : return HashCodes . hashInt ( ( ( Boolean ) key ) . booleanValue ( ) ? 1231 : 1237 ) ; case DOUBLE : long longBits = Double . doubleToRawLongBits ( ( ( Double ) key ) . doubleValue ( ) ) ; return HashCodes . hashInt ( ( int ) ( longBits ^ ( longBits >>> 32 ) ) ) ; case FLOAT : return HashCodes . hashInt ( Float . floatToRawIntBits ( ( ( Float ) key ) . floatValue ( ) ) ) ; default : throw new IllegalArgumentException ( "Unknown field type: " + fieldType ) ; }


signature:
public class FixedLengthMultipleOccurrenceElementArray { /** * This method adds an element at nodeIndex . Note that this does not check for duplicates ; if
 * the element already exists , another instance of it will be added .
 * This method is not thread - safe - you cannot call this method concurrently with itself or with
 * { @ link # getElements } .
 * @ param nodeIndex the node index
 * @ param element the element to add */
public void addElement ( long nodeIndex , long element ) { } }

implementation:
if ( element > elementMask ) { throw new IllegalArgumentException ( "Element " + element + " does not fit in " + bitsPerElement + " bits" ) ; } if ( nodeIndex >= numNodes ) { throw new IllegalArgumentException ( "Provided nodeIndex  " + nodeIndex + " greater then numNodes " + numNodes ) ; } if ( element == NO_ELEMENT ) { // we use 0 to indicate an " empty " element , so we have to store ordinal zero here
nodesWithOrdinalZero . setElementValue ( nodeIndex , 1 , 1 ) ; return ; } long bucketStart = nodeIndex * maxElementsPerNode * bitsPerElement ; long currentIndex ; int offset = 0 ; do { currentIndex = bucketStart + offset * bitsPerElement ; offset ++ ; } while ( storage . getElementValue ( currentIndex , bitsPerElement , elementMask ) != NO_ELEMENT && offset < maxElementsPerNode ) ; if ( storage . getElementValue ( currentIndex , bitsPerElement , elementMask ) != NO_ELEMENT ) { // we ' re full at this index - resize , then figure out the new current index
resizeStorage ( ) ; currentIndex = nodeIndex * maxElementsPerNode * bitsPerElement + offset * bitsPerElement ; } /* we ' re adding to the first empty spot from the beginning of the bucket - this is
 * preferable to adding at the end because we want our getElements method to be fast , and
 * it ' s okay for addElement to be comparatively slow */
storage . setElementValue ( currentIndex , bitsPerElement , element ) ;


signature:
public class FixedLengthMultipleOccurrenceElementArray { /** * Return a list of elements at the specified node index . The returned list may contain
 * duplicates .
 * This method not thread - safe - the caller must ensure that no one calls { @ link # addElement }
 * concurrently with this method , but calling this method concurrently with itself is safe .
 * @ param nodeIndex the node index
 * @ return a list of element at the node index */
public List < Long > getElements ( long nodeIndex ) { } }

implementation:
long bucketStart = nodeIndex * maxElementsPerNode * bitsPerElement ; List < Long > ret = new ArrayList < > ( ) ; if ( nodesWithOrdinalZero . getElementValue ( nodeIndex , 1 , 1 ) != NO_ELEMENT ) { // 0 indicates an " empty " element , so we fetch ordinal zeros from nodesWithOrdinalZero
ret . add ( NO_ELEMENT ) ; } for ( int offset = 0 ; offset < maxElementsPerNode ; offset ++ ) { long element = storage . getElementValue ( bucketStart + offset * bitsPerElement , bitsPerElement , elementMask ) ; if ( element == NO_ELEMENT ) { break ; // we have exhausted the elements at this index
} ret . add ( element ) ; } return ret ;


signature:
public class FixedLengthMultipleOccurrenceElementArray { /** * Resize the underlying storage to a multiple of what it currently is . This method is not
 * thread - safe . */
private void resizeStorage ( ) { } }

implementation:
int currentElementsPerNode = maxElementsPerNode ; int newElementsPerNode = ( int ) ( currentElementsPerNode * RESIZE_MULTIPLE ) ; if ( newElementsPerNode <= currentElementsPerNode ) { throw new IllegalStateException ( "cannot resize fixed length array from " + currentElementsPerNode + " to " + newElementsPerNode ) ; } FixedLengthElementArray newStorage = new FixedLengthElementArray ( memoryRecycler , numNodes * bitsPerElement * newElementsPerNode ) ; LongStream . range ( 0 , numNodes ) . forEach ( nodeIndex -> { long currentBucketStart = nodeIndex * currentElementsPerNode * bitsPerElement ; long newBucketStart = nodeIndex * newElementsPerNode * bitsPerElement ; for ( int offset = 0 ; offset < currentElementsPerNode ; offset ++ ) { long element = storage . getElementValue ( currentBucketStart + offset * bitsPerElement , bitsPerElement , elementMask ) ; if ( element == NO_ELEMENT ) { break ; // we have exhausted the elements at this index
} newStorage . setElementValue ( newBucketStart + offset * bitsPerElement , bitsPerElement , element ) ; } } ) ; storage . destroy ( memoryRecycler ) ; storage = newStorage ; maxElementsPerNode = newElementsPerNode ;


signature:
public class AbstractHollowJsonAdaptorTask { /** * / TODO : Many parse failures can cause out of memory errors . */
protected void processFile ( Reader r , int maxSample ) throws Exception { } }

implementation: JsonArrayChunker chunker = new JsonArrayChunker ( r , executor ) ; chunker . initialize ( ) ; int counter = 0 ; Reader jsonObj = chunker . nextChunk ( ) ; while ( jsonObj != null && counter < maxSample ) { final Reader currentObject = jsonObj ; executor . execute ( new Runnable ( ) { public void run ( ) { try { JsonFactory factory = new JsonFactory ( ) ; JsonParser parser = factory . createParser ( currentObject ) ; processRecord ( parser ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } } ) ; while ( executor . getQueue ( ) . size ( ) > maxWorkQueue ) { Thread . sleep ( 5 ) ; } counter ++ ; jsonObj . close ( ) ; jsonObj = chunker . nextChunk ( ) ; } executor . awaitSuccessfulCompletion ( ) ;


signature:
public class ByteArrayOrdinalMap { /** * Adds a sequence of bytes to this map . If the sequence of bytes has previously been added
 * to this map then its assigned ordinal is returned .
 * If the sequence of bytes has not been added to this map then a new ordinal is assigned
 * and returned .
 * This operation is thread - safe .
 * @ param serializedRepresentation the sequence of bytes
 * @ param preferredOrdinal the preferred ordinal to assign , if not already assigned to
 * another sequence of bytes and the given sequence of bytes has not previously been added
 * @ return the assigned ordinal */
public int getOrAssignOrdinal ( ByteDataBuffer serializedRepresentation , int preferredOrdinal ) { } }

implementation: int hash = HashCodes . hashCode ( serializedRepresentation ) ; int ordinal = get ( serializedRepresentation , hash ) ; return ordinal != - 1 ? ordinal : assignOrdinal ( serializedRepresentation , hash , preferredOrdinal ) ;


signature:
public class ByteArrayOrdinalMap { /** * / acquire the lock before writing . */
private synchronized int assignOrdinal ( ByteDataBuffer serializedRepresentation , int hash , int preferredOrdinal ) { } }

implementation:
if ( preferredOrdinal < - 1 || preferredOrdinal > ORDINAL_MASK ) { throw new IllegalArgumentException ( String . format ( "The given preferred ordinal %s is out of bounds and not within the closed interval [-1, %s]" , preferredOrdinal , ORDINAL_MASK ) ) ; } if ( size > sizeBeforeGrow ) { growKeyArray ( ) ; } // / check to make sure that after acquiring the lock , the element still does not exist .
// / this operation is akin to double - checked locking which is ' fixed ' with the JSR 133 memory model in JVM > = 1.5.
// / Note that this also requires pointersAndOrdinals be volatile so resizes are also visible
AtomicLongArray pao = pointersAndOrdinals ; int modBitmask = pao . length ( ) - 1 ; int bucket = hash & modBitmask ; long key = pao . get ( bucket ) ; while ( key != EMPTY_BUCKET_VALUE ) { if ( compare ( serializedRepresentation , key ) ) { return ( int ) ( key >>> BITS_PER_POINTER ) ; } bucket = ( bucket + 1 ) & modBitmask ; key = pao . get ( bucket ) ; } // / the ordinal for this object still does not exist in the list , even after the lock has been acquired .
// / it is up to this thread to add it at the current bucket position .
int ordinal = findFreeOrdinal ( preferredOrdinal ) ; if ( ordinal > ORDINAL_MASK ) { throw new IllegalStateException ( String . format ( "Ordinal cannot be assigned. The to be assigned ordinal, %s, is greater than the maximum supported ordinal value of %s" , ordinal , ORDINAL_MASK ) ) ; } long pointer = byteData . length ( ) ; VarInt . writeVInt ( byteData , ( int ) serializedRepresentation . length ( ) ) ; // / Copying might cause a resize to the segmented array held by byteData
// / A reading thread may observe a null value for a segment during the creation
// / of a new segments array ( see SegmentedByteArray . ensureCapacity ) .
serializedRepresentation . copyTo ( byteData ) ; if ( byteData . length ( ) > MAX_BYTE_DATA_LENGTH ) { throw new IllegalStateException ( String . format ( "The number of bytes for the serialized representations, %s, is too large and is greater than the maximum of %s bytes" , byteData . length ( ) , MAX_BYTE_DATA_LENGTH ) ) ; } key = ( ( long ) ordinal << BITS_PER_POINTER ) | pointer ; size ++ ; // / this set on the AtomicLongArray has volatile semantics ( i . e . behaves like a monitor release ) .
// / Any other thread reading this element in the AtomicLongArray will have visibility to all memory writes this thread has made up to this point .
// / This means the entire byte sequence is guaranteed to be visible to any thread which reads the pointer to that data .
pao . set ( bucket , key ) ; return ordinal ;


signature:
public class ByteArrayOrdinalMap { /** * If the preferredOrdinal has not already been used , mark it and use it . Otherwise ,
 * delegate to the FreeOrdinalTracker . */
private int findFreeOrdinal ( int preferredOrdinal ) { } }

implementation: if ( preferredOrdinal != - 1 && unusedPreviousOrdinals . get ( preferredOrdinal ) ) { unusedPreviousOrdinals . clear ( preferredOrdinal ) ; return preferredOrdinal ; } return freeOrdinalTracker . getFreeOrdinal ( ) ;


signature:
public class ByteArrayOrdinalMap { /** * Create an array mapping the ordinals to pointers , so that they can be easily looked up
 * when writing to blob streams . */
public void prepareForWrite ( ) { } }

implementation: int maxOrdinal = 0 ; AtomicLongArray pao = pointersAndOrdinals ; for ( int i = 0 ; i < pao . length ( ) ; i ++ ) { long key = pao . get ( i ) ; if ( key != EMPTY_BUCKET_VALUE ) { int ordinal = ( int ) ( key >>> BITS_PER_POINTER ) ; if ( ordinal > maxOrdinal ) { maxOrdinal = ordinal ; } } } long [ ] pbo = new long [ maxOrdinal + 1 ] ; Arrays . fill ( pbo , - 1 ) ; for ( int i = 0 ; i < pao . length ( ) ; i ++ ) { long key = pao . get ( i ) ; if ( key != EMPTY_BUCKET_VALUE ) { int ordinal = ( int ) ( key >>> BITS_PER_POINTER ) ; pbo [ ordinal ] = key & POINTER_MASK ; } } pointersByOrdinal = pbo ;


signature:
public class ByteArrayOrdinalMap { /** * Reclaim space in the byte array used in the previous cycle , but not referenced in this cycle . < p >
 * This is achieved by shifting all used byte sequences down in the byte array , then updating
 * the key array to reflect the new pointers and exclude the removed entries . This is also where ordinals
 * which are unused are returned to the pool . < p >
 * @ param usedOrdinals a bit set representing the ordinals which are currently referenced by any image . */
public void compact ( ThreadSafeBitSet usedOrdinals ) { } }

implementation:
long [ ] populatedReverseKeys = new long [ size ] ; int counter = 0 ; AtomicLongArray pao = pointersAndOrdinals ; for ( int i = 0 ; i < pao . length ( ) ; i ++ ) { long key = pao . get ( i ) ; if ( key != EMPTY_BUCKET_VALUE ) { populatedReverseKeys [ counter ++ ] = key << BITS_PER_ORDINAL | key >>> BITS_PER_POINTER ; } } Arrays . sort ( populatedReverseKeys ) ; SegmentedByteArray arr = byteData . getUnderlyingArray ( ) ; long currentCopyPointer = 0 ; for ( int i = 0 ; i < populatedReverseKeys . length ; i ++ ) { int ordinal = ( int ) ( populatedReverseKeys [ i ] & ORDINAL_MASK ) ; if ( usedOrdinals . get ( ordinal ) ) { long pointer = populatedReverseKeys [ i ] >>> BITS_PER_ORDINAL ; int length = VarInt . readVInt ( arr , pointer ) ; length += VarInt . sizeOfVInt ( length ) ; if ( currentCopyPointer != pointer ) { arr . copy ( arr , pointer , currentCopyPointer , length ) ; } populatedReverseKeys [ i ] = populatedReverseKeys [ i ] << BITS_PER_POINTER | currentCopyPointer ; currentCopyPointer += length ; } else { freeOrdinalTracker . returnOrdinalToPool ( ordinal ) ; populatedReverseKeys [ i ] = EMPTY_BUCKET_VALUE ; } } byteData . setPosition ( currentCopyPointer ) ; freeOrdinalTracker . sort ( ) ; // Reset the array then fill with compacted values
// Volatile store not required , could use plain store
// See VarHandles for JDK > = 9
for ( int i = 0 ; i < pao . length ( ) ; i ++ ) { pao . lazySet ( i , EMPTY_BUCKET_VALUE ) ; } populateNewHashArray ( pao , populatedReverseKeys ) ; size = usedOrdinals . cardinality ( ) ; pointersByOrdinal = null ; unusedPreviousOrdinals = null ;


signature:
public class ByteArrayOrdinalMap { /** * Compare the byte sequence contained in the supplied ByteDataBuffer with the
 * sequence contained in the map pointed to by the specified key , byte by byte . */
private boolean compare ( ByteDataBuffer serializedRepresentation , long key ) { } }

implementation: long position = key & POINTER_MASK ; int sizeOfData = VarInt . readVInt ( byteData . getUnderlyingArray ( ) , position ) ; if ( sizeOfData != serializedRepresentation . length ( ) ) { return false ; } position += VarInt . sizeOfVInt ( sizeOfData ) ; for ( int i = 0 ; i < sizeOfData ; i ++ ) { if ( serializedRepresentation . get ( i ) != byteData . get ( position ++ ) ) { return false ; } } return true ;


signature:
public class ByteArrayOrdinalMap { /** * Resize the ordinal map by increasing its capacity .
 * No action is take if the current capacity is sufficient for the given size .
 * WARNING : THIS OPERATION IS NOT THREAD - SAFE .
 * @ param size the size to increase to , rounded up to the nearest power of two . */
public void resize ( int size ) { } }

implementation: size = bucketSize ( size ) ; if ( pointersAndOrdinals . length ( ) < size ) { growKeyArray ( size ) ; }


signature:
public class ByteArrayOrdinalMap { /** * Grow the key array . All of the values in the current array must be re - hashed and added to the new array . */
private void growKeyArray ( ) { } }

implementation: int newSize = pointersAndOrdinals . length ( ) << 1 ; if ( newSize < 0 ) { throw new IllegalStateException ( "New size computed to grow the underlying array for the map is negative. " + "This is most likely due to the total number of keys added to map has exceeded the max capacity of the keys map can hold. " + "Current array size :" + pointersAndOrdinals . length ( ) + " and size to grow :" + newSize ) ; } growKeyArray ( newSize ) ;


signature:
public class ByteArrayOrdinalMap { /** * Get the hash code for the byte array pointed to by the specified key . */
private int rehashPreviouslyAddedData ( long key ) { } }

implementation: long position = key & POINTER_MASK ; int sizeOfData = VarInt . readVInt ( byteData . getUnderlyingArray ( ) , position ) ; position += VarInt . sizeOfVInt ( sizeOfData ) ; return HashCodes . hashCode ( byteData . getUnderlyingArray ( ) , position , sizeOfData ) ;


signature:
public class ByteArrayOrdinalMap { /** * Create an AtomicLongArray of the specified size , each value in the array will be EMPTY _ BUCKET _ VALUE */
private AtomicLongArray emptyKeyArray ( int size ) { } }

implementation:
AtomicLongArray arr = new AtomicLongArray ( size ) ; // Volatile store not required , could use plain store
// See VarHandles for JDK > = 9
for ( int i = 0 ; i < arr . length ( ) ; i ++ ) { arr . lazySet ( i , EMPTY_BUCKET_VALUE ) ; } return arr ;


signature:
public class HollowIndexerValueTraverser { /** * This method assumes the other traverser has the same match fields specified in the same order .
 * @ param matchIdx the match index
 * @ param otherTraverser the other traverser
 * @ param otherMatchIdx the other match index
 * @ return true if this and the other traverser are equal */
public boolean isMatchEqual ( int matchIdx , HollowIndexerValueTraverser otherTraverser , int otherMatchIdx ) { } }

implementation: for ( int i = 0 ; i < getNumFieldPaths ( ) ; i ++ ) { if ( ! HollowReadFieldUtils . fieldsAreEqual ( ( HollowObjectTypeDataAccess ) fieldTypeDataAccess [ i ] , fieldMatchLists [ i ] . get ( matchIdx ) , fieldSchemaPosition [ i ] , ( HollowObjectTypeDataAccess ) otherTraverser . fieldTypeDataAccess [ i ] , otherTraverser . fieldMatchLists [ i ] . get ( otherMatchIdx ) , otherTraverser . fieldSchemaPosition [ i ] ) ) return false ; } return true ;


signature:
public class HollowObjectTypeReadState { /** * Warning : Not thread - safe . Should only be called within the update thread .
 * @ param fieldName the field name
 * @ return the number of bits required for the field */
public int bitsRequiredForField ( String fieldName ) { } }

implementation: int maxBitsRequiredForField = shards [ 0 ] . bitsRequiredForField ( fieldName ) ; for ( int i = 1 ; i < shards . length ; i ++ ) { int shardRequiredBits = shards [ i ] . bitsRequiredForField ( fieldName ) ; if ( shardRequiredBits > maxBitsRequiredForField ) maxBitsRequiredForField = shardRequiredBits ; } return maxBitsRequiredForField ;


signature:
public class UniqueKeyIndex { /** * Finds the unique object , an instance of the unique type , for a given key .
 * @ param key the key
 * @ return the unique object */
public T findMatch ( Q key ) { } }

implementation: Object [ ] keyArray = matchFields . stream ( ) . map ( mf -> mf . extract ( key ) ) . toArray ( ) ; int ordinal = hpki . getMatchingOrdinal ( keyArray ) ; if ( ordinal == - 1 ) { return null ; } return uniqueTypeExtractor . extract ( api , ordinal ) ;


signature:
public class UniqueKeyIndex { /** * Starts the building of a { @ link UniqueKeyIndex } .
 * @ param consumer the consumer containing instances of the given unique type
 * @ param uniqueType the unique type
 * @ param < T > the unique type
 * @ return a builder */
public static < T extends HollowObject > Builder < T > from ( HollowConsumer consumer , Class < T > uniqueType ) { } }

implementation: Objects . requireNonNull ( consumer ) ; Objects . requireNonNull ( uniqueType ) ; return new Builder < > ( consumer , uniqueType ) ;


signature:
public class ReadStateHelper { /** * Swap underlying state engines between current and pending while keeping the versions consistent ;
 * used after delta integrity checks have altered the underlying state engines .
 * @ return */
ReadStateHelper swap ( ) { } }

implementation: return new ReadStateHelper ( newReadState ( current . getVersion ( ) , pending . getStateEngine ( ) ) , newReadState ( pending . getVersion ( ) , current . getStateEngine ( ) ) ) ;


signature:
public class HollowSchemaParser { /** * Parse a collection of { @ link HollowSchema } s from the provided Reader .
 * @ param reader the reader
 * @ return the list of schema
 * @ throws IOException if the schema cannot be parsed */
public static List < HollowSchema > parseCollectionOfSchemas ( Reader reader ) throws IOException { } }

implementation: StreamTokenizer tokenizer = new StreamTokenizer ( reader ) ; configureTokenizer ( tokenizer ) ; List < HollowSchema > schemaList = new ArrayList < HollowSchema > ( ) ; HollowSchema schema = parseSchema ( tokenizer ) ; while ( schema != null ) { schemaList . add ( schema ) ; schema = parseSchema ( tokenizer ) ; } return schemaList ;


signature:
public class HollowSchemaParser { /** * Parse a single { @ link HollowSchema } from the provided String .
 * @ param schema the schema as a string
 * @ return the schema
 * @ throws IOException if the schema cannot be parsed */
public static HollowSchema parseSchema ( String schema ) throws IOException { } }

implementation: StreamTokenizer tokenizer = new StreamTokenizer ( new StringReader ( schema ) ) ; configureTokenizer ( tokenizer ) ; return parseSchema ( tokenizer ) ;


signature:
public class HollowTypeMapper { /** * Calculates the type name from a given type .
 * If the type is annotated with { @ link HollowTypeName } then the type name
 * is the value of the { @ code HollowTypeName . name } attribute . Otherwise
 * the type name is derived from the type itself .
 * If the type is a { @ code Class } then the type name is the simple name of
 * that class .
 * If the type is a parameterized type and is assignable to a class of { @ code List } ,
 * { @ code Set } , or { @ code Map } then the type name begins with the simple class name of
 * the parameterized type ' s raw type , followed by " Of " , followed by the result of
 * calling this method with the associated parameterized types ( in order , in - fixed by " To " ) .
 * Otherwise , the type name is the simple class name of the parameterized type ' s raw type .
 * The translation from type to type name is lossy since the simple class name of a class
 * is used . This means that no two types , from different packages , but with the same simple
 * name can be utilized .
 * @ param type the type
 * @ return the type name . */
public static String getDefaultTypeName ( Type type ) { } }

implementation: if ( type instanceof Class ) { Class < ? > clazz = ( Class < ? > ) type ; HollowTypeName explicitTypeName = clazz . getAnnotation ( HollowTypeName . class ) ; if ( explicitTypeName != null ) return explicitTypeName . name ( ) ; return clazz . getSimpleName ( ) ; } ParameterizedType parameterizedType = ( ParameterizedType ) type ; Class < ? > clazz = ( Class < ? > ) parameterizedType . getRawType ( ) ; if ( List . class . isAssignableFrom ( clazz ) ) return "ListOf" + getDefaultTypeName ( parameterizedType . getActualTypeArguments ( ) [ 0 ] ) ; if ( Set . class . isAssignableFrom ( clazz ) ) return "SetOf" + getDefaultTypeName ( parameterizedType . getActualTypeArguments ( ) [ 0 ] ) ; if ( Map . class . isAssignableFrom ( clazz ) ) return "MapOf" + getDefaultTypeName ( parameterizedType . getActualTypeArguments ( ) [ 0 ] ) + "To" + getDefaultTypeName ( parameterizedType . getActualTypeArguments ( ) [ 1 ] ) ; return clazz . getSimpleName ( ) ;


signature:
public class HashCodes { /** * Determine size of hash table capable of storing the specified number of elements with a load
 * factor applied .
 * @ param numElements number of elements to be stored in the table
 * @ return size of hash table , always a power of 2
 * @ throws IllegalArgumentException when numElements is negative or exceeds
 * { @ link com . netflix . hollow . core . HollowConstants # HASH _ TABLE _ MAX _ SIZE } */
public static int hashTableSize ( int numElements ) throws IllegalArgumentException { } }

implementation:
if ( numElements < 0 ) { throw new IllegalArgumentException ( "cannot be negative; numElements=" + numElements ) ; } else if ( numElements > HASH_TABLE_MAX_SIZE ) { throw new IllegalArgumentException ( "exceeds maximum number of buckets; numElements=" + numElements ) ; } if ( numElements == 0 ) return 1 ; if ( numElements < 3 ) return numElements * 2 ; // Apply load factor to number of elements and determine next
// largest power of 2 that fits in an int
int sizeAfterLoadFactor = ( int ) ( ( long ) numElements * 10 / 7 ) ; int bits = 32 - Integer . numberOfLeadingZeros ( sizeAfterLoadFactor - 1 ) ; return 1 << bits ;


signature:
public class HollowProducer { /** * Restores the data state to a desired version .
 * Data model { @ link # initializeDataModel ( Class [ ] ) initialization } is required prior to
 * restoring the producer . This ensures that restoration can correctly compare the producer ' s
 * current data model with the data model of the restored data state and manage any differences
 * in those models ( such as not restoring state for any types in the restoring data model not
 * present in the producer ' s current data model )
 * @ param versionDesired the desired version
 * @ param blobRetriever the blob retriever
 * @ return the read state of the restored state
 * @ throws IllegalStateException if the producer ' s data model has not been initialized
 * @ see # initializeDataModel ( Class [ ] ) */
@ Override public HollowProducer . ReadState restore ( long versionDesired , HollowConsumer . BlobRetriever blobRetriever ) { } }

implementation: return super . restore ( versionDesired , blobRetriever ) ;


signature:
public class HollowProducer { /** * Run a compaction cycle , will produce a data state with exactly the same data as currently , but
 * reorganized so that ordinal holes are filled . This may need to be run multiple times to arrive
 * at an optimal state .
 * @ param config specifies what criteria to use to determine whether a compaction is necessary
 * @ return the version identifier of the produced state , or AnnouncementWatcher . NO _ ANNOUNCEMENT _ AVAILABLE if compaction was unnecessary . */
public long runCompactionCycle ( HollowCompactor . CompactionConfig config ) { } }

implementation: if ( config != null && readStates . hasCurrent ( ) ) { final HollowCompactor compactor = new HollowCompactor ( getWriteEngine ( ) , readStates . current ( ) . getStateEngine ( ) , config ) ; if ( compactor . needsCompaction ( ) ) { return runCycle ( newState -> compactor . compact ( ) ) ; } } return NO_ANNOUNCEMENT_AVAILABLE ;


signature:
public class HollowBlobWriter { /** * Write the current state as a snapshot blob .
 * @ param os the output stream to write the snapshot blob
 * @ throws IOException if the snapshot blob could not be written */
public void writeSnapshot ( OutputStream os ) throws IOException { } }

implementation: stateEngine . prepareForWrite ( ) ; DataOutputStream dos = new DataOutputStream ( os ) ; writeHeader ( dos , stateEngine . getSchemas ( ) , false ) ; VarInt . writeVInt ( dos , stateEngine . getOrderedTypeStates ( ) . size ( ) ) ; SimultaneousExecutor executor = new SimultaneousExecutor ( getClass ( ) , "write-snapshot" ) ; for ( final HollowTypeWriteState typeState : stateEngine . getOrderedTypeStates ( ) ) { executor . execute ( new Runnable ( ) { public void run ( ) { typeState . calculateSnapshot ( ) ; } } ) ; } try { executor . awaitSuccessfulCompletion ( ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } for ( HollowTypeWriteState typeState : stateEngine . getOrderedTypeStates ( ) ) { HollowSchema schema = typeState . getSchema ( ) ; schema . writeTo ( dos ) ; writeNumShards ( dos , typeState . getNumShards ( ) ) ; typeState . writeSnapshot ( dos ) ; } os . flush ( ) ;


signature:
public class HollowBlobWriter { /** * Serialize the changes necessary to transition a consumer from the previous state
 * to the current state as a delta blob .
 * @ param os the output stream to write the delta blob
 * @ throws IOException if the delta blob could not be written
 * @ throws IllegalStateException if the current state is restored from the previous state
 * and current state contains unrestored state for one or more types . This indicates those
 * types have not been declared to the producer as part it ' s initialized data model .
 * @ see com . netflix . hollow . api . producer . HollowProducer # initializeDataModel ( Class [ ] ) */
public void writeDelta ( OutputStream os ) throws IOException { } }

implementation: stateEngine . prepareForWrite ( ) ; if ( stateEngine . isRestored ( ) ) stateEngine . ensureAllNecessaryStatesRestored ( ) ; List < HollowSchema > changedTypes = changedTypes ( ) ; DataOutputStream dos = new DataOutputStream ( os ) ; writeHeader ( dos , changedTypes , false ) ; VarInt . writeVInt ( dos , changedTypes . size ( ) ) ; SimultaneousExecutor executor = new SimultaneousExecutor ( getClass ( ) , "write-delta" ) ; for ( final HollowTypeWriteState typeState : stateEngine . getOrderedTypeStates ( ) ) { executor . execute ( new Runnable ( ) { public void run ( ) { if ( typeState . hasChangedSinceLastCycle ( ) ) typeState . calculateDelta ( ) ; } } ) ; } try { executor . awaitSuccessfulCompletion ( ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } for ( HollowTypeWriteState typeState : stateEngine . getOrderedTypeStates ( ) ) { if ( typeState . hasChangedSinceLastCycle ( ) ) { HollowSchema schema = typeState . getSchema ( ) ; schema . writeTo ( dos ) ; writeNumShards ( dos , typeState . getNumShards ( ) ) ; typeState . writeDelta ( dos ) ; } } os . flush ( ) ;


signature:
public class HollowConsumerJavaFileGenerator { /** * Adds the schema name to the set if the schema name doesn ' t correspond to a Hollow
 * primitive type . Factored out to prevent bloat in the switch statement it is called
 * from . */
private void addToSetIfNotPrimitiveOrCollection ( Set < String > schemaNameSet , String ... schemaNames ) { } }

implementation:
for ( String schemaName : schemaNames ) { // collections schemas get brought in by a star import
if ( ! HollowCodeGenerationUtils . isCollectionType ( schemaName , dataset ) && ! HollowCodeGenerationUtils . isPrimitiveType ( schemaName ) ) { schemaNameSet . add ( schemaName ) ; } }


signature:
public class VersionMinterWithCounter { /** * Create a new state version . < p >
 * State versions should be ascending - - later states have greater versions . < p >
 * Here we use an easily readable timestamp format .
 * @ return a new state version */
public long mint ( ) { } }

implementation: SimpleDateFormat dateFormat = new SimpleDateFormat ( "yyyyMMddHHmmss" ) ; dateFormat . setTimeZone ( TimeZone . getTimeZone ( "UTC" ) ) ; String formattedDate = dateFormat . format ( new Date ( ) ) ; String versionStr = formattedDate + String . format ( "%03d" , versionCounter . incrementAndGet ( ) % 1000 ) ; return Long . parseLong ( versionStr ) ;


signature:
public class DuplicateDataDetectionValidator { /** * Registers { @ code DuplicateDataDetectionValidator } validators with the given { @ link HollowProducer producer } for
 * all object schema declared with a primary key .
 * This requires that the producer ' s data model has been initialized
 * ( see { @ link HollowProducer # initializeDataModel ( Class [ ] ) } or a prior run cycle has implicitly initialized
 * the data model .
 * For each { @ link HollowTypeWriteState write state } that has a { @ link HollowObjectSchema object schema }
 * declared with a { @ link PrimaryKey primary key } a { @ code DuplicateDataDetectionValidator } validator
 * is instantiated , with the primary key type name , and registered with the given producer ( if a
 * { @ code DuplicateDataDetectionValidator } validator is not already registered for the same primary key type name ) .
 * @ param producer the producer
 * @ apiNote This method registers a { @ code DuplicateDataDetectionValidator } validator with only the primary key type
 * name and not , in addition , the primary key fields . This is to ensure , for the common case , duplicate listeners
 * are not registered by this method if listeners with the same type names were explicitly registered when
 * building the producer .
 * @ see HollowProducer # initializeDataModel ( Class [ ] ) */
public static void addValidatorsForSchemaWithPrimaryKey ( HollowProducer producer ) { } }

implementation: producer . getWriteEngine ( ) . getOrderedTypeStates ( ) . stream ( ) . filter ( ts -> ts . getSchema ( ) . getSchemaType ( ) == SchemaType . OBJECT ) . map ( ts -> ( HollowObjectSchema ) ts . getSchema ( ) ) . filter ( hos -> hos . getPrimaryKey ( ) != null ) . map ( HollowObjectSchema :: getPrimaryKey ) . forEach ( k -> producer . addListener ( new DuplicateDataDetectionValidator ( k . getType ( ) ) ) ) ;


signature:
public class HollowCodeGenerationUtils { /** * Rules : prepend " get " / " is " + upper case first char of field name
 * boolean / Boolean field :
 * - has a boolean prefix ( @ see { @ link # booleanMethodPrefixes } ) , just return it ; otherwise , prepend " get " + upper case first char
 * boolean isPrimary - isPrimary ( )
 * boolean hasStreams - hasStreams ( )
 * boolean playable - getPlayable ( )
 * boolean value - getValue ( )
 * other field type : prepend " get " + upper case first char
 * String title - getTitle ( )
 * @ param fieldName
 * name of field
 * @ param clazz
 * type of field
 * @ return accessor method name */
public static String generateAccessortMethodName ( String fieldName , Class < ? > clazz ) { } }

implementation: String prefix = "get" ; if ( boolean . class . equals ( clazz ) || Boolean . class . equals ( clazz ) ) { for ( String booleanPrefix : booleanMethodPrefixes ) { if ( fieldName . startsWith ( booleanPrefix ) && fieldName . length ( ) > booleanPrefix . length ( ) ) { char firstCharAfterBooleanPrefix = fieldName . charAt ( booleanPrefix . length ( ) ) ; if ( Character . isUpperCase ( firstCharAfterBooleanPrefix ) ) { return fieldName ; } } } } return substituteInvalidChars ( prefix + uppercase ( fieldName ) ) ;


signature:
public class HollowCodeGenerationUtils { /** * Convert field path into Param name
 * Eg :
 * - Actor { @ literal - > } actor
 * - Actor . name { @ literal - > } actorName
 * @ param fieldPath the field path
 * @ return the param name */
public static String normalizeFieldPathToParamName ( String fieldPath ) { } }

implementation: String result = null ; if ( fieldPath . contains ( "." ) ) { String [ ] parts = fieldPath . split ( "\\." ) ; StringBuilder sb = new StringBuilder ( ) ; sb . append ( lowercase ( parts [ 0 ] ) ) ; for ( int i = 1 ; i < parts . length ; i ++ ) { sb . append ( uppercase ( parts [ i ] ) ) ; } result = sb . toString ( ) ; } else { result = lowercase ( fieldPath ) ; } if ( result . endsWith ( "!" ) ) { return result . substring ( 0 , result . length ( ) - 1 ) ; } return result ;


signature:
public class HollowHashIndex { /** * Recreate the hash index entirely */
private void reindexHashIndex ( ) { } }

implementation: HollowHashIndexBuilder builder = new HollowHashIndexBuilder ( stateEngine , type , selectField , matchFields ) ; builder . buildIndex ( ) ; this . hashStateVolatile = new HollowHashIndexState ( builder ) ;


signature:
public class HollowHashIndex { /** * Query the index .
 * @ param query the query
 * @ return the hash index result to gather the matched ordinals . A { @ code null } value indicated no matches were
 * found . */
public HollowHashIndexResult findMatches ( Object ... query ) { } }

implementation: int hashCode = 0 ; for ( int i = 0 ; i < query . length ; i ++ ) { if ( query [ i ] == null ) throw new IllegalArgumentException ( "querying by null unsupported; i=" + i ) ; hashCode ^= HashCodes . hashInt ( keyHashCode ( query [ i ] , i ) ) ; } HollowHashIndexResult result ; HollowHashIndexState hashState ; do { result = null ; hashState = hashStateVolatile ; long bucket = hashCode & hashState . getMatchHashMask ( ) ; long hashBucketBit = bucket * hashState . getBitsPerMatchHashEntry ( ) ; boolean bucketIsEmpty = hashState . getMatchHashTable ( ) . getElementValue ( hashBucketBit , hashState . getBitsPerTraverserField ( ) [ 0 ] ) == 0 ; while ( ! bucketIsEmpty ) { if ( matchIsEqual ( hashState . getMatchHashTable ( ) , hashBucketBit , query ) ) { int selectSize = ( int ) hashState . getMatchHashTable ( ) . getElementValue ( hashBucketBit + hashState . getBitsPerMatchHashKey ( ) , hashState . getBitsPerSelectTableSize ( ) ) ; long selectBucketPointer = hashState . getMatchHashTable ( ) . getElementValue ( hashBucketBit + hashState . getBitsPerMatchHashKey ( ) + hashState . getBitsPerSelectTableSize ( ) , hashState . getBitsPerSelectTablePointer ( ) ) ; result = new HollowHashIndexResult ( hashState , selectBucketPointer , selectSize ) ; break ; } bucket = ( bucket + 1 ) & hashState . getMatchHashMask ( ) ; hashBucketBit = bucket * hashState . getBitsPerMatchHashEntry ( ) ; bucketIsEmpty = hashState . getMatchHashTable ( ) . getElementValue ( hashBucketBit , hashState . getBitsPerTraverserField ( ) [ 0 ] ) == 0 ; } } while ( hashState != hashStateVolatile ) ; return result ;


signature:
public class HollowAnnouncementWatcher { /** * Triggers async refresh after some random number of milliseconds have passed ,
 * between now and the specified maximum number of milliseconds .
 * Any subsequent calls for async refresh will not begin until after the specified delay
 * has completed .
 * @ param maxDelayMillis the maximum delay in milliseconds */
public void triggerAsyncRefreshWithRandomDelay ( int maxDelayMillis ) { } }

implementation: Random rand = new Random ( ) ; int delayMillis = maxDelayMillis > 0 ? rand . nextInt ( maxDelayMillis ) : 0 ; triggerAsyncRefreshWithDelay ( delayMillis ) ;


signature:
public class HollowAnnouncementWatcher { /** * Triggers async refresh after the specified number of milliseconds has passed .
 * Any subsequent calls for async refresh will not begin until after the specified delay
 * has completed .
 * @ param delayMillis the delay in milliseconds */
public void triggerAsyncRefreshWithDelay ( int delayMillis ) { } }

implementation: final HollowClient client = this . client ; final long targetBeginTime = System . currentTimeMillis ( ) + delayMillis ; refreshExecutor . execute ( new Runnable ( ) { public void run ( ) { try { long delay = targetBeginTime - System . currentTimeMillis ( ) ; if ( delay > 0 ) Thread . sleep ( delay ) ; client . triggerRefresh ( ) ; } catch ( Throwable th ) { log . log ( Level . SEVERE , "Async refresh failed" , th ) ; } } } ) ;


signature:
public class HollowDiff { /** * Add a type to be included in the diff report
 * @ param type the type name
 * @ param primaryKeyPaths the path ( s ) to the field ( s ) which comprise the type ' s primary key
 * @ return the diff type */
public HollowTypeDiff addTypeDiff ( String type , String ... primaryKeyPaths ) { } }

implementation: HollowTypeDiff typeDiff = new HollowTypeDiff ( this , type , primaryKeyPaths ) ; if ( typeDiff . hasAnyData ( ) ) typeDiffs . put ( type , typeDiff ) ; return typeDiff ;


signature:
public class HollowDiff { /** * Run the diff */
public void calculateDiffs ( ) { } }

implementation: long startTime = System . currentTimeMillis ( ) ; prepareForDiffCalculation ( ) ; long endTime = System . currentTimeMillis ( ) ; log . info ( "PREPARED IN " + ( endTime - startTime ) + "ms" ) ; for ( HollowTypeDiff typeDiff : typeDiffs . values ( ) ) { typeDiff . calculateDiffs ( ) ; }


signature:
public class HollowHistory { /** * Call this method after each time a delta occurs in the backing { @ link HollowReadStateEngine } . This
 * is how the HollowHistory knows how to create a new { @ link HollowHistoricalState } .
 * @ param newVersion The version of the new state */
public void deltaOccurred ( long newVersion ) { } }

implementation: keyIndex . update ( latestHollowReadStateEngine , true ) ; HollowHistoricalStateDataAccess historicalDataAccess = creator . createBasedOnNewDelta ( latestVersion , latestHollowReadStateEngine ) ; historicalDataAccess . setNextState ( latestHollowReadStateEngine ) ; HollowHistoricalStateKeyOrdinalMapping keyOrdinalMapping = createKeyOrdinalMappingFromDelta ( ) ; HollowHistoricalState historicalState = new HollowHistoricalState ( newVersion , keyOrdinalMapping , historicalDataAccess , latestHeaderEntries ) ; addHistoricalState ( historicalState ) ; this . latestVersion = newVersion ; this . latestHeaderEntries = latestHollowReadStateEngine . getHeaderTags ( ) ;


signature:
public class HollowHistory { /** * Call this method after each time a double snapshot occurs .
 * This method will replace the previous backing { @ link HollowReadStateEngine } with the newly
 * supplied one , stitch together all of the existing history with the new state currently in the
 * new { @ link HollowReadStateEngine } , and create a new { @ link HollowHistoricalState } to represent
 * the transition .
 * @ param newHollowStateEngine the new state engine
 * @ param newVersion the new version */
public void doubleSnapshotOccurred ( HollowReadStateEngine newHollowStateEngine , long newVersion ) { } }

implementation: if ( ! keyIndex . isInitialized ( ) ) keyIndex . update ( latestHollowReadStateEngine , false ) ; keyIndex . update ( newHollowStateEngine , false ) ; HollowHistoricalStateDataAccess historicalDataAccess ; DiffEqualityMapping mapping = new DiffEqualityMapping ( latestHollowReadStateEngine , newHollowStateEngine , true , ! ignoreListOrderingOnDoubleSnapshot ) ; DiffEqualityMappingOrdinalRemapper remapper = new DiffEqualityMappingOrdinalRemapper ( mapping ) ; historicalDataAccess = creator . createHistoricalStateFromDoubleSnapshot ( latestVersion , latestHollowReadStateEngine , newHollowStateEngine , remapper ) ; HollowHistoricalStateDataAccess nextRemappedDataAccess = historicalDataAccess ; HollowHistoricalState nextRemappedState = null ; HollowHistoricalStateDataAccess [ ] remappedDataAccesses = new HollowHistoricalStateDataAccess [ historicalStates . size ( ) ] ; HollowHistoricalStateKeyOrdinalMapping [ ] remappedKeyOrdinalMappings = new HollowHistoricalStateKeyOrdinalMapping [ historicalStates . size ( ) ] ; remapHistoricalStateOrdinals ( remapper , remappedDataAccesses , remappedKeyOrdinalMappings ) ; for ( int i = 0 ; i < historicalStates . size ( ) ; i ++ ) { HollowHistoricalState historicalStateToRemap = historicalStates . get ( i ) ; HollowHistoricalStateDataAccess remappedDataAccess = remappedDataAccesses [ i ] ; HollowHistoricalStateKeyOrdinalMapping remappedKeyOrdinalMapping = remappedKeyOrdinalMappings [ i ] ; remappedDataAccess . setNextState ( nextRemappedDataAccess ) ; nextRemappedDataAccess = remappedDataAccess ; HollowHistoricalState remappedState = new HollowHistoricalState ( historicalStateToRemap . getVersion ( ) , remappedKeyOrdinalMapping , remappedDataAccess , historicalStateToRemap . getHeaderEntries ( ) ) ; remappedState . setNextState ( nextRemappedState ) ; nextRemappedState = remappedState ; historicalStates . set ( i , remappedState ) ; historicalStateLookupMap . put ( remappedState . getVersion ( ) , remappedState ) ; } historicalDataAccess . setNextState ( newHollowStateEngine ) ; HollowHistoricalStateKeyOrdinalMapping keyOrdinalMapping = createKeyOrdinalMappingFromDoubleSnapshot ( newHollowStateEngine , remapper ) ; HollowHistoricalState historicalState = new HollowHistoricalState ( newVersion , keyOrdinalMapping , historicalDataAccess , latestHeaderEntries ) ; addHistoricalState ( historicalState ) ; this . latestVersion = newVersion ; this . latestHollowReadStateEngine = newHollowStateEngine ; this . latestHeaderEntries = latestHollowReadStateEngine . getHeaderTags ( ) ;


signature:
public class HollowHistory { /** * Removes the last { @ code n } historical states .
 * @ param n the number of historical states to remove
 * @ throws IllegalArgumentException if the { @ code n } is less than { @ code 0 } or
 * greater than the { @ link # getNumberOfHistoricalStates ( ) number } of historical
 * states . */
public void removeHistoricalStates ( int n ) { } }

implementation: if ( n < 0 ) { throw new IllegalArgumentException ( String . format ( "Number of states to remove is negative: %d" , n ) ) ; } if ( n > historicalStates . size ( ) ) { throw new IllegalArgumentException ( String . format ( "Number of states to remove, %d, is greater than the number of states. %d" , n , historicalStates . size ( ) ) ) ; } while ( n -- > 0 ) { HollowHistoricalState removedState = historicalStates . remove ( historicalStates . size ( ) - 1 ) ; historicalStateLookupMap . remove ( removedState . getVersion ( ) ) ; }


signature:
public class VarInt { /** * Encode the specified long as a variable length integer into the supplied { @ link ByteDataBuffer }
 * @ param buf the buffer to write to
 * @ param value the long value */
public static void writeVLong ( ByteDataBuffer buf , long value ) { } }

implementation: if ( value < 0 ) buf . write ( ( byte ) 0x81 ) ; if ( value > 0xFFFFFFFFFFFFFFL || value < 0 ) buf . write ( ( byte ) ( 0x80 | ( ( value >>> 56 ) & 0x7FL ) ) ) ; if ( value > 0x1FFFFFFFFFFFFL || value < 0 ) buf . write ( ( byte ) ( 0x80 | ( ( value >>> 49 ) & 0x7FL ) ) ) ; if ( value > 0x3FFFFFFFFFFL || value < 0 ) buf . write ( ( byte ) ( 0x80 | ( ( value >>> 42 ) & 0x7FL ) ) ) ; if ( value > 0x7FFFFFFFFL || value < 0 ) buf . write ( ( byte ) ( 0x80 | ( ( value >>> 35 ) & 0x7FL ) ) ) ; if ( value > 0xFFFFFFFL || value < 0 ) buf . write ( ( byte ) ( 0x80 | ( ( value >>> 28 ) & 0x7FL ) ) ) ; if ( value > 0x1FFFFFL || value < 0 ) buf . write ( ( byte ) ( 0x80 | ( ( value >>> 21 ) & 0x7FL ) ) ) ; if ( value > 0x3FFFL || value < 0 ) buf . write ( ( byte ) ( 0x80 | ( ( value >>> 14 ) & 0x7FL ) ) ) ; if ( value > 0x7FL || value < 0 ) buf . write ( ( byte ) ( 0x80 | ( ( value >>> 7 ) & 0x7FL ) ) ) ; buf . write ( ( byte ) ( value & 0x7FL ) ) ;


signature:
public class VarInt { /** * Encode the specified long as a variable length integer into the supplied OuputStream
 * @ param out the output stream to write to
 * @ param value the long value
 * @ throws IOException if the value cannot be written to the output stream */
public static void writeVLong ( OutputStream out , long value ) throws IOException { } }

implementation: if ( value < 0 ) out . write ( ( byte ) 0x81 ) ; if ( value > 0xFFFFFFFFFFFFFFL || value < 0 ) out . write ( ( byte ) ( 0x80 | ( ( value >>> 56 ) & 0x7FL ) ) ) ; if ( value > 0x1FFFFFFFFFFFFL || value < 0 ) out . write ( ( byte ) ( 0x80 | ( ( value >>> 49 ) & 0x7FL ) ) ) ; if ( value > 0x3FFFFFFFFFFL || value < 0 ) out . write ( ( byte ) ( 0x80 | ( ( value >>> 42 ) & 0x7FL ) ) ) ; if ( value > 0x7FFFFFFFFL || value < 0 ) out . write ( ( byte ) ( 0x80 | ( ( value >>> 35 ) & 0x7FL ) ) ) ; if ( value > 0xFFFFFFFL || value < 0 ) out . write ( ( byte ) ( 0x80 | ( ( value >>> 28 ) & 0x7FL ) ) ) ; if ( value > 0x1FFFFFL || value < 0 ) out . write ( ( byte ) ( 0x80 | ( ( value >>> 21 ) & 0x7FL ) ) ) ; if ( value > 0x3FFFL || value < 0 ) out . write ( ( byte ) ( 0x80 | ( ( value >>> 14 ) & 0x7FL ) ) ) ; if ( value > 0x7FL || value < 0 ) out . write ( ( byte ) ( 0x80 | ( ( value >>> 7 ) & 0x7FL ) ) ) ; out . write ( ( byte ) ( value & 0x7FL ) ) ;


signature:
public class VarInt { /** * Encode the specified int as a variable length integer into the supplied { @ link ByteDataBuffer }
 * @ param buf the buffer to write to
 * @ param value the int value */
public static void writeVInt ( ByteDataBuffer buf , int value ) { } }

implementation: if ( value > 0x0FFFFFFF || value < 0 ) buf . write ( ( byte ) ( 0x80 | ( ( value >>> 28 ) ) ) ) ; if ( value > 0x1FFFFF || value < 0 ) buf . write ( ( byte ) ( 0x80 | ( ( value >>> 21 ) & 0x7F ) ) ) ; if ( value > 0x3FFF || value < 0 ) buf . write ( ( byte ) ( 0x80 | ( ( value >>> 14 ) & 0x7F ) ) ) ; if ( value > 0x7F || value < 0 ) buf . write ( ( byte ) ( 0x80 | ( ( value >>> 7 ) & 0x7F ) ) ) ; buf . write ( ( byte ) ( value & 0x7F ) ) ;


signature:
public class VarInt { /** * Encode the specified int as a variable length integer into the supplied OutputStream
 * @ param out the output stream to write to
 * @ param value the int value
 * @ throws IOException if the value cannot be written to the output stream */
public static void writeVInt ( OutputStream out , int value ) throws IOException { } }

implementation: if ( value > 0x0FFFFFFF || value < 0 ) out . write ( ( byte ) ( 0x80 | ( ( value >>> 28 ) ) ) ) ; if ( value > 0x1FFFFF || value < 0 ) out . write ( ( byte ) ( 0x80 | ( ( value >>> 21 ) & 0x7F ) ) ) ; if ( value > 0x3FFF || value < 0 ) out . write ( ( byte ) ( 0x80 | ( ( value >>> 14 ) & 0x7F ) ) ) ; if ( value > 0x7F || value < 0 ) out . write ( ( byte ) ( 0x80 | ( ( value >>> 7 ) & 0x7F ) ) ) ; out . write ( ( byte ) ( value & 0x7F ) ) ;


signature:
public class VarInt { /** * Write the value as a VarInt into the array , starting at the specified position .
 * @ param data the byte array to write to
 * @ param pos the position in the byte array
 * @ param value the int value
 * @ return the next position after the VarInt has been written . */
public static int writeVInt ( byte data [ ] , int pos , int value ) { } }

implementation: if ( value > 0x0FFFFFFF || value < 0 ) data [ pos ++ ] = ( ( byte ) ( 0x80 | ( ( value >>> 28 ) ) ) ) ; if ( value > 0x1FFFFF || value < 0 ) data [ pos ++ ] = ( ( byte ) ( 0x80 | ( ( value >>> 21 ) & 0x7F ) ) ) ; if ( value > 0x3FFF || value < 0 ) data [ pos ++ ] = ( ( byte ) ( 0x80 | ( ( value >>> 14 ) & 0x7F ) ) ) ; if ( value > 0x7F || value < 0 ) data [ pos ++ ] = ( ( byte ) ( 0x80 | ( ( value >>> 7 ) & 0x7F ) ) ) ; data [ pos ++ ] = ( byte ) ( value & 0x7F ) ; return pos ;


signature:
public class VarInt { /** * Read a variable length integer from the supplied { @ link ByteData } starting at the specified position .
 * @ param arr the byte data to read from
 * @ param position the position in the byte data to read from
 * @ return the int value */
public static int readVInt ( ByteData arr , long position ) { } }

implementation: byte b = arr . get ( position ++ ) ; if ( b == ( byte ) 0x80 ) throw new RuntimeException ( "Attempting to read null value as int" ) ; int value = b & 0x7F ; while ( ( b & 0x80 ) != 0 ) { b = arr . get ( position ++ ) ; value <<= 7 ; value |= ( b & 0x7F ) ; } return value ;


signature:
public class VarInt { /** * Read a variable length integer from the supplied InputStream
 * @ param in the input stream to read from
 * @ return the int value
 * @ throws IOException if the value cannot be read from the input stream */
public static int readVInt ( InputStream in ) throws IOException { } }

implementation: byte b = ( byte ) in . read ( ) ; if ( b == ( byte ) 0x80 ) throw new RuntimeException ( "Attempting to read null value as int" ) ; int value = b & 0x7F ; while ( ( b & 0x80 ) != 0 ) { b = ( byte ) in . read ( ) ; value <<= 7 ; value |= ( b & 0x7F ) ; } return value ;


signature:
public class VarInt { /** * Read a variable length long from the supplied { @ link ByteData } starting at the specified position .
 * @ param arr the byte data to read from
 * @ param position the position in the byte data to read from
 * @ return the long value */
public static long readVLong ( ByteData arr , long position ) { } }

implementation: byte b = arr . get ( position ++ ) ; if ( b == ( byte ) 0x80 ) throw new RuntimeException ( "Attempting to read null value as long" ) ; long value = b & 0x7F ; while ( ( b & 0x80 ) != 0 ) { b = arr . get ( position ++ ) ; value <<= 7 ; value |= ( b & 0x7F ) ; } return value ;


signature:
public class VarInt { /** * Determine the size ( in bytes ) of the variable length long in the supplied { @ link ByteData } , starting at the specified position .
 * @ param arr the byte data to read from
 * @ param position the position in the byte data to read from
 * @ return the long value */
public static int nextVLongSize ( ByteData arr , long position ) { } }

implementation: byte b = arr . get ( position ++ ) ; if ( b == ( byte ) 0x80 ) return 1 ; int length = 1 ; while ( ( b & 0x80 ) != 0 ) { b = arr . get ( position ++ ) ; length ++ ; } return length ;


signature:
public class VarInt { /** * Read a variable length long from the supplied InputStream .
 * @ param in the input stream to read from
 * @ return the long value
 * @ throws IOException if the value cannot be read from the input stream */
public static long readVLong ( InputStream in ) throws IOException { } }

implementation: byte b = ( byte ) in . read ( ) ; if ( b == ( byte ) 0x80 ) throw new RuntimeException ( "Attempting to read null value as long" ) ; long value = b & 0x7F ; while ( ( b & 0x80 ) != 0 ) { b = ( byte ) in . read ( ) ; value <<= 7 ; value |= ( b & 0x7F ) ; } return value ;


signature:
public class VarInt { /** * Determine the size ( in bytes ) of the specified value when encoded as a variable length integer .
 * @ param value the long value
 * @ return the size ( int bytes ) of the value when encoded */
public static int sizeOfVLong ( long value ) { } }

implementation: if ( value < 0L ) return 10 ; if ( value < 0x80L ) return 1 ; if ( value < 0x4000L ) return 2 ; if ( value < 0x200000L ) return 3 ; if ( value < 0x10000000L ) return 4 ; if ( value < 0x800000000L ) return 5 ; if ( value < 0x40000000000L ) return 6 ; if ( value < 0x2000000000000L ) return 7 ; if ( value < 0x100000000000000L ) return 8 ; return 9 ;


signature:
public class VarInt { /** * Count the number of variable length integers encoded in the supplied { @ link ByteData } in the specified range .
 * @ param byteData the byte data
 * @ param fieldPosition the field position
 * @ param length the length
 * @ return number of variable length integers encoded over a range in the byte data */
public static int countVarIntsInRange ( ByteData byteData , long fieldPosition , int length ) { } }

implementation: int numInts = 0 ; boolean insideInt = false ; for ( int i = 0 ; i < length ; i ++ ) { byte b = byteData . get ( fieldPosition + i ) ; if ( ( b & 0x80 ) == 0 ) { numInts ++ ; insideInt = false ; } else if ( ! insideInt && b == ( byte ) 0x80 ) { numInts ++ ; } else { insideInt = true ; } } return numInts ;


signature:
public class PullToRefreshExpandableListActivity { /** * Called when the activity is first created . */
@ Override public void onCreate ( Bundle savedInstanceState ) { } }

implementation:
super . onCreate ( savedInstanceState ) ; setContentView ( R . layout . activity_ptr_expandable_list ) ; mPullRefreshListView = ( PullToRefreshExpandableListView ) findViewById ( R . id . pull_refresh_expandable_list ) ; // Set a listener to be invoked when the list should be refreshed .
mPullRefreshListView . setOnRefreshListener ( new OnRefreshListener < ExpandableListView > ( ) { @ Override public void onRefresh ( PullToRefreshBase < ExpandableListView > refreshView ) { // Do work to refresh the list here .
new GetDataTask ( ) . execute ( ) ; } } ) ; for ( String group : mGroupStrings ) { Map < String , String > groupMap1 = new HashMap < String , String > ( ) ; groupData . add ( groupMap1 ) ; groupMap1 . put ( KEY , group ) ; List < Map < String , String > > childList = new ArrayList < Map < String , String > > ( ) ; for ( String string : mChildStrings ) { Map < String , String > childMap = new HashMap < String , String > ( ) ; childList . add ( childMap ) ; childMap . put ( KEY , string ) ; } childData . add ( childList ) ; } mAdapter = new SimpleExpandableListAdapter ( this , groupData , android . R . layout . simple_expandable_list_item_1 , new String [ ] { KEY } , new int [ ] { android . R . id . text1 } , childData , android . R . layout . simple_expandable_list_item_2 , new String [ ] { KEY } , new int [ ] { android . R . id . text1 } ) ; setListAdapter ( mAdapter ) ;


signature:
public class PullToRefreshBase { /** * Used internally for adding view . Need because we override addView to
 * pass - through to the Refreshable View */
protected final void addViewInternal ( View child , int index , ViewGroup . LayoutParams params ) { } }

implementation: super . addView ( child , index , params ) ;


signature:
public class PullToRefreshBase { /** * Used internally for { @ link # getLoadingLayoutProxy ( boolean , boolean ) } .
 * Allows derivative classes to include any extra LoadingLayouts . */
protected LoadingLayoutProxy createLoadingLayoutProxy ( final boolean includeStart , final boolean includeEnd ) { } }

implementation: LoadingLayoutProxy proxy = new LoadingLayoutProxy ( ) ; if ( includeStart && mMode . showHeaderLoadingLayout ( ) ) { proxy . addLayout ( mHeaderLayout ) ; } if ( includeEnd && mMode . showFooterLoadingLayout ( ) ) { proxy . addLayout ( mFooterLayout ) ; } return proxy ;


signature:
public class PullToRefreshBase { /** * Called when the UI has been to be updated to be in the
 * { @ link State # REFRESHING } or { @ link State # MANUAL _ REFRESHING } state .
 * @ param doScroll - Whether the UI should scroll for this event . */
protected void onRefreshing ( final boolean doScroll ) { } }

implementation:
if ( mMode . showHeaderLoadingLayout ( ) ) { mHeaderLayout . refreshing ( ) ; } if ( mMode . showFooterLoadingLayout ( ) ) { mFooterLayout . refreshing ( ) ; } if ( doScroll ) { if ( mShowViewWhileRefreshing ) { // Call Refresh Listener when the Scroll has finished
OnSmoothScrollFinishedListener listener = new OnSmoothScrollFinishedListener ( ) { @ Override public void onSmoothScrollFinished ( ) { callRefreshListener ( ) ; } } ; switch ( mCurrentMode ) { case MANUAL_REFRESH_ONLY : case PULL_FROM_END : smoothScrollTo ( getFooterSize ( ) , listener ) ; break ; default : case PULL_FROM_START : smoothScrollTo ( - getHeaderSize ( ) , listener ) ; break ; } } else { smoothScrollTo ( 0 ) ; } } else { // We ' re not scrolling , so just call Refresh Listener now
callRefreshListener ( ) ; }


signature:
public class PullToRefreshBase { /** * Called when the UI has been to be updated to be in the
 * { @ link State # RESET } state . */
protected void onReset ( ) { } }

implementation:
mIsBeingDragged = false ; mLayoutVisibilityChangesEnabled = true ; // Always reset both layouts , just in case . . .
mHeaderLayout . reset ( ) ; mFooterLayout . reset ( ) ; smoothScrollTo ( 0 ) ;


signature:
public class PullToRefreshBase { /** * Re - measure the Loading Views height , and adjust internal padding as
 * necessary */
protected final void refreshLoadingViewsSize ( ) { } }

implementation: final int maximumPullScroll = ( int ) ( getMaximumPullScroll ( ) * 1.2f ) ; int pLeft = getPaddingLeft ( ) ; int pTop = getPaddingTop ( ) ; int pRight = getPaddingRight ( ) ; int pBottom = getPaddingBottom ( ) ; switch ( getPullToRefreshScrollDirection ( ) ) { case HORIZONTAL : if ( mMode . showHeaderLoadingLayout ( ) ) { mHeaderLayout . setWidth ( maximumPullScroll ) ; pLeft = - maximumPullScroll ; } else { pLeft = 0 ; } if ( mMode . showFooterLoadingLayout ( ) ) { mFooterLayout . setWidth ( maximumPullScroll ) ; pRight = - maximumPullScroll ; } else { pRight = 0 ; } break ; case VERTICAL : if ( mMode . showHeaderLoadingLayout ( ) ) { mHeaderLayout . setHeight ( maximumPullScroll ) ; pTop = - maximumPullScroll ; } else { pTop = 0 ; } if ( mMode . showFooterLoadingLayout ( ) ) { mFooterLayout . setHeight ( maximumPullScroll ) ; pBottom = - maximumPullScroll ; } else { pBottom = 0 ; } break ; } if ( DEBUG ) { Log . d ( LOG_TAG , String . format ( "Setting Padding. L: %d, T: %d, R: %d, B: %d" , pLeft , pTop , pRight , pBottom ) ) ; } setPadding ( pLeft , pTop , pRight , pBottom ) ;


signature:
public class PullToRefreshBase { /** * Updates the View State when the mode has been set . This does not do any
 * checking that the mode is different to current state so always updates . */
protected void updateUIForMode ( ) { } }

implementation:
// We need to use the correct LayoutParam values , based on scroll
// direction
final LinearLayout . LayoutParams lp = getLoadingLayoutLayoutParams ( ) ; // Remove Header , and then add Header Loading View again if needed
if ( this == mHeaderLayout . getParent ( ) ) { removeView ( mHeaderLayout ) ; } if ( mMode . showHeaderLoadingLayout ( ) ) { addViewInternal ( mHeaderLayout , 0 , lp ) ; } // Remove Footer , and then add Footer Loading View again if needed
if ( this == mFooterLayout . getParent ( ) ) { removeView ( mFooterLayout ) ; } if ( mMode . showFooterLoadingLayout ( ) ) { addViewInternal ( mFooterLayout , lp ) ; } // Hide Loading Views
refreshLoadingViewsSize ( ) ; // If we ' re not using Mode . BOTH , set mCurrentMode to mMode , otherwise
// set it to pull down
mCurrentMode = ( mMode != Mode . BOTH ) ? mMode : Mode . PULL_FROM_START ;