java.io.DataInput#readFully ( )源码实例Demo

下面列出了java.io.DataInput#readFully ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: flink   文件: HybridMemorySegment.java
@Override
public final void put(DataInput in, int offset, int length) throws IOException {
	if (address <= addressLimit) {
		if (heapMemory != null) {
			in.readFully(heapMemory, offset, length);
		}
		else {
			while (length >= 8) {
				putLongBigEndian(offset, in.readLong());
				offset += 8;
				length -= 8;
			}
			while (length > 0) {
				put(offset, in.readByte());
				offset++;
				length--;
			}
		}
	}
	else {
		throw new IllegalStateException("segment has been freed");
	}
}
 
源代码2 项目: big-c   文件: GridmixRecord.java
@Override
public void readFields(DataInput in) throws IOException {
  size = WritableUtils.readVInt(in);
  int payload = size - WritableUtils.getVIntSize(size);
  if (payload > Long.SIZE / Byte.SIZE) {
    seed = in.readLong();
    payload -= Long.SIZE / Byte.SIZE;
  } else {
    Arrays.fill(literal, (byte)0);
    in.readFully(literal, 0, payload);
    dib.reset(literal, 0, literal.length);
    seed = dib.readLong();
    payload = 0;
  }
  final int vBytes = in.skipBytes(payload);
  if (vBytes != payload) {
    throw new EOFException("Expected " + payload + ", read " + vBytes);
  }
}
 
源代码3 项目: aegisthus   文件: AtomWritable.java
@Override
public void readFields(DataInput dis) throws IOException {
    int length = dis.readInt();
    byte[] bytes = new byte[length];
    dis.readFully(bytes);
    this.key = bytes;
    this.deletedAt = dis.readLong();

    boolean hasAtom = dis.readBoolean();
    if (hasAtom) {
        this.atom = serializer.deserializeFromSSTable(
                dis, ColumnSerializer.Flag.PRESERVE_SIZE, Integer.MIN_VALUE, version
        );
    } else {
        this.atom = null;
    }
}
 
源代码4 项目: phoenix-tephra   文件: TransactionEditCodecs.java
@Override
public void decode(TransactionEdit dest, DataInput in) throws IOException {
  dest.setWritePointer(in.readLong());
  int stateIdx = in.readInt();
  try {
    dest.setState(TransactionEdit.State.values()[stateIdx]);
  } catch (ArrayIndexOutOfBoundsException e) {
    throw new IOException("State enum ordinal value is out of range: " + stateIdx);
  }
  dest.setExpiration(in.readLong());
  dest.setCommitPointer(in.readLong());
  dest.setCanCommit(in.readBoolean());
  int changeSize = in.readInt();
  Set<ChangeId> changes = Sets.newHashSet();
  for (int i = 0; i < changeSize; i++) {
    int currentLength = in.readInt();
    byte[] currentBytes = new byte[currentLength];
    in.readFully(currentBytes);
    changes.add(new ChangeId(currentBytes));
  }
  dest.setChanges(changes);
  // 1st version did not store this info. It is safe to set firstInProgress to 0, it may decrease performance until
  // this tx is finished, but correctness will be preserved.
  dest.setVisibilityUpperBound(0);
}
 
源代码5 项目: hadoop   文件: BloomFilter.java
@Override
public void readFields(DataInput in) throws IOException {
  super.readFields(in);
  bits = new BitSet(this.vectorSize);
  byte[] bytes = new byte[getNBytes()];
  in.readFully(bytes);
  for(int i = 0, byteIndex = 0, bitIndex = 0; i < vectorSize; i++, bitIndex++) {
    if (bitIndex == 8) {
      bitIndex = 0;
      byteIndex++;
    }
    if ((bytes[byteIndex] & bitvalues[bitIndex]) != 0) {
      bits.set(i);
    }
  }
}
 
源代码6 项目: stratio-cassandra   文件: MerkleTree.java
public Inner deserialize(DataInput in, int version) throws IOException
{
    int hashLen = in.readInt();
    byte[] hash = hashLen >= 0 ? new byte[hashLen] : null;
    if (hash != null)
        in.readFully(hash);
    Token token = Token.serializer.deserialize(in);
    Hashable lchild = Hashable.serializer.deserialize(in, version);
    Hashable rchild = Hashable.serializer.deserialize(in, version);
    return new Inner(token, lchild, rchild);
}
 
源代码7 项目: incubator-retired-blur   文件: SerializerUtil.java
public static BytesRef readBytesRef(DataInput in) throws IOException {
  int length = in.readInt();
  BytesRef bytes = new BytesRef(length);
  in.readFully(bytes.bytes);
  bytes.offset = 0;
  bytes.length = length;
  return bytes;
}
 
源代码8 项目: gemfirexd-oss   文件: JSON.java
@Override
final void readData(DataInput in, boolean reuseArrayIfPossible)
    throws IOException {
  int length = in.readUnsignedShort();
  byte[] b = new byte[length];
  in.readFully(b);
  try {
    setValue(new String(b));
  } catch (StandardException e) {
    // FIXME: may not always be IOException
    throw new IOException(e);
  }
}
 
源代码9 项目: deeplearning4j   文件: Text.java
/** deserialize
 */
public void readFields(DataInput in) throws IOException {
    int newLength = WritableUtils.readVInt(in);
    setCapacity(newLength, false);
    in.readFully(bytes, 0, newLength);
    length = newLength;
}
 
源代码10 项目: PalDB   文件: StorageSerialization.java
private static int[] deserializeArrayIntCompressed(DataInput is)
    throws IOException {
  int size = LongPacker.unpackInt(is);
  byte[] b = new byte[size];
  is.readFully(b);
  return Snappy.uncompressIntArray(b);
}
 
源代码11 项目: kylin   文件: Bytes.java
/**
 * Reads a fixed-size field and interprets it as a string padded with zeros.
 */
public static String readStringFixedSize(final DataInput in, int size) throws IOException {
    byte[] b = new byte[size];
    in.readFully(b);
    int n = b.length;
    while (n > 0 && b[n - 1] == 0)
        --n;

    return toString(b, 0, n);
}
 
源代码12 项目: nutch-htmlunit   文件: Content.java
private final void readFieldsCompressed(DataInput in) throws IOException {
  byte oldVersion = in.readByte();
  switch (oldVersion) {
  case 0:
  case 1:
    url = Text.readString(in); // read url
    base = Text.readString(in); // read base

    content = new byte[in.readInt()]; // read content
    in.readFully(content);

    contentType = Text.readString(in); // read contentType
    // reconstruct metadata
    int keySize = in.readInt();
    String key;
    for (int i = 0; i < keySize; i++) {
      key = Text.readString(in);
      int valueSize = in.readInt();
      for (int j = 0; j < valueSize; j++) {
        metadata.add(key, Text.readString(in));
      }
    }
    break;
  case 2:
    url = Text.readString(in); // read url
    base = Text.readString(in); // read base

    content = new byte[in.readInt()]; // read content
    in.readFully(content);

    contentType = Text.readString(in); // read contentType
    metadata.readFields(in); // read meta data
    break;
  default:
    throw new VersionMismatchException((byte)2, oldVersion);
  }

}
 
源代码13 项目: geowave   文件: GridCoverageWritable.java
@Override
public void readFields(final DataInput input) throws IOException {
  final int rasterTileSize = Varint.readUnsignedVarInt(input);
  final byte[] rasterTileBinary = new byte[rasterTileSize];
  input.readFully(rasterTileBinary);
  rasterTile = new RasterTile();
  rasterTile.fromBinary(rasterTileBinary);
  minX = input.readDouble();
  maxX = input.readDouble();
  minY = input.readDouble();
  maxY = input.readDouble();
  final int crsStrSize = Varint.readUnsignedVarInt(input);

  if (crsStrSize > 0) {
    final byte[] crsStrBytes = new byte[crsStrSize];
    input.readFully(crsStrBytes);
    final String crsStr = StringUtils.stringFromBinary(crsStrBytes);
    try {
      crs = CRS.decode(crsStr);
    } catch (final FactoryException e) {
      LOGGER.error("Unable to decode " + crsStr + " CRS", e);
      throw new RuntimeException("Unable to decode " + crsStr + " CRS", e);
    }
  } else {
    crs = GeometryUtils.getDefaultCRS();
  }
}
 
源代码14 项目: geowave   文件: GeoWaveInputKey.java
@Override
public void readFields(final DataInput input) throws IOException {
  internalAdapterId = input.readShort();
  final int dataIdLength = input.readInt();
  final byte[] dataIdBytes = new byte[dataIdLength];
  input.readFully(dataIdBytes);
  dataId = new ByteArray(dataIdBytes);
}
 
源代码15 项目: waterdrop   文件: SerializedConfigValue.java
private static void skipField(DataInput in) throws IOException {
    int len = in.readInt();
    // skipBytes doesn't have to block
    int skipped = in.skipBytes(len);
    if (skipped < len) {
        // wastefully use readFully() if skipBytes didn't work
        byte[] bytes = new byte[(len - skipped)];
        in.readFully(bytes);
    }
}
 
源代码16 项目: spork   文件: DataReaderWriter.java
public static String bytesToBigCharArray(DataInput in) throws IOException{
    int size = in.readInt();
    byte[] ba = new byte[size];
    in.readFully(ba);
    return new String(ba, DataReaderWriter.UTF8);
}
 
源代码17 项目: spliceengine   文件: AllocatedFilter.java
@Override
public void readFields(DataInput in) throws IOException{
    addressMatch=new byte[in.readInt()];
    in.readFully(addressMatch);
}
 
源代码18 项目: kylin-on-parquet-v2   文件: AppendDictSliceKey.java
public void readFields(DataInput in) throws IOException {
    key = new byte[in.readInt()];
    in.readFully(key);
}
 
源代码19 项目: parquet-mr   文件: ParquetInputSplit.java
private static byte[] readArray(DataInput in) throws IOException {
  int len = in.readInt();
  byte[] bytes = new byte[len];
  in.readFully(bytes);
  return bytes;
}
 
源代码20 项目: rcrs-server   文件: EncodingTools.java
/**
 * Read a String from a DataInput.
 * 
 * @param in
 *            The DataInput to read.
 * @return The string that was read.
 * @throws IOException
 *             If the DataInput blows up.
 * @throws EOFException
 *             If the end of the stream is reached.
 */
public static String readString(DataInput in) throws IOException {
	int length = readInt32(in);
	byte[] buffer = new byte[length];
	in.readFully(buffer);
	return new String(buffer, CHARSET);
}