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

The following examples show how to use java.io.DataInput#readChar() . 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: ColGroupDDC2.java    From systemds with Apache License 2.0 6 votes vote down vote up
@Override
public void readFields(DataInput in) throws IOException {
	_numRows = in.readInt();
	int numCols = in.readInt();
	int numVals = in.readInt();

	// read col indices
	_colIndexes = new int[numCols];
	for(int i = 0; i < numCols; i++)
		_colIndexes[i] = in.readInt();

	// read distinct values
	_values = new double[numVals * numCols];
	for(int i = 0; i < numVals * numCols; i++)
		_values[i] = in.readDouble();

	// read data
	_data = new char[_numRows];
	for(int i = 0; i < _numRows; i++)
		_data[i] = in.readChar();
}
 
Example 2
Source File: ColGroupDDC2.java    From systemds with Apache License 2.0 6 votes vote down vote up
@Override
public void readFields(DataInput in) throws IOException {
	_numRows = in.readInt();
	int numCols = in.readInt();
	int numVals = in.readInt();

	// read col indices
	_colIndexes = new int[numCols];
	for(int i = 0; i < numCols; i++)
		_colIndexes[i] = in.readInt();

	// read distinct values
	double[] values = new double[numVals * numCols];
	for(int i = 0; i < numVals * numCols; i++)
		values[i] = in.readDouble();
	_dict = new Dictionary(values);
	
	// read data
	_data = new char[_numRows];
	for(int i = 0; i < _numRows; i++)
		_data[i] = in.readChar();
}
 
Example 3
Source File: DataSerializer.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Reads an array of <code>char</code>s from a
 * <code>DataInput</code>.
 *
 * @throws IOException
 *         A problem occurs while reading from <code>in</code>
 *
 * @see #writeCharArray
 * @since 5.7 
 */
public static char[] readCharArray(DataInput in)
  throws IOException {

  InternalDataSerializer.checkIn(in);

  int length = InternalDataSerializer.readArrayLength(in);
  if (length == -1) {
    return null;
  } else {
    char[] array = new char[length];
    for (int i = 0; i < length; i++) {
      array[i] = in.readChar();
    }

    if (DEBUG) {
      InternalDataSerializer.logger.info( LocalizedStrings.DEBUG, "Read char array of length " + length);
    }

    return array;
  }
}
 
Example 4
Source File: DynamoDBItemWritable.java    From emr-dynamodb-connector with Apache License 2.0 6 votes vote down vote up
private String readStringFromDataInput(DataInput in) throws IOException {
  byte[] data;
  char firstBytes = in.readChar();

  if (firstBytes == FIRST_MAGIC_BYTES) {
    byte nextByte = in.readByte();
    if (nextByte == NEXT_MAGIC_BYTE) {
      // After those three magic bytes the real input begins
      return readChunks(in);
    } else {
      data = new byte[3];
      data[0] = (byte) (firstBytes >> 8);
      data[1] = (byte) firstBytes;
      data[2] = nextByte;
    }
  } else {
    data = new byte[firstBytes + 2];
    data[0] = (byte) (firstBytes >> 8);
    data[1] = (byte) firstBytes;
    in.readFully(data, 2, firstBytes);
  }

  // In case the read bytes are not from the new input format, back up and
  // return the result readUTF would have returned
  return new DataInputStream(new ByteArrayInputStream(data)).readUTF();
}
 
Example 5
Source File: IOUtils.java    From btree4j with Apache License 2.0 5 votes vote down vote up
@Nullable
public static String readString(@Nonnull final DataInput in) throws IOException {
    final int len = in.readInt();
    if (len == -1) {
        return null;
    }
    final char[] ch = new char[len];
    for (int i = 0; i < len; i++) {
        ch[i] = in.readChar();
    }
    return new String(ch);
}
 
Example 6
Source File: DataSerializer.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Reads a primitive <code>char</code> from a
 * <code>DataInput</code>.
 *
 * @throws IOException
 *         A problem occurs while reading from <code>in</code>
 * @see DataInput#readChar
 * @since 5.1
 */
public static char readPrimitiveChar(DataInput in) throws IOException {
  InternalDataSerializer.checkIn(in);

  char value = in.readChar();
  if (DEBUG) {
    InternalDataSerializer.logger.info( LocalizedStrings.DEBUG, "Read Char " + value);
  }
  return value;
}
 
Example 7
Source File: Row.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * Construct a Row object from input carried in via the given input stream.
 * 
 * @param is the input stream
 * @exception IOException if an I/O error occurs
 */
public Row(DataInput is) throws IOException {
  for (int i = is.readInt(); i > 0; i--) {
    char ch = is.readChar();
    Cell c = new Cell();
    c.cmd = is.readInt();
    c.cnt = is.readInt();
    c.ref = is.readInt();
    c.skip = is.readInt();
    cells.put(ch, c);
  }
}
 
Example 8
Source File: IOUtils.java    From incubator-hivemall with Apache License 2.0 5 votes vote down vote up
@Nullable
public static String readString(@Nonnull final DataInput in) throws IOException {
    final int len = in.readInt();
    if (len == -1) {
        return null;
    }
    final char[] ch = new char[len];
    for (int i = 0; i < len; i++) {
        ch[i] = in.readChar();
    }
    return new String(ch);
}
 
Example 9
Source File: DataSerializer.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Reads a primitive <code>char</code> from a
 * <code>DataInput</code>.
 *
 * @throws IOException
 *         A problem occurs while reading from <code>in</code>
 * @see DataInput#readChar
 * @since 5.1
 */
public static char readPrimitiveChar(DataInput in) throws IOException {
  InternalDataSerializer.checkIn(in);

  char value = in.readChar();
  if (DEBUG) {
    InternalDataSerializer.logger.info( LocalizedStrings.DEBUG, "Read Char " + value);
  }
  return value;
}
 
Example 10
Source File: CharArraySerializer.java    From util with Apache License 2.0 5 votes vote down vote up
@Override
public char[] read(DataInput in) throws IOException {
    final int length = lengthSerializer.read(in);
    final char[] values = new char[length];
    for (int i = 0; i < values.length; i++) {
        values[i] = in.readChar();
    }
    return values;
}
 
Example 11
Source File: ArrayPrimitiveWritable.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private void readCharArray(DataInput in) throws IOException {
  char[] v = (char[]) value;
  for (int i = 0; i < length; i++)
    v[i] = in.readChar(); 
}
 
Example 12
Source File: MapLiteSerializer.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public static Character readCharacter(DataInput input) throws IOException
{
	return input.readChar();
}
 
Example 13
Source File: CharType.java    From stratosphere with Apache License 2.0 4 votes vote down vote up
@Override
public void read(DataInput in) throws IOException {
	this.value = in.readChar();
}
 
Example 14
Source File: SummationWritable.java    From big-c with Apache License 2.0 4 votes vote down vote up
/** Read ArithmeticProgression from DataInput */
private static ArithmeticProgression read(DataInput in) throws IOException {
  return new ArithmeticProgression(in.readChar(),
      in.readLong(), in.readLong(), in.readLong());
}
 
Example 15
Source File: ArrayPrimitiveWritable.java    From big-c with Apache License 2.0 4 votes vote down vote up
private void readCharArray(DataInput in) throws IOException {
  char[] v = (char[]) value;
  for (int i = 0; i < length; i++)
    v[i] = in.readChar(); 
}
 
Example 16
Source File: SummationWritable.java    From hadoop with Apache License 2.0 4 votes vote down vote up
/** Read ArithmeticProgression from DataInput */
private static ArithmeticProgression read(DataInput in) throws IOException {
  return new ArithmeticProgression(in.readChar(),
      in.readLong(), in.readLong(), in.readLong());
}
 
Example 17
Source File: MapLiteSerializer.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public static Character readCharacter(DataInput input) throws IOException
{
	return input.readChar();
}
 
Example 18
Source File: ResultLob.java    From evosql with Apache License 2.0 4 votes vote down vote up
public static ResultLob newLob(DataInput dataInput,
                               boolean readTerminate) throws IOException {

    ResultLob result = new ResultLob();

    result.databaseID = dataInput.readInt();
    result.sessionID  = dataInput.readLong();
    result.lobID      = dataInput.readLong();
    result.subType    = dataInput.readInt();

    switch (result.subType) {

        case LobResultTypes.REQUEST_CREATE_BYTES :
        case LobResultTypes.REQUEST_CREATE_CHARS :
            result.blockOffset = dataInput.readLong();
            result.blockLength = dataInput.readLong();
            break;

        case LobResultTypes.REQUEST_GET_LOB :
        case LobResultTypes.REQUEST_DUPLICATE_LOB :

        //
        case LobResultTypes.REQUEST_GET_BYTES :
        case LobResultTypes.REQUEST_GET_CHARS :
            result.blockOffset = dataInput.readLong();
            result.blockLength = dataInput.readLong();
            break;

        case LobResultTypes.REQUEST_SET_BYTES :
        case LobResultTypes.REQUEST_GET_BYTE_PATTERN_POSITION :
            result.blockOffset = dataInput.readLong();
            result.blockLength = dataInput.readLong();
            result.byteBlock   = new byte[(int) result.blockLength];

            dataInput.readFully(result.byteBlock);
            break;

        case LobResultTypes.REQUEST_SET_CHARS :
        case LobResultTypes.REQUEST_GET_CHAR_PATTERN_POSITION :
            result.blockOffset = dataInput.readLong();
            result.blockLength = dataInput.readLong();
            result.charBlock   = new char[(int) result.blockLength];

            for (int i = 0; i < result.charBlock.length; i++) {
                result.charBlock[i] = dataInput.readChar();
            }
            break;

        case LobResultTypes.REQUEST_GET_LENGTH :
        case LobResultTypes.REQUEST_TRUNCATE :
            result.blockOffset = dataInput.readLong();
            break;

        case LobResultTypes.RESPONSE_GET_BYTES :
            result.blockOffset = dataInput.readLong();
            result.blockLength = dataInput.readLong();
            result.byteBlock   = new byte[(int) result.blockLength];

            dataInput.readFully(result.byteBlock);
            break;

        case LobResultTypes.RESPONSE_GET_CHARS :
            result.blockOffset = dataInput.readLong();
            result.blockLength = dataInput.readLong();
            result.charBlock   = new char[(int) result.blockLength];

            for (int i = 0; i < result.charBlock.length; i++) {
                result.charBlock[i] = dataInput.readChar();
            }
            break;

        case LobResultTypes.RESPONSE_SET :
        case LobResultTypes.RESPONSE_CREATE_BYTES :
        case LobResultTypes.RESPONSE_CREATE_CHARS :
        case LobResultTypes.RESPONSE_TRUNCATE :
            result.blockLength = dataInput.readLong();
            break;

        case LobResultTypes.RESPONSE_GET_BYTE_PATTERN_POSITION :
        case LobResultTypes.RESPONSE_GET_CHAR_PATTERN_POSITION :
            result.blockOffset = dataInput.readLong();
            break;

        default :
            throw Error.runtimeError(ErrorCode.U_S0500, "ResultLob");
    }

    if (readTerminate) {
        dataInput.readByte();
    }

    return result;
}
 
Example 19
Source File: CharSerializer.java    From util with Apache License 2.0 4 votes vote down vote up
@Override
public Character read(final DataInput in) throws IOException {
    return in.readChar();
}
 
Example 20
Source File: CharValue.java    From stratosphere with Apache License 2.0 4 votes vote down vote up
@Override
public void read(DataInput in) throws IOException {
	this.value = in.readChar();
}