Class SegmentParser
- java.lang.Object
-
- org.apache.jackrabbit.oak.segment.SegmentParser
-
- Direct Known Subclasses:
RecordUsageAnalyser
public class SegmentParser extends Object
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 Classes Modifier and Type Class Description static class
SegmentParser.BlobInfo
Return type ofparseBlob(RecordId)
.static class
SegmentParser.BlobType
Type of blobs (and strings)static class
SegmentParser.ListBucketInfo
Return type ofparseListBucket(RecordId, int, int, int)
.static class
SegmentParser.ListInfo
Return type ofparseList(RecordId, RecordId, int)
.static class
SegmentParser.MapInfo
Result type ofparseMap(RecordId, RecordId, MapRecord)
.static class
SegmentParser.NodeInfo
Result type ofparseNode(RecordId)
.static class
SegmentParser.PropertyInfo
Result type ofparseProperty(RecordId, RecordId, PropertyTemplate)
.static class
SegmentParser.TemplateInfo
Result type ofparseTemplate(RecordId)
.static class
SegmentParser.ValueInfo
Result type ofparseValue(RecordId, RecordId, Type)
.
-
Constructor Summary
Constructors Constructor Description SegmentParser(@NotNull SegmentReader reader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
onBlob(RecordId parentId, RecordId blobId)
Callback called byparseValue(RecordId, RecordId, Type)
upon encountering a blob.protected void
onList(RecordId parentId, RecordId listId, int count)
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
onMap(RecordId parentId, RecordId mapId, MapRecord map)
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
onMapDiff(RecordId parentId, RecordId mapId, MapRecord map)
Callback called byparseMap(RecordId, RecordId, MapRecord)
upon encountering a map diff.protected void
onMapLeaf(RecordId parentId, RecordId mapId, MapRecord map)
Callback called byparseMap(RecordId, RecordId, MapRecord)
upon encountering a map leaf.protected void
onNode(RecordId parentId, RecordId nodeId)
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
onString(RecordId parentId, RecordId stringId)
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
onValue(RecordId parentId, RecordId valueId, Type<?> type)
Callback called byparseProperty(RecordId, RecordId, PropertyTemplate)
upon encountering a value.SegmentParser.BlobInfo
parseBlob(RecordId blobId)
Parse a blob recordSegmentParser.ListInfo
parseList(RecordId parentId, RecordId listId, int count)
Parse a list recordSegmentParser.ListBucketInfo
parseListBucket(RecordId listId, int index, int count, int capacity)
Parse item of list bucketsSegmentParser.MapInfo
parseMap(RecordId parentId, RecordId mapId, MapRecord map)
Parse a map recordSegmentParser.MapInfo
parseMapBranch(RecordId mapId, MapRecord map)
Parse a map branch recordSegmentParser.MapInfo
parseMapDiff(RecordId mapId, MapRecord map)
Parse a map diff recordSegmentParser.MapInfo
parseMapLeaf(RecordId mapId, MapRecord map)
Parse a map leaf recordSegmentParser.NodeInfo
parseNode(RecordId nodeId)
Parse a node recordSegmentParser.PropertyInfo
parseProperty(RecordId parentId, RecordId propertyId, PropertyTemplate template)
Parse a propertySegmentParser.BlobInfo
parseString(RecordId stringId)
Parse a string recordSegmentParser.TemplateInfo
parseTemplate(RecordId templateId)
Parse a template recordSegmentParser.ValueInfo
parseValue(RecordId parentId, RecordId valueId, Type<?> type)
Parse a value record
-
-
-
Constructor Detail
-
SegmentParser
public SegmentParser(@NotNull @NotNull SegmentReader reader)
-
-
Method Detail
-
onNode
protected void onNode(RecordId parentId, RecordId nodeId)
Callback called byparseNode(RecordId)
upon encountering a child node.- Parameters:
parentId
- id of the parent nodenodeId
- if of the child node
-
onTemplate
protected void onTemplate(RecordId parentId, RecordId templateId)
Callback called byparseNode(RecordId)
upon encountering a template- Parameters:
parentId
- id of the node being parsedtemplateId
- id of the template
-
onMap
protected void onMap(RecordId parentId, RecordId mapId, MapRecord map)
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
protected void onMapDiff(RecordId parentId, RecordId mapId, MapRecord map)
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
protected void onMapLeaf(RecordId parentId, RecordId mapId, MapRecord map)
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
protected void onMapBranch(RecordId parentId, RecordId mapId, MapRecord map)
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
protected void onProperty(RecordId parentId, RecordId propertyId, PropertyTemplate template)
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
protected void onValue(RecordId parentId, RecordId valueId, Type<?> type)
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
protected void onBlob(RecordId parentId, RecordId blobId)
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
protected void onString(RecordId parentId, RecordId stringId)
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
protected void onList(RecordId parentId, RecordId listId, int count)
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
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.- 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
public SegmentParser.NodeInfo parseNode(RecordId nodeId)
Parse a node record- Parameters:
nodeId
-- Returns:
-
parseTemplate
public SegmentParser.TemplateInfo parseTemplate(RecordId templateId)
Parse a template record- Parameters:
templateId
-- Returns:
-
parseMap
public SegmentParser.MapInfo parseMap(RecordId parentId, RecordId mapId, MapRecord map)
Parse a map record- Parameters:
parentId
- parent of this map ornull
if nonemapId
-map
-- Returns:
-
parseMapDiff
public SegmentParser.MapInfo parseMapDiff(RecordId mapId, MapRecord map)
Parse a map diff record- Parameters:
mapId
-map
-- Returns:
-
parseMapLeaf
public SegmentParser.MapInfo parseMapLeaf(RecordId mapId, MapRecord map)
Parse a map leaf record- Parameters:
mapId
-map
-- Returns:
-
parseMapBranch
public SegmentParser.MapInfo parseMapBranch(RecordId mapId, MapRecord map)
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
public SegmentParser.ValueInfo parseValue(RecordId parentId, RecordId valueId, Type<?> type)
Parse a value record- Parameters:
parentId
- parent of the value record,null
if nonevalueId
-type
-- Returns:
-
parseBlob
public SegmentParser.BlobInfo parseBlob(RecordId blobId)
Parse a blob record- Parameters:
blobId
-- Returns:
-
parseString
public SegmentParser.BlobInfo parseString(RecordId stringId)
Parse a string record- Parameters:
stringId
-- Returns:
-
parseList
public SegmentParser.ListInfo parseList(RecordId parentId, RecordId listId, int count)
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:
-
-