Class SegmentParser
java.lang.Object
org.apache.jackrabbit.oak.segment.SegmentParser
- Direct Known Subclasses:
RecordUsageAnalyser
SegmentParser
serves as a base class for parsing segments.
This base class provides means for parsing segments into their various
kinds of record. Descendants typically parametrise its behaviour by
overriding the on...()
methods as needed. By default those
methods just initiate the traversal of the same named record.
A typical usage for e.g. printing out the sizes of all templates would look as follows:
new TestParser() { protected void onTemplate(RecordId parentId, RecordId templateId) { TemplateInfo templateInfo = parseTemplate(parentId, templateId); System.out.println(templateInfo.size); } }.parseNode(null, nodeId);
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Return type ofparseBlob(RecordId)
.static enum
Type of blobs (and strings)static class
Return type ofparseListBucket(RecordId, int, int, int)
.static class
Return type ofparseList(RecordId, RecordId, int)
.static class
Result type ofparseMap(RecordId, RecordId, MapRecord)
.static class
Result type ofparseNode(RecordId)
.static class
Result type ofparseProperty(RecordId, RecordId, PropertyTemplate)
.static class
Result type ofparseTemplate(RecordId)
.static class
Result type ofparseValue(RecordId, RecordId, Type)
. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Callback called byparseValue(RecordId, RecordId, Type)
upon encountering a blob.protected void
Callback called byparseNode(RecordId)
,parseProperty(RecordId, RecordId, PropertyTemplate)
,parseTemplate(RecordId)
,parseBlob(RecordId)
andparseString(RecordId)
upon encountering a list.protected void
onListBucket
(RecordId parentId, RecordId listId, int index, int count, int capacity) Callback called byparseList(RecordId, RecordId, int)
andparseListBucket(RecordId, int, int, int)
upon encountering a list bucket.protected void
Callback called byparseNode(RecordId)
,parseMapDiff(RecordId, MapRecord)
andparseMapBranch(RecordId, MapRecord)
upon encountering a map.protected void
onMapBranch
(RecordId parentId, RecordId mapId, MapRecord map) Callback called byparseMap(RecordId, RecordId, MapRecord)
upon encountering a map branch.protected void
Callback called byparseMap(RecordId, RecordId, MapRecord)
upon encountering a map diff.protected void
Callback called byparseMap(RecordId, RecordId, MapRecord)
upon encountering a map leaf.protected void
Callback called byparseNode(RecordId)
upon encountering a child node.protected void
onProperty
(RecordId parentId, RecordId propertyId, PropertyTemplate template) Callback called byparseNode(RecordId)
upon encountering a property.protected void
Callback called byparseTemplate(RecordId)
,parseMapLeaf(RecordId, MapRecord)
andparseValue(RecordId, RecordId, Type)
upon encountering a string.protected void
onTemplate
(RecordId parentId, RecordId templateId) Callback called byparseNode(RecordId)
upon encountering a templateprotected void
Callback called byparseProperty(RecordId, RecordId, PropertyTemplate)
upon encountering a value.Parse a blob recordParse a list recordparseListBucket
(RecordId listId, int index, int count, int capacity) Parse item of list bucketsParse a map recordparseMapBranch
(RecordId mapId, MapRecord map) Parse a map branch recordparseMapDiff
(RecordId mapId, MapRecord map) Parse a map diff recordparseMapLeaf
(RecordId mapId, MapRecord map) Parse a map leaf recordParse a node recordparseProperty
(RecordId parentId, RecordId propertyId, PropertyTemplate template) Parse a propertyparseString
(RecordId stringId) Parse a string recordparseTemplate
(RecordId templateId) Parse a template recordparseValue
(RecordId parentId, RecordId valueId, Type<?> type) Parse a value record
-
Constructor Details
-
SegmentParser
-
-
Method Details
-
onNode
Callback called byparseNode(RecordId)
upon encountering a child node.- Parameters:
parentId
- id of the parent nodenodeId
- if of the child node
-
onTemplate
Callback called byparseNode(RecordId)
upon encountering a template- Parameters:
parentId
- id of the node being parsedtemplateId
- id of the template
-
onMap
Callback called byparseNode(RecordId)
,parseMapDiff(RecordId, MapRecord)
andparseMapBranch(RecordId, MapRecord)
upon encountering a map.- Parameters:
parentId
- the id of the parent of the mapmapId
- the id of the mapmap
- the map
-
onMapDiff
Callback called byparseMap(RecordId, RecordId, MapRecord)
upon encountering a map diff.- Parameters:
parentId
- the id of the parent mapmapId
- the id of the mapmap
- the map
-
onMapLeaf
Callback called byparseMap(RecordId, RecordId, MapRecord)
upon encountering a map leaf.- Parameters:
parentId
- the id of the parent mapmapId
- the id of the mapmap
- the map
-
onMapBranch
Callback called byparseMap(RecordId, RecordId, MapRecord)
upon encountering a map branch.- Parameters:
parentId
- the id of the parent mapmapId
- the id of the mapmap
- the map
-
onProperty
Callback called byparseNode(RecordId)
upon encountering a property.- Parameters:
parentId
- the id of the parent nodepropertyId
- the id of the propertytemplate
- the property template
-
onValue
Callback called byparseProperty(RecordId, RecordId, PropertyTemplate)
upon encountering a value.- Parameters:
parentId
- the id the value's parentvalueId
- the id of the valuetype
- the type of the value
-
onBlob
Callback called byparseValue(RecordId, RecordId, Type)
upon encountering a blob.- Parameters:
parentId
- the id of the blob's parentblobId
- the id of the blob
-
onString
Callback called byparseTemplate(RecordId)
,parseMapLeaf(RecordId, MapRecord)
andparseValue(RecordId, RecordId, Type)
upon encountering a string.- Parameters:
parentId
- the id of the string's parentstringId
- the id of the string
-
onList
Callback called byparseNode(RecordId)
,parseProperty(RecordId, RecordId, PropertyTemplate)
,parseTemplate(RecordId)
,parseBlob(RecordId)
andparseString(RecordId)
upon encountering a list.- Parameters:
parentId
- the id of the list's parentlistId
- the id of the listcount
- the number of elements in the list
-
onListBucket
Callback called byparseList(RecordId, RecordId, int)
andparseListBucket(RecordId, int, int, int)
upon encountering a list bucket.- Parameters:
parentId
- the id of the list's parentlistId
- the id of the listindex
- the index into the bucketcount
- the number of items in the bucketcapacity
- the capacity of the bucket
-
parseNode
Parse a node record- Parameters:
nodeId
-- Returns:
-
parseTemplate
Parse a template record- Parameters:
templateId
-- Returns:
-
parseMap
Parse a map record- Parameters:
parentId
- parent of this map ornull
if nonemapId
-map
-- Returns:
-
parseMapDiff
Parse a map diff record- Parameters:
mapId
-map
-- Returns:
-
parseMapLeaf
Parse a map leaf record- Parameters:
mapId
-map
-- Returns:
-
parseMapBranch
Parse a map branch record- Parameters:
mapId
-map
-- Returns:
-
parseProperty
public SegmentParser.PropertyInfo parseProperty(RecordId parentId, RecordId propertyId, PropertyTemplate template) Parse a property- Parameters:
parentId
-propertyId
-template
-- Returns:
-
parseValue
Parse a value record- Parameters:
parentId
- parent of the value record,null
if nonevalueId
-type
-- Returns:
-
parseBlob
Parse a blob record- Parameters:
blobId
-- Returns:
-
parseString
Parse a string record- Parameters:
stringId
-- Returns:
-
parseList
Parse a list record- Parameters:
parentId
- parent of the list,null
if nonelistId
-count
-- Returns:
-
parseListBucket
public SegmentParser.ListBucketInfo parseListBucket(RecordId listId, int index, int count, int capacity) Parse item of list buckets- Parameters:
listId
-index
- index of the first item to parsecount
- number of items to parsecapacity
- total number of items- Returns:
-