@Override public int fieldId(int typeId, String fieldName) { return typeId + ~BinaryContext.defaultIdMapper().fieldId(typeId, fieldName); } });
@Override public int typeId(String clsName) { return ~BinaryContext.defaultIdMapper().typeId(clsName); }
/** * @param typeName Type name. * @param nameMapper Name mapper. * @param mapper ID mapper. @return Type ID. */ private int typeId(String typeName, BinaryNameMapper nameMapper, BinaryIdMapper mapper) { if (mapper == null) mapper = BinaryContext.defaultIdMapper(); if (nameMapper == null) nameMapper = BinaryContext.defaultNameMapper(); return mapper.typeId(nameMapper.typeName(typeName)); }
/** * @return Expected hash code. * @param fullName Full name of type. */ private int expectedHashCode(String fullName) { BinaryIdMapper idMapper = cfg.getBinaryConfiguration().getIdMapper(); BinaryNameMapper nameMapper = cfg.getBinaryConfiguration().getNameMapper(); if (idMapper == null) idMapper = BinaryContext.defaultIdMapper(); if (nameMapper == null) nameMapper = BinaryContext.defaultNameMapper(); return idMapper.typeId(nameMapper.typeName(fullName)); }
/** * Test {@link BinaryObjectBuilder#build()} adds type mapping to the binary marshaller's cache. */ @Test public void testMarshallerMappings() throws IgniteCheckedException, ClassNotFoundException { String typeName = "TestType"; int typeId = BinaryContext.defaultIdMapper().typeId(typeName); BinaryObjectBuilder builder = newWrapper(typeName); builder.build(); MarshallerContext marshCtx = grid(0).context().marshallerContext(); String actualTypeName = marshCtx.getClassName(MarshallerPlatformIds.JAVA_ID, typeId); assertEquals(typeName, actualTypeName); }
btc.setIdMapper(BinaryContext.defaultIdMapper()); btc.setEnum(false); btc.setSerializer(new BinarySerializer() {
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); cfg.setConnectorConfiguration(new ConnectorConfiguration()); cfg.setMarshaller(new BinaryMarshaller()); BinaryConfiguration binaryCfg = new BinaryConfiguration(); BinaryTypeConfiguration btc = new BinaryTypeConfiguration("org.MyClass"); btc.setIdMapper(BinaryContext.defaultIdMapper()); btc.setEnum(false); // Set custom serializer that is unknown for Optimized marshaller. btc.setSerializer(new MyBinarySerializer()); binaryCfg.setTypeConfigurations(Collections.singletonList(btc)); cfg.setBinaryConfiguration(binaryCfg); // Set custom consistent ID that unknown for Optimized marshaller. cfg.setConsistentId(new MyConsistentId("test")); cfg.setCacheConfiguration(new CacheConfiguration("TEST")); return cfg; }