/** * @return Query info. * @throws GridException In case of error. */ @SuppressWarnings({"unchecked"}) private GridCacheQueryInfo localQueryInfo() throws GridException { GridCacheQueryBean qry = query(); GridPredicate<GridCacheEntry<Object, Object>> prjPred = qry.query().projectionFilter() == null ? F.<GridCacheEntry<Object, Object>>alwaysTrue() : qry.query().projectionFilter(); GridMarshaller marsh = cctx.marshaller(); GridReducer<Object, Object> rdc = qry.reducer() != null ? marsh.<GridReducer<Object, Object>>unmarshal(marsh.marshal(qry.reducer()), null) : null; GridClosure<Object, Object> trans = qry.transform() != null ? marsh.<GridClosure<Object, Object>>unmarshal(marsh.marshal(qry.transform()), null) : null; return new GridCacheQueryInfo( true, prjPred, trans, rdc, qry.query(), GridCacheLocalQueryFuture.this, ctx.localNodeId(), cctx.io().nextIoId(), qry.query().includeMetadata(), true, qry.arguments()); }
/** * Decodes value from a given byte array to the object according to the flags given. * * @param flags Flags. * @param bytes Byte array to decode. * @return Decoded value. * @throws GridException If deserialization failed. */ private Object decodeObj(short flags, byte[] bytes) throws GridException { assert bytes != null; if ((flags & SERIALIZED_FLAG) != 0) return jdkMarshaller.unmarshal(new ByteArrayInputStream(bytes), null); int masked = flags & 0xff00; switch (masked) { case BOOLEAN_FLAG: return bytes[0] == '1'; case INT_FLAG: return U.bytesToInt(bytes, 0); case LONG_FLAG: return U.bytesToLong(bytes, 0); case DATE_FLAG: return new Date(U.bytesToLong(bytes, 0)); case BYTE_FLAG: return bytes[0]; case FLOAT_FLAG: return Float.intBitsToFloat(U.bytesToInt(bytes, 0)); case DOUBLE_FLAG: return Double.longBitsToDouble(U.bytesToLong(bytes, 0)); case BYTE_ARR_FLAG: return bytes; default: return new String(bytes); } }
/** * Deserialize object from byte array using marshaller. * * @param bytes Bytes to deserialize. * @param <X> Result object type. * @return Deserialized object. * @throws GridException If failed. */ protected <X> X fromBytes(byte[] bytes) throws GridException { if (bytes == null || bytes.length == 0) return null; return marsh.unmarshal(bytes, getClass().getClassLoader()); }