Java Code Examples for java.io.ObjectInput#readUnsignedByte()

The following examples show how to use java.io.ObjectInput#readUnsignedByte() . 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: BinaryDecimal.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/** 
 * Note the use of data2c: we reuse the array if the
 * incoming array is the same length or smaller than
 * the array length.  
 * 
 * @see java.io.Externalizable#readExternal 
 */
public void readExternal(ObjectInput in) throws IOException 
{
	sqlScale = in.readUnsignedByte();
	int size = in.readUnsignedByte();

	/*
	** Allocate a new array if the data to read
	** is larger than the existing array, or if
	** we don't have an array yet.

       Need to use readFully below and NOT just read because read does not
       guarantee getting size bytes back, whereas readFully does (unless EOF).
       */
	if ((data2c == null) || size != data2c.length)
	{
		data2c = new byte[size];
	}
	in.readFully(data2c);

}
 
Example 2
Source File: BinaryDecimal.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/** 
 * Note the use of data2c: we reuse the array if the
 * incoming array is the same length or smaller than
 * the array length.  
 * 
 * @see java.io.Externalizable#readExternal 
 */
public void readExternal(ObjectInput in) throws IOException 
{
	sqlScale = in.readUnsignedByte();
	int size = in.readUnsignedByte();

	/*
	** Allocate a new array if the data to read
	** is larger than the existing array, or if
	** we don't have an array yet.

       Need to use readFully below and NOT just read because read does not
       guarantee getting size bytes back, whereas readFully does (unless EOF).
       */
	if ((data2c == null) || size != data2c.length)
	{
		data2c = new byte[size];
	}
	in.readFully(data2c);

}
 
Example 3
Source File: GridDhtPartitionMap.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    nodeId = U.readUuid(in);

    updateSeq = in.readLong();

    int size = in.readInt();

    map = new GridPartitionStateMap();

    for (int i = 0; i < size; i++) {
        int ordinal = in.readUnsignedByte();
        int part = in.readUnsignedShort();

        put(part, GridDhtPartitionState.fromOrdinal(ordinal));
    }

    long ver = in.readLong();
    int minorVer = in.readInt();

    if (ver != 0)
        top = new AffinityTopologyVersion(ver, minorVer);
}
 
Example 4
Source File: AbstractMessage.java    From flex-blazeds with Apache License 2.0 6 votes vote down vote up
/**
 *
 * To support efficient serialization for SmallMessage implementations,
 * this utility method reads in the property flags from an ObjectInput
 * stream. Flags are read in one byte at a time. Flags make use of
 * sign-extension so that if the high-bit is set to 1 this indicates that
 * another set of flags follows.
 * 
 * @return The array of property flags. 
 */
protected short[] readFlags(ObjectInput input) throws IOException
{
    boolean hasNextFlag = true;
    short[] flagsArray = new short[2];
    int i = 0;

    while (hasNextFlag)
    {
        short flags = (short)input.readUnsignedByte();
        if (i == flagsArray.length)
        {
            short[] tempArray = new short[i*2];
            System.arraycopy(flagsArray, 0, tempArray, 0, flagsArray.length);
            flagsArray = tempArray;
        }

        flagsArray[i] = flags;

        hasNextFlag = (flags & HAS_NEXT_FLAG) != 0;

        i++;
    }

    return flagsArray;
}
 
Example 5
Source File: BinaryDecimal.java    From spliceengine with GNU Affero General Public License v3.0 6 votes vote down vote up
/** 
 * Note the use of data2c: we reuse the array if the
 * incoming array is the same length or smaller than
 * the array length.  
 * 
 * @see java.io.Externalizable#readExternal 
 */
public void readExternal(ObjectInput in) throws IOException 
{
	sqlScale = in.readUnsignedByte();
	int size = in.readUnsignedByte();

	/*
	** Allocate a new array if the data to read
	** is larger than the existing array, or if
	** we don't have an array yet.

       Need to use readFully below and NOT just read because read does not
       guarantee getting size bytes back, whereas readFully does (unless EOF).
       */
	if ((data2c == null) || size != data2c.length)
	{
		data2c = new byte[size];
	}
	in.readFully(data2c);
	isNull = evaluateNull();

}
 
Example 6
Source File: ChecksumOperation.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
	checksumAlgo = (byte) in.readUnsignedByte();
	dataLength = in.readInt();
	checksumValue = in.readLong();
	initializeChecksumAlgo();
}
 
Example 7
Source File: ChecksumOperation.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
	checksumAlgo = (byte) in.readUnsignedByte();
	dataLength = in.readInt();
	checksumValue = in.readLong();
	initializeChecksumAlgo();
}
 
Example 8
Source File: ProjectRestrictOperation.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void readExternal(ObjectInput in) throws IOException,ClassNotFoundException {
		super.readExternal(in);
		restrictionMethodName = readNullableString(in);
		projectionMethodName = readNullableString(in);
		constantRestrictionMethodName = readNullableString(in);
		mapRefItem = in.readInt();
		cloneMapItem = in.readInt();
		int version = in.readUnsignedByte();
		if (version < PROJECT_RESTRICT_OPERATION_V2)
		    reuseResult = (version == 1);
		else
		    reuseResult = in.readBoolean();
		doesProjection = in.readBoolean();
		source = (SpliceOperation) in.readObject();
		if (version >= PROJECT_RESTRICT_OPERATION_V2) {
		    filterPred = readNullableString(in);
		    int numexpressions = in.readInt();
		    if (numexpressions > 0) {
		        expressions = new String[numexpressions];
		        for (int i = 0; i < numexpressions; i++) {
		            expressions[i] = readNullableString(in);
		        }
		    }
		    hasGroupingFunction = in.readBoolean();
		}
		subqueryText = readNullableString(in);
}
 
Example 9
Source File: SQLDecimal.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Note the use of rawData: we reuse the array if the
 * incoming array is the same length or smaller than
 * the array length.
 *
 * @see java.io.Externalizable#readExternal
 */
public void readExternal(ObjectInput in) throws IOException {

       if (in.readBoolean()) {
           setCoreValue(null);
           return;
       }

	// clear the previous value to ensure that the
	// rawData value will be used
	value = null;

	rawScale = in.readUnsignedByte();
	int size = in.readUnsignedByte();

	/*
	** Allocate a new array if the data to read
	** is larger than the existing array, or if
	** we don't have an array yet.

       Need to use readFully below and NOT just read because read does not
       guarantee getting size bytes back, whereas readFully does (unless EOF).
       */
	if ((rawData == null) || size != rawData.length)
	{
		rawData = new byte[size];
	}
	in.readFully(rawData);
	isNull = evaluateNull();

}
 
Example 10
Source File: InternalDistributedMember.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * For Externalizable
 *
 * @see Externalizable
 */
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException {
  // do it the way we like
  int len = in.readInt(); // IPv6 compatible
  byte addr[] = new byte[len];
  in.readFully(addr);
  InetAddress inetAddr = InetAddress.getByAddress(addr);
  int port = in.readInt();
  
  this.hostName = DataSerializer.readString(in);

  int flags = in.readUnsignedByte();
  boolean sbEnabled = (flags & SB_ENABLED_MASK) != 0;
  boolean elCoord = (flags & COORD_ENABLED_MASK) != 0;
  this.isPartial = (flags & PARTIAL_ID_MASK) != 0;
  
  this.dcPort = in.readInt();
  this.vmPid = in.readInt();
  this.vmKind = in.readInt();
  this.vmViewId = in.readInt();
  this.groups = DataSerializer.readStringArray(in);

  this.name = DataSerializer.readString(in);
  this.uniqueTag = DataSerializer.readString(in);
  String durableId = DataSerializer.readString(in);
  int durableTimeout = DataSerializer.readInteger(in).intValue();
  this.durableClientAttributes = new DurableClientAttributes(durableId, durableTimeout);

  readVersion(flags, in);

  ipAddr = MemberFactory.newNetMember(inetAddr, port, sbEnabled, elCoord,
      new MemberAttributes(dcPort, vmPid, vmKind, vmViewId, name, groups, durableClientAttributes));
  ((JGroupMember)ipAddr).getAddress().setVersionOrdinal(this.version);

  Assert.assertTrue(this.vmKind > 0);
  // [sumedh] loner VMs will have port as zero if no GFE client is connected
  // e.g. with GFXD clients
  Assert.assertTrue(vmKind == DistributionManager.LONER_DM_TYPE
      || getPort() > 0);
}
 
Example 11
Source File: InternalDistributedMember.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * For Externalizable
 *
 * @see Externalizable
 */
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException {
  // do it the way we like
  int len = in.readInt(); // IPv6 compatible
  byte addr[] = new byte[len];
  in.readFully(addr);
  InetAddress inetAddr = InetAddress.getByAddress(addr);
  int port = in.readInt();
  
  this.hostName = DataSerializer.readString(in);

  int flags = in.readUnsignedByte();
  boolean sbEnabled = (flags & SB_ENABLED_MASK) != 0;
  boolean elCoord = (flags & COORD_ENABLED_MASK) != 0;
  this.isPartial = (flags & PARTIAL_ID_MASK) != 0;
  
  this.dcPort = in.readInt();
  this.vmPid = in.readInt();
  this.vmKind = in.readInt();
  this.vmViewId = in.readInt();
  this.groups = DataSerializer.readStringArray(in);

  this.name = DataSerializer.readString(in);
  this.uniqueTag = DataSerializer.readString(in);
  String durableId = DataSerializer.readString(in);
  int durableTimeout = DataSerializer.readInteger(in).intValue();
  this.durableClientAttributes = new DurableClientAttributes(durableId, durableTimeout);

  readVersion(flags, in);

  ipAddr = MemberFactory.newNetMember(inetAddr, port, sbEnabled, elCoord,
      new MemberAttributes(dcPort, vmPid, vmKind, vmViewId, name, groups, durableClientAttributes));
  ((JGroupMember)ipAddr).getAddress().setVersionOrdinal(this.version);

  Assert.assertTrue(this.vmKind > 0);
  // [sumedh] loner VMs will have port as zero if no GFE client is connected
  // e.g. with GFXD clients
  Assert.assertTrue(vmKind == DistributionManager.LONER_DM_TYPE
      || getPort() > 0);
}