Changeset View
Changeset View
Standalone View
Standalone View
java/src/main/java/org/softwareheritage/graph/SwhLabel.java
- This file was added.
package org.softwareheritage.graph; | |||||
/** | |||||
* Wrapper class to store the edge labels of the graph. Labels can be encoded in a single long type. | |||||
* | |||||
* @author The Software Heritage developers | |||||
*/ | |||||
public class SwhLabel { | |||||
public long filenameId; | |||||
public int permission; | |||||
public SwhLabel(long filenameId, int permission) | |||||
{ | |||||
this.filenameId = filenameId; | |||||
this.permission = permission; | |||||
} | |||||
public static SwhLabel fromEncoded(long labelEncoded) | |||||
{ | |||||
long filenameId = labelEncoded >> SwhPerm.TOTAL_NB_BITS; | |||||
int permission = (int) (labelEncoded & ((1 << SwhPerm.TOTAL_NB_BITS) - 1)); | |||||
return new SwhLabel(filenameId, permission); | |||||
} | |||||
public static long toEncoded(SwhLabel label) | |||||
{ | |||||
long labelEncoded = (label.filenameId << SwhPerm.TOTAL_NB_BITS) + label.permission; | |||||
return labelEncoded; | |||||
} | |||||
} |