Example usage for java.io DataOutput writeLong

List of usage examples for java.io DataOutput writeLong

Introduction

In this page you can find the example usage for java.io DataOutput writeLong.

Prototype

void writeLong(long v) throws IOException;

Source Link

Document

Writes a long value, which is comprised of eight bytes, to the output stream.

Usage

From source file:org.apache.marmotta.kiwi.io.KiWiIO.java

/**
 * Efficiently serialize a KiWiBooleanLiteral to a DataOutput destination.
 *
 * @param out the destination/*from   w w  w .ja v a  2s .c  o  m*/
 * @param literal the KiWiBooleanLiteral to serialize
 * @throws IOException
 */
public static void writeBooleanLiteral(DataOutput out, KiWiBooleanLiteral literal) throws IOException {
    if (literal == null) {
        out.writeLong(-1L);
    } else {
        out.writeLong(literal.getId());
        out.writeBoolean(literal.booleanValue());
        writeURI(out, literal.getType());
        out.writeLong(literal.getCreated().getTime());
    }
}

From source file:org.apache.marmotta.kiwi.io.KiWiIO.java

/**
 * Efficiently serialize a KiWiStringLiteral to a DataOutput destination.
 *
 * @param out the destination//from w  w w .j  a v  a  2  s.co m
 * @param literal the KiWiStringLiteral to serialize
 * @throws IOException
 */
public static void writeStringLiteral(DataOutput out, KiWiStringLiteral literal) throws IOException {
    if (literal == null) {
        out.writeLong(-1L);
    } else {
        out.writeLong(literal.getId());
        writeContent(out, literal.getContent());
        if (langTable.containsKey(literal.getLanguage())) {
            out.writeByte(langTable.get(literal.getLanguage()));
        } else {
            out.writeByte(LANG_UNKNOWN);
            DataIO.writeString(out, literal.getLanguage());
        }
        writeURI(out, literal.getType());
        out.writeLong(literal.getCreated().getTime());
    }
}

From source file:org.apache.marmotta.kiwi.io.KiWiIO.java

/**
 * Efficiently serialize a KiWiUriResource to a DataOutput destination, using prefix compression for commonly used
 * prefixes.//from  ww  w.  j a  va 2  s .  c  om
 *
 * @param out  DataOutput destination
 * @param uri  KiWiUriResource to serialize
 * @throws IOException
 */
public static void writeURI(DataOutput out, KiWiUriResource uri) throws IOException {
    if (uri == null) {
        out.writeLong(-1L);
    } else {
        out.writeLong(uri.getId());

        // compression for commonly used constant prefixes
        if (uri.stringValue().startsWith(XSD.NAMESPACE)) {
            out.writeByte(PREFIX_XSD);
            DataIO.writeString(out, uri.stringValue().substring(XSD.NAMESPACE.length()));
        } else if (uri.stringValue().startsWith(RDF.NAMESPACE)) {
            out.writeByte(PREFIX_RDF);
            DataIO.writeString(out, uri.stringValue().substring(RDF.NAMESPACE.length()));
        } else if (uri.stringValue().startsWith(RDFS.NAMESPACE)) {
            out.writeByte(PREFIX_RDFS);
            DataIO.writeString(out, uri.stringValue().substring(RDFS.NAMESPACE.length()));
        } else if (uri.stringValue().startsWith(SKOS.NAMESPACE)) {
            out.writeByte(PREFIX_SKOS);
            DataIO.writeString(out, uri.stringValue().substring(SKOS.NAMESPACE.length()));
        } else if (uri.stringValue().startsWith(DC.NAMESPACE)) {
            out.writeByte(PREFIX_DC);
            DataIO.writeString(out, uri.stringValue().substring(DC.NAMESPACE.length()));
        } else if (uri.stringValue().startsWith(DCTERMS.NAMESPACE)) {
            out.writeByte(PREFIX_DCT);
            DataIO.writeString(out, uri.stringValue().substring(DCTERMS.NAMESPACE.length()));
        } else if (uri.stringValue().startsWith(OWL.NAMESPACE)) {
            out.writeByte(PREFIX_OWL);
            DataIO.writeString(out, uri.stringValue().substring(OWL.NAMESPACE.length()));
        } else if (uri.stringValue().startsWith(SCHEMA.NAMESPACE)) {
            out.writeByte(PREFIX_SCHEMA);
            DataIO.writeString(out, uri.stringValue().substring(SCHEMA.NAMESPACE.length()));
        } else if (uri.stringValue().startsWith(NS_REDLINK)) {
            out.writeByte(PREFIX_REDLINK);
            DataIO.writeString(out, uri.stringValue().substring(NS_REDLINK.length()));
        } else if (uri.stringValue().startsWith(NS_DBPEDIA)) {
            out.writeByte(PREFIX_DBPEDIA);
            DataIO.writeString(out, uri.stringValue().substring(NS_DBPEDIA.length()));
        } else if (uri.stringValue().startsWith(NS_FREEBASE)) {
            out.writeByte(PREFIX_FREEBASE);
            DataIO.writeString(out, uri.stringValue().substring(NS_FREEBASE.length()));
        } else if (uri.stringValue().startsWith(HTTP_LOCALHOST)) {
            out.writeByte(PREFIX_LOCAL);
            DataIO.writeString(out, uri.stringValue().substring(HTTP_LOCALHOST.length()));
        } else {
            out.writeByte(PREFIX_UNKNOWN);
            DataIO.writeString(out, uri.stringValue());
        }

        out.writeLong(uri.getCreated().getTime());
    }
}

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

/** Serialize an {@link INodeFileAttributes}. */
public static void writeINodeFileAttributes(INodeFileAttributes file, DataOutput out) throws IOException {
    LOG.info("== Inside writeINodeFileAttributes() ==");
    LOG.info("Parameters count and cached");
    LOG.info("ACCESSCNT " + file.getAccessCount());
    LOG.info("CACHED " + file.getIsCached());

    writeLocalName(file, out);/* w w  w  . j a va2 s  .com*/
    writePermissionStatus(file, out);
    out.writeLong(file.getModificationTime());
    out.writeLong(file.getAccessTime());

    out.writeShort(file.getFileReplication());
    out.writeLong(file.getPreferredBlockSize());
    out.writeLong(file.getAccessCount());
    out.writeInt(file.getIsCached());
}

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

/**
 * Serialize a {@link INodeFile} node/*from  ww  w .j ava2s .co  m*/
 * @param node The node to write
 * @param out The {@link DataOutputStream} where the fields are written
 * @param writeBlock Whether to write block information
 */
public static void writeINodeFile(INodeFile file, DataOutput out, boolean writeUnderConstruction)
        throws IOException {
    LOG.info("== Inside writeINodeFile() ==");
    LOG.info("Parameters count and cached logged into FSImage");
    LOG.info("ACCESSCNT " + file.getAccessCount());
    LOG.info("CACHED " + file.getIsCached());
    writeLocalName(file, out);
    out.writeLong(file.getId());
    out.writeShort(file.getFileReplication());
    out.writeLong(file.getModificationTime());
    out.writeLong(file.getAccessTime());
    out.writeLong(file.getPreferredBlockSize());

    writeBlocks(file.getBlocks(), out);
    SnapshotFSImageFormat.saveFileDiffList(file, out);

    if (writeUnderConstruction) {
        if (file instanceof INodeFileUnderConstruction) {
            out.writeBoolean(true);
            final INodeFileUnderConstruction uc = (INodeFileUnderConstruction) file;
            writeString(uc.getClientName(), out);
            writeString(uc.getClientMachine(), out);
        } else {
            out.writeBoolean(false);
        }
    }

    writePermissionStatus(file, out);
    out.writeLong(file.getAccessCount());
    out.writeInt(file.getIsCached());
}

From source file:org.apache.hadoop.hdfs.server.datanode.BlockCrcInfoWritable.java

@Override
public void write(DataOutput out) throws IOException {
    out.writeLong(blockId);
    out.writeLong(blockGenStamp);//  w w w. ja  v a  2s.  com
    out.writeInt(blockCrc);
}

From source file:com.sirius.hadoop.job.onlinetime.OnlineRecord.java

@Override
public void write(DataOutput out) throws IOException {
    out.writeLong(onlineTime);
    out.writeLong(offlineTime);//w w w  . j  a  v  a  2s.  c  om
    out.writeLong(cost);

}

From source file:org.apache.hadoop.hive.jdbc.storagehandler.JdbcDBInputSplit.java

/** {@inheritDoc} */

public void write(DataOutput output) throws IOException {
    output.writeLong(this.start);
    output.writeLong(this.end);
}

From source file:org.apache.cassandra.db.TimestampClock.java

public void serialize(IClock tc, DataOutput out) throws IOException {
    out.writeLong(((TimestampClock) tc).timestamp());
}

From source file:org.springdata.ehcache.core.Book.java

@Override
public void write(DataOutput out) throws IOException {
    out.writeLong(id);
    out.writeUTF(author);//  w  w  w  .j  av a2  s.  c  o m
    out.writeDouble(price);
}