@Override
  public void readFields(DataInput in) throws IOException {

    first_key = WritableUtils.readString(in);
    second_key = WritableUtils.readString(in);
    third_key = WritableUtils.readString(in);
  }
Beispiel #2
0
    /* Receive a response.
     * Because only one receiver, so no synchronization on in.
     */
    protected void receiveResponse() {
      if (shouldCloseConnection.get()) {
        return;
      }
      touch();

      try {
        // See HBaseServer.Call.setResponse for where we write out the response.
        // It writes the call.id (int), a flag byte, then optionally the length
        // of the response (int) followed by data.

        // Read the call id.
        int id = in.readInt();

        if (LOG.isDebugEnabled()) LOG.debug(getName() + " got value #" + id);
        Call call = calls.get(id);

        // Read the flag byte
        byte flag = in.readByte();
        boolean isError = ResponseFlag.isError(flag);
        if (ResponseFlag.isLength(flag)) {
          // Currently length if present is unused.
          in.readInt();
        }
        int state = in.readInt(); // Read the state.  Currently unused.
        if (isError) {
          if (call != null) {
            //noinspection ThrowableInstanceNeverThrown
            call.setException(
                new RemoteException(WritableUtils.readString(in), WritableUtils.readString(in)));
          }
        } else {
          Writable value = ReflectionUtils.newInstance(valueClass, conf);
          value.readFields(in); // read value
          // it's possible that this call may have been cleaned up due to a RPC
          // timeout, so check if it still exists before setting the value.
          if (call != null) {
            call.setValue(value);
          }
        }
        calls.remove(id);
      } catch (IOException e) {
        if (e instanceof SocketTimeoutException && remoteId.rpcTimeout > 0) {
          // Clean up open calls but don't treat this as a fatal condition,
          // since we expect certain responses to not make it by the specified
          // {@link ConnectionId#rpcTimeout}.
          closeException = e;
        } else {
          // Since the server did not respond within the default ping interval
          // time, treat this as a fatal condition and close this connection
          markClosed(e);
        }
      } finally {
        if (remoteId.rpcTimeout > 0) {
          cleanupCalls(remoteId.rpcTimeout);
        }
      }
    }
 /**
  * Read in a Map<String, String>
  *
  * @param in DataInput
  * @param map Map to read into
  * @throws IOException I/O errors
  */
 public static void readStrStrMap(DataInput in, Map<String, String> map) throws IOException {
   int size = in.readInt();
   map.clear();
   for (int i = 0; i < size; ++i) {
     String key = WritableUtils.readString(in);
     String value = WritableUtils.readString(in);
     map.put(key, value);
   }
 }
  public Object read(int token, DataInputStream inputStream) throws IOException {
    String className = tupleSerialization.getClassNameFor(token);

    if (className == null) className = WritableUtils.readString(inputStream);

    Deserializer deserializer = deserializers.get(className);

    if (deserializer == null) {
      deserializer = tupleSerialization.getNewDeserializer(className);
      deserializer.open(inputStream);
      deserializers.put(className, deserializer);
    }

    Object foundObject = null;
    Object object = null;

    try {
      object = deserializer.deserialize(foundObject);
    } catch (IOException exception) {
      LOG.error(
          "failed deserializing token: " + token + " with classname: " + className, exception);

      throw exception;
    }

    return object;
  }
Beispiel #5
0
 @Override
 public void readFields(DataInput input) throws IOException {
   super.readFields(input);
   formatString = WritableUtils.readString(input);
   type = WritableUtils.readEnum(input, FunctionArgumentType.class);
   formatter = type.getFormatter(formatString);
 }
Beispiel #6
0
 @Override
 public void readFields(DataInput input) throws IOException {
   byte[] tableNameBytes = Bytes.readByteArray(input);
   PName tableName = new PNameImpl(tableNameBytes);
   PTableType tableType = PTableType.values()[WritableUtils.readVInt(input)];
   long sequenceNumber = WritableUtils.readVLong(input);
   long timeStamp = input.readLong();
   byte[] pkNameBytes = Bytes.readByteArray(input);
   String pkName = pkNameBytes.length == 0 ? null : Bytes.toString(pkNameBytes);
   int nColumns = WritableUtils.readVInt(input);
   List<PColumn> columns = Lists.newArrayListWithExpectedSize(nColumns);
   for (int i = 0; i < nColumns; i++) {
     PColumn column = new PColumnImpl();
     column.readFields(input);
     columns.add(column);
   }
   Map<String, byte[][]> guidePosts = new HashMap<String, byte[][]>();
   int size = WritableUtils.readVInt(input);
   for (int i = 0; i < size; i++) {
     String key = WritableUtils.readString(input);
     int valueSize = WritableUtils.readVInt(input);
     byte[][] value = new byte[valueSize][];
     for (int j = 0; j < valueSize; j++) {
       value[j] = Bytes.readByteArray(input);
     }
     guidePosts.put(key, value);
   }
   PTableStats stats = new PTableStatsImpl(guidePosts);
   init(tableName, tableType, timeStamp, sequenceNumber, pkName, columns, stats);
 }
 /**
  * Read a List<String>
  *
  * @param in DataInput
  * @param data List to read into
  * @throws IOException I/O errors
  */
 public static void readStringList(DataInput in, List<String> data) throws IOException {
   int size = in.readInt();
   data.clear();
   for (int i = 0; i < size; ++i) {
     data.add(WritableUtils.readString(in));
   }
 }
 /**
  * Read a class
  *
  * @param in DataInput
  * @param <T> type of class
  * @return Class for type
  * @throws IOException I/O errors
  */
 public static <T> Class<T> readClass(DataInput in) throws IOException {
   String className = WritableUtils.readString(in);
   try {
     return (Class<T>) Class.forName(className);
   } catch (ClassNotFoundException e) {
     throw new IOException("Could now find class named " + className, e);
   }
 }
 /**
  * Read data for a Map<String, Integer>
  *
  * @param in DataInput
  * @param data Map to read into
  * @throws IOException I/O errors
  */
 public static void readStrIntMap(DataInput in, Map<String, Integer> data) throws IOException {
   int size = in.readInt();
   data.clear();
   for (int i = 0; i < size; ++i) {
     String key = WritableUtils.readString(in);
     int value = in.readInt();
     data.put(key, value);
   }
 }
 @Override
 public void readFields(DataInput in) throws IOException {
   String str = WritableUtils.readString(in);
   PyString pyString = new PyString(str);
   Object object;
   try {
     object = cPickle.loads(pyString);
   } catch (PyException e) {
     LOG.fatal("Could not deserialize Jython value from string " + str);
     throw e;
   }
   Preconditions.checkArgument(object instanceof PyObject);
   setPyObject((PyObject) object);
 }
    @Override
    public void readFields(DataInput in) throws IOException {
      String className = WritableUtils.readString(in);
      Class<?> splitClass;

      try {
        splitClass = Class.forName(className);
      } catch (ClassNotFoundException e) {
        throw new IOException(e);
      }

      realSplit =
          (org.apache.hadoop.mapred.InputSplit) ReflectionUtils.newInstance(splitClass, null);
      ((Writable) realSplit).readFields(in);
    }
 public Writable readWritable(Writable writable) throws IOException {
   ByteArrayInputStream bais = new ByteArrayInputStream(in.readBytes());
   DataInputStream dis = new DataInputStream(bais);
   String className = WritableUtils.readString(dis);
   if (writable == null) {
     try {
       Class<? extends Writable> cls = conf.getClassByName(className).asSubclass(Writable.class);
       writable = (Writable) ReflectionUtils.newInstance(cls, conf);
     } catch (ClassNotFoundException e) {
       throw new IOException(e);
     }
   } else if (!writable.getClass().getName().equals(className)) {
     throw new IOException("wrong Writable class given");
   }
   writable.readFields(dis);
   return writable;
 }
 public void readFields(DataInput in) throws IOException {
   file = new Path(WritableUtils.readString(in));
   len = WritableUtils.readVLong(in);
 }
 @Override
 public void readFields(DataInput in) throws IOException {
   key = WritableUtils.readVLong(in);
   keyValue = WritableUtils.readString(in);
 }
Beispiel #15
0
 @Override
 public void readFields(DataInput in) throws IOException {
   // TODO Auto-generated method stub
   empName = WritableUtils.readString(in);
   empID = WritableUtils.readVInt(in);
 }
 /**
  * Read a single field schema
  *
  * @param in DataInput
  * @return field schema read
  * @throws IOException I/O errors
  */
 public static FieldSchema readFieldSchema(DataInput in) throws IOException {
   FieldSchema fs = new FieldSchema();
   fs.setName(WritableUtils.readString(in));
   fs.setType(WritableUtils.readString(in));
   return fs;
 }
 @Override
 public void readFields(@Nonnull DataInput in) throws IOException {
   super.readFields(in);
   compressedPath = new Path(WritableUtils.readString(in));
 }
 @Override
 public void readFields(DataInput in) throws IOException {
   containerState = AppWorkerContainerState.valueOf(in.readUTF());
   progress = in.readFloat();
   statusMessage = WritableUtils.readString(in);
 }
 @Override
 public void readFields(DataInput dataInput) throws IOException {
   _id = WritableUtils.readString(dataInput);
   _name = WritableUtils.readString(dataInput);
 }
 public void readFields(DataInput in) throws IOException {
   layoutVersion = in.readInt();
   namespaceID = in.readInt();
   clusterID = WritableUtils.readString(in);
   cTime = in.readLong();
 }