[Challenge] large files smart compare (was: Re: Squeak for I/O and Memory Intensive tasks )

Yoel Jacobsen yoel at emet.co.il
Tue Jan 29 07:39:54 UTC 2002


Skipped content of type multipart/alternative-------------- next part --------------
'From Squeak3.3alpha of 24 January 2002 [latest update: #4653] on 29 January 2002 at 9:21:06 am'!
Object subclass: #LDAPObject
	instanceVariableNames: 'attr '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'YoelTests'!
!LDAPObject commentStamp: 'YJ 1/29/2002 09:20' prior: 0!
"Use the following lines to create an example LDIF file. Use CrLfFileStream if u got the wrong OS"

f _ FileStream fileNamed: 'ggg'.
f ascii.
1 to: 10000 do: [ :num | ns _ num asString.
f nextPutAll: ('dn: uid=yoel' , ns , ', ou=people, o=emet.co.il
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
uid: yoel' , ns , '
cn: yoel' , ns , '
sn: jacobsen

')].
f close.


f _ FileStream fileNamed: 'ggg'.
f ascii.
lines _ f contentsOfEntireFile.
f close.
crcr _ String cr , String cr.
blocks _ lines findBetweenSubStrs: { crcr  }.
objs _ blocks collect: [ :bl | LDAPObject fromStr: bl ].
!


!LDAPObject methodsFor: 'accessing' stamp: 'YJ 1/28/2002 22:47'!
attrs
	
	^ attr! !

!LDAPObject methodsFor: 'accessing' stamp: 'YJ 1/28/2002 22:46'!
attrs: aDict

	attr _ aDict.
	^ self! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

LDAPObject class
	instanceVariableNames: 'attributes '!

!LDAPObject class methodsFor: 'class initialization' stamp: 'YJ 1/28/2002 23:36'!
fromStr: str 
	| obj dict pairsKey pairsVal val point |
	obj _ self new.

	dict _ Dictionary new.
	str linesDo: [ :line |
		point _ line findString: ': '.
		pairsKey _ line copyFrom: 1 to: (point - 1).
		pairsVal _ line copyFrom: (point + 2) to: (line size).
		(dict includesKey: pairsKey)
			 ifTrue:	[
				val _ dict at: pairsKey.
				val add: pairsVal.
				dict at: pairsKey put: val
			 ] ifFalse:	[dict at: pairsKey put: (Bag newFrom: {pairsVal})].
	].
 
	^obj attrs: dict! !


More information about the Squeak-dev mailing list