Java Code Examples for org.mapdb.DataInput2#unpackInt()

The following examples show how to use org.mapdb.DataInput2#unpackInt() . 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: MapSerializer.java    From ipst with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public Map<String, Object> deserialize(DataInput2 input, int available) throws IOException {
    Objects.requireNonNull(input);
    Map<String, Object> map = new TreeMap();
    int size = input.unpackInt();
    for (int i = 0; i < size; i++) {

        String k = input.readUTF();

        if (k.startsWith("D")) {
            map.put(k.substring(1), input.readDouble());
        } else if (k.startsWith("L")) {
            map.put(k.substring(1), input.readLong());
        } else if (k.startsWith("S")) {
            map.put(k.substring(1), input.readUTF());
        } else if (k.startsWith("I")) {
            map.put(k.substring(1), input.readInt());
        }
    }
    return map;
}
 
Example 2
Source File: CachedEventGroupSerializer.java    From eagle with Apache License 2.0 5 votes vote down vote up
private PartitionedEvent readPartitionedEvent(DataInput2 in) throws IOException {
    PartitionedEvent event = new PartitionedEvent();
    event.setPartitionKey(in.unpackLong());
    int partitionHashCode = in.unpackInt();
    if (partitionHashCode != 0 && hashCodePartitionDict.containsKey(partitionHashCode)) {
        event.setPartition(hashCodePartitionDict.get(partitionHashCode));
    }
    int eventBytesLen = in.unpackInt();
    if (eventBytesLen > 0) {
        byte[] eventBytes = new byte[eventBytesLen];
        in.readFully(eventBytes);
        event.setEvent((StreamEvent) SerializableUtils.deserializeFromCompressedByteArray(eventBytes, "Deserialize event from bytes"));
    }
    return event;
}
 
Example 3
Source File: CachedEventGroupSerializer.java    From eagle with Apache License 2.0 5 votes vote down vote up
@Override
public PartitionedEvent[] deserialize(DataInput2 in, int available) throws IOException {
    final int size = in.unpackInt();
    PartitionedEvent[] ret = new PartitionedEvent[size];
    for (int i = 0; i < size; i++) {
        ret[i] = readPartitionedEvent(in);
    }
    return ret;
}