Class SegmentParser
- java.lang.Object
-
- org.apache.jackrabbit.oak.segment.SegmentParser
-
- Direct Known Subclasses:
RecordUsageAnalyser
public class SegmentParser extends Object
SegmentParserserves 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 classSegmentParser.BlobInfoReturn type ofparseBlob(RecordId).static classSegmentParser.BlobTypeType of blobs (and strings)static classSegmentParser.ListBucketInfoReturn type ofparseListBucket(RecordId, int, int, int).static classSegmentParser.ListInfoReturn type ofparseList(RecordId, RecordId, int).static classSegmentParser.MapInfoResult type ofparseMap(RecordId, RecordId, MapRecord).static classSegmentParser.NodeInfoResult type ofparseNode(RecordId).static classSegmentParser.PropertyInfoResult type ofparseProperty(RecordId, RecordId, PropertyTemplate).static classSegmentParser.TemplateInfoResult type ofparseTemplate(RecordId).static classSegmentParser.ValueInfoResult 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 voidonBlob(RecordId parentId, RecordId blobId)Callback called byparseValue(RecordId, RecordId, Type)upon encountering a blob.protected voidonList(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 voidonListBucket(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 voidonMap(RecordId parentId, RecordId mapId, MapRecord map)Callback called byparseNode(RecordId),parseMapDiff(RecordId, MapRecord)andparseMapBranch(RecordId, MapRecord)upon encountering a map.protected voidonMapBranch(RecordId parentId, RecordId mapId, MapRecord map)Callback called byparseMap(RecordId, RecordId, MapRecord)upon encountering a map branch.protected voidonMapDiff(RecordId parentId, RecordId mapId, MapRecord map)Callback called byparseMap(RecordId, RecordId, MapRecord)upon encountering a map diff.protected voidonMapLeaf(RecordId parentId, RecordId mapId, MapRecord map)Callback called byparseMap(RecordId, RecordId, MapRecord)upon encountering a map leaf.protected voidonNode(RecordId parentId, RecordId nodeId)Callback called byparseNode(RecordId)upon encountering a child node.protected voidonProperty(RecordId parentId, RecordId propertyId, PropertyTemplate template)Callback called byparseNode(RecordId)upon encountering a property.protected voidonString(RecordId parentId, RecordId stringId)Callback called byparseTemplate(RecordId),parseMapLeaf(RecordId, MapRecord)andparseValue(RecordId, RecordId, Type)upon encountering a string.protected voidonTemplate(RecordId parentId, RecordId templateId)Callback called byparseNode(RecordId)upon encountering a templateprotected voidonValue(RecordId parentId, RecordId valueId, Type<?> type)Callback called byparseProperty(RecordId, RecordId, PropertyTemplate)upon encountering a value.SegmentParser.BlobInfoparseBlob(RecordId blobId)Parse a blob recordSegmentParser.ListInfoparseList(RecordId parentId, RecordId listId, int count)Parse a list recordSegmentParser.ListBucketInfoparseListBucket(RecordId listId, int index, int count, int capacity)Parse item of list bucketsSegmentParser.MapInfoparseMap(RecordId parentId, RecordId mapId, MapRecord map)Parse a map recordSegmentParser.MapInfoparseMapBranch(RecordId mapId, MapRecord map)Parse a map branch recordSegmentParser.MapInfoparseMapDiff(RecordId mapId, MapRecord map)Parse a map diff recordSegmentParser.MapInfoparseMapLeaf(RecordId mapId, MapRecord map)Parse a map leaf recordSegmentParser.NodeInfoparseNode(RecordId nodeId)Parse a node recordSegmentParser.PropertyInfoparseProperty(RecordId parentId, RecordId propertyId, PropertyTemplate template)Parse a propertySegmentParser.BlobInfoparseString(RecordId stringId)Parse a string recordSegmentParser.TemplateInfoparseTemplate(RecordId templateId)Parse a template recordSegmentParser.ValueInfoparseValue(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 ornullif 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,nullif 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,nullif 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:
-
-