Java Code Examples for com.esotericsoftware.kryo.io.Input#read()

The following examples show how to use com.esotericsoftware.kryo.io.Input#read() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PercentileCounterSerializer.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@Override
public PercentileCounter read(Kryo kryo, Input input, Class type) {
    double compression = input.readDouble();
    double quantileRatio = input.readDouble();
    int length = input.readInt();
    byte[] buffer = new byte[length];

    int offset = 0;
    int bytesRead;
    while ((bytesRead = input.read(buffer, offset, buffer.length - offset)) != -1) {
        offset += bytesRead;
        if (offset >= buffer.length) {
            break;
        }
    }

    PercentileCounter counter = new PercentileCounter(compression, quantileRatio);
    counter.readRegisters(ByteBuffer.wrap(buffer));
    return counter;
}
 
Example 2
Source File: PercentileCounterSerializer.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@Override
public PercentileCounter read(Kryo kryo, Input input, Class type) {
    double compression = input.readDouble();
    double quantileRatio = input.readDouble();
    int length = input.readInt();
    byte[] buffer = new byte[length];

    int offset = 0;
    int bytesRead;
    while ((bytesRead = input.read(buffer, offset, buffer.length - offset)) != -1) {
        offset += bytesRead;
        if (offset >= buffer.length) {
            break;
        }
    }

    PercentileCounter counter = new PercentileCounter(compression, quantileRatio);
    counter.readRegisters(ByteBuffer.wrap(buffer));
    return counter;
}
 
Example 3
Source File: PercentileCounterSerializer.java    From kylin with Apache License 2.0 6 votes vote down vote up
@Override
public PercentileCounter read(Kryo kryo, Input input, Class type) {
    double compression = input.readDouble();
    double quantileRatio = input.readDouble();
    int length = input.readInt();
    byte[] buffer = new byte[length];

    int offset = 0;
    int bytesRead;
    while ((bytesRead = input.read(buffer, offset, buffer.length - offset)) != -1) {
        offset += bytesRead;
        if (offset >= buffer.length) {
            break;
        }
    }

    PercentileCounter counter = new PercentileCounter(compression, quantileRatio);
    counter.readRegisters(ByteBuffer.wrap(buffer));
    return counter;
}
 
Example 4
Source File: PercentileCounterSerializer.java    From kylin with Apache License 2.0 6 votes vote down vote up
@Override
public PercentileCounter read(Kryo kryo, Input input, Class type) {
    double compression = input.readDouble();
    double quantileRatio = input.readDouble();
    int length = input.readInt();
    byte[] buffer = new byte[length];

    int offset = 0;
    int bytesRead;
    while ((bytesRead = input.read(buffer, offset, buffer.length - offset)) != -1) {
        offset += bytesRead;
        if (offset >= buffer.length) {
            break;
        }
    }

    PercentileCounter counter = new PercentileCounter(compression, quantileRatio);
    counter.readRegisters(ByteBuffer.wrap(buffer));
    return counter;
}
 
Example 5
Source File: CpxVariantCanonicalRepresentation.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private CpxVariantCanonicalRepresentation(final Kryo kryo, final Input input) {

        final String refRegionChr = input.readString();
        final int refRegionStart = input.readInt();
        final int refRegionEnd = input.readInt();
        affectedRefRegion = new SimpleInterval(refRegionChr, refRegionStart, refRegionEnd);

        final int numSegments = input.readInt();
        referenceSegments = new ArrayList<>(numSegments);
        for (int i = 0; i < numSegments; ++i) {
            final String chr = input.readString();
            final int start = input.readInt();
            final int end = input.readInt();
            referenceSegments.add( new SimpleInterval(chr, start, end));
        }

        final int numDescriptions = input.readInt();
        eventDescriptions = new ArrayList<>(numDescriptions);
        for (int i = 0; i < numDescriptions; ++i)
            eventDescriptions.add(input.readString());

        altSeq = new byte[input.readInt()];
        input.read(altSeq);
    }
 
Example 6
Source File: Geometry.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Override
public void read(Kryo kryo, Input input) {
    readMetadata(kryo, input);
    int wkbLength = input.read();
    byte[] wellKnownBinary = new byte[wkbLength];
    input.read(wellKnownBinary);
    try {
        geometry = new WKBReader().read(wellKnownBinary);
    } catch (ParseException e) {
        throw new IllegalArgumentException("Cannot parse the geometry", e);
    }
}
 
Example 7
Source File: Cardinality.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Override
public void read(Kryo kryo, Input input) {
    super.readMetadata(kryo, input);
    content = new FieldValueCardinality();
    this.content.lower = input.readString();
    this.content.upper = input.readString();
    int size = input.readInt();
    byte[] cardArray = new byte[size];
    input.read(cardArray);
    try {
        this.content.estimate = HyperLogLogPlus.Builder.build(cardArray);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
Example 8
Source File: UTF8String.java    From Mycat2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void read(Kryo kryo, Input in) {
  this.offset = Platform.BYTE_ARRAY_OFFSET;
  this.numBytes = in.readInt();
  this.base = new byte[numBytes];
  in.read((byte[]) base);
}
 
Example 9
Source File: AbstractUserAgentAnalyzer.java    From yauaa with Apache License 2.0 5 votes vote down vote up
@Override
public AbstractUserAgentAnalyzer read(Kryo kryo, Input input, Class<AbstractUserAgentAnalyzerDirect> type) {
    final AbstractUserAgentAnalyzer uaa = (AbstractUserAgentAnalyzer) super.read(kryo, input, type);
    uaa.cacheSize = input.read();
    uaa.initializeCache();
    return uaa;
}
 
Example 10
Source File: MatchesList.java    From yauaa with Apache License 2.0 5 votes vote down vote up
@Override
public MatchesList read(Kryo kryo, Input input, Class<MatchesList> type) {
    MatchesList matchesList = new MatchesList();
    matchesList.maxSize = input.read();

    // Note: The matches list is always empty after deserialization.
    matchesList.initialize();

    return matchesList;
}
 
Example 11
Source File: MatcherList.java    From yauaa with Apache License 2.0 5 votes vote down vote up
@Override
public MatcherList read(Kryo kryo, Input input, Class<MatcherList> type) {
    MatcherList matcherList = new MatcherList();
    matcherList.maxSize = input.read();

    // Note: The matches list is always empty after deserialization.
    matcherList.initialize();

    return matcherList;
}
 
Example 12
Source File: KryoQuickTypeSerializer.java    From vertexium with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public <T> T valueToObject(byte[] data) {
    Input input = new UnsafeInput(data);
    input.read();
    return (T) kryo.get().readClassAndObject(input);
}
 
Example 13
Source File: PersistableSerializer.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public Persistable read(final Kryo kryo, final Input input, final Class<Persistable> classTag) {

  // Read object byte count and allocate buffer to read object data
  final int byteCount = input.readInt();
  final byte[] bytes = new byte[byteCount];
  final int bytesRead = input.read(bytes);
  // TODO: This was only added for findbugs warning, not really necessary
  // check
  if (bytesRead < 0) {
    return null;
  }

  return PersistenceUtils.fromBinary(bytes);
}
 
Example 14
Source File: ImmutableByteSequenceSerializer.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public ImmutableByteSequence read(Kryo kryo, Input input, Class<ImmutableByteSequence> type) {
    int length = input.readInt();
    byte[] data = new byte[length];
    int bytesRead = input.read(data);
    if (bytesRead != length) {
        throw new IllegalStateException("Byte sequence serializer read expected " + length +
                " but got " + bytesRead);
    }
    return ImmutableByteSequence.copyFrom(data);
}
 
Example 15
Source File: UserSerializer.java    From tutorials with MIT License 5 votes vote down vote up
@Override
public User read(Kryo kryo, Input input, Class<User> aClass) {
    User user = new User();
    String email = input.readString();
    String name = input.readString();
    int age = input.read();
    user.setAge(age);
    user.setEmail(email);
    user.setUsername(name);

    return  user;
}