Package com.esotericsoftware.kryo.io

Examples of com.esotericsoftware.kryo.io.Input


   * Deserializes expression from Kryo.
   * @param bytes Bytes containing the expression.
   * @return Expression; null if deserialization succeeded, but the result type is incorrect.
   */
  public static ExprNodeGenericFuncDesc deserializeExpressionFromKryo(byte[] bytes) {
    Input inp = new Input(new ByteArrayInputStream(bytes));
    ExprNodeGenericFuncDesc func = runtimeSerializationKryo.get().
      readObject(inp,ExprNodeGenericFuncDesc.class);
    inp.close();
    return func;
  }
View Full Code Here


      }
    }
  }

  private static <T> T deserializeObjectByKryo(Kryo kryo, InputStream in, Class<T> clazz ) {
    Input inp = new Input(in);
    T t = kryo.readObject(inp,clazz);
    inp.close();
    return t;
  }
View Full Code Here

        try
        {
            kh = pool.get();
            checkRegiterNeeded(kh.kryo, clazz);

            Input input = new Input(source);
            return kh.kryo.readObject(input, clazz);
        }
        finally
        {
            if (kh != null)
View Full Code Here

   @Override
   public Object createObjectFromBytes(byte[] bytes) {
      Kryo kryo = getCurrentThreadKryo();
     
      Object obj = null;
      Input in = new Input(bytes);
      obj = (Object) kryo.readClassAndObject(in);
      in.close();
      return obj;
   }
View Full Code Here

      Kryo kryo = getCurrentThreadKryo();
     
      // skip the buffer length parameter
      buffer.position(buffer.position() + 4);
     
      Input in = new Input(new ByteBufferInputStream(buffer));
      Message msg = (Message) kryo.readClassAndObject(in);
      in.close();
      msg.rewind();
      return msg;
   }
View Full Code Here

        Kryo kry = new Kryo();
        kry.writeObject(ko, skv);
        ko.flush();
        // Deserialize.
        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
        Input ki = new Input(bis);
        LazyVector des = (LazyVector)kry.readObject(ki, LazyVector.class);
        assertFalse(des.getFreezeKeySet());
        assertEquals(2, des.size());
        assertEquals(0.9, des.getCoordinate("foo"), eps);
        assertEquals(-1.8, des.getCoordinate("bar"), eps);
View Full Code Here

        Kryo kry = new Kryo();
        kry.writeObject(ko, skv);
        ko.flush();
        // Deserialize.
        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
        Input ki = new Input(bis);
        StringKeyedVector des = (StringKeyedVector)kry.readObject(ki,
                StringKeyedVector.class);
        assertFalse(des.getFreezeKeySet());
        assertEquals(2, des.size());
        assertEquals(1.0, des.getCoordinate("foo"), eps);
View Full Code Here

            }
        }
    }

    public void bload(String filepath) {
        Input input = null;
        try {
            input = new Input(new FileInputStream(filepath));
            SerializerHelper serializerHelper = helper.get();
            Basis base = serializerHelper.readB(input);
            Map<String, VectorSet> vecSets = serializerHelper.readVectorSets(input, base);
            Map<String, Recommendation> recs = serializerHelper.readRecommendations(input, vecSets);

            this.base = base;
            this.vectorSets = vecSets;
            this.recommendations = recs;

            for (String vkey : vecSets.keySet()) {
                for (SimBasisListener listener : listeners) {
                    listener.onVecSetAdded(key(), vkey);
                }
            }
            for (String key : recs.keySet()) {
                Recommendation rec = recs.get(key);
                String vkeySrc = rec.source.key();
                String vkeyTgt = rec.target.key();
                for (SimBasisListener listener : listeners) {
                    listener.onRecAdded(key(), vkeySrc, vkeyTgt);
                }
            }

        } catch (Throwable e) {
            throw new SimException(e);
        } finally {
            if (input != null) {
                input.close();
            }
        }
    }
View Full Code Here

    kryo.register(RegisterUDP.class);
    kryo.register(KeepAlive.class);
    kryo.register(DiscoverHost.class);
    kryo.register(Ping.class);

    input = new Input(byteBufferInputStream, 512);
    output = new Output(byteBufferOutputStream, 512);
  }
View Full Code Here

        randomAccessFile.seek(FIRST_RECORD_POSITION);
        byte[] data = new byte[f.limit-FIRST_RECORD_POSITION];
        int c = 0;
        while ((c += randomAccessFile.read(data,c,data.length-c)) < data.length);
        randomAccessFile.close();
        readData(new Input(data),SerializeUtil.createKryo(), fromTime, toTime, reverse);
       
      }
View Full Code Here

TOP

Related Classes of com.esotericsoftware.kryo.io.Input

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.