Object subclass: #AKGRandomCorruption instanceVariableNames: 'count arraySize corruptions' classVariableNames: '' poolDictionaries: '' category: 'AKG-Corruption'! !AKGRandomCorruption methodsFor: 'initialization'! initialize super initialize. count := 0. arraySize := 18202085. corruptions := OrderedCollection new! ! !AKGRandomCorruption methodsFor: 'accessing' stamp: 'AlistairGrant 1/24/2018 17:07'! runLoop 10 timesRepeat: [ 5 timesRepeat: [ self runOnce. count := count + 1 ]. arraySize := (arraySize / 10) rounded. arraySize < 50 ifTrue: [ ^ self halt: 'Finished' ] ]! ! !AKGRandomCorruption methodsFor: 'accessing' stamp: 'AlistairGrant 1/24/2018 17:07'! runOnce | species bufferSize buffer totalRead outputStream answer inputStream ba byte1 | ba := ByteArray new: 18202085. ba atAllPut: 99. 1 to: 20 do: [ :i | ba at: i put: (#[80 75 3 4 10 7 7 7 7 7 125 83 67 73 7 7 7 7 7 7] at: i) ]. inputStream := ba readStream. bufferSize := 16384. species := ByteArray. buffer := species new: bufferSize. totalRead := 0. outputStream := nil. [ inputStream atEnd ] whileFalse: [ | readCount | readCount := inputStream readInto: buffer startingAt: 1 count: bufferSize. totalRead = 0 ifTrue: [ byte1 := buffer first ]. totalRead := totalRead + readCount. outputStream ifNil: [ inputStream atEnd ifTrue: [ ^ buffer copyFrom: 1 to: readCount ] ifFalse: [ outputStream := (species new: bufferSize) writeStream ] ]. outputStream next: readCount putAll: buffer startingAt: 1. byte1 = outputStream contents first ifFalse: [ ^ corruptions add: 'One' -> { arraySize. totalRead. } ] ]. answer := outputStream ifNil: [ species new ] ifNotNil: [ outputStream contents ]. byte1 = answer first ifFalse: [ ^ corruptions add: 'Two' -> { arraySize. totalRead. } ]. ^ answer! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! AKGRandomCorruption class instanceVariableNames: ''! !AKGRandomCorruption class methodsFor: 'as yet unclassified' stamp: 'AlistairGrant 1/24/2018 17:10'! backgroundRun