Example #1
0
  public void readFields(DataInput in) throws IOException {
    in.readFully(internalBytes, 0, 4);
    if (TimestampWritable.hasDecimalOrSecondVInt(internalBytes[0])) {
      in.readFully(internalBytes, 4, 1);
      int len = (byte) WritableUtils.decodeVIntSize(internalBytes[4]);
      if (len > 1) {
        in.readFully(internalBytes, 5, len - 1);
      }

      long vlong = LazyBinaryUtils.readVLongFromByteArray(internalBytes, 4);
      if (vlong < -1000000000 || vlong > 999999999) {
        throw new IOException(
            "Invalid first vint value (encoded nanoseconds) of a TimestampWritable: "
                + vlong
                + ", expected to be between -1000000000 and 999999999.");
        // Note that -1000000000 is a valid value corresponding to a nanosecond timestamp
        // of 999999999, because if the second VInt is present, we use the value
        // (-reversedNanoseconds - 1) as the second VInt.
      }
      if (vlong < 0) {
        // This indicates there is a second VInt containing the additional bits of the seconds
        // field.
        in.readFully(internalBytes, 4 + len, 1);
        int secondVIntLen = (byte) WritableUtils.decodeVIntSize(internalBytes[4 + len]);
        if (secondVIntLen > 1) {
          in.readFully(internalBytes, 5 + len, secondVIntLen - 1);
        }
      }
    }
    currentBytes = internalBytes;
    this.offset = 0;
  }
 public void readInternal(DataInput in) throws IOException {
   name = in.readUTF();
   int targetBytesLength = in.readInt();
   byte[] targetBytes = new byte[targetBytesLength];
   in.readFully(targetBytes);
   this.target = (ActorRef) Util.toObject(targetBytes);
 }
  @SuppressWarnings("unchecked")
  @Override
  public void readFields(DataInput in) throws IOException {
    super.readFields(in);

    // First clear the map. Otherwise we will just accumulate
    // entries every time this method is called.
    this.instance.clear();

    // Read the number of entries in the map

    int entries = in.readInt();

    // Then read each key/value pair

    for (int i = 0; i < entries; i++) {
      Writable key = (Writable) ReflectionUtils.newInstance(getClass(in.readByte()), getConf());

      key.readFields(in);

      Writable value = (Writable) ReflectionUtils.newInstance(getClass(in.readByte()), getConf());

      value.readFields(in);
      instance.put(key, value);
    }
  }
 @Override
 public void readFields(DataInput in) throws IOException {
   RowKeySchema schema = new RowKeySchema();
   schema.readFields(in);
   int maxLength = getTerminatorCount(schema);
   int andLen = in.readInt();
   List<List<KeyRange>> slots = Lists.newArrayListWithExpectedSize(andLen);
   for (int i = 0; i < andLen; i++) {
     int orlen = in.readInt();
     List<KeyRange> orclause = Lists.newArrayListWithExpectedSize(orlen);
     slots.add(orclause);
     int maxSlotLength = 0;
     for (int j = 0; j < orlen; j++) {
       KeyRange range = new KeyRange();
       range.readFields(in);
       if (range.getLowerRange().length > maxSlotLength) {
         maxSlotLength = range.getLowerRange().length;
       }
       if (range.getUpperRange().length > maxSlotLength) {
         maxSlotLength = range.getUpperRange().length;
       }
       orclause.add(range);
     }
     maxLength += maxSlotLength;
   }
   this.init(slots, schema, maxLength);
 }
 public void a(DataInput datainput) {
   this.a = datainput.readInt();
   this.b = datainput.readShort();
   this.c = datainput.readInt();
   this.d = datainput.readByte();
   this.e = d(datainput);
 }
  @Override
  public void readConstructorParams(DataInput in) throws IOException {
    super.readConstructorParams(in);

    width = in.readInt();
    height = in.readInt();
  }
 /**
  * Deserializes this object.
  *
  * @param in source for raw byte representation
  */
 public void readFields(DataInput in) throws IOException {
   this.clear();
   int size = in.readInt();
   for (int i = 0; i < size; i++) {
     add(i, in.readInt());
   }
 }
 public FileEntry(DataInput in, boolean dummy /* to distinguish from general constructor*/)
     throws IOException {
   super(in);
   myTimestamp = in.readLong();
   isReadOnly = in.readBoolean();
   myContent = new StoredContent(in);
 }
Example #9
0
    @Override
    public void readFields(DataInput dataInput) throws IOException {
      int len;
      byte[] buf;

      locations = new ArrayList<String>();
      length = dataInput.readLong();
      LOG.debug("Read length of " + length);
      int numElements = dataInput.readInt();
      LOG.debug("Read numElements of " + numElements);
      for (int i = 0; i < numElements; i++) {
        len = dataInput.readInt();
        LOG.debug("Read file length of " + len);
        buf = new byte[len];
        dataInput.readFully(buf);
        locations.add(new String(buf));
      }
      bucketNum = dataInput.readInt();
      LOG.debug("Read bucket number of " + bucketNum);
      len = dataInput.readInt();
      LOG.debug("Read base path length of " + len);
      if (len > 0) {
        buf = new byte[len];
        dataInput.readFully(buf);
        base = new Path(new String(buf));
      }
      numElements = dataInput.readInt();
      deltas = new Path[numElements];
      for (int i = 0; i < numElements; i++) {
        len = dataInput.readInt();
        buf = new byte[len];
        dataInput.readFully(buf);
        deltas[i] = new Path(new String(buf));
      }
    }
  @Override
  public void readObject(DataInput in) throws IOException {
    super.readObject(in);

    ((PositionInterpolator) node).setStartPosition(in.readFloat());
    ((PositionInterpolator) node).setEndPosition(in.readFloat());
  }
 protected String looseUnmarshalString(DataInput dataIn) throws IOException {
   if (dataIn.readBoolean()) {
     return dataIn.readUTF();
   } else {
     return null;
   }
 }
  private static Object loadTyped(final DataInput in) {
    try {
      switch (in.readByte()) {
        case STRING:
          return RW.readUTF(in);
        case NONE:
          return null;
        case INTEGER:
          return DataInputOutputUtil.readINT(in);
        case LONG:
          return in.readLong();
        case FLOAT:
          return in.readFloat();
        case DOUBLE:
          return in.readDouble();
        case TYPE:
          return Type.getType(RW.readUTF(in));
      }
    } catch (IOException e) {
      throw new BuildDataCorruptedException(e);
    }

    assert (false);

    return null;
  }
Example #13
0
 public Object readData(DataInput dataInput) throws IOException {
   if (!dataInput.readBoolean()) {
     return null;
   }
   float val = dataInput.readFloat();
   return Float.valueOf(val);
 }
Example #14
0
 /**
  * Reads the state from the stream.
  *
  * @param in the input stream, not null
  * @return the created object, not null
  * @throws IOException if an error occurs
  */
 static ZoneRules readExternal(DataInput in) throws IOException, ClassNotFoundException {
   int stdSize = in.readInt();
   long[] stdTrans = (stdSize == 0) ? EMPTY_LONG_ARRAY : new long[stdSize];
   for (int i = 0; i < stdSize; i++) {
     stdTrans[i] = Ser.readEpochSec(in);
   }
   ZoneOffset[] stdOffsets = new ZoneOffset[stdSize + 1];
   for (int i = 0; i < stdOffsets.length; i++) {
     stdOffsets[i] = Ser.readOffset(in);
   }
   int savSize = in.readInt();
   long[] savTrans = (savSize == 0) ? EMPTY_LONG_ARRAY : new long[savSize];
   for (int i = 0; i < savSize; i++) {
     savTrans[i] = Ser.readEpochSec(in);
   }
   ZoneOffset[] savOffsets = new ZoneOffset[savSize + 1];
   for (int i = 0; i < savOffsets.length; i++) {
     savOffsets[i] = Ser.readOffset(in);
   }
   int ruleSize = in.readByte();
   ZoneOffsetTransitionRule[] rules =
       (ruleSize == 0) ? EMPTY_LASTRULES : new ZoneOffsetTransitionRule[ruleSize];
   for (int i = 0; i < ruleSize; i++) {
     rules[i] = ZoneOffsetTransitionRule.readExternal(in);
   }
   return new ZoneRules(stdTrans, stdOffsets, savTrans, savOffsets, rules);
 }
Example #15
0
  @Override
  @SuppressWarnings("unchecked")
  public void readFields(DataInput in) throws IOException {
    this.fst = null;
    this.snd = null;

    final ClassIndex index = new ClassIndex();
    index.readFields(in);

    int flags = in.readByte();

    try {
      if ((flags & FST_NULL) == NOT_NULL) {
        fst = (A) index.getClass(in.readByte()).newInstance();
        fst.readFields(in);
      }

      if ((flags & SND_NULL) == NOT_NULL) {
        snd = (B) index.getClass(in.readByte()).newInstance();
        snd.readFields(in);
      }
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
Example #16
0
  mymemory() {
    mem = new int[65536];
    for (int i = 0; i < 65536; i++) mem[i] = 0;

    try {
      DataInput in = new DataInputStream(new FileInputStream("zexdoc.com"));
      for (int i = 0; i < 8704; i++) mem[i + 0x100] = (int) (in.readByte() & 0xFF);
    } catch (Exception e) {
      System.out.println("Cannot read mc1000.rom");
      System.exit(1);
    }

    mem[5] = 0x32;
    mem[6] = 0x00;
    mem[7] = 0x00;
    mem[8] = 0x79;
    mem[9] = 0x32;
    mem[10] = 0x81;
    mem[11] = 0x00;
    mem[12] = 0x7b;
    mem[13] = 0x32;
    mem[14] = 0x82;
    mem[15] = 0x00;
    mem[16] = 0x7a;
    mem[17] = 0x32;
    mem[18] = 0x83;
    mem[19] = 0x00;
    mem[20] = 0xc9;
  }
 @Override
 public void fromData(DataInput in) throws IOException, ClassNotFoundException {
   super.fromData(in);
   this.prId = in.readInt();
   this.processorId = in.readInt();
   this.profiles = DataSerializer.readObject(in);
 }
  protected boolean consumeHttpResponseHead(DataInput dataInput) throws IOException {

    String statusLine = dataInput.readLine();

    if (!statusLine.equals("HTTP/1.1 200 OK")) {
      throw new IOException("Error status line: " + statusLine);
    }

    boolean forceCloseSocket = false;

    String line = null;

    while (((line = dataInput.readLine()) != null) && (line.length() > 0)) {
      String[] headerKeyValuePair = StringUtil.split(line, CharPool.COLON);

      String headerName = headerKeyValuePair[0].trim();

      headerName = StringUtil.toLowerCase(headerName);

      if (headerName.equals("connection")) {
        String headerValue = headerKeyValuePair[1].trim();

        headerValue = StringUtil.toLowerCase(headerValue);

        if (headerValue.equals("close")) {
          forceCloseSocket = true;
        }
      }
    }

    return forceCloseSocket;
  }
 /** Abstract. Reads the raw packet data from the data stream. */
 public void readPacketData(DataInput par1DataInput) throws IOException {
   this.xPosition = par1DataInput.readDouble();
   this.yPosition = par1DataInput.readDouble();
   this.stance = par1DataInput.readDouble();
   this.zPosition = par1DataInput.readDouble();
   super.readPacketData(par1DataInput);
 }
Example #20
0
  @Override
  public void readFields(DataInput dIn) throws IOException {
    instanceId = dIn.readUTF();

    // Hadoop Configuration has to get its act right
    int len = dIn.readInt();
    byte[] array = new byte[len];
    dIn.readFully(array);
    ByteArrayInputStream bais = new ByteArrayInputStream(array);
    conf = new XConfiguration(bais);

    def = new LiteWorkflowApp();
    def.readFields(dIn);
    status = Status.valueOf(dIn.readUTF());
    int numExPaths = dIn.readInt();
    for (int x = 0; x < numExPaths; x++) {
      String path = dIn.readUTF();
      String nodeName = dIn.readUTF();
      boolean isStarted = dIn.readBoolean();
      NodeInstance nodeInstance = new NodeInstance(nodeName);
      nodeInstance.started = isStarted;
      executionPaths.put(path, nodeInstance);
    }
    int numVars = dIn.readInt();
    for (int x = 0; x < numVars; x++) {
      String vName = dIn.readUTF();
      String vVal = readBytesAsString(dIn);
      persistentVars.put(vName, vVal);
    }
    refreshLog();
  }
Example #21
0
 @Override
 public void readFields(DataInput in) throws IOException {
   attr = in.readInt();
   split = in.readDouble();
   loChild = Node.read(in);
   hiChild = Node.read(in);
 }
 @Override
 public void handleRequest(
     final DataInput input,
     final ActiveOperation.ResultHandler<Void> resultHandler,
     final ManagementRequestContext<Void> context)
     throws IOException {
   byte param = input.readByte();
   // If it failed
   if (param != DomainControllerProtocol.PARAM_OK) {
     final byte errorCode = input.readByte();
     final String message = input.readUTF();
     resultHandler.failed(
         new SlaveRegistrationException(
             SlaveRegistrationException.ErrorCode.parseCode(errorCode), message));
     return;
   }
   final ModelNode extensions = new ModelNode();
   extensions.readExternal(input);
   context.executeAsync(
       new ManagementRequestContext.AsyncTask<Void>() {
         @Override
         public void execute(ManagementRequestContext<Void> voidManagementRequestContext)
             throws Exception {
           //
           final ModelNode subsystems = resolveSubsystemVersions(extensions);
           channelHandler.executeRequest(
               context.getOperationId(), new RegisterSubsystemsRequest(subsystems));
         }
       });
 }
 @Override
 public void fromData(DataInput in) throws IOException, ClassNotFoundException {
   this.prId = in.readInt();
   this.scope = Scope.fromOrdinal(in.readByte());
   this.pAttrs = PartitionAttributesImpl.createFromData(in);
   this.isDestroying = in.readBoolean();
   this.isColocationComplete = in.readBoolean();
   this.nodes = new VersionedArrayList();
   InternalDataSerializer.invokeFromData(this.nodes, in);
   this.partitionResolver = DataSerializer.readString(in);
   this.colocatedWith = DataSerializer.readString(in);
   this.fullPath = DataSerializer.readString(in);
   this.ea = EvictionAttributesImpl.createFromData(in);
   this.regionIdleTimeout = ExpirationAttributes.createFromData(in);
   this.regionTimeToLive = ExpirationAttributes.createFromData(in);
   this.entryIdleTimeout = ExpirationAttributes.createFromData(in);
   this.entryTimeToLive = ExpirationAttributes.createFromData(in);
   this.firstDataStoreCreated = in.readBoolean();
   this.elderFPAs = DataSerializer.readObject(in);
   if (this.elderFPAs == null) {
     this.elderFPAs = new LinkedHashSet<FixedPartitionAttributesImpl>();
   }
   this.partitionListenerClassNames = DataSerializer.readArrayList(in);
   this.gatewaySenderIds = DataSerializer.readObject(in);
   if (this.gatewaySenderIds == null) {
     this.gatewaySenderIds = Collections.emptySet();
   }
 }
Example #24
0
  private static Node deserializeNode(DataInput input) throws IOException {
    int level = input.readUnsignedByte();
    long value = input.readLong();
    double weight = input.readDouble();

    return new Node(value, level, weight);
  }
 /**
  * Construct object from file stream.
  *
  * @param file Input stream
  * @throws IOException
  */
 InnerClass(DataInput file) throws IOException {
   this(
       file.readUnsignedShort(),
       file.readUnsignedShort(),
       file.readUnsignedShort(),
       file.readUnsignedShort());
 }
Example #26
0
  public final void readFields(DataInput in) throws IOException {
    metadata.clear();
    int sizeOrVersion = in.readInt();
    if (sizeOrVersion < 0) { // version
      version = sizeOrVersion;
      switch (version) {
        case VERSION:
          url = Text.readString(in);
          base = Text.readString(in);

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

          contentType = Text.readString(in);
          metadata.readFields(in);
          break;
        default:
          throw new VersionMismatchException((byte) VERSION, (byte) version);
      }
    } else { // size
      byte[] compressed = new byte[sizeOrVersion];
      in.readFully(compressed, 0, compressed.length);
      ByteArrayInputStream deflated = new ByteArrayInputStream(compressed);
      DataInput inflater = new DataInputStream(new InflaterInputStream(deflated));
      readFieldsCompressed(inflater);
    }
  }
Example #27
0
 /*
  * Read a String as a Network Int n, followed by n Bytes
  * Alternative to 16 bit read/writeUTF.
  * Encoding standard is... ?
  *
  */
 public static String readString(DataInput in) throws IOException {
   int length = in.readInt();
   if (length == -1) return null;
   byte[] buffer = new byte[length];
   in.readFully(buffer); // could/should use readFully(buffer,0,length)?
   return new String(buffer, "UTF-8");
 }
 @Override
 public void readFields(DataInput in) throws IOException {
   // read head (rows, cols)
   _numRows = in.readInt();
   int numCols = in.readInt();
   // read columns (value type, data)
   _schema.clear();
   _coldata.clear();
   for (int j = 0; j < numCols; j++) {
     ValueType vt = ValueType.values()[in.readByte()];
     String name = in.readUTF();
     Array arr = null;
     switch (vt) {
       case STRING:
         arr = new StringArray(new String[_numRows]);
         break;
       case BOOLEAN:
         arr = new BooleanArray(new boolean[_numRows]);
         break;
       case INT:
         arr = new LongArray(new long[_numRows]);
         break;
       case DOUBLE:
         arr = new DoubleArray(new double[_numRows]);
         break;
       default:
         throw new IOException("Unsupported value type: " + vt);
     }
     arr.readFields(in);
     _schema.add(vt);
     _colnames.add(name);
     _coldata.add(arr);
   }
 }
 @Override
 public void fromData(DataInput in) throws IOException, ClassNotFoundException {
   super.fromData(in);
   this.attributeCode = in.readByte();
   this.newValue = in.readInt();
   this.cacheId = in.readInt();
 }
Example #30
0
 public RowCacheKey deserialize(DataInput dataInput) throws IOException {
   long msb = dataInput.readLong();
   long lsb = dataInput.readLong();
   byte[] key = new byte[dataInput.readInt()];
   dataInput.readFully(key);
   return new RowCacheKey(new UUID(msb, lsb), key);
 }