Search in sources :

Example 1 with PlatformReaderBiClosure

use of org.apache.ignite.internal.processors.platform.utils.PlatformReaderBiClosure in project ignite by apache.

the class PlatformContextImpl method processMetadata.

/** {@inheritDoc} */
@SuppressWarnings("ConstantConditions")
@Override
public void processMetadata(BinaryRawReaderEx reader) {
    Collection<BinaryMetadata> metas = PlatformUtils.readCollection(reader, new PlatformReaderClosure<BinaryMetadata>() {

        @Override
        public BinaryMetadata read(BinaryRawReaderEx reader) {
            int typeId = reader.readInt();
            String typeName = reader.readString();
            String affKey = reader.readString();
            Map<String, BinaryFieldMetadata> fields = PlatformUtils.readLinkedMap(reader, new PlatformReaderBiClosure<String, BinaryFieldMetadata>() {

                @Override
                public IgniteBiTuple<String, BinaryFieldMetadata> read(BinaryRawReaderEx reader) {
                    String name = reader.readString();
                    int typeId = reader.readInt();
                    int fieldId = reader.readInt();
                    return new IgniteBiTuple<String, BinaryFieldMetadata>(name, new BinaryFieldMetadata(typeId, fieldId));
                }
            });
            Map<String, Integer> enumMap = null;
            boolean isEnum = reader.readBoolean();
            if (isEnum) {
                int size = reader.readInt();
                enumMap = new LinkedHashMap<>(size);
                for (int idx = 0; idx < size; idx++) enumMap.put(reader.readString(), reader.readInt());
            }
            // Read schemas
            int schemaCnt = reader.readInt();
            List<BinarySchema> schemas = null;
            if (schemaCnt > 0) {
                schemas = new ArrayList<>(schemaCnt);
                for (int i = 0; i < schemaCnt; i++) {
                    int id = reader.readInt();
                    int fieldCnt = reader.readInt();
                    List<Integer> fieldIds = new ArrayList<>(fieldCnt);
                    for (int j = 0; j < fieldCnt; j++) fieldIds.add(reader.readInt());
                    schemas.add(new BinarySchema(id, fieldIds));
                }
            }
            return new BinaryMetadata(typeId, typeName, fields, affKey, schemas, isEnum, enumMap);
        }
    });
    BinaryContext binCtx = cacheObjProc.binaryContext();
    for (BinaryMetadata meta : metas) binCtx.updateMetadata(meta.typeId(), meta);
}
Also used : IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) PlatformReaderBiClosure(org.apache.ignite.internal.processors.platform.utils.PlatformReaderBiClosure) ArrayList(java.util.ArrayList) BinaryRawReaderEx(org.apache.ignite.internal.binary.BinaryRawReaderEx) BinaryMetadata(org.apache.ignite.internal.binary.BinaryMetadata) LinkedHashMap(java.util.LinkedHashMap) BinaryFieldMetadata(org.apache.ignite.internal.binary.BinaryFieldMetadata) BinarySchema(org.apache.ignite.internal.binary.BinarySchema) List(java.util.List) ArrayList(java.util.ArrayList) BinaryContext(org.apache.ignite.internal.binary.BinaryContext) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 BinaryContext (org.apache.ignite.internal.binary.BinaryContext)1 BinaryFieldMetadata (org.apache.ignite.internal.binary.BinaryFieldMetadata)1 BinaryMetadata (org.apache.ignite.internal.binary.BinaryMetadata)1 BinaryRawReaderEx (org.apache.ignite.internal.binary.BinaryRawReaderEx)1 BinarySchema (org.apache.ignite.internal.binary.BinarySchema)1 PlatformReaderBiClosure (org.apache.ignite.internal.processors.platform.utils.PlatformReaderBiClosure)1 IgniteBiTuple (org.apache.ignite.lang.IgniteBiTuple)1