Package com.esotericsoftware.kryo.io

Examples of com.esotericsoftware.kryo.io.InputChunked


    outputChunked.endChunks();
  }

  public Object read (Kryo kryo, Input input, Class type) {
    // The inflater would read from input beyond the compressed bytes if chunked enoding wasn't used.
    InflaterInputStream inflaterStream = new InflaterInputStream(new InputChunked(input, 256), new Inflater(noHeaders));
    return kryo.readObject(new Input(inflaterStream, 256), type, serializer);
  }
View Full Code Here


        if (TRACE) trace("kryo", "Ignore obsolete field: " + schemaName);
      }
      context.put(this, fields);
    }

    InputChunked inputChunked = new InputChunked(input, 1024);
    for (int i = 0, n = fields.length; i < n; i++) {
      CachedField cachedField = fields[i];
      if (cachedField == null) {
        if (TRACE) trace("kryo", "Skip obsolete field.");
        inputChunked.nextChunks();
        continue;
      }
      cachedField.read(inputChunked, object);
      inputChunked.nextChunks();
    }
    return object;
  }
View Full Code Here

    output.writeInt(5678);
    output.close();

    Input input = new Input(output.getBuffer());
    assertEquals(1234, input.readInt());
    InputChunked inputChunked = new InputChunked(input);
    assertEquals(1, inputChunked.readInt());
    inputChunked.nextChunks();
    inputChunked.nextChunks(); // skip 3
    assertEquals(3, inputChunked.readInt());
    inputChunked.nextChunks();
    inputChunked.nextChunks(); // skip 4
    assertEquals(5, inputChunked.readInt());
    assertEquals(5678, input.readInt());
    input.close();
  }
View Full Code Here

        if (TRACE) trace("kryo", "Ignore obsolete field: " + schemaName);
      }
      context.put(this, fields);
    }

    InputChunked inputChunked = new InputChunked(input, 1024);
    for (int i = 0, n = fields.length; i < n; i++) {
      CachedField cachedField = fields[i];
      try {
        if (cachedField == null) {
          if (TRACE) trace("kryo", "Skip obsolete field.");
          inputChunked.nextChunks();
          continue;
        }

        if (TRACE) trace("kryo", "Read field: " + cachedField + " (" + getType().getName() + ")");

        Object value;

        Class concreteType = cachedField.valueClass;
        Serializer serializer = cachedField.serializer;
        if (concreteType == null) {
          Registration registration = kryo.readClass(inputChunked);
          if (registration == null)
            value = null;
          else {
            if (serializer == null) serializer = registration.getSerializer();
            if (cachedField.generics != null) serializer.setGenerics(kryo, cachedField.generics);
            value = kryo.readObject(inputChunked, registration.getType(), serializer);
          }
        } else {
          if (serializer == null) cachedField.serializer = serializer = kryo.getSerializer(concreteType);
          if (cachedField.generics != null) serializer.setGenerics(kryo, cachedField.generics);
          if (cachedField.canBeNull)
            value = kryo.readObjectOrNull(inputChunked, concreteType, serializer);
          else
            value = kryo.readObject(inputChunked, concreteType, serializer);
        }

        cachedField.set(object, value);

        inputChunked.nextChunks();
      } catch (IllegalAccessException ex) {
        throw new KryoException("Error accessing field: " + cachedField + " (" + getType().getName() + ")", ex);
      } catch (KryoException ex) {
        ex.addTrace(cachedField + " (" + getType().getName() + ")");
        throw ex;
View Full Code Here

        if (TRACE) trace("kryo", "Ignore obsolete field: " + schemaName);
      }
      context.put(this, fields);
    }

    InputChunked inputChunked = new InputChunked(input, 1024);
    for (int i = 0, n = fields.length; i < n; i++) {
      CachedField cachedField = fields[i];
      try {
        if (cachedField == null) {
          if (TRACE) trace("kryo", "Skip obsolete field.");
          inputChunked.nextChunks();
          continue;
        }

        if (TRACE) trace("kryo", "Read field: " + cachedField + " (" + getType().getName() + ")");

        Object value;

        Class concreteType = cachedField.fieldClass;
        Serializer serializer = cachedField.serializer;
        if (concreteType == null) {
          Registration registration = kryo.readClass(inputChunked);
          if (registration == null)
            value = null;
          else {
            concreteType = registration.getType();
            if (serializer == null) serializer = registration.getSerializer();
            value = kryo.readObject(inputChunked, concreteType, serializer);
          }
        } else {
          if (serializer == null) cachedField.serializer = serializer = kryo.getRegistration(concreteType).getSerializer();
          if (!cachedField.canBeNull)
            value = kryo.readObject(inputChunked, concreteType, serializer);
          else
            value = kryo.readObjectOrNull(inputChunked, concreteType, serializer);
        }

        cachedField.set(object, value);

        inputChunked.nextChunks();
      } catch (IllegalAccessException ex) {
        throw new KryoException("Error accessing field in class: " + getType().getName(), ex);
      } catch (KryoException ex) {
        ex.addTrace(cachedField + " (" + getType().getName() + ")");
        throw ex;
View Full Code Here

        if (TRACE) trace("kryo", "Ignore obsolete field: " + schemaName);
      }
      context.put(this, fields);
    }

    InputChunked inputChunked = new InputChunked(input, 1024);
    for (int i = 0, n = fields.length; i < n; i++) {
      CachedField cachedField = fields[i];
      if (cachedField == null) {
        if (TRACE) trace("kryo", "Skip obsolete field.");
        inputChunked.nextChunks();
        continue;
      }
      cachedField.read(inputChunked, object);
      inputChunked.nextChunks();
    }
    return object;
  }
View Full Code Here

  public Object read (Kryo kryo, Input input, Class type) {
    // The inflater would read from input beyond the compressed bytes if chunked enoding wasn't used.
    Inflater inflater = new Inflater(noHeaders);
    try {
      InflaterInputStream inflaterStream = new InflaterInputStream(new InputChunked(input, 256), inflater);
      return serializer.read(kryo, new Input(inflaterStream, 256), type);
    } finally {
      inflater.end();
    }
  }
View Full Code Here

        if (TRACE) trace("kryo", "Ignore obsolete field: " + schemaName);
      }
      context.put(this, fields);
    }

    InputChunked inputChunked = new InputChunked(input, 1024);
    boolean hasGenerics = getGenerics() != null;
    for (int i = 0, n = fields.length; i < n; i++) {
      CachedField cachedField = fields[i];
      if(cachedField != null && hasGenerics) {
        // Generic type used to instantiate this field could have
        // been changed in the meantime. Therefore take the most
        // up-to-date definition of a field
        cachedField = getField(cachedField.field.getName());
      }
      if (cachedField == null) {
        if (TRACE) trace("kryo", "Skip obsolete field.");
        inputChunked.nextChunks();
        continue;
      }
      cachedField.read(inputChunked, object);
      inputChunked.nextChunks();
    }
    return object;
  }
View Full Code Here

        if (TRACE) trace("kryo", "Ignore obsolete field: " + schemaName);
      }
      context.put(this, fields);
    }

    InputChunked inputChunked = new InputChunked(input, 1024);
    for (int i = 0, n = fields.length; i < n; i++) {
      CachedField cachedField = fields[i];
      if (cachedField == null) {
        if (TRACE) trace("kryo", "Skip obsolete field.");
        inputChunked.nextChunks();
        continue;
      }
      cachedField.read(inputChunked, object);
      inputChunked.nextChunks();
    }
    return object;
  }
View Full Code Here

TOP

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

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.