コード例 #1
0
ファイル: QuantileDigest.java プロジェクト: cyenjung/pinot
  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);
  }
コード例 #2
0
ファイル: Local.java プロジェクト: slemur/SF3
 void read(DataInput in) throws IOException {
   setStartPc(in.readUnsignedShort());
   setLength(in.readUnsignedShort());
   setNameIndex(in.readUnsignedShort());
   setTypeIndex(in.readUnsignedShort());
   setLocal(in.readUnsignedShort());
 }
コード例 #3
0
 @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();
   }
 }
コード例 #4
0
 public Set<String> read(DataInput s) throws IOException {
   int count = s.readInt();
   Set<String> result = new THashSet<String>(count);
   while (count-- > 0) {
     result.add(s.readUTF());
   }
   return result;
 }
コード例 #5
0
ファイル: JUnitXMLReporter.java プロジェクト: xiongrl/JGroups
 public void readFrom(DataInput in) throws Exception {
   status = in.readInt();
   classname = Bits.readString(in);
   name = Bits.readString(in);
   start_time = in.readLong();
   stop_time = in.readLong();
   failure_type = Bits.readString(in);
   failure_msg = Bits.readString(in);
   stack_trace = Bits.readString(in);
 }
コード例 #6
0
 /**
  * {@inheritDoc}
  *
  * @see Writable#readFields(DataInput)
  */
 public void readFields(DataInput in) throws IOException {
   BSONDecoder dec = new BSONDecoder();
   BSONCallback cb = new BasicBSONCallback();
   // Read the BSON length from the start of the record
   int dataLen = in.readInt();
   byte[] buf = new byte[dataLen];
   in.readFully(buf);
   dec.decode(buf, cb);
   _doc = (BSONObject) cb.get();
   log.info("Decoded a BSON Object: " + _doc);
 }
コード例 #7
0
    @Override
    public GeobufFeature deserialize(DataInput dataInput, int i) throws IOException {
      int len = dataInput.readInt();
      byte[] feat = new byte[len];
      dataInput.readFully(feat);
      Geobuf.Data data = Geobuf.Data.parseFrom(feat);

      return new GeobufFeature(
          data.getFeatureCollection().getFeatures(0),
          data.getKeysList(),
          Math.pow(10, data.getPrecision()));
    }
コード例 #8
0
  @SuppressWarnings("unchecked")
  void load(DataInput dis) throws IOException {
    type = dis.readByte();
    int size = dis.readInt();

    list = new ArrayList<T>();
    for (int i = 0; i < size; i++) {
      Tag tag = Tag.newTag(type, null);
      tag.load(dis);
      list.add((T) tag);
    }
  }
コード例 #9
0
ファイル: GMS.java プロジェクト: jtoerber/JGroups
 public void readFrom(DataInput in) throws Exception {
   type = in.readByte();
   boolean isMergeView = in.readBoolean();
   if (isMergeView) view = (View) Util.readStreamable(MergeView.class, in);
   else view = (View) Util.readStreamable(View.class, in);
   mbr = Util.readAddress(in);
   mbrs = Util.readAddresses(in, ArrayList.class);
   join_rsp = (JoinRsp) Util.readStreamable(JoinRsp.class, in);
   my_digest = (Digest) Util.readStreamable(Digest.class, in);
   merge_id = (MergeId) Util.readStreamable(MergeId.class, in);
   merge_rejected = in.readBoolean();
   useFlushIfPresent = in.readBoolean();
 }
コード例 #10
0
ファイル: Node.java プロジェクト: jd836/CornellCourseProject
 // 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);
   }
 }
コード例 #11
0
  public LocalVariableTable_attribute(ConstantPool constantPool, Visitable owner, DataInput in)
      throws IOException {
    super(constantPool, owner);

    int byteCount = in.readInt();
    Logger.getLogger(getClass()).debug("Attribute length: " + byteCount);

    int localVariableTableLength = in.readUnsignedShort();
    Logger.getLogger(getClass())
        .debug("Reading " + localVariableTableLength + " local variable(s) ...");
    for (int i = 0; i < localVariableTableLength; i++) {
      Logger.getLogger(getClass()).debug("Local variable " + i + ":");
      localVariables.add(new LocalVariable(this, in));
    }
  }
コード例 #12
0
  static Attribute define(ConstantPool cp, String name, int length, DataInput din)
      throws IOException {

    LineNumberTableAttr lineNumbers = new LineNumberTableAttr(cp);

    int size = din.readUnsignedShort();
    for (int i = 0; i < size; i++) {
      int start_pc = din.readUnsignedShort();
      int line_number = din.readUnsignedShort();

      lineNumbers.addEntry(new FixedLocation(start_pc), line_number);
    }

    return lineNumbers;
  }
コード例 #13
0
    public TreeRequest deserialize(DataInput dis, int version) throws IOException {
      String sessId = dis.readUTF();
      InetAddress endpoint = CompactEndpointSerializationHelper.deserialize(dis);
      CFPair cfpair = new CFPair(dis.readUTF(), dis.readUTF());
      Range<Token> range;
      if (version > MessagingService.VERSION_07)
        range = (Range<Token>) AbstractBounds.serializer().deserialize(dis, version);
      else
        range =
            new Range<Token>(
                StorageService.getPartitioner().getMinimumToken(),
                StorageService.getPartitioner().getMinimumToken());

      return new TreeRequest(sessId, endpoint, range, cfpair);
    }
コード例 #14
0
 public void readFields(DataInput in) throws IOException {
   // instance-specific
   this.sampleStrs = new ArrayList<String>();
   int numSamples = in.readInt();
   for (int i = 0; i < numSamples; i++) {
     sampleStrs.add(UTF8.readString(in).toString());
   }
   this.tokenClassIdentifier = in.readInt();
   if (in.readBoolean()) {
     this.tokenParameter = UTF8.readString(in);
   } else {
     this.tokenParameter = null;
   }
   this.schema = computeAvroSchema();
 }
コード例 #15
0
ファイル: PTableImpl.java プロジェクト: cclien/phoenix
 @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);
 }
コード例 #16
0
 public void readFields(DataInput in) throws IOException {
   int numUnionElts = in.readInt();
   this.unionTypes = new ArrayList<InferredType>();
   for (int i = 0; i < numUnionElts; i++) {
     unionTypes.add(InferredType.readType(in));
   }
   this.schema = computeAvroSchema();
 }
コード例 #17
0
 /** Deserialize an unknown InferredType from the given input stream */
 public static InferredType readType(DataInput in) throws IOException {
   InferredType it = null;
   byte b = in.readByte();
   String name = in.readUTF();
   if (b == BASE_TYPE) {
     it = new BaseType(name);
   } else if (b == STRUCT_TYPE) {
     it = new StructType(name);
   } else if (b == ARRAY_TYPE) {
     it = new ArrayType(name);
   } else if (b == UNION_TYPE) {
     it = new UnionType(name);
   } else {
     throw new IOException("No type found: " + b);
   }
   it.readFields(in);
   return it;
 }
コード例 #18
0
 public void readFields(DataInput in) throws IOException {
   isNode = in.readBoolean();
   if (isNode) {
     node = new PageRankNode();
     node.readFields(in);
   } else {
     contribution = new Contribution();
     contribution.readFields(in);
   }
 }
コード例 #19
0
  static Attribute define(ConstantPool cp, String name, int length, DataInput din)
      throws IOException {

    InnerClassesAttr innerClasses = new InnerClassesAttr(cp);

    int size = din.readUnsignedShort();
    for (int i = 0; i < size; i++) {
      int inner_index = din.readUnsignedShort();
      int outer_index = din.readUnsignedShort();
      int name_index = din.readUnsignedShort();
      int af = din.readUnsignedShort();

      ConstantClassInfo inner;
      if (inner_index == 0) {
        inner = null;
      } else {
        inner = (ConstantClassInfo) cp.getConstant(inner_index);
      }

      ConstantClassInfo outer;
      if (outer_index == 0) {
        outer = null;
      } else {
        outer = (ConstantClassInfo) cp.getConstant(outer_index);
      }

      ConstantUTFInfo innerName;
      if (name_index == 0) {
        innerName = null;
      } else {
        innerName = (ConstantUTFInfo) cp.getConstant(name_index);
      }

      Info info = new Info(inner, outer, innerName, af);
      innerClasses.mInnerClasses.add(info);
    }

    return innerClasses;
  }
コード例 #20
0
ファイル: Subpopulation.java プロジェクト: pgoelz/xfp
 /**
  * Reads a subpopulation in binary form, from the format generated by writeSubpopulation(...). If
  * the number of individuals is not identical, the individuals array will be deleted and replaced
  * with a new array, and a warning will be generated as individuals will have to be created using
  * newIndividual(...) rather than readIndividual(...)
  */
 public void readSubpopulation(final EvolutionState state, final DataInput dataInput)
     throws IOException {
   int numIndividuals = dataInput.readInt();
   if (numIndividuals != individuals.length) {
     state.output.warnOnce(
         "On reading subpopulation from binary stream, the subpopulation size was incorrect.\n"
             + "Had to resize and use newIndividual() instead of readIndividual().");
     individuals = new Individual[numIndividuals];
     for (int i = 0; i < individuals.length; i++)
       individuals[i] = species.newIndividual(state, dataInput);
   } else
     for (int i = 0; i < individuals.length; i++) individuals[i].readIndividual(state, dataInput);
 }
コード例 #21
0
ファイル: Executing.java プロジェクト: rhusar/JGroups
    public void readFrom(DataInput in) throws Exception {
      type = Type.values()[in.readByte()];
      // We can't use Util.readObject since it's size is limited to 2^15-1
      try {
        short first = in.readShort();
        if (first == -1) {
          object = Util.readGenericStreamable(in);
        } else {
          ByteBuffer bb = ByteBuffer.allocate(4);
          bb.putShort(first);
          bb.putShort(in.readShort());

          int size = bb.getInt(0);
          byte[] bytes = new byte[size];
          in.readFully(bytes, 0, size);
          object = Util.objectFromByteBuffer(bytes);
        }
      } catch (IOException e) {
        throw e;
      } catch (Exception e) {
        throw new IOException("Exception encountered while serializing execution request", e);
      }
      request = in.readLong();
    }
コード例 #22
0
ファイル: QuantileDigest.java プロジェクト: cyenjung/pinot
  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);
    }
  }
コード例 #23
0
ファイル: ENCRYPT.java プロジェクト: x97mdr/JGroups
 public void readFrom(DataInput in) throws Exception {
   type = in.readByte();
   short len = in.readShort();
   version = new byte[len];
   in.readFully(version);
 }
コード例 #24
0
  public void readFields(DataInput in) throws IOException {
    super.readFields(in);

    score = in.readFloat();
  }
コード例 #25
0
ファイル: Executing.java プロジェクト: rhusar/JGroups
 @Override
 public void readFrom(DataInput in) throws Exception {
   super.readFrom(in);
   threadId = in.readLong();
 }
コード例 #26
0
 public void readGenotype(final EvolutionState state, final DataInput dataInput)
     throws IOException {
   int len = dataInput.readInt();
   if (genome == null || genome.length != len) genome = new boolean[len];
   for (int x = 0; x < genome.length; x++) genome[x] = dataInput.readBoolean();
 }
コード例 #27
0
ファイル: ObjectWritable.java プロジェクト: hmilxin/hadoop
  /** Read a {@link Writable}, {@link String}, primitive type, or an array of the preceding. */
  @SuppressWarnings("unchecked")
  public static Object readObject(DataInput in, ObjectWritable objectWritable, Configuration conf)
      throws IOException {
    String className = UTF8.readString(in);
    Class<?> declaredClass = PRIMITIVE_NAMES.get(className);
    if (declaredClass == null) {
      declaredClass = loadClass(conf, className);
    }

    Object instance;

    if (declaredClass.isPrimitive()) { // primitive types

      if (declaredClass == Boolean.TYPE) { // boolean
        instance = Boolean.valueOf(in.readBoolean());
      } else if (declaredClass == Character.TYPE) { // char
        instance = Character.valueOf(in.readChar());
      } else if (declaredClass == Byte.TYPE) { // byte
        instance = Byte.valueOf(in.readByte());
      } else if (declaredClass == Short.TYPE) { // short
        instance = Short.valueOf(in.readShort());
      } else if (declaredClass == Integer.TYPE) { // int
        instance = Integer.valueOf(in.readInt());
      } else if (declaredClass == Long.TYPE) { // long
        instance = Long.valueOf(in.readLong());
      } else if (declaredClass == Float.TYPE) { // float
        instance = Float.valueOf(in.readFloat());
      } else if (declaredClass == Double.TYPE) { // double
        instance = Double.valueOf(in.readDouble());
      } else if (declaredClass == Void.TYPE) { // void
        instance = null;
      } else {
        throw new IllegalArgumentException("Not a primitive: " + declaredClass);
      }

    } else if (declaredClass.isArray()) { // array
      int length = in.readInt();
      instance = Array.newInstance(declaredClass.getComponentType(), length);
      for (int i = 0; i < length; i++) {
        Array.set(instance, i, readObject(in, conf));
      }

    } else if (declaredClass == String.class) { // String
      instance = UTF8.readString(in);
    } else if (declaredClass.isEnum()) { // enum
      instance = Enum.valueOf((Class<? extends Enum>) declaredClass, UTF8.readString(in));
    } else { // Writable
      Class instanceClass = null;
      String str = UTF8.readString(in);
      instanceClass = loadClass(conf, str);

      Writable writable = WritableFactories.newInstance(instanceClass, conf);
      writable.readFields(in);
      instance = writable;

      if (instanceClass == NullInstance.class) { // null
        declaredClass = ((NullInstance) instance).declaredClass;
        instance = null;
      }
    }

    if (objectWritable != null) { // store values
      objectWritable.declaredClass = declaredClass;
      objectWritable.instance = instance;
    }

    return instance;
  }