org.mapdb.DataInput2 Java Examples

The following examples show how to use org.mapdb.DataInput2. 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: CacheRevisionSerializer.java    From git-as-svn with GNU General Public License v2.0 6 votes vote down vote up
@Override
public CacheRevision deserialize(@NotNull DataInput2 input, int available) throws IOException {
  final ObjectId objectId = input.readBoolean() ? ObjectIdSerializer.instance.deserialize(input, available) : null;

  final Map<String, String> renames = new TreeMap<>();
  final int renamesCount = input.readInt();
  for (int i = 0; i < renamesCount; ++i) {
    renames.put(Serializer.STRING.deserialize(input, available), Serializer.STRING.deserialize(input, available));
  }

  final Map<String, CacheChange> fileChange = new TreeMap<>();
  final int fileChangeCount = input.readInt();
  for (int i = 0; i < fileChangeCount; ++i) {
    final String name = Serializer.STRING.deserialize(input, available);
    final ObjectId oldFile = input.readBoolean() ? ObjectIdSerializer.instance.deserialize(input, available) : null;
    final ObjectId newFile = input.readBoolean() ? ObjectIdSerializer.instance.deserialize(input, available) : null;
    fileChange.put(name, new CacheChange(oldFile, newFile));
  }

  return new CacheRevision(objectId, renames, fileChange);
}
 
Example #3
Source File: MapSerializer.java    From NNAnalytics with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, Long> deserialize(@NotNull DataInput2 input, int available)
    throws IOException {
  int size = input.readInt();
  Map<String, Long> map = new HashMap<>(size);
  for (int i = 0; i < size; i++) {
    map.put(input.readUTF(), input.readLong());
  }
  return map;
}
 
Example #4
Source File: MapSerializer.java    From ipst with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public Object valueArrayDeserialize(DataInput2 in, int size) throws IOException {
    Objects.requireNonNull(in);
    List<TreeMap> maplist = new ArrayList();
    for (int i = 0; i < size; i++) {
        maplist.add((TreeMap) deserialize(in, 1));
    }
    return maplist.toArray();
}
 
Example #5
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 #6
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;
}
 
Example #7
Source File: MapDBTools.java    From OSPREY3 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int[] deserialize(@NotNull DataInput2 in, int available)
	throws IOException {
	int[] data = new int[numPos];
	for (int i=0; i<numPos; i++) {
		data[i] = encoding.read(in) - 1;
	}
	return data;
}
 
Example #8
Source File: MapDBTools.java    From OSPREY3 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public MathTools.BigDecimalBounds deserialize(@NotNull DataInput2 in, int available)
	throws IOException {
	return new MathTools.BigDecimalBounds(
		s.deserialize(in, available),
		s.deserialize(in, available)
	);
}
 
Example #9
Source File: LockDescSerializer.java    From git-as-svn with GNU General Public License v2.0 5 votes vote down vote up
@Override
public LockDesc deserialize(@NotNull DataInput2 input, int available) throws IOException {
  final String path = input.readUTF();
  final String branch = input.readBoolean() ? input.readUTF() : null;
  final String hash = input.readBoolean() ? input.readUTF() : null;
  final String token = input.readUTF();
  final String owner = input.readBoolean() ? input.readUTF() : null;
  final String comment = input.readBoolean() ? input.readUTF() : null;
  final long created = input.readLong();
  return new LockDesc(path, branch, hash, token, owner, comment, created);
}
 
Example #10
Source File: PartitionedEventGroupSerializer.java    From eagle with Apache License 2.0 4 votes vote down vote up
@Override
public Object valueArrayDeserialize(DataInput2 in, int size) throws IOException {
    return delegate.valueArrayDeserialize(in, size);
}
 
Example #11
Source File: PartitionedEventGroupSerializer.java    From eagle with Apache License 2.0 4 votes vote down vote up
@Override
public PartitionedEvent[] deserialize(@NotNull DataInput2 input, int available) throws IOException {
    return deserialize(delegate.deserialize(input, available));
}
 
Example #12
Source File: MapDBTools.java    From OSPREY3 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Sequence deserialize(@NotNull DataInput2 in, int available)
	throws IOException {
	return makeSequenceFromId(in.readUTF());
}
 
Example #13
Source File: MapDBTools.java    From OSPREY3 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public BigDecimal deserialize(@NotNull DataInput2 in, int available)
	throws IOException {
	return io.read(in);
}
 
Example #14
Source File: ObjectIdSerializer.java    From git-as-svn with GNU General Public License v2.0 4 votes vote down vote up
@Override
public ObjectId deserialize(@NotNull DataInput2 input, int available) throws IOException {
  final byte[] raw = new byte[fixedSize()];
  input.readFully(raw);
  return ObjectId.fromRaw(raw);
}