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 ofProperties
that are to be stored in the column qualifier.byte[]
buildColumnVisibility(String group, Properties properties)
Creates a byte array representing a set ofProperties
that are to be stored in the column visibility.long
buildTimestamp(String group, Properties properties)
Creates a timestamp based on the providedProperties
will return a default value if properties do not have a valid timestamp valueElement
getElementFromKey(org.apache.accumulo.core.data.Key key, boolean includeMatchedVertex)
Gets a newElement
from an AccumuloKey
.ElementId
getElementId(org.apache.accumulo.core.data.Key key, boolean includeMatchedVertex)
Gets a newElementId
from an AccumuloKey
.Element
getFullElement(org.apache.accumulo.core.data.Key key, org.apache.accumulo.core.data.Value value, boolean includeMatchedVertex)
String
getGroupFromColumnFamily(byte[] columnFamily)
Returns the element class from the given bytes.org.apache.accumulo.core.data.Key
getKeyFromEntity(Entity entity)
Converts anEntity
to aKey
.Pair<org.apache.accumulo.core.data.Key,org.apache.accumulo.core.data.Key>
getKeysFromEdge(Edge edge)
Converts anEdge
to a pair ofKey
s.Pair<org.apache.accumulo.core.data.Key,org.apache.accumulo.core.data.Key>
getKeysFromElement(Element element)
BytesAndRange
getPropertiesAsBytesFromColumnQualifier(String group, byte[] bytes, int numProps)
Truncates the provided columnQualifier, returning the byte representation of the serialised version of the specified properties.Properties
getPropertiesFromColumnQualifier(String group, byte[] bytes)
Returns a set ofProperties
that are stored in the part of the key that is provided.Properties
getPropertiesFromColumnVisibility(String group, byte[] columnVisibility)
Returns a set ofProperties
that are stored in the part of the key that is provided.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.Properties
getPropertiesFromValue(String group, org.apache.accumulo.core.data.Value value)
Converts an AccumuloValue
to aProperties
object.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.Value
getValueFromElement(Element element)
Converts theProperties
in an element to an AccumuloValue
where the property has a position within the store schema that indicates it should be stored in the value.org.apache.accumulo.core.data.Value
getValueFromProperties(String group, Properties properties)
Converts a set ofProperties
to 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:AccumuloElementConverter
Gets a newElementId
from an AccumuloKey
.- Specified by:
getElementId
in 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:AccumuloElementConverter
Converts anElement
Pair
of 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:
getKeysFromElement
in 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:AccumuloElementConverter
Converts anEdge
to a pair ofKey
s.- Specified by:
getKeysFromEdge
in 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:AccumuloElementConverter
Converts anEntity
to aKey
.- Specified by:
getKeyFromEntity
in 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:AccumuloElementConverter
Converts a set ofProperties
to an AccumuloValue
.- Specified by:
getValueFromProperties
in interfaceAccumuloElementConverter
- Parameters:
group
- the element groupproperties
- the properties to use to create a Value- Returns:
- A new Accumulo
Value
containing the serialisedProperties
-
getValueFromElement
public org.apache.accumulo.core.data.Value getValueFromElement(Element element)
Description copied from interface:AccumuloElementConverter
Converts theProperties
in an element to an AccumuloValue
where the property has a position within the store schema that indicates it should be stored in the value.- Specified by:
getValueFromElement
in interfaceAccumuloElementConverter
- Parameters:
element
- the element to be converted- Returns:
- An Accumulo
Value
representing theProperties
that should be stored in the value.
-
getPropertiesFromValue
public Properties getPropertiesFromValue(String group, org.apache.accumulo.core.data.Value value)
Description copied from interface:AccumuloElementConverter
Converts an AccumuloValue
to aProperties
object.- Specified by:
getPropertiesFromValue
in interfaceAccumuloElementConverter
- Parameters:
group
- the element groupvalue
- the Value containing the serialised properties- Returns:
- A set of
Properties
that represent the property stored within theValue
-
getElementFromKey
public Element getElementFromKey(org.apache.accumulo.core.data.Key key, boolean includeMatchedVertex)
Description copied from interface:AccumuloElementConverter
Gets a newElement
from an AccumuloKey
.- Specified by:
getElementFromKey
in interfaceAccumuloElementConverter
- Parameters:
key
- the Key containing serialised parts of the ElementincludeMatchedVertex
- if true then the matchedVertex field is set on Edges- Returns:
- A new
Element
including a partial set ofProperties
that 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:
getFullElement
in 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
Element
populated with all the properties defined within theKey
andValue
-
getRowKeysFromElement
public Pair<byte[],byte[]> getRowKeysFromElement(Element element)
Description copied from interface:AccumuloElementConverter
Creates a byte array representing the Element identifiers, this will be stored in the Accumulo row Key.- Specified by:
getRowKeysFromElement
in interfaceAccumuloElementConverter
- Parameters:
element
- the element- Returns:
- the byte array(s) representing the provided
Element
identifiers.
-
buildColumnFamily
public byte[] buildColumnFamily(String group)
Description copied from interface:AccumuloElementConverter
Creates a byte array representing the group.- Specified by:
buildColumnFamily
in interfaceAccumuloElementConverter
- Parameters:
group
- the element group- Returns:
- A byte array representing the group
-
getGroupFromColumnFamily
public String getGroupFromColumnFamily(byte[] columnFamily)
Description copied from interface:AccumuloElementConverter
Returns the element class from the given bytes.- Specified by:
getGroupFromColumnFamily
in interfaceAccumuloElementConverter
- Parameters:
columnFamily
- the column family bytes- Returns:
- The element class
-
buildColumnVisibility
public byte[] buildColumnVisibility(String group, Properties properties)
Description copied from interface:AccumuloElementConverter
Creates a byte array representing a set ofProperties
that are to be stored in the column visibility.- Specified by:
buildColumnVisibility
in interfaceAccumuloElementConverter
- Parameters:
group
- the element groupproperties
- the element properties- Returns:
- A byte array representing the provided
Properties
that 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:AccumuloElementConverter
Returns a set ofProperties
that are stored in the part of the key that is provided.- Specified by:
getPropertiesFromColumnVisibility
in interfaceAccumuloElementConverter
- Parameters:
group
- the element groupcolumnVisibility
- the element visibility property serialised into bytes- Returns:
- The Properties stored within the part of the
Key
specified e.g Column Qualifier
-
buildColumnQualifier
public byte[] buildColumnQualifier(String group, Properties properties)
Description copied from interface:AccumuloElementConverter
Creates a byte array representing a set ofProperties
that are to be stored in the column qualifier.- Specified by:
buildColumnQualifier
in interfaceAccumuloElementConverter
- Parameters:
group
- the element groupproperties
- the element properties- Returns:
- A byte array representing the provided
Properties
that are marked as to be stored in the provided position in theuk.gov.gchq.gaffer.accumulostore
schema.
-
getPropertiesFromColumnQualifier
public Properties getPropertiesFromColumnQualifier(String group, byte[] bytes)
Description copied from interface:AccumuloElementConverter
Returns a set ofProperties
that are stored in the part of the key that is provided.- Specified by:
getPropertiesFromColumnQualifier
in interfaceAccumuloElementConverter
- Parameters:
group
- the element groupbytes
- the element column qualifier properties serialised into bytes- Returns:
- The Properties stored within the part of the
Key
specified e.g Column Qualifier
-
getPropertiesAsBytesFromColumnQualifier
public BytesAndRange getPropertiesAsBytesFromColumnQualifier(String group, byte[] bytes, int numProps)
Description copied from interface:AccumuloElementConverter
Truncates the provided columnQualifier, returning the byte representation of the serialised version of the specified properties.- Specified by:
getPropertiesAsBytesFromColumnQualifier
in 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:AccumuloElementConverter
Creates a timestamp based on the providedProperties
will return a default value if properties do not have a valid timestamp value- Specified by:
buildTimestamp
in 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:
getPropertiesFromTimestamp
in interfaceAccumuloElementConverter
- Parameters:
group
- TheElement
type 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:AccumuloElementConverter
Helper Used to create Bloom Filters, method Serialises a given object (from anEntityId
) with the Identifier Serialiser defined in the schema.- Specified by:
serialiseVertex
in interfaceAccumuloElementConverter
- Parameters:
vertex
- the vertex identifier to serialise- Returns:
- A byte array representing the given object
-
-