Search in sources :

Example 11 with BinaryMetadata

use of org.apache.ignite.internal.binary.BinaryMetadata in project ignite by apache.

the class PlatformContextImpl method writeMetadata0.

/**
 * Write binary metadata.
 *
 * @param writer Writer.
 * @param meta Metadata.
 */
private void writeMetadata0(BinaryRawWriterEx writer, BinaryType meta, boolean includeSchemas) {
    if (meta == null)
        writer.writeBoolean(false);
    else {
        writer.writeBoolean(true);
        BinaryMetadata meta0 = ((BinaryTypeImpl) meta).metadata();
        PlatformUtils.writeBinaryMetadata(writer, meta0, includeSchemas);
    }
}
Also used : BinaryTypeImpl(org.apache.ignite.internal.binary.BinaryTypeImpl) BinaryMetadata(org.apache.ignite.internal.binary.BinaryMetadata)

Example 12 with BinaryMetadata

use of org.apache.ignite.internal.binary.BinaryMetadata in project ignite by apache.

the class PlatformContextImpl method processMetadata.

/**
 * {@inheritDoc}
 */
@Override
public void processMetadata(BinaryRawReaderEx reader) {
    Collection<BinaryMetadata> metas = PlatformUtils.readBinaryMetadataCollection(reader);
    BinaryContext binCtx = cacheObjProc.binaryContext();
    for (BinaryMetadata meta : metas) binCtx.updateMetadata(meta.typeId(), meta, false);
}
Also used : BinaryContext(org.apache.ignite.internal.binary.BinaryContext) BinaryMetadata(org.apache.ignite.internal.binary.BinaryMetadata)

Example 13 with BinaryMetadata

use of org.apache.ignite.internal.binary.BinaryMetadata in project ignite by apache.

the class JdbcBinaryTypePutRequest method readBinary.

/**
 * {@inheritDoc}
 */
@Override
public void readBinary(BinaryReaderExImpl reader, JdbcProtocolContext protoCtx) throws BinaryObjectException {
    super.readBinary(reader, protoCtx);
    meta = new BinaryMetadata();
    try {
        meta.readFrom(reader);
    } catch (IOException e) {
        throw new BinaryObjectException(e);
    }
}
Also used : IOException(java.io.IOException) BinaryMetadata(org.apache.ignite.internal.binary.BinaryMetadata) BinaryObjectException(org.apache.ignite.binary.BinaryObjectException)

Example 14 with BinaryMetadata

use of org.apache.ignite.internal.binary.BinaryMetadata in project ignite by apache.

the class ClientBinary method buildEnum.

/**
 * {@inheritDoc}
 */
@Override
public BinaryObject buildEnum(String typeName, String name) {
    if (typeName == null || typeName.isEmpty())
        throw new IllegalArgumentException("typeName");
    if (name == null || name.isEmpty())
        throw new IllegalArgumentException("name");
    BinaryContext ctx = marsh.context();
    int typeId = ctx.typeId(typeName);
    BinaryMetadata metadata = ctx.metadata0(typeId);
    if (metadata == null)
        throw new BinaryObjectException(String.format("Failed to get metadata for type [typeId=%s, typeName='%s']", typeId, typeName));
    Integer ordinal = metadata.getEnumOrdinalByName(name);
    if (ordinal == null)
        throw new BinaryObjectException(String.format("Failed to resolve enum ordinal by name [typeId=%s, typeName='%s', name='%s']", typeId, typeName, name));
    return new BinaryEnumObjectImpl(ctx, typeId, null, ordinal);
}
Also used : BinaryContext(org.apache.ignite.internal.binary.BinaryContext) BinaryEnumObjectImpl(org.apache.ignite.internal.binary.BinaryEnumObjectImpl) BinaryMetadata(org.apache.ignite.internal.binary.BinaryMetadata) BinaryObjectException(org.apache.ignite.binary.BinaryObjectException)

Example 15 with BinaryMetadata

use of org.apache.ignite.internal.binary.BinaryMetadata in project ignite by apache.

the class ClientBinary method registerEnum.

/**
 * {@inheritDoc}
 */
@Override
public BinaryType registerEnum(String typeName, Map<String, Integer> vals) {
    if (typeName == null || typeName.isEmpty())
        throw new IllegalArgumentException("typeName");
    BinaryContext ctx = marsh.context();
    int typeId = ctx.typeId(typeName);
    ctx.updateMetadata(typeId, new BinaryMetadata(typeId, typeName, null, null, null, true, vals), false);
    return ctx.metadata(typeId);
}
Also used : BinaryContext(org.apache.ignite.internal.binary.BinaryContext) BinaryMetadata(org.apache.ignite.internal.binary.BinaryMetadata)

Aggregations

BinaryMetadata (org.apache.ignite.internal.binary.BinaryMetadata)32 BinaryObjectException (org.apache.ignite.binary.BinaryObjectException)11 HashMap (java.util.HashMap)9 BinaryTypeImpl (org.apache.ignite.internal.binary.BinaryTypeImpl)9 BinaryContext (org.apache.ignite.internal.binary.BinaryContext)7 IOException (java.io.IOException)6 Map (java.util.Map)6 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)6 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 BinaryObject (org.apache.ignite.binary.BinaryObject)6 LinkedHashMap (java.util.LinkedHashMap)4 BinaryType (org.apache.ignite.binary.BinaryType)4 ArrayList (java.util.ArrayList)3 LinkedHashSet (java.util.LinkedHashSet)3 IgniteException (org.apache.ignite.IgniteException)3 BinaryFieldMetadata (org.apache.ignite.internal.binary.BinaryFieldMetadata)3 Array (java.lang.reflect.Array)2 SimpleEntry (java.util.AbstractMap.SimpleEntry)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2