Codota Logo
ToBytesSerialiser.deserialise
Code IndexAdd Codota to your IDE (free)

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

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

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
ScheduledThreadPoolExecutor s =
  • Codota Iconnew ScheduledThreadPoolExecutor(corePoolSize)
  • Codota IconThreadFactory threadFactory;new ScheduledThreadPoolExecutor(corePoolSize, threadFactory)
  • Codota IconString str;new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder().setNameFormat(str).build())
  • Smart code suggestions by Codota
}
origin: gchq/Gaffer

private static <T> T getValue(final ToBytesSerialiser<T> serialiser, final byte[] valueBytes) throws SerialisationException {
  if (0 == valueBytes.length) {
    return serialiser.deserialiseEmpty();
  }
  return serialiser.deserialise(valueBytes);
}
origin: gchq/Gaffer

/**
 * @param allBytes The bytes to be decoded into characters
 * @param offset   The index of the first byte to decode
 * @param length   The number of bytes to decode
 * @return T the deserialised object
 * @throws SerialisationException issues during deserialisation
 */
default T deserialise(final byte[] allBytes, final int offset, final int length) throws SerialisationException {
  final byte[] selection = new byte[length];
  try {
    System.arraycopy(allBytes, offset, selection, 0, length);
  } catch (final NullPointerException e) {
    throw new SerialisationException(String.format("Deserialising with giving range caused ArrayIndexOutOfBoundsException. byte[].size:%d startPos:%d length:%d", allBytes.length, 0, length), e);
  }
  return deserialise(selection);
}
origin: gchq/Gaffer

public static <T> ObjectCarriage<T> deserialiseNextObject(final ToBytesSerialiser<T> serialiser, final int currentCarriage, final byte[] bytes) throws SerialisationException {
  int rtn = currentCarriage;
  int numBytesForLength = CompactRawSerialisationUtils.decodeVIntSize(bytes[rtn]);
  int currentPropLength = getCurrentPropLength(bytes, rtn, numBytesForLength);
  int from = rtn += numBytesForLength;
  int to = rtn += currentPropLength;
  T object = serialiser.deserialise(Arrays.copyOfRange(bytes, from, to));
  return new ObjectCarriage<T>(object, rtn);
}
origin: uk.gov.gchq.gaffer/accumulo-store

private Object getDeserialisedObject(final ToBytesSerialiser serialiser, final byte[] bytes, final int from, final int length) throws SerialisationException {
  //Don't initialise with  #deserialiseEmpty() as this might initialise an complex empty structure to be immediately overwritten e.g. TreeSet<String>
  Object deserialisedObject;
  if (length > 0) {
    deserialisedObject = serialiser.deserialise(bytes, from, length);
  } else {
    deserialisedObject = serialiser.deserialiseEmpty();
  }
  return deserialisedObject;
}
origin: gchq/Gaffer

@Override
public Object deserialise(final byte[] bytes) throws SerialisationException {
  try {
    byte keyByte = bytes[0];
    ToBytesSerialiser serialiser = nullCheck(supportedSerialisers.getSerialiserFromKey(keyByte));
    return serialiser.deserialise(bytes, 1, bytes.length - 1);
  } 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

private static <T> T getValue(final ToBytesSerialiser<T> serialiser, final byte[] valueBytes) throws SerialisationException {
  if (0 == valueBytes.length) {
    return serialiser.deserialiseEmpty();
  }
  return serialiser.deserialise(valueBytes);
}
origin: gchq/Gaffer

private void test(final long value) throws SerialisationException {
  final byte[] b = serialiser.serialise(value);
  final Object o = ((ToBytesSerialiser) serialiser).deserialise(b, 0, b.length);
  assertEquals(Long.class, o.getClass());
  assertEquals(value, o);
  final ByteArrayOutputStream stream = new ByteArrayOutputStream();
  CompactRawSerialisationUtils.write(value, new DataOutputStream(stream));
  final long result = CompactRawSerialisationUtils.read(new DataInputStream(new ByteArrayInputStream(stream.toByteArray())));
  assertEquals(result, value);
}
origin: uk.gov.gchq.gaffer/accumulo-store

@Override
public Properties getPropertiesFromColumnVisibility(final String group, final byte[] columnVisibility) {
  final Properties properties = new Properties();
  final SchemaElementDefinition elementDefinition = getSchemaElementDefinition(group);
  if (null != schema.getVisibilityProperty()) {
    final TypeDefinition propertyDef = elementDefinition.getPropertyTypeDef(schema.getVisibilityProperty());
    if (null != propertyDef) {
      final ToBytesSerialiser serialiser = (ToBytesSerialiser) propertyDef.getSerialiser();
      try {
        if (null == columnVisibility || columnVisibility.length == 0) {
          final Object value = serialiser.deserialiseEmpty();
          if (null != value) {
            properties.put(schema.getVisibilityProperty(), value);
          }
        } else {
          properties.put(schema.getVisibilityProperty(), serialiser.deserialise(columnVisibility));
        }
      } catch (final SerialisationException e) {
        throw new AccumuloElementConversionException(e.getMessage(), e);
      }
    }
  }
  return properties;
}
origin: uk.gov.gchq.gaffer/serialisation

/**
 * @param allBytes The bytes to be decoded into characters
 * @param offset   The index of the first byte to decode
 * @param length   The number of bytes to decode
 * @return T the deserialised object
 * @throws SerialisationException issues during deserialisation
 */
default T deserialise(final byte[] allBytes, final int offset, final int length) throws SerialisationException {
  final byte[] selection = new byte[length];
  try {
    System.arraycopy(allBytes, offset, selection, 0, length);
  } catch (final NullPointerException e) {
    throw new SerialisationException(String.format("Deserialising with giving range caused ArrayIndexOutOfBoundsException. byte[].size:%d startPos:%d length:%d", allBytes.length, 0, length), e);
  }
  return deserialise(selection);
}
origin: uk.gov.gchq.gaffer/serialisation

public static <T> ObjectCarriage<T> deserialiseNextObject(final ToBytesSerialiser<T> serialiser, final int currentCarriage, final byte[] bytes) throws SerialisationException {
  int rtn = currentCarriage;
  int numBytesForLength = CompactRawSerialisationUtils.decodeVIntSize(bytes[rtn]);
  int currentPropLength = getCurrentPropLength(bytes, rtn, numBytesForLength);
  int from = rtn += numBytesForLength;
  int to = rtn += currentPropLength;
  T object = serialiser.deserialise(Arrays.copyOfRange(bytes, from, to));
  return new ObjectCarriage<T>(object, rtn);
}
origin: uk.gov.gchq.gaffer/spark-library

  @Override
  public T read(final Kryo kryo, final Input input, final Class<T> type) {
    final int serialisedLength = input.readInt();
    final byte[] serialised = input.readBytes(serialisedLength);
    try {
      return serialiser.deserialise(serialised);
    } catch (final SerialisationException e) {
      throw new GafferRuntimeException("Exception deserialising "
          + type.getSimpleName()
          + " to a byte array", e);
    }
  }
}
origin: uk.gov.gchq.gaffer/serialisation

@Override
public Object deserialise(final byte[] bytes) throws SerialisationException {
  try {
    byte keyByte = bytes[0];
    ToBytesSerialiser serialiser = nullCheck(supportedSerialisers.getSerialiserFromKey(keyByte));
    return serialiser.deserialise(bytes, 1, bytes.length - 1);
  } 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

@SuppressWarnings("unchecked")
@Override
protected EntityId getEntityId(final byte[] row) {
  try {
    return new EntitySeed(((ToBytesSerialiser) schema.getVertexSerialiser())
        .deserialise(ByteArrayEscapeUtils.unEscape(Arrays.copyOfRange(row, 0,
            row.length - 2))));
  } catch (final SerialisationException e) {
    throw new AccumuloElementConversionException("Failed to create EntityId from Accumulo row key", e);
  }
}
origin: uk.gov.gchq.gaffer/accumulo-store

protected EdgeId getEdgeId(final byte[] row, final boolean includeMatchedVertex) {
  final byte[][] result = new byte[2][];
  final EdgeDirection direction = getSourceAndDestinationFromRowKey(row, result);
  final EdgeId.MatchedVertex matchedVertex;
  if (!includeMatchedVertex) {
    matchedVertex = null;
  } else if (EdgeDirection.DIRECTED_REVERSED == direction) {
    matchedVertex = EdgeId.MatchedVertex.DESTINATION;
  } else {
    matchedVertex = EdgeId.MatchedVertex.SOURCE;
  }
  try {
    return new EdgeSeed(((ToBytesSerialiser) schema.getVertexSerialiser()).deserialise(result[0]),
        ((ToBytesSerialiser) schema.getVertexSerialiser()).deserialise(result[1]), direction.isDirected(), matchedVertex);
  } catch (final SerialisationException e) {
    throw new AccumuloElementConversionException("Failed to create EdgeId from Accumulo row key", e);
  }
}
origin: uk.gov.gchq.gaffer/accumulo-store

@Override
protected EntityId getEntityId(final byte[] row) {
  try {
    return new EntitySeed(((ToBytesSerialiser) schema.getVertexSerialiser())
        .deserialise(ByteArrayEscapeUtils.unEscape(row)));
  } catch (final SerialisationException e) {
    throw new AccumuloElementConversionException("Failed to create EntityId from Accumulo row key", e);
  }
}
origin: uk.gov.gchq.gaffer/accumulo-store

@Override
protected Entity getEntityFromKey(final Key key, final byte[] row) {
  try {
    final Entity entity = new Entity(getGroupFromKey(key), ((ToBytesSerialiser) schema.getVertexSerialiser())
        .deserialise(ByteArrayEscapeUtils.unEscape(row)));
    addPropertiesToElement(entity, key);
    return entity;
  } catch (final SerialisationException e) {
    throw new AccumuloElementConversionException("Failed to re-create Entity from key", e);
  }
}
origin: uk.gov.gchq.gaffer/accumulo-store

@Override
protected Entity getEntityFromKey(final Key key, final byte[] row) {
  try {
    final Entity entity = new Entity(getGroupFromKey(key), ((ToBytesSerialiser) schema.getVertexSerialiser())
        .deserialise(ByteArrayEscapeUtils.unEscape(row, 0, row.length - 2)));
    addPropertiesToElement(entity, key);
    return entity;
  } catch (final SerialisationException e) {
    throw new AccumuloElementConversionException("Failed to re-create Entity from key", e);
  }
}
origin: uk.gov.gchq.gaffer/accumulo-store

@SuppressWarnings("WeakerAccess")
protected Edge getEdgeFromKey(final Key key, final byte[] row, final boolean includeMatchedVertex) {
  final byte[][] result = new byte[2][];
  final EdgeDirection direction = getSourceAndDestinationFromRowKey(row, result);
  final EdgeId.MatchedVertex matchedVertex;
  if (!includeMatchedVertex) {
    matchedVertex = null;
  } else if (EdgeDirection.DIRECTED_REVERSED == direction) {
    matchedVertex = EdgeId.MatchedVertex.DESTINATION;
  } else {
    matchedVertex = EdgeId.MatchedVertex.SOURCE;
  }
  final String group = getGroupFromColumnFamily(key.getColumnFamilyData().getBackingArray());
  try {
    final Edge edge = new Edge(group, ((ToBytesSerialiser) schema.getVertexSerialiser()).deserialise(result[0]),
        ((ToBytesSerialiser) schema.getVertexSerialiser()).deserialise(result[1]), direction.isDirected(), matchedVertex, null);
    addPropertiesToElement(edge, key);
    return edge;
  } catch (final SerialisationException e) {
    throw new AccumuloElementConversionException("Failed to re-create Edge from key", e);
  }
}
uk.gov.gchq.gaffer.serialisationToBytesSerialiserdeserialise

Popular methods of ToBytesSerialiser

  • serialise
  • 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

  • Updating database using SQL prepared statement
  • setRequestProperty (URLConnection)
  • getSystemService (Context)
  • findViewById (Activity)
  • BitSet (java.util)
    This class implements a vector of bits that grows as needed. Each component of the bit set has a boo
  • Set (java.util)
    A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1
  • Stack (java.util)
    The Stack class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with
  • StringTokenizer (java.util)
    The string tokenizer class allows an application to break a string into tokens. The tokenization met
  • Vector (java.util)
    The Vector class implements a growable array of objects. Like an array, it contains components that
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now