/** {@inheritDoc} */ @Override public BinarySerializedFieldComparator createFieldComparator() { int schemaOff = BinaryPrimitives.readInt(arr, start + GridBinaryMarshaller.SCHEMA_OR_RAW_OFF_POS); short flags = BinaryPrimitives.readShort(arr, start + GridBinaryMarshaller.FLAGS_POS); int fieldIdLen = BinaryUtils.isCompactFooter(flags) ? 0 : BinaryUtils.FIELD_ID_LEN; int fieldOffLen = BinaryUtils.fieldOffsetLength(flags); int orderBase = start + schemaOff + fieldIdLen; int orderMultiplier = fieldIdLen + fieldOffLen; return new BinarySerializedFieldComparator(this, arr, 0L, start, orderBase, orderMultiplier, fieldOffLen); }
/** * @param cls type to examine. * @return true if typeId equals for passed type and current * binary enum. */ public boolean isTypeEquals(final Class<?> cls) { return ctx.descriptorForClass(cls, false, false).typeId() == typeId(); } }
/** {@inheritDoc} */ @Override public int footerStartOffset() { short flags = BinaryPrimitives.readShort(ptr, start + GridBinaryMarshaller.FLAGS_POS); if (!BinaryUtils.hasSchema(flags)) return start + length(); return start + BinaryPrimitives.readInt(ptr, start + GridBinaryMarshaller.SCHEMA_OR_RAW_OFF_POS); }
/** * @param obj Instance of the BinaryObjectImpl to offheap marshalling. * @param marsh Binary marshaller. * @return Instance of BinaryObjectOffheapImpl. */ private BinaryObjectOffheapImpl marshalOffHeap(BinaryObjectImpl obj, BinaryMarshaller marsh) { long ptr = copyOffheap(obj); return new BinaryObjectOffheapImpl(binaryContext(marsh), ptr, 0, obj.array().length); }
/** {@inheritDoc} */ @Override public int footerStartOffset() { short flags = BinaryPrimitives.readShort(arr, start + GridBinaryMarshaller.FLAGS_POS); if (!BinaryUtils.hasSchema(flags)) return start + length(); return start + BinaryPrimitives.readInt(arr, start + GridBinaryMarshaller.SCHEMA_OR_RAW_OFF_POS); }
/** {@inheritDoc} */ @Override protected BinaryObjectExImpl toBinary(BinaryMarshaller marsh, Object obj) throws Exception { byte[] bytes = marsh.marshal(obj); return new BinaryObjectImpl(binaryContext(marsh), bytes, 0); } }
/** * @param obj Object to transform to a binary object. * @param marsh Binary marshaller. * @return Binary object. */ protected BinaryObjectImpl toBinary(Object obj, BinaryMarshaller marsh) throws Exception { byte[] bytes = marsh.marshal(obj); return new BinaryObjectImpl(binaryContext(marsh), bytes, 0); }
/** * Create binary field. * * @param typeId Type ID. * @param fieldName Field name. * @return Binary field. */ public BinaryFieldImpl createField(int typeId, String fieldName) { BinarySchemaRegistry schemaReg = schemaRegistry(typeId); BinaryInternalMapper mapper = userTypeMapper(typeId); int fieldId = mapper.fieldId(typeId, fieldName); return new BinaryFieldImpl(this, typeId, schemaReg, fieldName, fieldId); }
/** * Gets writer for the given output stream. * * @param out Output stream. * @return Writer. */ public BinaryWriterExImpl writer(BinaryOutputStream out) { return new BinaryWriterExImpl(ctx, out, BinaryThreadLocalContext.get().schemaHolder(), null); }
/** {@inheritDoc} */ @Override protected BinaryObjectExImpl toBinary(BinaryMarshaller marsh, Object obj) throws Exception { byte[] bytes = marsh.marshal(obj); return new BinaryObjectImpl(ctx, bytes, 0); } }
/** * @param clsName Class name. * @return Type name. */ public String userTypeName(String clsName) { BinaryInternalMapper mapper = userTypeMapper(clsName); return mapper.typeName(clsName); }
/** * Sets {@link BinaryContext}. * <p/> * @param ctx Binary context. */ private void setBinaryContext(BinaryContext ctx, IgniteConfiguration cfg) { ctx.configure(this, cfg); impl = new GridBinaryMarshaller(ctx); }
/** * @return Current writer's schema. */ public BinarySchema currentSchema() { BinarySchema.Builder builder = BinarySchema.Builder.newBuilder(); if (schema != null) schema.build(builder, fieldCnt); return builder.build(); }
/** * @return Deserialized value. */ private Object deserializeValue() { return reader(null, true).deserialize(); }
/** * @param typeId Type ID. * @param fieldName Field name. * @return Field ID. */ public int fieldId(int typeId, String fieldName) { BinaryInternalMapper mapper = userTypeMapper(typeId); return mapper.fieldId(typeId, fieldName); }
/** {@inheritDoc} */ @Override public BinarySerializedFieldComparator createFieldComparator() { int schemaOff = BinaryPrimitives.readInt(ptr, start + GridBinaryMarshaller.SCHEMA_OR_RAW_OFF_POS); short flags = BinaryPrimitives.readShort(ptr, start + GridBinaryMarshaller.FLAGS_POS); int fieldIdLen = BinaryUtils.isCompactFooter(flags) ? 0 : BinaryUtils.FIELD_ID_LEN; int fieldOffLen = BinaryUtils.fieldOffsetLength(flags); int orderBase = start + schemaOff + fieldIdLen; int orderMultiplier = fieldIdLen + fieldOffLen; return new BinarySerializedFieldComparator(this, null, ptr, start, orderBase, orderMultiplier, fieldOffLen); }