use of com.tencent.angel.ml.math2.vector.IntFloatVector in project angel by Tencent.
the class GraphNode method deepClone.
@Override
public GraphNode deepClone() {
IntFloatVector cloneFeats = null;
if (feats != null) {
cloneFeats = feats.clone();
}
long[] cloneNeighbors = null;
if (neighbors != null) {
cloneNeighbors = new long[neighbors.length];
System.arraycopy(neighbors, 0, cloneNeighbors, 0, neighbors.length);
}
int[] cloneTypes = null;
if (types != null) {
cloneTypes = new int[types.length];
System.arraycopy(types, 0, cloneTypes, 0, types.length);
}
int[] cloneEdgeTypes = null;
if (edgeTypes != null) {
cloneEdgeTypes = new int[edgeTypes.length];
System.arraycopy(edgeTypes, 0, cloneEdgeTypes, 0, edgeTypes.length);
}
IntFloatVector[] cloneEdgeFeatures = null;
if (edgeFeatures != null) {
cloneEdgeFeatures = new IntFloatVector[edgeFeatures.length];
System.arraycopy(edgeFeatures, 0, cloneEdgeFeatures, 0, edgeFeatures.length);
}
float[] cloneWeights = null;
if (weights != null) {
cloneWeights = new float[weights.length];
System.arraycopy(weights, 0, cloneWeights, 0, weights.length);
}
float[] cloneLables = null;
if (labels != null) {
cloneLables = new float[labels.length];
System.arraycopy(labels, 0, cloneLables, 0, labels.length);
}
return new GraphNode(cloneFeats, cloneNeighbors, cloneTypes, cloneEdgeTypes, cloneEdgeFeatures, cloneWeights, cloneLables);
}
use of com.tencent.angel.ml.math2.vector.IntFloatVector in project angel by Tencent.
the class GraphNode method serialize.
@Override
public void serialize(DataOutputStream output) throws IOException {
if (feats != null) {
StreamSerdeUtils.serializeInt(output, 1);
StreamSerdeUtils.serializeVector(output, feats);
} else {
StreamSerdeUtils.serializeInt(output, 0);
}
if (neighbors != null) {
StreamSerdeUtils.serializeInt(output, 1);
StreamSerdeUtils.serializeLongs(output, neighbors);
} else {
StreamSerdeUtils.serializeInt(output, 0);
}
if (types != null) {
StreamSerdeUtils.serializeInt(output, 1);
StreamSerdeUtils.serializeInts(output, types);
} else {
StreamSerdeUtils.serializeInt(output, 0);
}
if (edgeTypes != null) {
StreamSerdeUtils.serializeInt(output, 1);
StreamSerdeUtils.serializeInts(output, edgeTypes);
} else {
StreamSerdeUtils.serializeInt(output, 0);
}
if (edgeFeatures != null) {
StreamSerdeUtils.serializeInt(output, 1);
StreamSerdeUtils.serializeInt(output, edgeFeatures.length);
for (IntFloatVector edgeFeature : edgeFeatures) {
StreamSerdeUtils.serializeVector(output, edgeFeature);
}
} else {
StreamSerdeUtils.serializeInt(output, 0);
}
if (weights != null) {
StreamSerdeUtils.serializeInt(output, 1);
StreamSerdeUtils.serializeFloats(output, weights);
} else {
StreamSerdeUtils.serializeInt(output, 0);
}
if (labels != null) {
StreamSerdeUtils.serializeInt(output, 1);
StreamSerdeUtils.serializeFloats(output, labels);
} else {
StreamSerdeUtils.serializeInt(output, 0);
}
}
use of com.tencent.angel.ml.math2.vector.IntFloatVector in project angel by Tencent.
the class GraphNode method serialize.
@Override
public void serialize(ByteBuf output) {
if (feats != null) {
ByteBufSerdeUtils.serializeInt(output, 1);
ByteBufSerdeUtils.serializeVector(output, feats);
} else {
ByteBufSerdeUtils.serializeInt(output, 0);
}
if (neighbors != null) {
ByteBufSerdeUtils.serializeInt(output, 1);
ByteBufSerdeUtils.serializeLongs(output, neighbors);
} else {
ByteBufSerdeUtils.serializeInt(output, 0);
}
if (types != null) {
ByteBufSerdeUtils.serializeInt(output, 1);
ByteBufSerdeUtils.serializeInts(output, types);
} else {
ByteBufSerdeUtils.serializeInt(output, 0);
}
if (edgeTypes != null) {
ByteBufSerdeUtils.serializeInt(output, 1);
ByteBufSerdeUtils.serializeInts(output, edgeTypes);
} else {
ByteBufSerdeUtils.serializeInt(output, 0);
}
if (edgeFeatures != null) {
ByteBufSerdeUtils.serializeInt(output, 1);
ByteBufSerdeUtils.serializeInt(output, edgeFeatures.length);
for (IntFloatVector edgeFeature : edgeFeatures) {
ByteBufSerdeUtils.serializeVector(output, edgeFeature);
}
} else {
ByteBufSerdeUtils.serializeInt(output, 0);
}
if (weights != null) {
ByteBufSerdeUtils.serializeInt(output, 1);
ByteBufSerdeUtils.serializeFloats(output, weights);
} else {
ByteBufSerdeUtils.serializeInt(output, 0);
}
if (labels != null) {
ByteBufSerdeUtils.serializeInt(output, 1);
ByteBufSerdeUtils.serializeFloats(output, labels);
} else {
ByteBufSerdeUtils.serializeInt(output, 0);
}
}
use of com.tencent.angel.ml.math2.vector.IntFloatVector in project angel by Tencent.
the class PartSampleNodeFeatResult method serialize.
@Override
public void serialize(ByteBuf output) {
ByteBufSerdeUtils.serializeInt(output, partId);
ByteBufSerdeUtils.serializeInt(output, feats.length);
for (IntFloatVector feat : feats) {
if (feat == null) {
ByteBufSerdeUtils.serializeBoolean(output, true);
} else {
ByteBufSerdeUtils.serializeBoolean(output, false);
ByteBufSerdeUtils.serializeVector(output, feat);
}
}
}
use of com.tencent.angel.ml.math2.vector.IntFloatVector in project angel by Tencent.
the class GetNodes method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
ServerPartition part = psContext.getMatrixStorageManager().getPart(partParam.getPartKey());
ServerRow ranks = psContext.getMatrixStorageManager().getRow(partParam.getPartKey(), 2);
FloatVector ranksVector = ServerRowUtils.getVector((ServerLongFloatRow) ranks);
long[] ret;
if (ranksVector instanceof IntFloatVector)
ret = gatherNodes((IntFloatVector) ranksVector, part.getPartitionKey().getStartCol());
else if (ranksVector instanceof LongFloatVector)
ret = gatherNodes((LongFloatVector) ranksVector, part.getPartitionKey().getStartCol());
else {
throw new AngelException("vector should be intfloat or longfloat but is " + ranksVector.getClass().getName());
}
return new IndexPartGetLongResult(part.getPartitionKey(), ret);
}
Aggregations