Search in sources :

Example 26 with CompactSerializationConfig

use of com.hazelcast.config.CompactSerializationConfig in project hazelcast by hazelcast.

the class ExtractionWithExtractorsSpecTest method doWithConfig.

@Override
public void doWithConfig(Config config) {
    MapConfig mapConfig = config.getMapConfig("map");
    AttributeConfig tattoosCount = new AttributeConfig();
    tattoosCount.setName("tattoosCount");
    tattoosCount.setExtractorClassName("com.hazelcast.internal.serialization.impl.compact.extractor.ExtractionWithExtractorsSpecTest$LimbTattoosCountExtractor");
    mapConfig.addAttributeConfig(tattoosCount);
    config.getSerializationConfig().setCompactSerializationConfig(new CompactSerializationConfig().setEnabled(true));
}
Also used : CompactSerializationConfig(com.hazelcast.config.CompactSerializationConfig) MapConfig(com.hazelcast.config.MapConfig) AttributeConfig(com.hazelcast.config.AttributeConfig)

Example 27 with CompactSerializationConfig

use of com.hazelcast.config.CompactSerializationConfig in project hazelcast by hazelcast.

the class ClientCompactTest method setup.

@Override
public void setup() {
    member1 = factory.newHazelcastInstance(getConfig());
    member2 = factory.newHazelcastInstance(getConfig());
    ClientConfig clientConfig = new ClientConfig();
    CompactSerializationConfig compactSerializationConfig = new CompactSerializationConfig();
    clientConfig.getSerializationConfig().setCompactSerializationConfig(compactSerializationConfig.setEnabled(true));
    instance1 = factory.newHazelcastClient(clientConfig);
    instance2 = factory.newHazelcastClient(clientConfig);
}
Also used : CompactSerializationConfig(com.hazelcast.config.CompactSerializationConfig) ClientConfig(com.hazelcast.client.config.ClientConfig)

Example 28 with CompactSerializationConfig

use of com.hazelcast.config.CompactSerializationConfig in project hazelcast by hazelcast.

the class CompactStreamSerializerTest method createSerializationService.

private InternalSerializationService createSerializationService() {
    CompactSerializationConfig compactSerializationConfig = new CompactSerializationConfig();
    compactSerializationConfig.setEnabled(true);
    return new DefaultSerializationServiceBuilder().setSchemaService(schemaService).setConfig(new SerializationConfig().setCompactSerializationConfig(compactSerializationConfig)).build();
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) CompactSerializationConfig(com.hazelcast.config.CompactSerializationConfig) SerializationConfig(com.hazelcast.config.SerializationConfig) CompactSerializationConfig(com.hazelcast.config.CompactSerializationConfig)

Example 29 with CompactSerializationConfig

use of com.hazelcast.config.CompactSerializationConfig in project hazelcast by hazelcast.

the class CompactWithSchemaStreamSerializerTest method createSerializationService.

private InternalSerializationService createSerializationService() {
    SchemaService schemaService = CompactTestUtil.createInMemorySchemaService();
    CompactSerializationConfig compactSerializationConfig = new CompactSerializationConfig();
    compactSerializationConfig.setEnabled(true);
    return new DefaultSerializationServiceBuilder().setSchemaService(schemaService).setConfig(new SerializationConfig().setCompactSerializationConfig(compactSerializationConfig)).build();
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) CompactSerializationConfig(com.hazelcast.config.CompactSerializationConfig) SerializationConfig(com.hazelcast.config.SerializationConfig) CompactSerializationConfig(com.hazelcast.config.CompactSerializationConfig)

Example 30 with CompactSerializationConfig

use of com.hazelcast.config.CompactSerializationConfig in project hazelcast by hazelcast.

the class CompactStreamSerializerValueReaderSpecTest method executeTestScenario.

@Test
@SuppressWarnings("unchecked")
public void executeTestScenario() throws Exception {
    // handle result
    Object resultToMatch = expectedResult;
    if (expectedResult instanceof Class) {
        // expected exception case
        expected.expect(isA((Class) expectedResult));
    } else if (expectedResult instanceof List) {
        // just convenience -> if result is a list if will be compared to an array, so it has to be converted
        resultToMatch = ((List) resultToMatch).toArray();
    }
    // print test scenario for debug purposes
    // it makes debugging easier since all scenarios are generated
    printlnScenarioDescription(resultToMatch);
    SchemaService schemaService = CompactTestUtil.createInMemorySchemaService();
    SerializationConfig serializationConfig = new SerializationConfig();
    serializationConfig.setCompactSerializationConfig(new CompactSerializationConfig().setEnabled(true));
    InternalSerializationService ss = new DefaultSerializationServiceBuilder().setConfig(serializationConfig).setSchemaService(schemaService).build();
    Data data = ss.toData(inputObject);
    GenericRecordQueryReader reader = new GenericRecordQueryReader(ss.readAsInternalGenericRecord(data));
    Object result = reader.read(pathToRead);
    if (result instanceof MultiResult) {
        MultiResult multiResult = (MultiResult) result;
        if (multiResult.getResults().size() == 1 && multiResult.getResults().get(0) == null && multiResult.isNullEmptyTarget()) {
            // explode null in case of a single multi-result target result
            result = null;
        } else {
            // in case of multi result while invoking generic "read" method deal with the multi results
            result = ((MultiResult) result).getResults().toArray();
        }
    }
    assertThat(result, equalTo(resultToMatch));
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) CompactSerializationConfig(com.hazelcast.config.CompactSerializationConfig) MultiResult(com.hazelcast.query.impl.getters.MultiResult) SchemaService(com.hazelcast.internal.serialization.impl.compact.SchemaService) SerializationConfig(com.hazelcast.config.SerializationConfig) CompactSerializationConfig(com.hazelcast.config.CompactSerializationConfig) GenericRecordQueryReader(com.hazelcast.internal.serialization.impl.GenericRecordQueryReader) GroupObject(com.hazelcast.internal.serialization.impl.compact.reader.CompactValueReaderTestStructure.GroupObject) PrimitiveObject(com.hazelcast.internal.serialization.impl.compact.reader.CompactValueReaderTestStructure.PrimitiveObject) NestedGroupObject(com.hazelcast.internal.serialization.impl.compact.reader.CompactValueReaderTestStructure.NestedGroupObject) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) Data(com.hazelcast.internal.serialization.Data) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Aggregations

CompactSerializationConfig (com.hazelcast.config.CompactSerializationConfig)30 Test (org.junit.Test)12 SerializationConfig (com.hazelcast.config.SerializationConfig)10 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)10 QuickTest (com.hazelcast.test.annotation.QuickTest)9 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)8 Config (com.hazelcast.config.Config)7 TriTuple (com.hazelcast.internal.util.TriTuple)6 MapConfig (com.hazelcast.config.MapConfig)5 HazelcastInstance (com.hazelcast.core.HazelcastInstance)5 IndexConfig (com.hazelcast.config.IndexConfig)4 Data (com.hazelcast.internal.serialization.Data)4 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)4 ClientConfig (com.hazelcast.client.config.ClientConfig)3 IMap (com.hazelcast.map.IMap)3 Before (org.junit.Before)3 Node (org.w3c.dom.Node)3 GenericRecordQueryReader (com.hazelcast.internal.serialization.impl.GenericRecordQueryReader)2 SchemaService (com.hazelcast.internal.serialization.impl.compact.SchemaService)2 CompactReader (com.hazelcast.nio.serialization.compact.CompactReader)2