Package org.apache.mahout.math

Examples of org.apache.mahout.math.VectorWritable.readFields()


      rowIndices = new int[numRows];
    }
    VectorWritable vw = new VectorWritable();
    for (int i = 0; i < numRows; i++) {
      rowIndices[i] = Varint.readUnsignedVarInt(in);
      vw.readFields(in);
      rows[i] = vw.get().clone();
    }

  }
View Full Code Here


      rating = in.readFloat();
    }
    boolean containsFeatureVector = in.readBoolean();
    if (containsFeatureVector) {
      VectorWritable vw = new VectorWritable();
      vw.readFields(in);
      vector = vw.get();
    }
  }

  public int getIDIndex() {
View Full Code Here

    vector = null;
    idIndex = null;
    boolean hasVector = in.readBoolean();
    if (hasVector) {
      VectorWritable writable = new VectorWritable();
      writable.readFields(in);
      vector = writable.get();
    }
    boolean hasRating = in.readBoolean();
    if (hasRating) {
      idIndex = Varint.readSignedVarInt(in);
View Full Code Here

        if (!fs.exists(meanVectorFile.get())) {
          throw new FileNotFoundException(meanVectorFile.get().toString());
        }
        DataInputStream in = fs.open(meanVectorFile.get());
        try {
          meanVector.readFields(in);
        } finally {
          in.close();
        }
        this.meanVector = meanVector.get();
      }
View Full Code Here

  @Override
  public void readFields(DataInput in) throws IOException {
    this.id = in.readInt();
    this.numPoints = in.readLong();
    VectorWritable temp = new VectorWritable();
    temp.readFields(in);
    this.center = temp.get();
    temp.readFields(in);
    this.radius = temp.get();
  }
 
View Full Code Here

    this.id = in.readInt();
    this.numPoints = in.readLong();
    VectorWritable temp = new VectorWritable();
    temp.readFields(in);
    this.center = temp.get();
    temp.readFields(in);
    this.radius = temp.get();
  }
 
  @Override
  public void write(DataOutput out) throws IOException {
View Full Code Here

    }

    public static Vector fromBytes(DataByteArray data) {
        try {
            VectorWritable r = new VectorWritable();
            r.readFields(new DataInputStream(new ByteArrayInputStream(data.get())));
            return r.get();
        } catch (IOException e) {
            throw new ImpossibleStateError("Can't have error in BAIS", e);
        }
    }
View Full Code Here

  @Override
  public void readFields(DataInput in) throws IOException {
    boolean hasVector = in.readBoolean();
    if (hasVector) {
      VectorWritable writable = new VectorWritable();
      writable.readFields(in);
      set(writable.get());
    } else {
      long theUserID = Varint.readSignedVarLong(in);
      float theValue = in.readFloat();
      set(theUserID, theValue);
View Full Code Here

  }

  @Override
  public void readFields(DataInput in) throws IOException {
    VectorWritable writable = new VectorWritable();
    writable.readFields(in);
    vector = writable.get();
    int size = Varint.readUnsignedVarInt(in);
    userIDs = Lists.newArrayListWithCapacity(size);
    values = Lists.newArrayListWithCapacity(size);
    for (int i = 0; i < size; i++) {
View Full Code Here

  @Override
  public void readFields(DataInput in) throws IOException {
    this.combinerState = in.readInt();
    this.s0 = in.readDouble();
    VectorWritable temp = new VectorWritable();
    temp.readFields(in);
    this.s1 = temp.get();
    temp.readFields(in);
    this.s2 = temp.get();
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.