All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.olapdb.obase.data.LatentFactorEntity Maven / Gradle / Ivy

The newest version!
package com.olapdb.obase.data;

import org.apache.hadoop.hbase.util.Bytes;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;

public abstract class LatentFactorEntity extends RecommendEntity{
	public LatentFactorEntity(byte[] row){
		super(row);
	}

	public int getLatentFactorCount(){
		byte[] bytes = this.getAttribute("latentFactorCount");
		if(bytes == null)
			return 0;

		return Bytes.toInt(bytes);
	}

	public void setLatentFactorCount(int count){
		this.setAttribute("latentFactorCount", Bytes.toBytes(count));
	}

	public double[] getLatentFactors() {
		int count = this.getLatentFactorCount();
		double[] ret = new double[count];

		try {
			byte[] bytes = this.getAttribute("latentFactor");

			if(bytes != null){
				ByteArrayInputStream bios = new ByteArrayInputStream(bytes);
				DataInputStream dis = new DataInputStream(bios);
				for(int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy