use of uk.gov.gchq.gaffer.serialisation.implementation.raw.RawFloatSerialiser in project Gaffer by gchq.
the class CustomMapSerialiserTest method getHistoricSerialisationPairs.
@Override
public Pair<CustomMap, byte[]>[] getHistoricSerialisationPairs() {
final CustomMap<String, Integer> cm1 = new CustomMap(new StringSerialiser(), new IntegerSerialiser());
cm1.put("One", 1);
final CustomMap<Float, String> cm2 = new CustomMap<>(new RawFloatSerialiser(), new StringSerialiser());
cm2.put(3.1f, "three point 1");
return new Pair[] { new Pair(cm1, new byte[] { -84, -19, 0, 5, 115, 114, 0, 69, 117, 107, 46, 103, 111, 118, 46, 103, 99, 104, 113, 46, 103, 97, 102, 102, 101, 114, 46, 115, 101, 114, 105, 97, 108, 105, 115, 97, 116, 105, 111, 110, 46, 67, 117, 115, 116, 111, 109, 77, 97, 112, 83, 101, 114, 105, 97, 108, 105, 115, 101, 114, 36, 67, 117, 115, 116, 111, 109, 77, 97, 112, 73, 110, 116, 101, 114, 105, 109, 112, 50, 94, -101, 109, -71, 126, 20, 2, 0, 3, 91, 0, 7, 98, 121, 116, 101, 77, 97, 112, 116, 0, 2, 91, 66, 76, 0, 13, 107, 101, 121, 83, 101, 114, 105, 97, 108, 105, 115, 101, 114, 116, 0, 52, 76, 117, 107, 47, 103, 111, 118, 47, 103, 99, 104, 113, 47, 103, 97, 102, 102, 101, 114, 47, 115, 101, 114, 105, 97, 108, 105, 115, 97, 116, 105, 111, 110, 47, 84, 111, 66, 121, 116, 101, 115, 83, 101, 114, 105, 97, 108, 105, 115, 101, 114, 59, 76, 0, 15, 118, 97, 108, 117, 101, 83, 101, 114, 105, 97, 108, 105, 115, 101, 114, 113, 0, 126, 0, 2, 120, 112, 117, 114, 0, 2, 91, 66, -84, -13, 23, -8, 6, 8, 84, -32, 2, 0, 0, 120, 112, 0, 0, 0, 6, 3, 79, 110, 101, 1, 49, 115, 114, 0, 64, 117, 107, 46, 103, 111, 118, 46, 103, 99, 104, 113, 46, 103, 97, 102, 102, 101, 114, 46, 115, 101, 114, 105, 97, 108, 105, 115, 97, 116, 105, 111, 110, 46, 105, 109, 112, 108, 101, 109, 101, 110, 116, 97, 116, 105, 111, 110, 46, 83, 116, 114, 105, 110, 103, 83, 101, 114, 105, 97, 108, 105, 115, 101, 114, 78, 96, -36, -19, 29, -23, 32, -19, 2, 0, 0, 120, 114, 0, 61, 117, 107, 46, 103, 111, 118, 46, 103, 99, 104, 113, 46, 103, 97, 102, 102, 101, 114, 46, 115, 101, 114, 105, 97, 108, 105, 115, 97, 116, 105, 111, 110, 46, 84, 111, 66, 121, 116, 101, 115, 86, 105, 97, 83, 116, 114, 105, 110, 103, 68, 101, 115, 101, 114, 105, 97, 108, 105, 115, 101, 114, -88, 123, -44, -50, -55, 101, -92, 46, 2, 0, 1, 76, 0, 7, 99, 104, 97, 114, 115, 101, 116, 116, 0, 18, 76, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 83, 116, 114, 105, 110, 103, 59, 120, 112, 116, 0, 5, 85, 84, 70, 45, 56, 115, 114, 0, 50, 117, 107, 46, 103, 111, 118, 46, 103, 99, 104, 113, 46, 103, 97, 102, 102, 101, 114, 46, 115, 101, 114, 105, 97, 108, 105, 115, 97, 116, 105, 111, 110, 46, 73, 110, 116, 101, 103, 101, 114, 83, 101, 114, 105, 97, 108, 105, 115, 101, 114, 78, 96, -36, -19, 29, -23, 32, -19, 2, 0, 0, 120, 113, 0, 126, 0, 7, 116, 0, 10, 73, 83, 79, 45, 56, 56, 53, 57, 45, 49 }), new Pair(cm2, new byte[] { -84, -19, 0, 5, 115, 114, 0, 69, 117, 107, 46, 103, 111, 118, 46, 103, 99, 104, 113, 46, 103, 97, 102, 102, 101, 114, 46, 115, 101, 114, 105, 97, 108, 105, 115, 97, 116, 105, 111, 110, 46, 67, 117, 115, 116, 111, 109, 77, 97, 112, 83, 101, 114, 105, 97, 108, 105, 115, 101, 114, 36, 67, 117, 115, 116, 111, 109, 77, 97, 112, 73, 110, 116, 101, 114, 105, 109, 112, 50, 94, -101, 109, -71, 126, 20, 2, 0, 3, 91, 0, 7, 98, 121, 116, 101, 77, 97, 112, 116, 0, 2, 91, 66, 76, 0, 13, 107, 101, 121, 83, 101, 114, 105, 97, 108, 105, 115, 101, 114, 116, 0, 52, 76, 117, 107, 47, 103, 111, 118, 47, 103, 99, 104, 113, 47, 103, 97, 102, 102, 101, 114, 47, 115, 101, 114, 105, 97, 108, 105, 115, 97, 116, 105, 111, 110, 47, 84, 111, 66, 121, 116, 101, 115, 83, 101, 114, 105, 97, 108, 105, 115, 101, 114, 59, 76, 0, 15, 118, 97, 108, 117, 101, 83, 101, 114, 105, 97, 108, 105, 115, 101, 114, 113, 0, 126, 0, 2, 120, 112, 117, 114, 0, 2, 91, 66, -84, -13, 23, -8, 6, 8, 84, -32, 2, 0, 0, 120, 112, 0, 0, 0, 19, 4, 102, 102, 70, 64, 13, 116, 104, 114, 101, 101, 32, 112, 111, 105, 110, 116, 32, 49, 115, 114, 0, 70, 117, 107, 46, 103, 111, 118, 46, 103, 99, 104, 113, 46, 103, 97, 102, 102, 101, 114, 46, 115, 101, 114, 105, 97, 108, 105, 115, 97, 116, 105, 111, 110, 46, 105, 109, 112, 108, 101, 109, 101, 110, 116, 97, 116, 105, 111, 110, 46, 114, 97, 119, 46, 82, 97, 119, 70, 108, 111, 97, 116, 83, 101, 114, 105, 97, 108, 105, 115, 101, 114, -119, 5, 40, -76, -66, -52, 123, 37, 2, 0, 0, 120, 112, 115, 114, 0, 64, 117, 107, 46, 103, 111, 118, 46, 103, 99, 104, 113, 46, 103, 97, 102, 102, 101, 114, 46, 115, 101, 114, 105, 97, 108, 105, 115, 97, 116, 105, 111, 110, 46, 105, 109, 112, 108, 101, 109, 101, 110, 116, 97, 116, 105, 111, 110, 46, 83, 116, 114, 105, 110, 103, 83, 101, 114, 105, 97, 108, 105, 115, 101, 114, 78, 96, -36, -19, 29, -23, 32, -19, 2, 0, 0, 120, 114, 0, 61, 117, 107, 46, 103, 111, 118, 46, 103, 99, 104, 113, 46, 103, 97, 102, 102, 101, 114, 46, 115, 101, 114, 105, 97, 108, 105, 115, 97, 116, 105, 111, 110, 46, 84, 111, 66, 121, 116, 101, 115, 86, 105, 97, 83, 116, 114, 105, 110, 103, 68, 101, 115, 101, 114, 105, 97, 108, 105, 115, 101, 114, -88, 123, -44, -50, -55, 101, -92, 46, 2, 0, 1, 76, 0, 7, 99, 104, 97, 114, 115, 101, 116, 116, 0, 18, 76, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 83, 116, 114, 105, 110, 103, 59, 120, 112, 116, 0, 5, 85, 84, 70, 45, 56 }) };
}
use of uk.gov.gchq.gaffer.serialisation.implementation.raw.RawFloatSerialiser in project Gaffer by gchq.
the class SerialisationFactoryTest method shouldReturnCustomSerialiserIfCustomSerialiserFound.
@Test
public void shouldReturnCustomSerialiserIfCustomSerialiserFound() throws SerialisationException {
// Given
final Serialiser[] serialisers = new Serialiser[] { new RawDateSerialiser(), new RawDoubleSerialiser(), new RawFloatSerialiser() };
final SerialisationFactory factory = new SerialisationFactory(serialisers);
final Class<?> clazz = Double.class;
// When
final Serialiser serialiser = factory.getSerialiser(clazz);
// Then
assertTrue(serialiser.canHandle(clazz));
assertEquals(RawDoubleSerialiser.class, serialiser.getClass());
}
use of uk.gov.gchq.gaffer.serialisation.implementation.raw.RawFloatSerialiser in project Gaffer by gchq.
the class SerialisationFactoryTest method testAddSerialisers.
@Test
public void testAddSerialisers() throws SerialisationException {
// Given
final Serialiser[] serialisers = new Serialiser[] { new RawDateSerialiser(), new RawDoubleSerialiser(), new RawFloatSerialiser() };
final SerialisationFactory factory = new SerialisationFactory(serialisers);
final Class<?> clazz = String.class;
// When
factory.addSerialisers(new StringSerialiser());
Serialiser serialiser = factory.getSerialiser(clazz);
// Then
assertTrue(serialiser.canHandle(clazz));
assertEquals(StringSerialiser.class, serialiser.getClass());
}
use of uk.gov.gchq.gaffer.serialisation.implementation.raw.RawFloatSerialiser in project Gaffer by gchq.
the class SerialisationFactoryTest method shouldReturnJavaSerialiserIfNoCustomSerialiserFound.
@Test
public void shouldReturnJavaSerialiserIfNoCustomSerialiserFound() throws SerialisationException {
// Given
final Serialiser[] serialisers = new Serialiser[] { new RawDateSerialiser(), new RawDoubleSerialiser(), new RawFloatSerialiser() };
final SerialisationFactory factory = new SerialisationFactory(serialisers);
final Class<?> clazz = String.class;
// When
final Serialiser serialiser = factory.getSerialiser(clazz);
// Then
assertTrue(serialiser.canHandle(clazz));
assertEquals(JavaSerialiser.class, serialiser.getClass());
}
use of uk.gov.gchq.gaffer.serialisation.implementation.raw.RawFloatSerialiser in project Gaffer by gchq.
the class RBMBackedTimestampSetSerialiserTest method shouldJSONSerialiseFloatRDM.
@Test
public void shouldJSONSerialiseFloatRDM() throws IOException {
// given
System.setProperty(JSONSerialiser.JSON_SERIALISER_MODULES, BitmapJsonModules.class.getCanonicalName());
final RBMBackedTimestampSet timestampSet1 = new RBMBackedTimestampSet.Builder().timeBucket(TimeBucket.MINUTE).timestamps(Lists.newArrayList(Instant.ofEpochSecond(11))).build();
final RBMBackedTimestampSet timestampSet2 = new RBMBackedTimestampSet.Builder().timeBucket(TimeBucket.HOUR).timestamps(Lists.newArrayList(Instant.ofEpochSecond(222222))).build();
final CustomMap<Float, RBMBackedTimestampSet> expectedMap = new CustomMap<>(new RawFloatSerialiser(), new RBMBackedTimestampSetSerialiser());
expectedMap.put(123.3f, timestampSet1);
expectedMap.put(345.6f, timestampSet2);
final String expectedJson = jsonFromFile("custom-map04.json");
// when
final byte[] serialise = JSONSerialiser.serialise(expectedMap, true);
final CustomMap jsonMap = JSONSerialiser.deserialise(expectedJson, CustomMap.class);
final CustomMap deserialiseMap = JSONSerialiser.deserialise(serialise, CustomMap.class);
// then
assertEquals(jsonMap, deserialiseMap, "The expected map from Json doesn't match");
assertEquals(expectedMap, deserialiseMap, "The expected map doesn't match");
}
Aggregations