use of org.apache.hop.core.exception.HopEofException in project hop by apache.
the class ValueMetaAvroRecord method readData.
@Override
public Object readData(DataInputStream inputStream) throws HopFileException, SocketTimeoutException {
try {
// Is the value NULL?
if (inputStream.readBoolean()) {
// done
return null;
}
//
if (schema == null) {
throw new HopFileException("An Avro schema is needed to read a GenericRecord from an input stream");
}
BinaryDecoder binaryDecoder = DecoderFactory.get().directBinaryDecoder(inputStream, null);
GenericDatumReader<GenericRecord> datumReader = new GenericDatumReader<>(schema);
GenericRecord genericRecord = datumReader.read(null, binaryDecoder);
return genericRecord;
} catch (EOFException e) {
throw new HopEofException(e);
} catch (SocketTimeoutException e) {
throw e;
} catch (IOException e) {
throw new HopFileException(toString() + " : Unable to read value data from input stream", e);
}
}
use of org.apache.hop.core.exception.HopEofException in project hop by apache.
the class ValueMetaFactory method loadValueMeta.
public static IValueMeta loadValueMeta(DataInputStream inputStream) throws HopFileException {
try {
int type = inputStream.readInt();
IValueMeta valueMeta = createValueMeta(type);
valueMeta.readMetaData(inputStream);
return valueMeta;
} catch (EOFException e) {
throw new HopEofException(e);
} catch (Exception e) {
throw new HopFileException("Unable to read value metadata from input stream", e);
}
}
use of org.apache.hop.core.exception.HopEofException in project hop by apache.
the class ValueMetaTimestamp method readData.
@Override
public Object readData(DataInputStream inputStream) throws HopFileException, HopEofException, SocketTimeoutException {
try {
// Is the value NULL?
if (inputStream.readBoolean()) {
// done
return null;
}
switch(storageType) {
case STORAGE_TYPE_NORMAL:
// Handle Content -- only when not NULL
long time = inputStream.readLong();
int nanos = inputStream.readInt();
Timestamp timestamp = new Timestamp(time);
timestamp.setNanos(nanos);
return timestamp;
case STORAGE_TYPE_BINARY_STRING:
return readBinaryString(inputStream);
case STORAGE_TYPE_INDEXED:
// just an index: 4-bytes should be enough.
return readSmallInteger(inputStream);
default:
throw new HopFileException(toString() + " : Unknown storage type " + getStorageType());
}
} catch (EOFException e) {
throw new HopEofException(e);
} catch (SocketTimeoutException e) {
throw e;
} catch (IOException e) {
throw new HopFileException(toString() + " : Unable to read value timestamp data from input stream", e);
}
}
use of org.apache.hop.core.exception.HopEofException in project hop by apache.
the class CubeInput method processRow.
@Override
public boolean processRow() throws HopException {
if (first) {
first = false;
realRowLimit = Const.toInt(resolve(meta.getRowLimit()), 0);
}
try {
Object[] r = data.meta.readData(data.dis);
// fill the rowset(s). (sleeps if full)
putRow(data.meta, r);
incrementLinesInput();
if (realRowLimit > 0 && getLinesInput() >= realRowLimit) {
// finished!
setOutputDone();
return false;
}
} catch (HopEofException eof) {
setOutputDone();
return false;
} catch (SocketTimeoutException e) {
// shouldn't happen on files
throw new HopException(e);
}
if (checkFeedback(getLinesInput())) {
if (log.isBasic()) {
logBasic(BaseMessages.getString(PKG, "CubeInput.Log.LineNumber") + getLinesInput());
}
}
return true;
}
Aggregations