Ignore:
Timestamp:
2013-04-07T17:07:27+02:00 (12 years ago)
Author:
akks
Message:

JOSM/ImageryCache: updated MapDB (no more deadlocks, Java 1.6 compatible), less crashes, multiple-JOSM support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/imagerycache/src/org/mapdb/Serializer.java

    r29363 r29484  
    2020import java.io.DataOutput;
    2121import java.io.IOException;
     22import java.io.Serializable;
    2223import java.util.zip.CRC32;
    2324
     
    148149     */
    149150   
    150     public static final Serializer<byte[]> CRC32_CHECKSUM = new Serializer<byte[]>() {
     151    Serializer<byte[]> CRC32_CHECKSUM = new Serializer<byte[]>() {
    151152        @Override
    152153        public void serialize(DataOutput out, byte[] value) throws IOException {
     
    174175
    175176
     177    Serializer<byte[] > BYTE_ARRAY_SERIALIZER = new Serializer<byte[]>() {
     178
     179        @Override
     180        public void serialize(DataOutput out, byte[] value) throws IOException {
     181            out.write(value);
     182        }
     183
     184        @Override
     185        public byte[] deserialize(DataInput in, int available) throws IOException {
     186            byte[] ret = new byte[available];
     187            in.readFully(ret);
     188            return ret;
     189        }
     190    } ;
     191
     192
     193    class CompressSerializerWrapper<E> implements Serializer<E>, Serializable {
     194        protected final Serializer<E> serializer;
     195        public CompressSerializerWrapper(Serializer<E> serializer) {
     196            this.serializer = serializer;
     197        }
     198
     199        @Override
     200        public void serialize(DataOutput out, E value) throws IOException {
     201            //serialize to byte[]
     202            DataOutput2 out2 = new DataOutput2();
     203            serializer.serialize(out2, value);
     204            byte[] b = out2.copyBytes();
     205            CompressLZF.SERIALIZER.serialize(out, b);
     206        }
     207
     208        @Override
     209        public E deserialize(DataInput in, int available) throws IOException {
     210            byte[] b = CompressLZF.SERIALIZER.deserialize(in, available);
     211            DataInput2 in2 = new DataInput2(b);
     212            return serializer.deserialize(in2, b.length);
     213        }
     214    }
    176215}
    177216
Note: See TracChangeset for help on using the changeset viewer.