Code example for DataInput

Methods: readIntreadLongreadUnsignedByte

0
        return deserialize(dis, (int) (System.currentTimeMillis() / 1000));
    } 
 
    public Column deserialize(DataInput dis, int expireBefore) throws IOException
    { 
        ByteBuffer name = ByteBufferUtil.readWithShortLength(dis);
        if (name.remaining() <= 0)
            throw new CorruptColumnException("invalid column name length " + name.remaining());
 
        int b = dis.readUnsignedByte();
        if ((b & EXPIRATION_MASK) != 0)
        { 
            int ttl = dis.readInt();
            int expiration = dis.readInt();
            long ts = dis.readLong();
            ByteBuffer value = ByteBufferUtil.readWithLength(dis);
            if (expiration < expireBefore)
            { 
                // the column is now expired, we can safely return a simple 
                // tombstone 
                ByteBuffer bytes = ByteBuffer.allocate(4);
                bytes.putInt(expiration);
                bytes.rewind();
                return new DeletedColumn(name, bytes, ts);
            } 
            else 
            { 
                return new ExpiringColumn(name, value, ts, ttl, expiration);
            } 
        } 
        else 
        { 
            long ts = dis.readLong();
            ByteBuffer value = ByteBufferUtil.readWithLength(dis);
            return (b & DELETION_MASK) == 0
                   ? new Column(name, value, ts)
                   : new DeletedColumn(name, value, ts);
        } 
    } 
Stop searching for code, let great code find you!  Add Codota to your java IDE