
org.zoodb.jdo.internal.server.ObjectReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of parent Show documentation
Show all versions of parent Show documentation
ZooDB Java JDO Object Database.
The newest version!
/*
* Copyright 2009-2013 Tilmann Zaeschke. All rights reserved.
*
* This file is part of ZooDB.
*
* ZooDB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZooDB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ZooDB. If not, see .
*
* See the README and COPYING files for further information.
*/
package org.zoodb.jdo.internal.server;
import org.zoodb.jdo.api.impl.DBStatistics;
import org.zoodb.jdo.internal.SerialInput;
import org.zoodb.jdo.internal.server.DiskIO.DATA_TYPE;
import org.zoodb.jdo.internal.util.DBLogger;
import org.zoodb.jdo.internal.util.PrimLongMapLI;
/**
* This class serves as a mediator between the serializer and the file access class.
*
* @author Tilmann Zaeschke
*/
public class ObjectReader implements SerialInput {
private final SerialInput in;
public ObjectReader(StorageChannel file) {
this.in = file.getReader(true);
}
public ObjectReader(SerialInput in) {
this.in = in;
}
@Override
public int readInt() {
return in.readInt();
}
@Override
public long readLong() {
return in.readLong();
}
@Override
public boolean readBoolean() {
return in.readBoolean();
}
@Override
public byte readByte() {
return in.readByte();
}
@Override
public char readChar() {
return in.readChar();
}
@Override
public double readDouble() {
return in.readDouble();
}
@Override
public float readFloat() {
return in.readFloat();
}
@Override
public short readShort() {
return in.readShort();
}
@Override
public void readFully(byte[] array) {
in.readFully(array);
}
@Override
public String readString() {
return in.readString();
}
@Override
public void skipRead(int nBytes) {
in.skipRead(nBytes);
}
public long startReading(int page, int offs) {
//TODO Hmm this is dirty...
((StorageChannelInput)in).seekPage(DATA_TYPE.DATA, page, offs);
if (DBStatistics.isEnabled()) {
statNRead++;
statNReadUnique.put(page, null);
}
return in.getHeaderClassOID();
}
private static final PrimLongMapLI
© 2015 - 2025 Weber Informatics LLC | Privacy Policy