congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
ToBytesSerialiser.serialise
Code IndexAdd Tabnine to your IDE (free)

How to use
serialise
method
in
uk.gov.gchq.gaffer.serialisation.ToBytesSerialiser

Best Java code snippets using uk.gov.gchq.gaffer.serialisation.ToBytesSerialiser.serialise (Showing top 18 results out of 315)

origin: gchq/Gaffer

public static <T> byte[] getValueBytes(final ToBytesSerialiser<T> serialiser, final T value) throws SerialisationException {
  final byte[] valueBytes;
  if (null == serialiser) {
    valueBytes = EMPTY_BYTES;
  } else if (null == value) {
    valueBytes = serialiser.serialiseNull();
  } else {
    valueBytes = serialiser.serialise(value);
  }
  return valueBytes;
}
origin: gchq/Gaffer

public static ByteArrayOutputStream appendLengthValueFromObjectToByteStream(final ByteArrayOutputStream byteOut, final ToBytesSerialiser serialiser, final Object object) throws SerialisationException {
  return appendLengthValueFromBytesToByteStream(byteOut, serialiser.serialise(object));
}
origin: gchq/Gaffer

@Override
public byte[] serialise(final Object object) throws SerialisationException {
  try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
    byte key = supportedSerialisers.getKeyFromValue(object);
    byte[] bytes = nullCheck(supportedSerialisers.getSerialiserFromKey(key)).serialise(object);
    stream.write(key);
    stream.write(bytes);
    return stream.toByteArray();
  } catch (final SerialisationException e) {
    //re-throw SerialisationException
    throw e;
  } catch (final Exception e) {
    //wraps other exceptions.
    throw new SerialisationException(e.getMessage(), e);
  }
}
origin: uk.gov.gchq.gaffer/serialisation

public static <T> byte[] getValueBytes(final ToBytesSerialiser<T> serialiser, final T value) throws SerialisationException {
  final byte[] valueBytes;
  if (null == serialiser) {
    valueBytes = EMPTY_BYTES;
  } else if (null == value) {
    valueBytes = serialiser.serialiseNull();
  } else {
    valueBytes = serialiser.serialise(value);
  }
  return valueBytes;
}
origin: uk.gov.gchq.gaffer/serialisation

public static ByteArrayOutputStream appendLengthValueFromObjectToByteStream(final ByteArrayOutputStream byteOut, final ToBytesSerialiser serialiser, final Object object) throws SerialisationException {
  return appendLengthValueFromBytesToByteStream(byteOut, serialiser.serialise(object));
}
origin: uk.gov.gchq.gaffer/accumulo-store

protected void serialiseSizeAndPropertyValue(final String propertyName, final SchemaElementDefinition elementDefinition, final Properties properties, final ByteArrayOutputStream stream) {
  try {
    final TypeDefinition typeDefinition = elementDefinition.getPropertyTypeDef(propertyName);
    final ToBytesSerialiser serialiser = (null == typeDefinition) ? null : (ToBytesSerialiser) typeDefinition.getSerialiser();
    byte[] bytes;
    if (null == serialiser) {
      bytes = AccumuloStoreConstants.EMPTY_BYTES;
    } else {
      Object value = properties.get(propertyName);
      //serialiseNull could be different to AccumuloStoreConstants.EMPTY_BYTES
      bytes = (null == value) ? serialiser.serialiseNull() : serialiser.serialise(value);
    }
    writeBytes(bytes, stream);
  } catch (final IOException e) {
    throw new AccumuloElementConversionException("Failed to write serialised property to ByteArrayOutputStream" + propertyName, e);
  }
}
origin: uk.gov.gchq.gaffer/spark-library

@Override
public void write(final Kryo kryo, final Output output, final T obj) {
  final byte[] serialised;
  try {
    serialised = serialiser.serialise(obj);
  } catch (final SerialisationException e) {
    throw new GafferRuntimeException("Exception serialising "
        + obj.getClass().getSimpleName()
        + " to a byte array", e);
  }
  output.writeInt(serialised.length);
  output.writeBytes(serialised);
}
origin: uk.gov.gchq.gaffer/accumulo-store

@Override
public byte[] buildColumnVisibility(final String group, final Properties properties) {
  byte[] rtn = AccumuloStoreConstants.EMPTY_BYTES;
  final SchemaElementDefinition elementDefinition = getSchemaElementDefinition(group);
  if (null != schema.getVisibilityProperty()) {
    final TypeDefinition propertyDef = elementDefinition.getPropertyTypeDef(schema.getVisibilityProperty());
    if (null != propertyDef) {
      final Object property = properties.get(schema.getVisibilityProperty());
      final ToBytesSerialiser serialiser = (ToBytesSerialiser) propertyDef.getSerialiser();
      if (null != property) {
        try {
          rtn = serialiser.serialise(property);
        } catch (final SerialisationException e) {
          throw new AccumuloElementConversionException(e.getMessage(), e);
        }
      } else {
        rtn = serialiser.serialiseNull();
      }
    }
  }
  return rtn;
}
origin: uk.gov.gchq.gaffer/serialisation

@Override
public byte[] serialise(final Object object) throws SerialisationException {
  try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
    byte key = supportedSerialisers.getKeyFromValue(object);
    byte[] bytes = nullCheck(supportedSerialisers.getSerialiserFromKey(key)).serialise(object);
    stream.write(key);
    stream.write(bytes);
    return stream.toByteArray();
  } catch (final SerialisationException e) {
    //re-throw SerialisationException
    throw e;
  } catch (final Exception e) {
    //wraps other exceptions.
    throw new SerialisationException(e.getMessage(), e);
  }
}
origin: uk.gov.gchq.gaffer/accumulo-store

@Override
public byte[] serialiseVertex(final Object vertex) {
  try {
    return ByteArrayEscapeUtils.escape(((ToBytesSerialiser) schema.getVertexSerialiser()).serialise(vertex));
  } catch (final SerialisationException e) {
    throw new AccumuloElementConversionException(
        "Failed to serialise given identifier object for use in the bloom filter", e);
  }
}
origin: uk.gov.gchq.gaffer/accumulo-store

protected byte[] getSerialisedDestination(final Edge edge) {
  try {
    return ByteArrayEscapeUtils.escape(((ToBytesSerialiser) schema.getVertexSerialiser()).serialise(edge.getDestination()));
  } catch (final SerialisationException e) {
    throw new AccumuloElementConversionException("Failed to serialise Edge Destination", e);
  }
}
origin: uk.gov.gchq.gaffer/accumulo-store

protected byte[] getSerialisedSource(final Edge edge) {
  try {
    return ByteArrayEscapeUtils.escape(((ToBytesSerialiser) schema.getVertexSerialiser()).serialise(edge.getSource()));
  } catch (final SerialisationException e) {
    throw new AccumuloElementConversionException("Failed to serialise Edge Source", e);
  }
}
origin: uk.gov.gchq.gaffer/accumulo-store

@Override
protected byte[] getRowKeyFromEntity(final Entity entity) {
  try {
    return ByteArrayEscapeUtils.escape(((ToBytesSerialiser) schema.getVertexSerialiser()).serialise(entity.getVertex()),
        ByteArrayEscapeUtils.DELIMITER,
        ByteEntityPositions.ENTITY);
  } catch (final SerialisationException e) {
    throw new AccumuloElementConversionException("Failed to serialise Entity Identifier", e);
  }
}
origin: uk.gov.gchq.gaffer/accumulo-store

@Override
protected byte[] getRowKeyFromEntity(final Entity entity) {
  // No Delimiters but need to escape bytes
  // because later we check how many delimiter characters there are
  try {
    return ByteArrayEscapeUtils.escape(((ToBytesSerialiser) schema.getVertexSerialiser()).serialise(entity.getVertex()));
  } catch (final SerialisationException e) {
    throw new AccumuloElementConversionException("Failed to serialise Entity Identifier", e);
  }
}
origin: uk.gov.gchq.gaffer/accumulo-store

protected Key getKeyFromEdgeId(final Object source, final Object destination, final boolean directed,
                final boolean endKey) throws RangeFactoryException {
  final ToBytesSerialiser vertexSerialiser = (ToBytesSerialiser) schema.getVertexSerialiser();
  final byte directionFlag = directed ? ByteEntityPositions.CORRECT_WAY_DIRECTED_EDGE
      : ByteEntityPositions.UNDIRECTED_EDGE;
  byte[] sourceValue;
  try {
    sourceValue = ByteArrayEscapeUtils.escape(vertexSerialiser.serialise(source));
  } catch (final SerialisationException e) {
    throw new RangeFactoryException("Failed to serialise Edge Source", e);
  }
  byte[] destinationValue;
  try {
    destinationValue = ByteArrayEscapeUtils.escape(vertexSerialiser.serialise(destination));
  } catch (final SerialisationException e) {
    throw new RangeFactoryException("Failed to serialise Edge Destination", e);
  }
  byte[] key = getKey(endKey, directionFlag, sourceValue, destinationValue);
  return new Key(key, AccumuloStoreConstants.EMPTY_BYTES, AccumuloStoreConstants.EMPTY_BYTES, AccumuloStoreConstants.EMPTY_BYTES, Long.MAX_VALUE);
}
origin: uk.gov.gchq.gaffer/accumulo-store

  serialisedVertex = ByteArrayEscapeUtils.escape(((ToBytesSerialiser) schema.getVertexSerialiser()).serialise(vertex));
} catch (final SerialisationException e) {
  throw new RangeFactoryException("Failed to serialise identifier", e);
origin: uk.gov.gchq.gaffer/accumulo-store

  source = ByteArrayEscapeUtils.escape(vertexSerialiser.serialise(sourceVal));
} catch (final SerialisationException e) {
  throw new RangeFactoryException("Failed to serialise Edge Source", e);
  destination = ByteArrayEscapeUtils.escape(vertexSerialiser.serialise(destVal));
} catch (final SerialisationException e) {
  throw new RangeFactoryException("Failed to serialise Edge Destination", e);
origin: uk.gov.gchq.gaffer/accumulo-store

  serialisedVertex = ByteArrayEscapeUtils.escape(((ToBytesSerialiser) schema.getVertexSerialiser()).serialise(vertex));
} catch (final SerialisationException e) {
  throw new RangeFactoryException("Failed to serialise identifier", e);
uk.gov.gchq.gaffer.serialisationToBytesSerialiserserialise

Javadoc

Handle an incoming null value and generate an appropriate byte array representation.

Popular methods of ToBytesSerialiser

  • deserialise
  • deserialiseEmpty
    Handle an empty byte array and reconstruct an appropriate representation in T form.
  • serialiseNull
    Handle an incoming null value and generate an appropriate byte array representation.
  • canHandle
  • isConsistent
  • preservesObjectOrdering
    Indicates whether the serialisation process preserves the ordering of the T, i.e. if x and y are obj

Popular in Java

  • Start an intent from android
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getApplicationContext (Context)
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Top 17 Free Sublime Text Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now