[Glass] Variable - pointer classes, do you have them?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[Glass] Variable - pointer classes, do you have them?

GLASS mailing list
Hi guys,

In Pharo, there are "variable" classes that hold pointers. That is, besides the named instVars, there is a space for "variables". To create these classes in Pharo we use variableSubclass:... etc...Example: Array. 

ArrayedCollection variableSubclass: #Array
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Collections-Sequenceable'

So...to serialize these instances, what we do, is 2 things: serialize the "fixed/named" instVars (none in this example of Array) and iterate and serialize the "variable part" using #basicSize and #basicAt:. And then, upon materialization, I can send #basicNew: with the desired size and using #basicAt:put: 

The way to get those classes in Pharo is:

Smalltalk allClasses select: [ :each | ((each isWeak not and: [ each isFixed not ])  and: [ each isBytes not ]) and: [ each isPointers ] ]

->   an OrderedCollection(AbsolutePath AdditionalMethodState Array BlockClosure Cubic FaFnSeries FaSeries FileReferenceTest MCMockClassE MetacelloMethodSectionPath MetacelloVersionNumber MethodContext MethodDictionary Path PathTest RelativePath SixxMockBinaryData SixxMockMementoArray SixxMockVariableAlternativeClass SixxMockVariableNewFailedClass SparseLargeArray SparseLargeTable WAExampleClass WeakActionSequence)

Now I know in GemStone you have indexable classes. I think the equivalent are those classes that answer true to #isPointers and #isIndexable


Smalltalk allClasses select: [:each | each isPointers and: [ each isIndexable ] ]

-> [ anArray( Array, Collection, CompiledMethod, InvariantArray, OldRepository, SequenceableCollection, SymbolList, AbstractCollisionBucket, KeyValueDictionary, IntegerKeyValueDictionary, StringKeyValueDictionary, CharacterCollection, ClusterBucketArray, ClassHistory, RcQueue, StackBuffer, BtreeNode, BtreeInteriorNode, BtreeLeafNode, BtreeBasicInteriorNode, BtreeBasicLeafNode, RcKeyValueDictionary, RcIndexDictionary, RcIndexBucket, IdentityIndex, RangeEqualityIndex, PathTerm, IndexList, DependencyList, SetValuedPathTerm, MappingInfo, ConstrainedPathTerm, QueryExecuter, IdentityKeyValueDictionary, PathEvaluator, OrderedCollection, SortedCollection, SortNode, BasicSortNode, RcIndexBucketWithCache, GsMethod, ...)]

So..first question, is this assumption correct?   If true.... then which methods can I use for what I need? that is, #basicSize, #basicAt: , #basicAt:put: , #basicNew: 
I tried different combinations of #basicAt: , #_at: etc but it  never worked. 

What is strange for example, is that if I serialize these objects as FIXED pointers...they seem to work. But the fixed part serializes only via instVarNames... so I don't understand how this could work since I would be missing the variable part.

Any help is appreciated. 




--
Mariano

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: [Glass] Variable - pointer classes, do you have them?

GLASS mailing list
BTW...one of the examples I am trying to serialize/materialize in Gemstone is Interval. And I cannot find a way to recreate them, neither via #basicNew: or #_basicNew:

Thanks, 


On Thu, Sep 4, 2014 at 6:22 PM, Mariano Martinez Peck <[hidden email]> wrote:
Hi guys,

In Pharo, there are "variable" classes that hold pointers. That is, besides the named instVars, there is a space for "variables". To create these classes in Pharo we use variableSubclass:... etc...Example: Array. 

ArrayedCollection variableSubclass: #Array
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Collections-Sequenceable'

So...to serialize these instances, what we do, is 2 things: serialize the "fixed/named" instVars (none in this example of Array) and iterate and serialize the "variable part" using #basicSize and #basicAt:. And then, upon materialization, I can send #basicNew: with the desired size and using #basicAt:put: 

The way to get those classes in Pharo is:

Smalltalk allClasses select: [ :each | ((each isWeak not and: [ each isFixed not ])  and: [ each isBytes not ]) and: [ each isPointers ] ]

->   an OrderedCollection(AbsolutePath AdditionalMethodState Array BlockClosure Cubic FaFnSeries FaSeries FileReferenceTest MCMockClassE MetacelloMethodSectionPath MetacelloVersionNumber MethodContext MethodDictionary Path PathTest RelativePath SixxMockBinaryData SixxMockMementoArray SixxMockVariableAlternativeClass SixxMockVariableNewFailedClass SparseLargeArray SparseLargeTable WAExampleClass WeakActionSequence)

Now I know in GemStone you have indexable classes. I think the equivalent are those classes that answer true to #isPointers and #isIndexable


Smalltalk allClasses select: [:each | each isPointers and: [ each isIndexable ] ]

-> [ anArray( Array, Collection, CompiledMethod, InvariantArray, OldRepository, SequenceableCollection, SymbolList, AbstractCollisionBucket, KeyValueDictionary, IntegerKeyValueDictionary, StringKeyValueDictionary, CharacterCollection, ClusterBucketArray, ClassHistory, RcQueue, StackBuffer, BtreeNode, BtreeInteriorNode, BtreeLeafNode, BtreeBasicInteriorNode, BtreeBasicLeafNode, RcKeyValueDictionary, RcIndexDictionary, RcIndexBucket, IdentityIndex, RangeEqualityIndex, PathTerm, IndexList, DependencyList, SetValuedPathTerm, MappingInfo, ConstrainedPathTerm, QueryExecuter, IdentityKeyValueDictionary, PathEvaluator, OrderedCollection, SortedCollection, SortNode, BasicSortNode, RcIndexBucketWithCache, GsMethod, ...)]

So..first question, is this assumption correct?   If true.... then which methods can I use for what I need? that is, #basicSize, #basicAt: , #basicAt:put: , #basicNew: 
I tried different combinations of #basicAt: , #_at: etc but it  never worked. 

What is strange for example, is that if I serialize these objects as FIXED pointers...they seem to work. But the fixed part serializes only via instVarNames... so I don't understand how this could work since I would be missing the variable part.

Any help is appreciated. 




--
Mariano



--
Mariano
http://marianopeck.wordpress.com

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: [Glass] Variable - pointer classes, do you have them?

GLASS mailing list



On Thu, Sep 4, 2014 at 6:27 PM, Mariano Martinez Peck <[hidden email]> wrote:
BTW...one of the examples I am trying to serialize/materialize in Gemstone is Interval. And I cannot find a way to recreate them, neither via #basicNew: or #_basicNew:


I am trying the combination #basicSize, #_at:  , #_at:put  and #basicNew:

However, creating an internal gives me something strange!


(-10 to: 10 by: 5) basicSize -> 3
(-10 to: 10 by: 5) _basicSize -> 0

(Interval basicNew: 3) basicSize -> 6
(Interval basicNew: 3) _basicSize -> 3

And also I have another problem with (0 to: 0 by: 1). 

Anyway,..any clarification is appreciated. 

thoughts? 

 
Thanks, 


On Thu, Sep 4, 2014 at 6:22 PM, Mariano Martinez Peck <[hidden email]> wrote:
Hi guys,

In Pharo, there are "variable" classes that hold pointers. That is, besides the named instVars, there is a space for "variables". To create these classes in Pharo we use variableSubclass:... etc...Example: Array. 

ArrayedCollection variableSubclass: #Array
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Collections-Sequenceable'

So...to serialize these instances, what we do, is 2 things: serialize the "fixed/named" instVars (none in this example of Array) and iterate and serialize the "variable part" using #basicSize and #basicAt:. And then, upon materialization, I can send #basicNew: with the desired size and using #basicAt:put: 

The way to get those classes in Pharo is:

Smalltalk allClasses select: [ :each | ((each isWeak not and: [ each isFixed not ])  and: [ each isBytes not ]) and: [ each isPointers ] ]

->   an OrderedCollection(AbsolutePath AdditionalMethodState Array BlockClosure Cubic FaFnSeries FaSeries FileReferenceTest MCMockClassE MetacelloMethodSectionPath MetacelloVersionNumber MethodContext MethodDictionary Path PathTest RelativePath SixxMockBinaryData SixxMockMementoArray SixxMockVariableAlternativeClass SixxMockVariableNewFailedClass SparseLargeArray SparseLargeTable WAExampleClass WeakActionSequence)

Now I know in GemStone you have indexable classes. I think the equivalent are those classes that answer true to #isPointers and #isIndexable


Smalltalk allClasses select: [:each | each isPointers and: [ each isIndexable ] ]

-> [ anArray( Array, Collection, CompiledMethod, InvariantArray, OldRepository, SequenceableCollection, SymbolList, AbstractCollisionBucket, KeyValueDictionary, IntegerKeyValueDictionary, StringKeyValueDictionary, CharacterCollection, ClusterBucketArray, ClassHistory, RcQueue, StackBuffer, BtreeNode, BtreeInteriorNode, BtreeLeafNode, BtreeBasicInteriorNode, BtreeBasicLeafNode, RcKeyValueDictionary, RcIndexDictionary, RcIndexBucket, IdentityIndex, RangeEqualityIndex, PathTerm, IndexList, DependencyList, SetValuedPathTerm, MappingInfo, ConstrainedPathTerm, QueryExecuter, IdentityKeyValueDictionary, PathEvaluator, OrderedCollection, SortedCollection, SortNode, BasicSortNode, RcIndexBucketWithCache, GsMethod, ...)]

So..first question, is this assumption correct?   If true.... then which methods can I use for what I need? that is, #basicSize, #basicAt: , #basicAt:put: , #basicNew: 
I tried different combinations of #basicAt: , #_at: etc but it  never worked. 

What is strange for example, is that if I serialize these objects as FIXED pointers...they seem to work. But the fixed part serializes only via instVarNames... so I don't understand how this could work since I would be missing the variable part.

Any help is appreciated. 




--
Mariano



--
Mariano
http://marianopeck.wordpress.com



--
Mariano
http://marianopeck.wordpress.com

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: [Glass] Variable - pointer classes, do you have them?

GLASS mailing list
In reply to this post by GLASS mailing list
Mariano,

Here's the method that i use for extracting the fields from an object for STON:

  1 to: self class instSize do: [ :each | self instVarAt: each put: (block value: (self instVarAt: each)) ].
  (self class isVariable and: [ self class isBytes not ])
    ifTrue: [ 1 to: self _basicSize do: [ :each | self basicAt: each put: (block value: (self basicAt: each)) ] ]

and here is method that I use for constructing an inspector in tODE:

  | parentObj coll specialElements ivs dvs indexableSize moreElements |
  parentObj := parentNode basicContents.
  ivs := parentObj class allInstVarNames.
  dvs := (parentObj respondsTo: #'dynamicInstanceVariables')
    ifTrue: [ parentObj dynamicInstanceVariables ]
    ifFalse: [ #() ].
  moreElements := #().
  indexableSize := Reflection sizeOf: parentObj.
  indexableSize > self indexableWindowSize
    ifTrue: [ 
      indexableEndIndex := self indexableStartIndex + self indexableWindowSize - 1
        min: indexableSize.
      indexableEndIndex < indexableSize
        ifTrue: [ moreElements := #('<<more>>') ] ]
    ifFalse: [ indexableEndIndex := indexableSize - ivs size ].
  specialElements := self specialChildNodeNameList: parentNode.
  coll := (ivs , dvs) sorted collect: [ :each | each asString ].
  ^ specialElements , coll
    ,
      ((self indexableStartIndex to: indexableEndIndex)
        collect: [ :each | each asString ])
    , moreElements

Which I think should give you some interesting information about accessing instvars and indexable slots in an object ...

Dale


On Thu, Sep 4, 2014 at 2:22 PM, Mariano Martinez Peck via Glass <[hidden email]> wrote:
Hi guys,

In Pharo, there are "variable" classes that hold pointers. That is, besides the named instVars, there is a space for "variables". To create these classes in Pharo we use variableSubclass:... etc...Example: Array. 

ArrayedCollection variableSubclass: #Array
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Collections-Sequenceable'

So...to serialize these instances, what we do, is 2 things: serialize the "fixed/named" instVars (none in this example of Array) and iterate and serialize the "variable part" using #basicSize and #basicAt:. And then, upon materialization, I can send #basicNew: with the desired size and using #basicAt:put: 

The way to get those classes in Pharo is:

Smalltalk allClasses select: [ :each | ((each isWeak not and: [ each isFixed not ])  and: [ each isBytes not ]) and: [ each isPointers ] ]

->   an OrderedCollection(AbsolutePath AdditionalMethodState Array BlockClosure Cubic FaFnSeries FaSeries FileReferenceTest MCMockClassE MetacelloMethodSectionPath MetacelloVersionNumber MethodContext MethodDictionary Path PathTest RelativePath SixxMockBinaryData SixxMockMementoArray SixxMockVariableAlternativeClass SixxMockVariableNewFailedClass SparseLargeArray SparseLargeTable WAExampleClass WeakActionSequence)

Now I know in GemStone you have indexable classes. I think the equivalent are those classes that answer true to #isPointers and #isIndexable


Smalltalk allClasses select: [:each | each isPointers and: [ each isIndexable ] ]

-> [ anArray( Array, Collection, CompiledMethod, InvariantArray, OldRepository, SequenceableCollection, SymbolList, AbstractCollisionBucket, KeyValueDictionary, IntegerKeyValueDictionary, StringKeyValueDictionary, CharacterCollection, ClusterBucketArray, ClassHistory, RcQueue, StackBuffer, BtreeNode, BtreeInteriorNode, BtreeLeafNode, BtreeBasicInteriorNode, BtreeBasicLeafNode, RcKeyValueDictionary, RcIndexDictionary, RcIndexBucket, IdentityIndex, RangeEqualityIndex, PathTerm, IndexList, DependencyList, SetValuedPathTerm, MappingInfo, ConstrainedPathTerm, QueryExecuter, IdentityKeyValueDictionary, PathEvaluator, OrderedCollection, SortedCollection, SortNode, BasicSortNode, RcIndexBucketWithCache, GsMethod, ...)]

So..first question, is this assumption correct?   If true.... then which methods can I use for what I need? that is, #basicSize, #basicAt: , #basicAt:put: , #basicNew: 
I tried different combinations of #basicAt: , #_at: etc but it  never worked. 

What is strange for example, is that if I serialize these objects as FIXED pointers...they seem to work. But the fixed part serializes only via instVarNames... so I don't understand how this could work since I would be missing the variable part.

Any help is appreciated. 




--
Mariano

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass



_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: [Glass] Variable - pointer classes, do you have them?

GLASS mailing list
In reply to this post by GLASS mailing list
Mariano,

I think that Interval should just be treated as an instance with three instance variables. you should be able to use the instVarAt: and instVarAt:put: methods ... 

I am inclined to consider the odd behavior you are seeing as a bug and I will submit an internal bug to have this looked into and/or explained ...

BTW, if you haven't already looked you might find implementors of #basicWriteTo:,  #basicLoadFromNoRead:  and #basicLoadFromNoRead: size: helpful as they are part of  passivation which is the native GemStone serialization implementation ...

Thanks,

Dale


On Thu, Sep 4, 2014 at 2:39 PM, Mariano Martinez Peck via Glass <[hidden email]> wrote:



On Thu, Sep 4, 2014 at 6:27 PM, Mariano Martinez Peck <[hidden email]> wrote:
BTW...one of the examples I am trying to serialize/materialize in Gemstone is Interval. And I cannot find a way to recreate them, neither via #basicNew: or #_basicNew:


I am trying the combination #basicSize, #_at:  , #_at:put  and #basicNew:

However, creating an internal gives me something strange!


(-10 to: 10 by: 5) basicSize -> 3
(-10 to: 10 by: 5) _basicSize -> 0

(Interval basicNew: 3) basicSize -> 6
(Interval basicNew: 3) _basicSize -> 3

And also I have another problem with (0 to: 0 by: 1). 

Anyway,..any clarification is appreciated. 

thoughts? 

 
Thanks, 


On Thu, Sep 4, 2014 at 6:22 PM, Mariano Martinez Peck <[hidden email]> wrote:
Hi guys,

In Pharo, there are "variable" classes that hold pointers. That is, besides the named instVars, there is a space for "variables". To create these classes in Pharo we use variableSubclass:... etc...Example: Array. 

ArrayedCollection variableSubclass: #Array
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Collections-Sequenceable'

So...to serialize these instances, what we do, is 2 things: serialize the "fixed/named" instVars (none in this example of Array) and iterate and serialize the "variable part" using #basicSize and #basicAt:. And then, upon materialization, I can send #basicNew: with the desired size and using #basicAt:put: 

The way to get those classes in Pharo is:

Smalltalk allClasses select: [ :each | ((each isWeak not and: [ each isFixed not ])  and: [ each isBytes not ]) and: [ each isPointers ] ]

->   an OrderedCollection(AbsolutePath AdditionalMethodState Array BlockClosure Cubic FaFnSeries FaSeries FileReferenceTest MCMockClassE MetacelloMethodSectionPath MetacelloVersionNumber MethodContext MethodDictionary Path PathTest RelativePath SixxMockBinaryData SixxMockMementoArray SixxMockVariableAlternativeClass SixxMockVariableNewFailedClass SparseLargeArray SparseLargeTable WAExampleClass WeakActionSequence)

Now I know in GemStone you have indexable classes. I think the equivalent are those classes that answer true to #isPointers and #isIndexable


Smalltalk allClasses select: [:each | each isPointers and: [ each isIndexable ] ]

-> [ anArray( Array, Collection, CompiledMethod, InvariantArray, OldRepository, SequenceableCollection, SymbolList, AbstractCollisionBucket, KeyValueDictionary, IntegerKeyValueDictionary, StringKeyValueDictionary, CharacterCollection, ClusterBucketArray, ClassHistory, RcQueue, StackBuffer, BtreeNode, BtreeInteriorNode, BtreeLeafNode, BtreeBasicInteriorNode, BtreeBasicLeafNode, RcKeyValueDictionary, RcIndexDictionary, RcIndexBucket, IdentityIndex, RangeEqualityIndex, PathTerm, IndexList, DependencyList, SetValuedPathTerm, MappingInfo, ConstrainedPathTerm, QueryExecuter, IdentityKeyValueDictionary, PathEvaluator, OrderedCollection, SortedCollection, SortNode, BasicSortNode, RcIndexBucketWithCache, GsMethod, ...)]

So..first question, is this assumption correct?   If true.... then which methods can I use for what I need? that is, #basicSize, #basicAt: , #basicAt:put: , #basicNew: 
I tried different combinations of #basicAt: , #_at: etc but it  never worked. 

What is strange for example, is that if I serialize these objects as FIXED pointers...they seem to work. But the fixed part serializes only via instVarNames... so I don't understand how this could work since I would be missing the variable part.

Any help is appreciated. 




--
Mariano



--
Mariano
http://marianopeck.wordpress.com



--
Mariano
http://marianopeck.wordpress.com

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass



_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: [Glass] Variable - pointer classes, do you have them?

GLASS mailing list
In reply to this post by GLASS mailing list
On 09/04/2014 02:27 PM, Mariano Martinez Peck via Glass wrote:
> BTW...one of the examples I am trying to serialize/materialize in
> Gemstone is Interval. And I cannot find a way to recreate them, neither
> via #basicNew: or #_basicNew:
>


Interval is not a variable class, it's a normal fixed-size pointer
object. New instances can be created with #basicNew (as opposed to
#basicNew:).

Regards,

-Martin

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: [Glass] Variable - pointer classes, do you have them?

GLASS mailing list



On Thu, Sep 4, 2014 at 11:59 PM, Martin McClure <[hidden email]> wrote:
On 09/04/2014 02:27 PM, Mariano Martinez Peck via Glass wrote:
BTW...one of the examples I am trying to serialize/materialize in
Gemstone is Interval. And I cannot find a way to recreate them, neither
via #basicNew: or #_basicNew:



Interval is not a variable class, it's a normal fixed-size pointer object. New instances can be created with #basicNew (as opposed to #basicNew:).


But then my "test" to see if a class is variable is wrong? 
I mean, 

Interval isVariable -> true

I guess Interval should NOT be indexable subclass then. Right? 

Thanks 

 
Regards,

-Martin




--
Mariano
http://marianopeck.wordpress.com

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: [Glass] Variable - pointer classes, do you have them?

GLASS mailing list
On 09/04/2014 08:05 PM, Mariano Martinez Peck wrote:

>
>
>
> On Thu, Sep 4, 2014 at 11:59 PM, Martin McClure
> <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     On 09/04/2014 02:27 PM, Mariano Martinez Peck via Glass wrote:
>
>         BTW...one of the examples I am trying to serialize/materialize in
>         Gemstone is Interval. And I cannot find a way to recreate them,
>         neither
>         via #basicNew: or #_basicNew:
>
>
>
>     Interval is not a variable class, it's a normal fixed-size pointer
>     object. New instances can be created with #basicNew (as opposed to
>     #basicNew:).
>
>
> But then my "test" to see if a class is variable is wrong?
> I mean,
>
> Interval isVariable -> true
>
> I guess Interval should NOT be indexable subclass then. Right?
>

My apologies. Interval *is* an indexable class (though it should always
have 0 indexed instance variable). For me, #basicNew: does create a new
instance. What error do you get when creating one that way?

Also, are you sure you want is #isVariable and not #isIndexable?
#isVariable will also get you the NSCs. I think you'll have trouble with
NSCs using #_basicAt: and #basicAt:put:, you probably need to use #do:
and #add: to enumerate and build these.

Regards,

-Martin
_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass