Class AbstractCoreKeyAccumuloElementConverter
- java.lang.Object
-
- uk.gov.gchq.gaffer.accumulostore.key.core.AbstractCoreKeyAccumuloElementConverter
-
- All Implemented Interfaces:
AccumuloElementConverter
- Direct Known Subclasses:
ByteEntityAccumuloElementConverter,ClassicAccumuloElementConverter
public abstract class AbstractCoreKeyAccumuloElementConverter extends Object implements AccumuloElementConverter
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]buildColumnFamily(String group)Creates a byte array representing the group.byte[]buildColumnQualifier(String group, Properties properties)Creates a byte array representing a set ofPropertiesthat are to be stored in the column qualifier.byte[]buildColumnVisibility(String group, Properties properties)Creates a byte array representing a set ofPropertiesthat are to be stored in the column visibility.longbuildTimestamp(String group, Properties properties)Creates a timestamp based on the providedPropertieswill return a default value if properties do not have a valid timestamp valueElementgetElementFromKey(org.apache.accumulo.core.data.Key key, boolean includeMatchedVertex)Gets a newElementfrom an AccumuloKey.ElementIdgetElementId(org.apache.accumulo.core.data.Key key, boolean includeMatchedVertex)Gets a newElementIdfrom an AccumuloKey.ElementgetFullElement(org.apache.accumulo.core.data.Key key, org.apache.accumulo.core.data.Value value, boolean includeMatchedVertex)StringgetGroupFromColumnFamily(byte[] columnFamily)Returns the element class from the given bytes.org.apache.accumulo.core.data.KeygetKeyFromEntity(Entity entity)Converts anEntityto aKey.Pair<org.apache.accumulo.core.data.Key,org.apache.accumulo.core.data.Key>getKeysFromEdge(Edge edge)Converts anEdgeto a pair ofKeys.Pair<org.apache.accumulo.core.data.Key,org.apache.accumulo.core.data.Key>getKeysFromElement(Element element)BytesAndRangegetPropertiesAsBytesFromColumnQualifier(String group, byte[] bytes, int numProps)Truncates the provided columnQualifier, returning the byte representation of the serialised version of the specified properties.PropertiesgetPropertiesFromColumnQualifier(String group, byte[] bytes)Returns a set ofPropertiesthat are stored in the part of the key that is provided.PropertiesgetPropertiesFromColumnVisibility(String group, byte[] columnVisibility)Returns a set ofPropertiesthat are stored in the part of the key that is provided.PropertiesgetPropertiesFromTimestamp(String group, long timestamp)Get the properties for a given group defined in the Schema as being stored in the Accumulo timestamp column.PropertiesgetPropertiesFromValue(String group, org.apache.accumulo.core.data.Value value)Converts an AccumuloValueto aPropertiesobject.Pair<byte[],byte[]>getRowKeysFromElement(Element element)Creates a byte array representing the Element identifiers, this will be stored in the Accumulo row Key.org.apache.accumulo.core.data.ValuegetValueFromElement(Element element)Converts thePropertiesin an element to an AccumuloValuewhere the property has a position within the store schema that indicates it should be stored in the value.org.apache.accumulo.core.data.ValuegetValueFromProperties(String group, Properties properties)Converts a set ofPropertiesto an AccumuloValue.byte[]serialiseVertex(Object vertex)Helper Used to create Bloom Filters, method Serialises a given object (from anEntityId) with the Identifier Serialiser defined in the schema.
-
-
-
Method Detail
-
getElementId
public ElementId getElementId(org.apache.accumulo.core.data.Key key, boolean includeMatchedVertex)
Description copied from interface:AccumuloElementConverterGets a newElementIdfrom an AccumuloKey.- Specified by:
getElementIdin interfaceAccumuloElementConverter- Parameters:
key- the Key containing serialised parts of the ElementincludeMatchedVertex- if true then the matchedVertex field is set on Edges- Returns:
- A new
ElementId
-
getKeysFromElement
public Pair<org.apache.accumulo.core.data.Key,org.apache.accumulo.core.data.Key> getKeysFromElement(Element element)
Description copied from interface:AccumuloElementConverterConverts anElementPairof keys which represent the keys created from the given element. If the given element was an entity only one key will be created and the second item in the pair will be null.- Specified by:
getKeysFromElementin interfaceAccumuloElementConverter- Parameters:
element- the element to be converted- Returns:
- The key(s) that represent the given element.
-
getKeysFromEdge
public Pair<org.apache.accumulo.core.data.Key,org.apache.accumulo.core.data.Key> getKeysFromEdge(Edge edge)
Description copied from interface:AccumuloElementConverterConverts anEdgeto a pair ofKeys.- Specified by:
getKeysFromEdgein interfaceAccumuloElementConverter- Parameters:
edge- The edge to be converted- Returns:
- The key(s) that represent the given edge
-
getKeyFromEntity
public org.apache.accumulo.core.data.Key getKeyFromEntity(Entity entity)
Description copied from interface:AccumuloElementConverterConverts anEntityto aKey.- Specified by:
getKeyFromEntityin interfaceAccumuloElementConverter- Parameters:
entity- the entity to be converted- Returns:
- The key(s) that represent the given entity
-
getValueFromProperties
public org.apache.accumulo.core.data.Value getValueFromProperties(String group, Properties properties)
Description copied from interface:AccumuloElementConverterConverts a set ofPropertiesto an AccumuloValue.- Specified by:
getValueFromPropertiesin interfaceAccumuloElementConverter- Parameters:
group- the element groupproperties- the properties to use to create a Value- Returns:
- A new Accumulo
Valuecontaining the serialisedProperties
-
getValueFromElement
public org.apache.accumulo.core.data.Value getValueFromElement(Element element)
Description copied from interface:AccumuloElementConverterConverts thePropertiesin an element to an AccumuloValuewhere the property has a position within the store schema that indicates it should be stored in the value.- Specified by:
getValueFromElementin interfaceAccumuloElementConverter- Parameters:
element- the element to be converted- Returns:
- An Accumulo
Valuerepresenting thePropertiesthat should be stored in the value.
-
getPropertiesFromValue
public Properties getPropertiesFromValue(String group, org.apache.accumulo.core.data.Value value)
Description copied from interface:AccumuloElementConverterConverts an AccumuloValueto aPropertiesobject.- Specified by:
getPropertiesFromValuein interfaceAccumuloElementConverter- Parameters:
group- the element groupvalue- the Value containing the serialised properties- Returns:
- A set of
Propertiesthat represent the property stored within theValue
-
getElementFromKey
public Element getElementFromKey(org.apache.accumulo.core.data.Key key, boolean includeMatchedVertex)
Description copied from interface:AccumuloElementConverterGets a newElementfrom an AccumuloKey.- Specified by:
getElementFromKeyin interfaceAccumuloElementConverter- Parameters:
key- the Key containing serialised parts of the ElementincludeMatchedVertex- if true then the matchedVertex field is set on Edges- Returns:
- A new
Elementincluding a partial set ofPropertiesthat were store in theKey
-
getFullElement
public Element getFullElement(org.apache.accumulo.core.data.Key key, org.apache.accumulo.core.data.Value value, boolean includeMatchedVertex)
Description copied from interface:AccumuloElementConverter- Specified by:
getFullElementin interfaceAccumuloElementConverter- Parameters:
key- the accumulo Key containing serialised parts of the Elementvalue- the accumulo Value containing serialised properties of the ElementincludeMatchedVertex- if true then the matchedVertex field is set on Edges- Returns:
- Returns an
Elementpopulated with all the properties defined within theKeyandValue
-
getRowKeysFromElement
public Pair<byte[],byte[]> getRowKeysFromElement(Element element)
Description copied from interface:AccumuloElementConverterCreates a byte array representing the Element identifiers, this will be stored in the Accumulo row Key.- Specified by:
getRowKeysFromElementin interfaceAccumuloElementConverter- Parameters:
element- the element- Returns:
- the byte array(s) representing the provided
Elementidentifiers.
-
buildColumnFamily
public byte[] buildColumnFamily(String group)
Description copied from interface:AccumuloElementConverterCreates a byte array representing the group.- Specified by:
buildColumnFamilyin interfaceAccumuloElementConverter- Parameters:
group- the element group- Returns:
- A byte array representing the group
-
getGroupFromColumnFamily
public String getGroupFromColumnFamily(byte[] columnFamily)
Description copied from interface:AccumuloElementConverterReturns the element class from the given bytes.- Specified by:
getGroupFromColumnFamilyin interfaceAccumuloElementConverter- Parameters:
columnFamily- the column family bytes- Returns:
- The element class
-
buildColumnVisibility
public byte[] buildColumnVisibility(String group, Properties properties)
Description copied from interface:AccumuloElementConverterCreates a byte array representing a set ofPropertiesthat are to be stored in the column visibility.- Specified by:
buildColumnVisibilityin interfaceAccumuloElementConverter- Parameters:
group- the element groupproperties- the element properties- Returns:
- A byte array representing the provided
Propertiesthat are marked as to be stored in the provided position in the schema.
-
getPropertiesFromColumnVisibility
public Properties getPropertiesFromColumnVisibility(String group, byte[] columnVisibility)
Description copied from interface:AccumuloElementConverterReturns a set ofPropertiesthat are stored in the part of the key that is provided.- Specified by:
getPropertiesFromColumnVisibilityin interfaceAccumuloElementConverter- Parameters:
group- the element groupcolumnVisibility- the element visibility property serialised into bytes- Returns:
- The Properties stored within the part of the
Keyspecified e.g Column Qualifier
-
buildColumnQualifier
public byte[] buildColumnQualifier(String group, Properties properties)
Description copied from interface:AccumuloElementConverterCreates a byte array representing a set ofPropertiesthat are to be stored in the column qualifier.- Specified by:
buildColumnQualifierin interfaceAccumuloElementConverter- Parameters:
group- the element groupproperties- the element properties- Returns:
- A byte array representing the provided
Propertiesthat are marked as to be stored in the provided position in theuk.gov.gchq.gaffer.accumulostoreschema.
-
getPropertiesFromColumnQualifier
public Properties getPropertiesFromColumnQualifier(String group, byte[] bytes)
Description copied from interface:AccumuloElementConverterReturns a set ofPropertiesthat are stored in the part of the key that is provided.- Specified by:
getPropertiesFromColumnQualifierin interfaceAccumuloElementConverter- Parameters:
group- the element groupbytes- the element column qualifier properties serialised into bytes- Returns:
- The Properties stored within the part of the
Keyspecified e.g Column Qualifier
-
getPropertiesAsBytesFromColumnQualifier
public BytesAndRange getPropertiesAsBytesFromColumnQualifier(String group, byte[] bytes, int numProps)
Description copied from interface:AccumuloElementConverterTruncates the provided columnQualifier, returning the byte representation of the serialised version of the specified properties.- Specified by:
getPropertiesAsBytesFromColumnQualifierin interfaceAccumuloElementConverter- Parameters:
group- the element groupbytes- the full list of property bytesnumProps- the number of properties to extract- Returns:
- details of the bytes range.
-
buildTimestamp
public long buildTimestamp(String group, Properties properties)
Description copied from interface:AccumuloElementConverterCreates a timestamp based on the providedPropertieswill return a default value if properties do not have a valid timestamp value- Specified by:
buildTimestampin interfaceAccumuloElementConverter- Parameters:
group- the element groupproperties- the element properties- Returns:
- the timestamp
-
getPropertiesFromTimestamp
public Properties getPropertiesFromTimestamp(String group, long timestamp)
Get the properties for a given group defined in the Schema as being stored in the Accumulo timestamp column.- Specified by:
getPropertiesFromTimestampin interfaceAccumuloElementConverter- Parameters:
group- TheElementtype to be queriedtimestamp- the element timestamp property- Returns:
- The Properties stored within the Timestamp part of the
Key
-
serialiseVertex
public byte[] serialiseVertex(Object vertex)
Description copied from interface:AccumuloElementConverterHelper Used to create Bloom Filters, method Serialises a given object (from anEntityId) with the Identifier Serialiser defined in the schema.- Specified by:
serialiseVertexin interfaceAccumuloElementConverter- Parameters:
vertex- the vertex identifier to serialise- Returns:
- A byte array representing the given object
-
-