Example usage for java.io DataInput readInt

List of usage examples for java.io DataInput readInt

Introduction

In this page you can find the example usage for java.io DataInput readInt.

Prototype

int readInt() throws IOException;

Source Link

Document

Reads four input bytes and returns an int value.

Usage

From source file:org.apache.bigtop.bigpetstore.generator.PetStoreTransactionInputSplit.java

public void readFields(DataInput dataInputStream) throws IOException {
    records = dataInputStream.readInt();
    state = State.valueOf(dataInputStream.readUTF());
    customerIdRange = Range.between(dataInputStream.readLong(), dataInputStream.readLong());
}

From source file:org.apache.hadoop.hdfs.server.namenode.FSImageSerialization.java

static INodeFileUnderConstruction readINodeUnderConstruction(DataInput in, FSNamesystem fsNamesys,
        int imgVersion) throws IOException {
    byte[] name = readBytes(in);
    long inodeId = LayoutVersion.supports(Feature.ADD_INODE_ID, imgVersion) ? in.readLong()
            : fsNamesys.allocateNewInodeId();
    short blockReplication = in.readShort();
    long modificationTime = in.readLong();
    long preferredBlockSize = in.readLong();

    int numBlocks = in.readInt();
    BlockInfo[] blocks = new BlockInfo[numBlocks];
    Block blk = new Block();
    int i = 0;//from   w  ww .  ja v a 2 s .  c o m
    for (; i < numBlocks - 1; i++) {
        blk.readFields(in);
        blocks[i] = new BlockInfo(blk, blockReplication);
    }
    // last block is UNDER_CONSTRUCTION
    if (numBlocks > 0) {
        blk.readFields(in);
        blocks[i] = new BlockInfoUnderConstruction(blk, blockReplication, BlockUCState.UNDER_CONSTRUCTION,
                null);
    }
    PermissionStatus perm = PermissionStatus.read(in);
    String clientName = readString(in);
    String clientMachine = readString(in);

    // We previously stored locations for the last block, now we
    // just record that there are none
    int numLocs = in.readInt();
    assert numLocs == 0 : "Unexpected block locations";

    return new INodeFileUnderConstruction(inodeId, name, blockReplication, modificationTime, preferredBlockSize,
            blocks, perm, clientName, clientMachine, null);
}

From source file:org.apache.drill.exec.cache.CachedVectorContainer.java

@Override
public void read(DataInput input) throws IOException {
    int len = input.readInt();
    this.data = new byte[len];
    input.readFully(data);//from   w w w.  jav a2s . co m
}

From source file:uk.bl.wa.hadoop.indexer.WritableSolrRecord.java

@Override
public void readFields(DataInput input) throws IOException {
    int length = input.readInt();
    byte[] bytes = new byte[length];
    input.readFully(bytes);//from  w  w w.  j av a2  s.  co  m
    if (this.sr == null) {
        this.sr = SolrRecordFactory.createFactory(null).createRecord();
    }
    this.sr.setSolrDocument((SolrInputDocument) SerializationUtils.deserialize(bytes));
}

From source file:edu.nyu.vida.data_polygamy.scalar_function.Median.java

@Override
public void readFields(DataInput in) throws IOException {
    count = in.readInt();
    int size = in.readInt();
    floatValues = new ArrayList<Float>(size);
    for (int i = 0; i < size; i++)
        floatValues.add(in.readFloat());
}

From source file:org.apache.hadoop.raid.protocol.PolicyList.java

public void readFields(DataInput in) throws IOException {
    int count = in.readInt();
    for (int i = 0; i < count; i++) {
        PolicyInfo p = new PolicyInfo();
        p.readFields(in);//  ww w  . j a  v  a 2 s  .  com
        add(p);
    }
}

From source file:org.apache.hama.bsp.BSPMessageBundle.java

@SuppressWarnings("unchecked")
@Override//from w  ww .  jav  a 2  s.c  o m
public void readFields(DataInput in) throws IOException {
    int num = in.readInt();

    if (num > 0) {
        Class<M> clazz = null;
        try {
            clazz = (Class<M>) Class.forName(in.readUTF());
        } catch (ClassNotFoundException e) {
            LOG.error("Class was not found.", e);
        }

        for (int i = 0; i < num; i++) {
            M msg = ReflectionUtils.newInstance(clazz);
            msg.readFields(in);
            messages.add(msg);
        }
    }
}

From source file:org.apache.rya.reasoning.mr.SchemaWritable.java

@Override
public void readFields(DataInput in) throws IOException {
    int size = in.readInt();
    if (size < 1)
        throw new Error("De-serializtion failed, count is less than one.");
    byte[] bytes = new byte[size];
    in.readFully(bytes);/*  w w w  . j a  v  a2 s. c o  m*/
    // ObjectInputStream stream = new ObjectInputStream(new ByteArrayInputStream(bytes));
    try (final ByteArrayInputStream bais = new ByteArrayInputStream(bytes); //
            final ValidatingObjectInputStream vois = new ValidatingObjectInputStream(bais)
    // this is how you find classes that you missed in the vois.accept() list, below.
    // { @Override protected void invalidClassNameFound(String className) throws java.io.InvalidClassException {
    // System.out.println("vois.accept(" + className + ".class, ");};};
    ) {
        // this is a (hopefully) complete list of classes involved in a Schema to be serialized.
        // if a useful class is missing, throws an InvalidClassException.
        vois.accept(java.util.ArrayList.class, //
                org.apache.rya.reasoning.OwlProperty.class, //
                java.util.HashSet.class, //
                org.apache.rya.reasoning.OwlClass.class, //
                org.eclipse.rdf4j.model.impl.SimpleIRI.class, //
                org.eclipse.rdf4j.model.impl.SimpleBNode.class);
        try {
            Iterable<?> propList = (Iterable<?>) vois.readObject();
            Iterable<?> classList = (Iterable<?>) vois.readObject();
            for (Object p : propList) {
                OwlProperty prop = (OwlProperty) p;
                properties.put(prop.getURI(), prop);
            }
            for (Object c : classList) {
                OwlClass owlClass = (OwlClass) c;
                classes.put(owlClass.getURI(), owlClass);
            }
        } catch (ClassNotFoundException e) {
            throw new Error("While reading a schema object.");
        }
    }
}

From source file:org.apache.mahout.classifier.df.node.CategoricalNode.java

@Override
public void readFields(DataInput in) throws IOException {
    attr = in.readInt();
    values = DFUtils.readDoubleArray(in);
    childs = DFUtils.readNodeArray(in);/* w  w w .  ja va2  s.c o  m*/
}

From source file:com.vmware.demo.sgf.tests.domain.PersonKey.java

@Override
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
    id = in.readInt();
    surname = in.readUTF();//from   w w w.j a v a 2  s .  c  om
}