3131import it .unimi .dsi .util .FrontCodedStringList ;
3232import it .unimi .dsi .util .ImmutableExternalPrefixMap ;
3333import it .unimi .dsi .util .Interval ;
34+ import it .unimi .dsi .util .LiterallySignedStringMap ;
3435import it .unimi .dsi .util .ShiftAddXorSignedStringMap ;
3536import it .unimi .dsi .webgraph .ImmutableGraph ;
3637import it .unimi .dsi .webgraph .LazyIntIterator ;
@@ -56,6 +57,7 @@ public class Graph {
5657 protected FrontCodedStringList vertexMapFcl ;
5758 protected ShiftAddXorSignedStringMap vertexMapSmph ;
5859 protected GOV4Function <String > vertexMapMph ;
60+ protected LiterallySignedStringMap vertexMapLmap ;
5961
6062 private static int LAZY_INT_ITERATOR_EMPTY_VALUE = LazyIntIterators .EMPTY_ITERATOR .nextInt ();
6163
@@ -84,6 +86,9 @@ public Graph(String name) throws Exception {
8486 } else {
8587 LOG .error ("No vertex mapping found, cannot translate from vertex names to IDs." );
8688 }
89+ } else if (Files .exists (Paths .get (name + ".lmap" ))) {
90+ LOG .info ("Loading vertex map {}.lmap (LiterallySignedStringMap)" , name );
91+ vertexMapLmap = (LiterallySignedStringMap ) BinIO .loadObject (name + ".lmap" );
8792 } else {
8893 LOG .error ("No vertex mapping found, cannot translate from vertex names to IDs." );
8994 }
@@ -97,8 +102,12 @@ public Graph(String name) throws Exception {
97102 public String vertexIdToLabel (long id ) {
98103 if (vertexMap != null ) {
99104 return vertexMap .list ().get ((int ) id ).toString ();
100- } else {
105+ } else if ( vertexMapFcl != null ) {
101106 return vertexMapFcl .get ((int ) id ).toString ();
107+ } else if (vertexMapLmap != null ) {
108+ return vertexMapLmap .list ().get ((int ) id ).toString ();
109+ } else {
110+ throw new RuntimeException ("No vertex map loaded." );
102111 }
103112 }
104113
@@ -109,6 +118,8 @@ public long vertexLabelToId(String label) {
109118 return vertexMapSmph .getLong (label );
110119 } else if (vertexMapMph != null ) {
111120 return vertexMapMph .getLong (label );
121+ } else if (vertexMapLmap != null ) {
122+ return vertexMapLmap .getLong (label );
112123 } else {
113124 throw new RuntimeException ("No vertex map loaded." );
114125 }
@@ -221,7 +232,7 @@ public Stream<Entry<String, Long>> topLevelDomainCounts(IntStream vertexIds) {
221232 List <Entry <String , Long >> res = new LinkedList <>();
222233 PrimitiveIterator .OfInt iter = vertexIds .iterator ();
223234 if (iter .hasNext ()) {
224- int curr = iter .nextInt ();;
235+ int curr = iter .nextInt ();
225236 do {
226237 final MutableString currLabel = vertexMap .list ().get (curr );
227238 final int pos = currLabel .indexOf ('.' );
@@ -397,7 +408,7 @@ public static String getRegisteredDomainReversed(String reversedHostName, boolea
397408 * "https://en.wikipedia.org/wiki/Reverse_domain_name_notation">reverse
398409 * domain name notation</a> (un)applied
399410 */
400- private static String reverseDomainName (String reversedDomainName ) {
411+ public static String reverseDomainName (String reversedDomainName ) {
401412 return HostToDomainGraph .reverseHost (reversedDomainName );
402413 }
403414}
0 commit comments