Java Code Examples for java.io.DataInput#readLong()

The following examples show how to use java.io.DataInput#readLong() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileInputSplit.java    From stratosphere with Apache License 2.0 6 votes vote down vote up
@Override
public void read(final DataInput in) throws IOException {
	// read partition number
	this.partitionNumber = in.readInt();

	// read file path
	boolean isNotNull = in.readBoolean();
	if (isNotNull) {
		this.file = new Path();
		this.file.read(in);
	}

	this.start = in.readLong();
	this.length = in.readLong();

	isNotNull = in.readBoolean();
	if (isNotNull) {
		final int numHosts = in.readInt();
		this.hosts = new String[numHosts];
		for (int i = 0; i < numHosts; i++) {
			this.hosts[i] = StringRecord.readString(in);
		}
	} else {
		this.hosts = null;
	}
}
 
Example 2
Source File: CombineFileSplit.java    From RDFS with Apache License 2.0 6 votes vote down vote up
public void readFields(DataInput in) throws IOException {
  totLength = in.readLong();
  int arrLength = in.readInt();
  lengths = new long[arrLength];
  for(int i=0; i<arrLength;i++) {
    lengths[i] = in.readLong();
  }
  int filesLength = in.readInt();
  paths = new Path[filesLength];
  for(int i=0; i<filesLength;i++) {
    paths[i] = new Path(Text.readString(in));
  }
  arrLength = in.readInt();
  startoffset = new long[arrLength];
  for(int i=0; i<arrLength;i++) {
    startoffset[i] = in.readLong();
  }
}
 
Example 3
Source File: InitialImageOperation.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public void fromData(DataInput in) throws IOException,
    ClassNotFoundException {
  this.entryBits = in.readByte();
  byte flags = in.readByte();
  this.key = DataSerializer.readObject(in);
  
  if (EntryBits.isTombstone(this.entryBits)) {
    this.value = Token.TOMBSTONE;
  }
  else {
    if (!isEagerDeserialize()) {
      this.value = DataSerializer.readByteArray(in);
    }
    else {
      this.value = DataSerializer.readObject(in);
    }
  }
  this.lastModified = in.readLong();
  if ((flags & HAS_VERSION) != 0) {
    // note that null IDs must be later replaced with the image provider's ID
    this.versionTag = VersionTag.create((flags & PERSISTENT_VERSION) != 0, in);
  }
}
 
Example 4
Source File: SnapshotFSImageFormat.java    From hadoop with Apache License 2.0 6 votes vote down vote up
public INodeReference.WithCount loadINodeReferenceWithCount(
    boolean isSnapshotINode, DataInput in, FSImageFormat.Loader loader
    ) throws IOException {
  final boolean firstReferred = in.readBoolean();

  final INodeReference.WithCount withCount;
  if (firstReferred) {
    final INode referred = loader.loadINodeWithLocalName(isSnapshotINode,
        in, true);
    withCount = new INodeReference.WithCount(null, referred);
    referenceMap.put(withCount.getId(), withCount);
  } else {
    final long id = in.readLong();
    withCount = referenceMap.get(id);
  }
  return withCount;
}
 
Example 5
Source File: ZoneInfoFile.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static long readEpochSec(DataInput in) throws IOException {
    int hiByte = in.readByte() & 255;
    if (hiByte == 255) {
        return in.readLong();
    } else {
        int midByte = in.readByte() & 255;
        int loByte = in.readByte() & 255;
        long tot = ((hiByte << 16) + (midByte << 8) + loByte);
        return (tot * 900) - 4575744000L;
    }
}
 
Example 6
Source File: ForestDocument.java    From marklogic-contentpump with Apache License 2.0 5 votes vote down vote up
@Override
public void readFields(DataInput in) throws IOException {
    fragmentOrdinal = in.readLong();
    collections = WritableUtils.readStringArray(in);
    int numMetadata = in.readInt();
    if (numMetadata > 0) {
        String[] metaStrings = WritableUtils.readStringArray(in);
        metadata = new HashMap<String, String>(numMetadata);
        for (int i = 0; i < metaStrings.length - 1; i++) {
            metadata.put(metaStrings[i], metaStrings[i + 1]);
        }
    }
    quality = in.readInt();
}
 
Example 7
Source File: Nopol2015_0010_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Reads encoding generated by writeMillis.
 */
static long readMillis(DataInput in) throws IOException {
    int v = in.readUnsignedByte();
    switch (v >> 6) {
    case 0: default:
        // Form 00 (6 bits effective precision)
        v = (v << (32 - 6)) >> (32 - 6);
        return v * (30 * 60000L);

    case 1:
        // Form 01 (30 bits effective precision)
        v = (v << (32 - 6)) >> (32 - 30);
        v |= (in.readUnsignedByte()) << 16;
        v |= (in.readUnsignedByte()) << 8;
        v |= (in.readUnsignedByte());
        return v * 60000L;

    case 2:
        // Form 10 (38 bits effective precision)
        long w = (((long)v) << (64 - 6)) >> (64 - 38);
        w |= (in.readUnsignedByte()) << 24;
        w |= (in.readUnsignedByte()) << 16;
        w |= (in.readUnsignedByte()) << 8;
        w |= (in.readUnsignedByte());
        return w * 1000L;

    case 3:
        // Form 11 (64 bits effective precision)
        return in.readLong();
    }
}
 
Example 8
Source File: WireCommands.java    From pravega with Apache License 2.0 5 votes vote down vote up
public static WireCommand readFrom(DataInput in, int length) throws IOException {
    long requestId = in.readLong();
    String segment = in.readUTF();
    UUID attributeId = new UUID(in.readLong(), in.readLong());
    long newValue = in.readLong();
    long excpecteValue = in.readLong();
    String delegationToken = in.readUTF();
    return new UpdateSegmentAttribute(requestId, segment, attributeId, newValue, excpecteValue, delegationToken);
}
 
Example 9
Source File: ZoneInfoFile.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static long readEpochSec(DataInput in) throws IOException {
    int hiByte = in.readByte() & 255;
    if (hiByte == 255) {
        return in.readLong();
    } else {
        int midByte = in.readByte() & 255;
        int loByte = in.readByte() & 255;
        long tot = ((hiByte << 16) + (midByte << 8) + loByte);
        return (tot * 900) - 4575744000L;
    }
}
 
Example 10
Source File: TensorIndexes.java    From systemds with Apache License 2.0 5 votes vote down vote up
@Override
public void readFields(DataInput in)
		throws IOException {
	_ix = new long[in.readInt()];
	for (int i = 0; i < _ix.length; i++) {
		_ix[i] = in.readLong();
	}
}
 
Example 11
Source File: WireCommands.java    From pravega with Apache License 2.0 5 votes vote down vote up
public static WireCommand readFrom(DataInput in, int length) throws IOException {
    long requestId = in.readLong();
    int numberOfEntries = in.readInt();
    List<Long> updatedVersions = new ArrayList<>(numberOfEntries);
    for (int i = 0; i < numberOfEntries; i++) {
        updatedVersions.add(in.readLong());
    }
    return new TableEntriesUpdated(requestId, updatedVersions);
}
 
Example 12
Source File: SortedHoplogPersistedEvent.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@Override
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
  super.fromData(in);
  if (hasVersionTag()) {
    this.versionTag = (VersionTag)DataSerializer.readObject(in);
  } else {
    this.timestamp = in.readLong();
  }
}
 
Example 13
Source File: JGenProg2017_0076_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Reads encoding generated by writeMillis.
 */
static long readMillis(DataInput in) throws IOException {
    int v = in.readUnsignedByte();
    switch (v >> 6) {
    case 0: default:
        // Form 00 (6 bits effective precision)
        v = (v << (32 - 6)) >> (32 - 6);
        return v * (30 * 60000L);

    case 1:
        // Form 01 (30 bits effective precision)
        v = (v << (32 - 6)) >> (32 - 30);
        v |= (in.readUnsignedByte()) << 16;
        v |= (in.readUnsignedByte()) << 8;
        v |= (in.readUnsignedByte());
        return v * 60000L;

    case 2:
        // Form 10 (38 bits effective precision)
        long w = (((long)v) << (64 - 6)) >> (64 - 38);
        w |= (in.readUnsignedByte()) << 24;
        w |= (in.readUnsignedByte()) << 16;
        w |= (in.readUnsignedByte()) << 8;
        w |= (in.readUnsignedByte());
        return w * 1000L;

    case 3:
        // Form 11 (64 bits effective precision)
        return in.readLong();
    }
}
 
Example 14
Source File: jMutRepair_0037_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Reads encoding generated by writeMillis.
 */
static long readMillis(DataInput in) throws IOException {
    int v = in.readUnsignedByte();
    switch (v >> 6) {
    case 0: default:
        // Form 00 (6 bits effective precision)
        v = (v << (32 - 6)) >> (32 - 6);
        return v * (30 * 60000L);

    case 1:
        // Form 01 (30 bits effective precision)
        v = (v << (32 - 6)) >> (32 - 30);
        v |= (in.readUnsignedByte()) << 16;
        v |= (in.readUnsignedByte()) << 8;
        v |= (in.readUnsignedByte());
        return v * 60000L;

    case 2:
        // Form 10 (38 bits effective precision)
        long w = (((long)v) << (64 - 6)) >> (64 - 38);
        w |= (in.readUnsignedByte()) << 24;
        w |= (in.readUnsignedByte()) << 16;
        w |= (in.readUnsignedByte()) << 8;
        w |= (in.readUnsignedByte());
        return w * 1000L;

    case 3:
        // Form 11 (64 bits effective precision)
        return in.readLong();
    }
}
 
Example 15
Source File: SnapshotFSImageFormat.java    From big-c with Apache License 2.0 5 votes vote down vote up
private static FileDiff loadFileDiff(FileDiff posterior, DataInput in,
    FSImageFormat.Loader loader) throws IOException {
  // 1. Read the id of the Snapshot root to identify the Snapshot
  final Snapshot snapshot = loader.getSnapshot(in);

  // 2. Load file size
  final long fileSize = in.readLong();
  
  // 3. Load snapshotINode 
  final INodeFileAttributes snapshotINode = in.readBoolean()?
      loader.loadINodeFileAttributes(in): null;
  
  return new FileDiff(snapshot.getId(), snapshotINode, posterior, fileSize);
}
 
Example 16
Source File: InternalDataSerializer.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/** read a set of Long objects */
public static List<Long> readListOfLongs(DataInput in) throws IOException {
  int size = in.readInt();
  if (size < 0) {
    return null;
  } else {
    List result = new LinkedList();
    boolean longIDs = in.readBoolean();
    for (int i=0; i<size; i++) {
      long l = longIDs? in.readLong() : in.readInt();
      result.add(Long.valueOf(l));
    }
    return result;
  }
}
 
Example 17
Source File: UUIDSerializer.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
public UUID deserialize(DataInput in, int version) throws IOException
{
    return new UUID(in.readLong(), in.readLong());
}
 
Example 18
Source File: LongWritable.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
public void readFields(DataInput in) throws IOException {
    value = in.readLong();
}
 
Example 19
Source File: GenerateProfiles.java    From aerospike-hadoop with Apache License 2.0 4 votes vote down vote up
public void readFields(DataInput in) throws IOException {
    userid = in.readLong();
    age = in.readInt();
    isMale = in.readInt();
}
 
Example 20
Source File: UID.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs and returns a new <code>UID</code> instance by
 * unmarshalling a binary representation from an
 * <code>DataInput</code> instance.
 *
 * <p>Specifically, this method first invokes the given stream's
 * {@link DataInput#readInt()} method to read a <code>unique</code> value,
 * then it invoke's the stream's
 * {@link DataInput#readLong()} method to read a <code>time</code> value,
 * then it invoke's the stream's
 * {@link DataInput#readShort()} method to read a <code>count</code> value,
 * and then it creates and returns a new <code>UID</code> instance
 * that contains the <code>unique</code>, <code>time</code>, and
 * <code>count</code> values that were read from the stream.
 *
 * @param   in the <code>DataInput</code> instance to read
 * <code>UID</code> from
 *
 * @return  unmarshalled <code>UID</code> instance
 *
 * @throws  IOException if an I/O error occurs while performing
 * this operation
 */
public static UID read(DataInput in) throws IOException {
    int unique = in.readInt();
    long time = in.readLong();
    short count = in.readShort();
    return new UID(unique, time, count);
}