Java Code Examples for com.esotericsoftware.kryo.Kryo#getReferences()

The following examples show how to use com.esotericsoftware.kryo.Kryo#getReferences() . 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: HopscotchCollection.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@SuppressWarnings("unchecked")
protected HopscotchCollection( final Kryo kryo, final Input input ) {
    final boolean oldReferences = kryo.getReferences();
    kryo.setReferences(false);

    capacity = input.readInt();
    size = 0;
    buckets = (T[])new Object[capacity];
    status = new byte[capacity];
    int nElements = input.readInt();
    while ( nElements-- > 0 ) {
        add((T)kryo.readClassAndObject(input));
    }

    kryo.setReferences(oldReferences);
}
 
Example 2
Source File: PSTreeNode.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private PSTreeNode(final Kryo kryo, final Input input) {
    final boolean oldReferences = kryo.getReferences();
    kryo.setReferences(false);

    name = input.readString();
    rank = input.readString();
    parent = input.readInt();
    length = input.readLong();
    final int numChildren = input.readInt();
    children = new HashSet<>(numChildren);
    for (int i = 0; i < numChildren; i++) {
        children.add(Integer.valueOf(input.readString()));
    }

    kryo.setReferences(oldReferences);
}
 
Example 3
Source File: PSTree.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@SuppressWarnings("unchecked")
protected PSTree(final Kryo kryo, final Input input) {
    final boolean oldReferences = kryo.getReferences();
    kryo.setReferences(false);

    root = Integer.valueOf(input.readString());
    final int treeSize = input.readInt();
    tree = new HashMap<>(treeSize);
    for (int i = 0; i < treeSize; i++) {
        final int key = input.readInt();
        final PSTreeNode value = kryo.readObject(input, PSTreeNode.class);
        tree.put(key, value);
    }

    kryo.setReferences(oldReferences);
}
 
Example 4
Source File: HopscotchCollection.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void serialize( final Kryo kryo, final Output output ) {
    final boolean oldReferences = kryo.getReferences();
    kryo.setReferences(false);

    output.writeInt(capacity);
    output.writeInt(size);

    // write the chain heads, and then the squatters
    int count = 0;
    for ( int idx = 0; idx != capacity; ++idx ) {
        if ( isChainHead(idx) ) {
            kryo.writeClassAndObject(output, buckets[idx]);
            count += 1;
        }
    }
    for ( int idx = 0; idx != capacity; ++idx ) {
        final T val = buckets[idx];
        if ( val != null && !isChainHead(idx) ) {
            kryo.writeClassAndObject(output, val);
            count += 1;
        }
    }

    kryo.setReferences(oldReferences);

    if ( count != size ) {
        throw new IllegalStateException("Failed to serialize the expected number of objects: expected="+size+" actual="+count+".");
    }
}
 
Example 5
Source File: LargeLongHopscotchSet.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@SuppressWarnings("unchecked")
protected LargeLongHopscotchSet(final Kryo kryo, final Input stream) {
    final boolean oldReferences = kryo.getReferences();
    kryo.setReferences(false);

    numSets = stream.readInt();
    sets = new ArrayList<>(numSets);
    for (int i = 0; i < numSets; i++) {
        sets.add(kryo.readObject(stream, LongHopscotchSet.class));
    }

    kryo.setReferences(oldReferences);
}
 
Example 6
Source File: LargeLongHopscotchSet.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void serialize(final Kryo kryo, final Output stream) {
    final boolean oldReferences = kryo.getReferences();
    kryo.setReferences(false);

    stream.writeInt(sets.size());
    for (final LongHopscotchSet set : sets) {
        kryo.writeObject(stream, set);
    }

    kryo.setReferences(oldReferences);
}
 
Example 7
Source File: PSTreeNode.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void serialize(final Kryo kryo, final Output output) {
    final boolean oldReferences = kryo.getReferences();
    kryo.setReferences(false);

    output.writeString(name);
    output.writeString(rank);
    output.writeInt(parent);
    output.writeLong(length);
    output.writeInt(children.size());
    for (final int child : children) {
        output.writeString(String.valueOf(child));
    }

    kryo.setReferences(oldReferences);
}
 
Example 8
Source File: PSTaxonomyDatabase.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private PSTaxonomyDatabase(final Kryo kryo, final Input input) {
    final boolean oldReferences = kryo.getReferences();
    kryo.setReferences(false);

    tree = kryo.readObject(input, PSTree.class);
    final int setSize = input.readInt();
    accessionToTaxId = new HashMap<>(setSize);
    for (int i = 0; i < setSize; i++) {
        final String key = input.readString();
        final String value = input.readString();
        accessionToTaxId.put(key, Integer.valueOf(value));
    }

    kryo.setReferences(oldReferences);
}
 
Example 9
Source File: PSTaxonomyDatabase.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void serialize(final Kryo kryo, final Output output) {
    final boolean oldReferences = kryo.getReferences();
    kryo.setReferences(false);

    kryo.writeObject(output, tree);
    output.writeInt(accessionToTaxId.size());
    for (final String key : accessionToTaxId.keySet()) {
        output.writeString(key);
        output.writeString(String.valueOf(accessionToTaxId.get(key)));
    }

    kryo.setReferences(oldReferences);
}
 
Example 10
Source File: PSTree.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void serialize(final Kryo kryo, final Output output) {
    final boolean oldReferences = kryo.getReferences();
    kryo.setReferences(false);

    output.writeString(String.valueOf(root));
    output.writeInt(tree.size());
    for (final int key : tree.keySet()) {
        output.writeInt(key);
        kryo.writeObject(output, tree.get(key));
    }

    kryo.setReferences(oldReferences);
}