X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Flocal%2FTextIndex.java;h=73ad07c7db90dd4572da43dea9c1b832a1e3d4f6;hb=refs%2Fchanges%2F87%2F65287%2F1;hp=bb1b61178ed148f93fdd2f072b7b578c3a944fc3;hpb=ead32f193586e39b59bb366bddf70e665173a52d;p=aaf%2Fauthz.git diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/local/TextIndex.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/local/TextIndex.java index bb1b6117..73ad07c7 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/local/TextIndex.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/local/TextIndex.java @@ -54,7 +54,7 @@ public class TextIndex { } public void close() throws IOException { - if(dataFile!=null) { + if (dataFile!=null) { dataFile.close(); dataFile=null; } @@ -65,7 +65,7 @@ public class TextIndex { } public int find(Object key, DataFile.Token dtok, Field df, int offset) throws IOException { - if(dataFile==null) { + if (dataFile==null) { throw new IOException("File not opened"); } long hash = hashToLong(key.hashCode()); @@ -74,13 +74,13 @@ public class TextIndex { IntBuffer tib = ttok.getIntBuffer(); long lhash; int curr; - while((max-min)>100) { + while ((max-min)>100) { ttok.pos((curr=(min+(max-min)/2))*REC_SIZE); tib.rewind(); lhash = hashToLong(tib.get()); - if(lhashhash) { + } else if (lhash>hash) { max=curr-1; } else { min=curr-40; @@ -90,20 +90,20 @@ public class TextIndex { } List entries = new ArrayList<>(); - for(int i=min;i<=max;++i) { + for (int i=min;i<=max;++i) { ttok.pos(i*REC_SIZE); tib.rewind(); lhash = hashToLong(tib.get()); - if(lhash==hash) { + if (lhash==hash) { entries.add(tib.get()); - } else if(lhash>hash) { + } else if (lhash>hash) { break; } } - for(Integer i : entries) { + for (Integer i : entries) { dtok.pos(i); - if(df.at(offset).equals(key)) { + if (df.at(offset).equals(key)) { return i; } } @@ -116,7 +116,7 @@ public class TextIndex { */ private static long hashToLong(int hash) { long rv; - if(hash<0) { + if (hash<0) { rv = 0xFFFFFFFFL & hash; } else { rv = hash; @@ -145,15 +145,15 @@ public class TextIndex { Field f = t.new Field(delim); int count = 0; - if(skipLines>0) { + if (skipLines>0) { trans.info().log("Skipping",skipLines,"line"+(skipLines==1?" in":"s in"),data.file().getName()); } - for(int i=0;i