Example usage for java.io DataInput readLong

List of usage examples for java.io DataInput readLong

Introduction

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

Prototype

long readLong() throws IOException;

Source Link

Document

Reads eight input bytes and returns a long value.

Usage

From source file:com.chinamobile.bcbsp.sync.SuperStepReportContainer.java

@Override
public void readFields(DataInput in) throws IOException {
    this.partitionId = in.readInt();
    this.stageFlag = in.readInt();
    int count = in.readInt();
    this.dirFlag = new String[count];
    for (int i = 0; i < count; i++) {
        this.dirFlag[i] = Text.readString(in);
    }/*w  w w  . j a v a2s  .  co  m*/
    this.judgeFlag = in.readLong();
    this.localBarrierNum = in.readInt();
    this.port1 = in.readInt();
    this.port2 = in.readInt();
    count = in.readInt();
    this.aggValues = new String[count];
    for (int i = 0; i < count; i++) {
        this.aggValues[i] = Text.readString(in);
    }
    this.staffRunTime = in.readLong();
    this.sid = in.readInt();
    this.currentSuperStep = in.readInt();
    this.migrateCost = in.readLong();
    this.splitEdgefactor = in.readFloat();
}

From source file:com.chinamobile.bcbsp.util.StaffStatus.java

/**
 * deserialize/*from   w  w  w . j av  a  2 s  .c o  m*/
 *
 * @param in Reads some bytes from an input.
 */
@Override
public void readFields(DataInput in) throws IOException {
    this.jobId.readFields(in);
    this.staffId.readFields(in);
    this.progress = in.readInt();
    this.runState = WritableUtils.readEnum(in, State.class);
    this.stateString = Text.readString(in);
    this.phase = WritableUtils.readEnum(in, Phase.class);
    this.startTime = in.readLong();
    this.finishTime = in.readLong();
    this.superstepCount = in.readLong();
    this.faultFlag = in.readInt();
    if (this.faultFlag == 1) {
        this.fault.readFields(in);
    }
    this.recovery = in.readBoolean();
    this.currentSSTime = in.readLong();
    this.workerManager = Text.readString(in);
}

From source file:com.mobicage.rogerthat.registration.RegistrationWizard2.java

@SuppressWarnings("unchecked")
@Override//ww  w  .  j av a2s .  c  o  m
public void readFromPickle(int version, DataInput in) throws IOException, PickleException {
    T.UI();
    super.readFromPickle(version, in);
    boolean set = in.readBoolean();
    if (set)
        mCredentials = new Credentials(new Pickle(in.readInt(), in));
    set = in.readBoolean();
    mEmail = set ? in.readUTF() : null;
    mTimestamp = in.readLong();
    mRegistrationId = in.readUTF();
    mInGoogleAuthenticationProcess = in.readBoolean();
    mInstallationId = in.readUTF();
    // A version bump was forgotten when serializing mDeviceId, so we need a try/catch
    try {
        mDeviceId = in.readUTF();
    } catch (EOFException e) {
        mDeviceId = null;
    }
    if (version >= 2) {
        try {
            set = in.readBoolean();
            mBeaconRegions = set
                    ? new GetBeaconRegionsResponseTO((Map<String, Object>) JSONValue.parse(in.readUTF()))
                    : null;

            set = in.readBoolean();
            if (set) {
                String detectedBeacons = in.readUTF();
                JSONArray db1 = (JSONArray) JSONValue.parse(detectedBeacons);
                if (db1 != null) {
                    mDetectedBeacons = new HashSet<String>();
                    for (int i = 0; i < db1.size(); i++) {
                        mDetectedBeacons.add((String) db1.get(i));
                    }
                } else {
                    mDetectedBeacons = null;
                }
            } else {
                mDetectedBeacons = null;
            }
        } catch (IncompleteMessageException e) {
            L.bug(e);
        }
    }
}

From source file:com.marklogic.tree.ExpandedTree.java

@Override
public void readFields(DataInput in) throws IOException {
    uriKey = in.readLong();
    uniqKey = in.readLong();// ww  w.  j  a  v  a 2 s.  c om
    linkKey = in.readLong();
    numKeys = in.readInt();
    if (numKeys > 0) {
        keys = new long[numKeys];
        for (int i = 0; i < numKeys; i++) {
            keys[i] = in.readLong();
        }
    }
    int atomDataLen = in.readInt();
    if (atomDataLen > 0) {
        atomData = new byte[atomDataLen];
        for (int i = 0; i < atomDataLen; i++) {
            atomData[i] = in.readByte();
        }
    }
    atomLimit = in.readInt();
    if (atomLimit > 0) {
        atomIndex = new int[atomLimit + 1];
        for (int i = 0; i < atomLimit + 1; i++) {
            atomIndex[i] = in.readInt();
        }
    }
    int nodeNameNameAtomLen = in.readInt();
    if (nodeNameNameAtomLen > 0) {
        nodeNameNameAtom = new int[nodeNameNameAtomLen];
        nodeNameNamespaceAtom = new int[nodeNameNameAtomLen];
        for (int i = 0; i < nodeNameNameAtomLen; i++) {
            nodeNameNameAtom[i] = in.readInt();
            nodeNameNamespaceAtom[i] = in.readInt();
        }
    }
    numNodeReps = in.readInt();
    if (numNodeReps > 0) {
        nodes = new NodeImpl[numNodeReps];
        nodeOrdinal = new long[numNodeReps];
        nodeKind = new byte[numNodeReps];
        nodeRepID = new int[numNodeReps];
        nodeParentNodeRepID = new int[numNodeReps];
        for (int i = 0; i < numNodeReps; i++) {
            nodeOrdinal[i] = in.readLong();
            nodeKind[i] = in.readByte();
            nodeRepID[i] = in.readInt();
            nodeParentNodeRepID[i] = in.readInt();
        }
    }
    int numElemNodeReps = in.readInt();
    if (numElemNodeReps > 0) {
        elemNodeNodeNameRepID = new int[numElemNodeReps];
        elemNodeAttrNodeRepID = new int[numElemNodeReps];
        elemNodeChildNodeRepID = new int[numElemNodeReps];
        elemNodeElemDeclRepID = new int[numElemNodeReps];
        elemNodeNumAttributes = new int[numElemNodeReps];
        elemNodeNumDefaultAttrs = new int[numElemNodeReps];
        elemNodeNumChildren = new int[numElemNodeReps];
        elemNodeFlags = new int[numElemNodeReps];
        for (int i = 0; i < numElemNodeReps; i++) {
            elemNodeNodeNameRepID[i] = in.readInt();
            elemNodeAttrNodeRepID[i] = in.readInt();
            elemNodeChildNodeRepID[i] = in.readInt();
            elemNodeElemDeclRepID[i] = in.readInt();
            elemNodeNumAttributes[i] = in.readInt();
            elemNodeNumDefaultAttrs[i] = in.readInt();
            elemNodeNumChildren[i] = in.readInt();
            elemNodeFlags[i] = in.readInt();
        }
    }
    int numAttrNodeReps = in.readInt();
    if (numAttrNodeReps > 0) {
        attrNodeNodeNameRepID = new int[numAttrNodeReps];
        attrNodeTextRepID = new int[numAttrNodeReps];
        attrNodeAttrDeclRepID = new int[numAttrNodeReps];
        for (int i = 0; i < numAttrNodeReps; i++) {
            attrNodeNodeNameRepID[i] = in.readInt();
            attrNodeTextRepID[i] = in.readInt();
            attrNodeAttrDeclRepID[i] = in.readInt();
        }
    }
    numLinkNodeReps = in.readInt();
    if (numLinkNodeReps > 0) {
        linkNodeKey = new long[numLinkNodeReps];
        linkNodeNodeCount = new long[numLinkNodeReps];
        linkNodeNodeNameRepID = new int[numLinkNodeReps];
        linkNodeNodeRepID = new int[numLinkNodeReps];
        for (int i = 0; i < numLinkNodeReps; i++) {
            linkNodeKey[i] = in.readLong();
            linkNodeNodeCount[i] = in.readLong();
            linkNodeNodeNameRepID[i] = in.readInt();
            linkNodeNodeRepID[i] = in.readInt();
        }
    }
    int numDocNodeReps = in.readInt();
    if (numDocNodeReps > 0) {
        docNodeTextRepID = new int[numDocNodeReps];
        docNodeChildNodeRepID = new int[numDocNodeReps];
        docNodeNumChildren = new int[numDocNodeReps];
        for (int i = 0; i < numDocNodeReps; i++) {
            docNodeTextRepID[i] = in.readInt();
            docNodeChildNodeRepID[i] = in.readInt();
            docNodeNumChildren[i] = in.readInt();
        }
    }
    int numPINodeReps = in.readInt();
    if (numPINodeReps > 0) {
        piNodeTargetAtom = new int[numPINodeReps];
        piNodeTextRepID = new int[numPINodeReps];
        for (int i = 0; i < numPINodeReps; i++) {
            piNodeTargetAtom[i] = in.readInt();
            piNodeTextRepID[i] = in.readInt();
        }
    }
    numNSNodeReps = in.readInt();
    if (numNSNodeReps > 0) {
        nsNodeOrdinal = new long[numNSNodeReps];
        nsNodePrevNSNodeRepID = new int[numNSNodeReps];
        nsNodePrefixAtom = new int[numNSNodeReps];
        nsNodeUriAtom = new int[numNSNodeReps];
        for (int i = 0; i < numNSNodeReps; i++) {
            nsNodeOrdinal[i] = in.readLong();
            nsNodePrevNSNodeRepID[i] = in.readInt();
            nsNodePrefixAtom[i] = in.readInt();
            nsNodeUriAtom[i] = in.readInt();
        }
    }
    // skip permission node since it's not exposed to the API
    uriTextRepID = in.readInt();
    colsTextRepID = in.readInt();
    numTextReps = in.readInt();
    if (numTextReps > 0) {
        textReps = new int[numTextReps];
        for (int i = 0; i < numTextReps; i++) {
            textReps[i] = in.readInt();
        }
    }
    int numArrayNodeReps = in.readInt();
    if (numArrayNodeReps > 0) {
        arrayNodeTextRepID = new int[numArrayNodeReps];
        arrayNodeChildNodeRepID = new int[numArrayNodeReps];
        arrayNodeNumChildren = new int[numArrayNodeReps];
        for (int i = 0; i < numArrayNodeReps; i++) {
            arrayNodeTextRepID[i] = in.readInt();
            arrayNodeChildNodeRepID[i] = in.readInt();
            arrayNodeNumChildren[i] = in.readInt();
        }
    }
    int numDoubles = in.readInt();
    if (numDoubles > 0) {
        doubles = new double[numDoubles];
        for (int i = 0; i < numDoubles; i++) {
            doubles[i] = in.readDouble();
        }
    }
}

From source file:com.mapr.hbase.support.objects.MHRegionInfo090x.java

@Override
public void readFields(DataInput in) throws IOException {
    super.readFields(in);
    this.endKey = Bytes.readByteArray(in);
    this.offLine = in.readBoolean();
    this.regionId = in.readLong();
    this.regionName = Bytes.readByteArray(in);
    this.regionNameStr = Bytes.toStringBinary(this.regionName);
    this.split = in.readBoolean();
    this.startKey = Bytes.readByteArray(in);
    try {//from  w  ww  .  ja  va2 s .c o  m
        this.tableDesc.readFields(in);
    } catch (EOFException eofe) {
        throw new IOException("HTD not found in input buffer");
    }
    this.hashCode = in.readInt();
}

From source file:edu.msu.cme.rdp.readseq.readers.core.SFFCore.java

private void parseCommonHeader() throws IOException {
    if (commonHeader != null) {
        throw new IOException("Common header already initialized");
    }/* w  ww  .  j a v  a 2 s.co m*/
    commonHeader = new CommonHeader();

    DataInput seqFile = super.getDataInput();

    commonHeader.magicNumber = seqFile.readInt();

    if (commonHeader.magicNumber != SeqUtils.SFF_MAGIC_NUMBER) {
        throw new IOException("Not an SFF File");
    }

    commonHeader.version = seqFile.readInt();

    if (commonHeader.version != 1) {
        throw new IOException("Cannot parse v" + commonHeader.version + " sff files");
    }

    commonHeader.indexOffset = seqFile.readLong();
    commonHeader.indexLength = seqFile.readInt();
    commonHeader.numReads = seqFile.readInt();
    commonHeader.headerLength = seqFile.readShort();
    commonHeader.keyLength = seqFile.readShort();
    commonHeader.flowLength = seqFile.readShort();
    commonHeader.flowgramFormat = seqFile.readByte();

    byte[] flow = new byte[commonHeader.flowLength];
    super.read(flow);
    commonHeader.flow = new String(flow);

    byte[] key = new byte[commonHeader.keyLength];
    super.read(key);
    commonHeader.key = new String(key);

    int readBytes = COMMON_HEADER_STATIC_SIZE + flow.length + key.length;

    alignToBoundary(readBytes);

    if (super.isSeekable() && commonHeader.indexOffset > commonHeader.headerLength) {
        readIndex();
    }
}

From source file:dk.statsbiblioteket.util.LineReaderTest.java

public void testSample(String type, DataInput in) throws Exception {
    assertEquals("Int 1 should work for " + type, 12345, in.readInt());
    assertEquals("Int 2 should work for " + type, -87, in.readInt());
    assertEquals("Long should work for " + type, 123456789L, in.readLong());
    assertEquals("String 1 should work for " + type, "Hello World!", in.readLine());
    assertEquals("String 2 should work for " + type, "Another world", in.readLine());
    assertEquals("Float should work for " + type, 0.5f, in.readFloat());
    assertEquals("Boolean 1 should work for " + type, true, in.readBoolean());
    assertEquals("Boolean 2 should work for " + type, false, in.readBoolean());
    assertEquals("Byte 1 should work for " + type, (byte) 12, in.readByte());
    assertEquals("Byte 2 should work for " + type, (byte) -12, in.readByte());
    assertEquals("Unsigned byte should work for " + type, 129, in.readUnsignedByte());
    assertEquals("Short should work for " + type, -4567, in.readShort());
    byte[] loaded = new byte[5];
    byte[] expected = new byte[] { (byte) 'A', (byte) 'S', (byte) 'C', (byte) 'I', (byte) 'I' };
    in.readFully(loaded);//from w  ww .  j  a va 2s  . c om
    for (int i = 0; i < loaded.length; i++) {
        assertEquals("Byte-stored string should be equal at byte " + i + " for " + type, expected[i],
                loaded[i]);
    }
}

From source file:com.linkedin.cubert.io.rubix.RubixFile.java

@SuppressWarnings("unchecked")
public List<KeyData<K>> getKeyData() throws IOException, ClassNotFoundException {
    if (keyData != null)
        return keyData;

    final FileSystem fs = FileSystem.get(conf);
    keyData = new ArrayList<KeyData<K>>();

    final long filesize = fs.getFileStatus(path).getLen();
    FSDataInputStream in = fs.open(path);

    /* The last long in the file is the start position of the trailer section */
    in.seek(filesize - 8);/*ww w.  ja v a 2  s .com*/
    long metaDataStartPos = in.readLong();

    in.seek(metaDataStartPos);

    ObjectMapper mapper = new ObjectMapper();
    metadataJson = mapper.readValue(in.readUTF(), JsonNode.class);

    int keySectionSize = in.readInt();

    // load the key section
    byte[] keySection = new byte[keySectionSize];

    in.seek(filesize - keySectionSize - 8);
    in.read(keySection, 0, keySectionSize);
    in.close();

    ByteArrayInputStream bis = new ByteArrayInputStream(keySection);
    DataInput dataInput = new DataInputStream(bis);

    int numberOfBlocks = metadataJson.get("numberOfBlocks").getIntValue();

    // load the key section
    keyClass = (Class<K>) ClassCache.forName(JsonUtils.getText(metadataJson, "keyClass"));
    valueClass = (Class<V>) ClassCache.forName(JsonUtils.getText(metadataJson, "valueClass"));

    SerializationFactory serializationFactory = new SerializationFactory(conf);
    Deserializer<K> deserializer = serializationFactory.getDeserializer(keyClass);

    deserializer.open(bis);

    while (bis.available() > 0 && numberOfBlocks > 0) {
        K key = deserializer.deserialize(null);

        long offset = dataInput.readLong();
        long blockId = dataInput.readLong();
        long numRecords = dataInput.readLong();

        keyData.add(new KeyData<K>(key, offset, 0, numRecords, blockId));
        numberOfBlocks--;
    }

    // Assign length to each keydata entry
    int numEntries = keyData.size();
    for (int i = 1; i < numEntries; i++) {
        KeyData<K> prev = keyData.get(i - 1);
        KeyData<K> current = keyData.get(i);

        prev.setLength(current.getOffset() - prev.getOffset());
    }

    if (numEntries > 0) {
        KeyData<K> last = keyData.get(numEntries - 1);
        last.setLength(metaDataStartPos - last.offset);
    }

    return keyData;
}

From source file:com.mapr.hbase.support.objects.MHRegionInfo.java

@Override
public void readFields(DataInput in) throws IOException {
    // Read the single version byte.  We don't ask the super class do it
    // because freaks out if its not the current classes' version.  This method
    // can deserialize version 0 and version 1 of HRI.
    byte version = in.readByte();
    if (version == 0) {
        // This is the old HRI that carried an HTD.  Migrate it.  The below
        // was copied from the old 0.90 HRI readFields.
        this.endKey = Bytes.readByteArray(in);
        this.offLine = in.readBoolean();
        this.regionId = in.readLong();
        this.regionName = Bytes.readByteArray(in);
        this.regionNameStr = Bytes.toStringBinary(this.regionName);
        this.split = in.readBoolean();
        this.startKey = Bytes.readByteArray(in);
        try {//ww w  .j  av  a2  s. com
            tableDesc = new HTableDescriptor();
            tableDesc.readFields(in);
            this.tableName = tableDesc.getName();
        } catch (EOFException eofe) {
            throw new IOException("HTD not found in input buffer", eofe);
        }
        this.hashCode = in.readInt();
    } else if (getVersion() == version) {
        this.endKey = Bytes.readByteArray(in);
        this.offLine = in.readBoolean();
        this.regionId = in.readLong();
        this.regionName = Bytes.readByteArray(in);
        this.regionNameStr = Bytes.toStringBinary(this.regionName);
        this.split = in.readBoolean();
        this.startKey = Bytes.readByteArray(in);
        this.tableName = Bytes.readByteArray(in);
        this.hashCode = in.readInt();
    } else {
        throw new IOException("Non-migratable/unknown version=" + getVersion());
    }
}

From source file:com.cloudera.sqoop.lib.LobRef.java

@Override
public void readFields(DataInput in) throws IOException {
    // The serialization format for this object is:
    // boolean isExternal
    // if true, then:
    //   a string identifying the external storage type
    //   and external-storage-specific data.
    // if false, then we use readFieldsInternal() to allow BlobRef/ClobRef
    // to serialize as it sees fit.
    ///*from   w  w w . ja  va  2s .  com*/
    // Currently the only external storage supported is LobFile, identified
    // by the string "lf". This serializes with the filename (as a string),
    // followed by a long-valued offset and a long-valued length.

    boolean isExternal = in.readBoolean();
    if (isExternal) {
        this.realData = null;

        String storageType = Text.readString(in);
        if (!storageType.equals("lf")) {
            throw new IOException("Unsupported external LOB storage code: " + storageType);
        }

        // Storage type "lf" is LobFile: filename, offset, length.
        this.fileName = Text.readString(in);
        this.offset = in.readLong();
        this.length = in.readLong();
    } else {
        readFieldsInternal(in);

        this.fileName = null;
        this.offset = 0;
        this.length = 0;
    }
}