예제 #1
0
 /** 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);
 }
예제 #2
0
파일: Prism.java 프로젝트: easysg/spatedb
 public void readFields(DataInput in) throws IOException {
   this.t1 = in.readDouble();
   this.x1 = in.readDouble();
   this.y1 = in.readDouble();
   this.t2 = in.readDouble();
   this.x2 = in.readDouble();
   this.y2 = in.readDouble();
 }
 @Override
 public APoint deserialize(DataInput in) throws HyracksDataException {
   try {
     return new APoint(in.readDouble(), in.readDouble());
   } catch (IOException e) {
     throw new HyracksDataException(e);
   }
 }
 @Override
 public void doReadFields(DataInput in) throws IOException {
   int length = in.readInt();
   parameters = new double[length];
   for (int i = 0; i < length; i++) {
     parameters[i] = in.readDouble();
   }
   this.error = in.readDouble();
 }
예제 #5
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);
  }
  @Override
  public void readFields(DataInput in) throws IOException {
    initialize();
    int numFields = in.readInt();

    for (int i = 0; i < numFields; ++i) {
      byte type = in.readByte();

      if (type == BYTE) {
        fields.add(in.readByte());
      } else if (type == BOOLEAN) {
        fields.add(in.readBoolean());
      } else if (type == INT) {
        fields.add(in.readInt());
      } else if (type == LONG) {
        fields.add(in.readLong());
      } else if (type == FLOAT) {
        fields.add(in.readFloat());
      } else if (type == DOUBLE) {
        fields.add(in.readDouble());
      } else if (type == STRING) {
        fields.add(in.readUTF());
      } else if (type == BYTE_ARRAY) {
        int len = in.readShort();
        byte[] bytes = new byte[len];
        in.readFully(bytes);
        fields.add(bytes);
      } else {
        throw new IllegalArgumentException("Failed encoding, unknown element type in stream");
      }
    }
  }
  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;
  }
예제 #8
0
 /**
  * Read this pixel tissues object from the given data input stream.
  *
  * <p><I>Note:</I> The file index and pixel index are not read.
  *
  * @param in Data input stream.
  * @exception IOException Thrown if an I/O error occurred.
  */
 public void read(DataInput in) throws IOException {
   int L = in.readShort();
   if (L == 0) {
     rho = null;
     R1 = null;
   } else {
     rho = new double[L];
     R1 = new double[L];
     for (int i = 0; i < L; ++i) {
       rho[i] = in.readDouble();
     }
     for (int i = 0; i < L; ++i) {
       R1[i] = in.readDouble();
     }
   }
 }
예제 #9
0
 /*
  * (non-Javadoc)
  *
  * @see com.ibm.jaql.json.meta.MetaAccessor#read(java.io.DataInput,
  *      java.lang.Object)
  */
 @Override
 public void read(DataInput in, Object obj)
     throws IOException, IllegalArgumentException, IllegalAccessException,
         InvocationTargetException {
   double x = in.readDouble();
   setter.invoke(obj, x);
 }
예제 #10
0
 @Override
 public void readFields(DataInput in) throws IOException {
   attr = in.readInt();
   split = in.readDouble();
   loChild = Node.read(in);
   hiChild = Node.read(in);
 }
예제 #11
0
  public void readFields(DataInput in) throws IOException {
    if (in.readBoolean()) {
      this.semiClusterId = in.readUTF();
    }
    this.semiClusterScore = in.readDouble();

    if (in.readBoolean()) {
      int len = in.readInt();
      if (len > 0) {
        for (int i = 0; i < len; i++) {
          SemiClusteringVertex v = new SemiClusteringVertex();
          v.readFields(in);
          semiClusterVertexList.add(v);
        }
      }
    }
    int len = in.readInt();
    if (len > 0) {
      for (int i = 0; i < len; i++) {
        SemiClusterDetails sd = new SemiClusterDetails();
        sd.readFields(in);
        semiClusterContainThis.add(sd);
      }
    }
  }
예제 #12
0
  @Override
  public void readFields(DataInput in) throws IOException {
    int flags = in.readByte();
    Preconditions.checkArgument(
        flags >> NUM_FLAGS == 0, "Unknown flags set: %d", Integer.toString(flags, 2));
    boolean dense = (flags & FLAG_DENSE) != 0;
    boolean sequential = (flags & FLAG_SEQUENTIAL) != 0;
    boolean named = (flags & FLAG_NAMED) != 0;
    boolean laxPrecision = (flags & FLAG_LAX_PRECISION) != 0;

    int size = Varint.readUnsignedVarInt(in);
    Vector v;
    if (dense) {
      double[] values = new double[size];
      for (int i = 0; i < size; i++) {
        values[i] = laxPrecision ? in.readFloat() : in.readDouble();
      }
      v = new DenseVector(values);
    } else {
      int numNonDefaultElements = Varint.readUnsignedVarInt(in);
      v =
          sequential
              ? new SequentialAccessSparseVector(size, numNonDefaultElements)
              : new RandomAccessSparseVector(size, numNonDefaultElements);
      if (sequential) {
        int lastIndex = 0;
        for (int i = 0; i < numNonDefaultElements; i++) {
          int delta = Varint.readUnsignedVarInt(in);
          int index = lastIndex + delta;
          lastIndex = index;
          double value = laxPrecision ? in.readFloat() : in.readDouble();
          v.setQuick(index, value);
        }
      } else {
        for (int i = 0; i < numNonDefaultElements; i++) {
          int index = Varint.readUnsignedVarInt(in);
          double value = laxPrecision ? in.readFloat() : in.readDouble();
          v.setQuick(index, value);
        }
      }
    }
    if (named) {
      String name = in.readUTF();
      v = new NamedVector(v, name);
    }
    vector = v;
  }
예제 #13
0
 @Override
 public double readDouble() {
   try {
     return input.readDouble();
   } catch (IOException e) {
     throw new IllegalStateException(e);
   }
 }
예제 #14
0
 public void readFields(DataInput in) throws IOException {
   timespent = in.readInt();
   estimated_revenue = in.readDouble();
   int len = in.readInt();
   byte[] b = new byte[len];
   in.readFully(b);
   query_term = new String(b);
 }
 public void readData(DataInput in) throws IOException {
   if (!in.readBoolean()) this.name = in.readUTF();
   if (!in.readBoolean()) this.familyName = in.readUTF();
   if (!in.readBoolean()) this.middleName = in.readUTF();
   this.age = in.readInt();
   this.active = in.readBoolean();
   this.salary = in.readDouble();
 }
예제 #16
0
 @Override
 public void readFields(DataInput in) throws IOException {
   docId = new Text();
   docId.readFields(in);
   distance = new DoubleWritable(in.readDouble());
   vector = new VectorWritable();
   vector.readFields(in);
 }
예제 #17
0
 public void readFrom(DataInput in) throws Exception {
   oob = in.readBoolean();
   sync = in.readBoolean();
   num_threads = in.readInt();
   num_msgs = in.readInt();
   msg_size = in.readInt();
   anycast_count = in.readInt();
   read_percentage = in.readDouble();
 }
예제 #18
0
  public static QuantileDigest deserialize(DataInput input) {
    try {
      double maxError = input.readDouble();
      double alpha = input.readDouble();

      QuantileDigest result = new QuantileDigest(maxError, alpha);

      result.landmarkInSeconds = input.readLong();
      result.min = input.readLong();
      result.max = input.readLong();
      result.totalNodeCount = input.readInt();

      Deque<Node> stack = new ArrayDeque<>();
      for (int i = 0; i < result.totalNodeCount; i++) {
        int flags = input.readByte();

        Node node = deserializeNode(input);

        if ((flags & Flags.HAS_RIGHT) != 0) {
          node.right = stack.pop();
        }

        if ((flags & Flags.HAS_LEFT) != 0) {
          node.left = stack.pop();
        }

        stack.push(node);
        result.weightedCount += node.weightedCount;
        if (node.weightedCount >= ZERO_WEIGHT_THRESHOLD) {
          result.nonZeroNodeCount++;
        }
      }

      if (!stack.isEmpty()) {
        Preconditions.checkArgument(
            stack.size() == 1, "Tree is corrupted. Expected a single root node");
        result.root = stack.pop();
      }

      return result;
    } catch (IOException e) {
      throw Throwables.propagate(e);
    }
  }
예제 #19
0
    public StreamingHistogram deserialize(DataInput dis) throws IOException {
      int maxBinSize = dis.readInt();
      int size = dis.readInt();
      Map<Double, Long> tmp = new HashMap<Double, Long>(size);
      for (int i = 0; i < size; i++) {
        tmp.put(dis.readDouble(), dis.readLong());
      }

      return new StreamingHistogram(maxBinSize, tmp);
    }
예제 #20
0
 @Override
 public void readFields(DataInput in) throws IOException {
   this.id = in.readInt();
   this.setNumObservations(in.readLong());
   this.setTotalObservations(in.readLong());
   this.setCenter(VectorWritable.readVector(in));
   this.setRadius(VectorWritable.readVector(in));
   this.setS0(in.readDouble());
   this.setS1(VectorWritable.readVector(in));
   this.setS2(VectorWritable.readVector(in));
 }
 public void readFields(DataInput in) throws IOException {
   int len = in.readInt();
   hm.clear();
   for (int i = 0; i < len; i++) {
     int l = in.readInt();
     byte[] ba = new byte[l];
     in.readFully(ba);
     String key = new String(ba);
     Double value = in.readDouble();
     hm.put(key, value);
   }
 }
예제 #22
0
  @Override
  public void readConstructorParams(DataInput in) throws IOException {
    super.readConstructorParams(in);

    String fontName = in.readUTF();
    int style = in.readInt();
    int size = in.readInt();
    font = new Font(fontName, style, size);

    tesselationTolerance = in.readDouble();

    GeneralPath shape = null;
    int segType = in.readInt();
    while (segType != Integer.MIN_VALUE) {
      if (shape == null) shape = new GeneralPath();

      if (segType == PathIterator.SEG_MOVETO) {
        shape.moveTo(in.readFloat(), in.readFloat());
      } else if (segType == PathIterator.SEG_LINETO) {
        shape.lineTo(in.readFloat(), in.readFloat());
      } else if (segType == PathIterator.SEG_QUADTO) {
        shape.quadTo(in.readFloat(), in.readFloat(), in.readFloat(), in.readFloat());
      } else if (segType == PathIterator.SEG_CUBICTO) {
        shape.curveTo(
            in.readFloat(),
            in.readFloat(),
            in.readFloat(),
            in.readFloat(),
            in.readFloat(),
            in.readFloat());
      } else if (segType == PathIterator.SEG_CLOSE) {
        shape.closePath();
      }

      segType = in.readInt();
    }
    if (shape != null) extrudePath = new FontExtrusion(shape, in.readDouble());
    else extrudePath = null;
  }
예제 #23
0
 // Used for internal Hadoop purposes
 // Describes how to read this node from across a network
 public void readFields(DataInput in) throws IOException {
   nodeid = in.readLong();
   pageRank = in.readDouble();
   long next = in.readLong();
   ArrayList<Long> ins = new ArrayList<Long>();
   while (next != -1) {
     ins.add(next);
     next = in.readLong();
   }
   outgoing = new long[ins.size()];
   for (int i = 0; i < ins.size(); i++) {
     outgoing[i] = ins.get(i);
   }
 }
  @Override
  public void readFields(DataInput in) throws IOException {
    this.freeEntries = WritableUtils.readVInt(in);
    this.distinct = WritableUtils.readVInt(in);
    this.lowWaterMark = WritableUtils.readVInt(in);
    this.highWaterMark = WritableUtils.readVInt(in);
    this.minLoadFactor = in.readDouble();
    this.maxLoadFactor = in.readDouble();

    this.table = new int[WritableUtils.readVInt(in)];
    for (int i = 0; i < table.length; i++) {
      table[i] = WritableUtils.readVInt(in);
    }

    this.values = new double[WritableUtils.readVInt(in)];
    for (int i = 0; i < values.length; i++) {
      values[i] = in.readDouble();
    }

    this.state = new byte[WritableUtils.readVInt(in)];
    for (int i = 0; i < state.length; i++) {
      state[i] = in.readByte();
    }
  }
 private Object[] processConstantPool(DataInput in, int size) throws IOException {
   Object[] constant_pool = new Object[size];
   for (int i = 1; i < size; ++i) { // CP slot 0 is unused
     byte b = in.readByte();
     switch (b) {
       case jq_ClassFileConstants.CONSTANT_Integer:
         in.readInt();
         break;
       case jq_ClassFileConstants.CONSTANT_Float:
         in.readFloat();
         break;
       case jq_ClassFileConstants.CONSTANT_Long:
         ++i;
         in.readLong();
         break;
       case jq_ClassFileConstants.CONSTANT_Double:
         ++i;
         in.readDouble();
         break;
       case jq_ClassFileConstants.CONSTANT_Utf8:
         {
           byte utf[] = new byte[in.readUnsignedShort()];
           in.readFully(utf);
           constant_pool[i] = Utf8.get(utf);
           break;
         }
       case jq_ClassFileConstants.CONSTANT_Class:
         constant_pool[i] = new Integer(in.readUnsignedShort());
         break;
       case jq_ClassFileConstants.CONSTANT_String:
         in.readUnsignedShort();
         break;
       case jq_ClassFileConstants.CONSTANT_NameAndType:
       case jq_ClassFileConstants.CONSTANT_FieldRef:
       case jq_ClassFileConstants.CONSTANT_MethodRef:
       case jq_ClassFileConstants.CONSTANT_InterfaceMethodRef:
         in.readUnsignedShort();
         in.readUnsignedShort();
         break;
       default:
         throw new ClassFormatError("bad constant pool entry tag: entry=" + i + ", tag=" + b);
     }
   }
   return constant_pool;
 }
 private static AbstractConfigValue readValueData(DataInput in, SimpleConfigOrigin origin)
     throws IOException {
   int stb = in.readUnsignedByte();
   SerializedValueType st = SerializedValueType.forInt(stb);
   if (st == null) throw new IOException("Unknown serialized value type: " + stb);
   switch (st) {
     case BOOLEAN:
       return new ConfigBoolean(origin, in.readBoolean());
     case NULL:
       return new ConfigNull(origin);
     case INT:
       int vi = in.readInt();
       String si = in.readUTF();
       return new ConfigInt(origin, vi, si);
     case LONG:
       long vl = in.readLong();
       String sl = in.readUTF();
       return new ConfigLong(origin, vl, sl);
     case DOUBLE:
       double vd = in.readDouble();
       String sd = in.readUTF();
       return new ConfigDouble(origin, vd, sd);
     case STRING:
       return new ConfigString.Quoted(origin, in.readUTF());
     case LIST:
       int listSize = in.readInt();
       List<AbstractConfigValue> list = new ArrayList<AbstractConfigValue>(listSize);
       for (int i = 0; i < listSize; ++i) {
         AbstractConfigValue v = readValue(in, origin);
         list.add(v);
       }
       return new SimpleConfigList(origin, list);
     case OBJECT:
       int mapSize = in.readInt();
       Map<String, AbstractConfigValue> map = new HashMap<String, AbstractConfigValue>(mapSize);
       for (int i = 0; i < mapSize; ++i) {
         String key = in.readUTF();
         AbstractConfigValue v = readValue(in, origin);
         map.put(key, v);
       }
       return new SimpleConfigObject(origin, map);
   }
   throw new IOException("Unhandled serialized value type: " + st);
 }
  /**
   * Reads a primitive value of the specified class type from the stream.
   *
   * @param in A stream to read from.
   * @param cls A class type of the primitive.
   * @return A primitive.
   * @throws IOException If an I/O error occurs.
   */
  static Object readPrimitive(DataInput in, Class cls) throws IOException {
    if (cls == byte.class) return in.readByte();

    if (cls == short.class) return in.readShort();

    if (cls == int.class) return in.readInt();

    if (cls == long.class) return in.readLong();

    if (cls == float.class) return in.readFloat();

    if (cls == double.class) return in.readDouble();

    if (cls == boolean.class) return in.readBoolean();

    if (cls == char.class) return in.readChar();

    throw new IllegalArgumentException();
  }
예제 #28
0
 @Override
 public void read(DataInput in) throws IOException {
   x = in.readDouble();
   y = in.readDouble();
   z = in.readDouble();
 }
예제 #29
0
 public void readFields(final DataInput dataInput) throws IOException {
   this.setFieldType(FieldType.valueOf(dataInput.readUTF()));
   this.setLowerValue(dataInput.readDouble());
   this.setUpperValue(dataInput.readDouble());
 }
예제 #30
0
 public void readFields(DataInput in) throws IOException {
   _size = _data.length;
   for (int i = 0; i < _size; i++) _data[i] = in.readDouble();
 }