コード例 #1
0
        private void append(Map <string, float> userId2Score, string userId, float score)
        {
            if (userId2Score.size() <= 5)
            {
                userId2Score.put(userId, score);
                return;
            }

            userId2Score.put(userId, score);
            Iterator iterator = userId2Score.entrySet().iterator();
            string   min      = "";
            float    minVal   = 0;

            while (iterator.hasNext())
            {
                Map.Entry <string, float> entry = (Map.Entry <string, float>)iterator.next();
                if (TextUtils.isEmpty(min))
                {
                    min    = entry.getKey();
                    minVal = entry.getValue();
                    continue;
                }
                float scoreTmp = entry.getValue();
                if (scoreTmp < minVal)
                {
                    min    = entry.getKey();
                    minVal = entry.getValue();
                }
            }
            userId2Score.remove(min);
        }
コード例 #2
0
        public static void dumpPropStructure(ConfigurationManager cm)
        {
            Map map = ConfigurationManagerUtils.listAllsPropNames(cm);

            [email protected](new StringBuilder().append("Property-structure of '").append(cm.getConfigURL()).append("':").toString());
            [email protected]("\nUnambiguous properties = ");
            Iterator iterator = map.entrySet().iterator();

            while (iterator.hasNext())
            {
                Map.Entry entry = (Map.Entry)iterator.next();
                if (((List)entry.getValue()).size() == 1)
                {
                    [email protected](new StringBuilder().append((string)entry.getKey()).append(", ").toString());
                }
            }
            [email protected]("\n\nAmbiguous properties: ");
            iterator = map.entrySet().iterator();
            while (iterator.hasNext())
            {
                Map.Entry entry = (Map.Entry)iterator.next();
                if (((List)entry.getValue()).size() != 1)
                {
                    [email protected](new StringBuilder().append((string)entry.getKey()).append('=').toString());
                    Iterator iterator2 = ((List)entry.getValue()).iterator();
                    while (iterator2.hasNext())
                    {
                        PropertySheet propertySheet = (PropertySheet)iterator2.next();
                        [email protected](new StringBuilder().append(propertySheet.getInstanceName()).append(", ").toString());
                    }
                    [email protected]();
                }
            }
        }
コード例 #3
0
        private static ConstArrayValue toUnicodeArray(Env env, ArrayValue array)
        {
            ArrayValueImpl copy = new ArrayValueImpl();

            Iterator <Map.Entry <Value, Value> > iter = array.getIterator(env);

            while (iter.hasNext())
            {
                Map.Entry <Value, Value> entry = iter.next();

                Value key   = entry.getKey();
                Value value = entry.getValue();

                if (key.isString())
                {
                    key = key.toUnicodeValue(env);
                }

                if (value.isString())
                {
                    value = value.toUnicodeValue(env);
                }

                copy.put(key, value);
            }

            return(new ConstArrayValue(copy));
        }
コード例 #4
0
            public virtual void connect()
            {
                GrammarArc[] successors = this.getSuccessors();
                int          num        = successors.Length;

                for (int i = 0; i < num; i++)
                {
                    GrammarArc          grammarArc = successors[i];
                    FlatLinguist.GState gstate     = this.this_0.getGState(grammarArc.getGrammarNode());
                    if (gstate.getNode().isEmpty() || !String.instancehelper_equals(gstate.getNode().getWord().getSpelling(), "<s>"))
                    {
                        float num2 = grammarArc.getProbability();
                        if (FlatLinguist.access_800(this.this_0) && !gstate.getNode().isEmpty())
                        {
                            int num3 = gstate.getNode().getWord().getPronunciations().Length;
                            num2 -= this.this_0.logMath.linearToLog((double)num3);
                        }
                        float    num4     = num2;
                        Iterator iterator = this.exitPoints.entrySet().iterator();
                        while (iterator.hasNext())
                        {
                            Map.Entry entry = (Map.Entry)iterator.next();
                            List      list  = gstate.getEntryPoints((ContextPair)entry.getKey());
                            if (list != null)
                            {
                                List list2 = (List)entry.getValue();
                                this.connect(list2, list, num4);
                            }
                        }
                    }
                }
            }
コード例 #5
0
        private void checkClasses()
        {
            HashMap  hashMap  = new HashMap();
            Iterator iterator = this.wordToClassProbabilities.values().iterator();

            while (iterator.hasNext())
            {
                ClassProbability classProbability = (ClassProbability)iterator.next();
                Float            @float           = (Float)hashMap.get(classProbability.getClassName());
                if (@float == null)
                {
                    hashMap.put(classProbability.getClassName(), Float.valueOf(0f));
                }
                else
                {
                    hashMap.put(classProbability.getClassName(), Float.valueOf((float)this.logMath.logToLinear(classProbability.getLogProbability()) + @float.floatValue()));
                }
            }
            iterator = hashMap.entrySet().iterator();
            while (iterator.hasNext())
            {
                Map.Entry entry = (Map.Entry)iterator.next();
                if (Math.abs((double)1f - (double)((Float)entry.getValue()).floatValue()) > 0.001)
                {
                    this.logger.warning(new StringBuilder().append("Word probabilities for class ").append((string)entry.getKey()).append(" sum to ").append(entry.getValue()).toString());
                }
            }
        }
コード例 #6
0
 public override void putAll(Map t)
 {
     for (Iterator it = t.entrySet().iterator(); it.hasNext();)
     {
         Map.Entry entry = (Map.Entry)it.next();
         setAttribute(entry.getKey().ToString(), entry.getValue());
     }
 }
コード例 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="K"></typeparam>
        /// <typeparam name="V"></typeparam>
        /// <param name="javaMap"></param>
        /// <returns></returns>
        public static IDictionary <K, V> ConvertFromJavaMap <K, V>(Map javaMap)
        {
            IDictionary <K, V> result   = new Dictionary <K, V>();
            Iterator           iterator = javaMap.entrySet().iterator();

            while (iterator.hasNext())
            {
                Map.Entry entry = (Map.Entry)iterator.next();
                result.Add((K)entry.getKey(), (V)entry.getValue());
            }
            return(result);
        }
コード例 #8
0
        public virtual void purge()
        {
            int      num      = this.maxEdges - 1;
            Iterator iterator = this.viterbiLoserMap.entrySet().iterator();

            while (iterator.hasNext())
            {
                Map.Entry entry = (Map.Entry)iterator.next();
                List      list  = (List)entry.getValue();
                Collections.sort(list, Scoreable.COMPARATOR);
                List list2 = list.subList(0, (list.size() <= num) ? list.size() : num);
                this.viterbiLoserMap.put(entry.getKey(), list2);
            }
        }
コード例 #9
0
        public override string toString()
        {
            TreeMap       treeMap       = new TreeMap(this.dictionary);
            StringBuilder stringBuilder = new StringBuilder();
            Iterator      iterator      = treeMap.entrySet().iterator();

            while (iterator.hasNext())
            {
                Map.Entry entry = (Map.Entry)iterator.next();
                stringBuilder.append((string)entry.getKey());
                stringBuilder.append("   ").append((string)entry.getValue()).append('\n');
            }
            return(stringBuilder.toString());
        }
コード例 #10
0
            public virtual void expand()
            {
                Iterator iterator = this.leftContexts.iterator();

                while (iterator.hasNext())
                {
                    UnitContext unitContext = (UnitContext)iterator.next();
                    Iterator    iterator2   = this.getStartingContexts().iterator();
                    while (iterator2.hasNext())
                    {
                        UnitContext unitContext2 = (UnitContext)iterator2.next();
                        ContextPair contextPair  = ContextPair.get(unitContext, unitContext2);
                        this.entryPoints.put(contextPair, new ArrayList());
                    }
                }
                if (this.node.isFinalNode())
                {
                    GrammarState grammarState = new GrammarState(this.node);
                    Iterator     iterator3    = this.entryPoints.values().iterator();
                    while (iterator3.hasNext())
                    {
                        List list = (List)iterator3.next();
                        list.add(grammarState);
                    }
                }
                else if (!this.node.isEmpty())
                {
                    iterator = this.leftContexts.iterator();
                    while (iterator.hasNext())
                    {
                        UnitContext unitContext = (UnitContext)iterator.next();
                        this.expandWord(unitContext);
                    }
                }
                else
                {
                    iterator = this.entryPoints.entrySet().iterator();
                    while (iterator.hasNext())
                    {
                        Map.Entry   entry        = (Map.Entry)iterator.next();
                        ContextPair contextPair2 = (ContextPair)entry.getKey();
                        List        list2        = (List)entry.getValue();
                        BranchState branchState  = new BranchState(contextPair2.getLeftContext().toString(), contextPair2.getRightContext().toString(), this.node.getID());
                        list2.add(branchState);
                        this.addExitPoint(contextPair2, branchState);
                    }
                }
                this.addEmptyEntryPoints();
            }
コード例 #11
0
        /**
         * <p>
         * We assume here that the passed-in inner LinkedHashMaps are already sorted
         * in order of "Best Possible Correction".
         * </p>
         *
         * @param suggestions
         */
        public PossibilityIterator(Map /*<Token, LinkedHashMap<String, Integer>>*/ suggestions)
        {
            for (var iter = suggestions.entrySet().iterator(); iter.hasNext();)
            {
                Map.Entry /*<Token, LinkedHashMap<String, Integer>>*/ entry = (Map.Entry)iter.next();
                Token token = (Token)entry.getKey();
                List /*<SpellCheckCorrection>*/ possibleCorrections = new ArrayList/*<SpellCheckCorrection>*/ ();
                for (var iter1 = ((LinkedHashMap)entry.getValue()).entrySet().iterator(); iter1.hasNext();)
                {
                    Map.Entry /*<String, Integer>*/ entry1     = (Map.Entry)iter1.next();
                    SpellCheckCorrection            correction = new SpellCheckCorrection();
                    correction.setOriginal(token);
                    correction.setCorrection((string)entry1.getKey());
                    correction.setNumberOfOccurences((int)entry1.getValue());
                    possibleCorrections.add(correction);
                }
                possibilityList.add(possibleCorrections);
            }

            int wrapSize = possibilityList.size();

            if (wrapSize == 0)
            {
                done = true;
            }
            else
            {
                correctionIndex = new int[wrapSize];
                for (int i = 0; i < wrapSize; i++)
                {
                    int suggestSize = ((List)possibilityList.get(i)).size();
                    if (suggestSize == 0)
                    {
                        done = true;
                        break;
                    }
                    correctionIndex[i] = 0;
                }
            }

            while (internalHasNext())
            {
                rankedPossibilityList.add(internalNext());
            }
            Collections.sort(rankedPossibilityList);
            rankedPossibilityIterator = rankedPossibilityList.iterator();
        }
コード例 #12
0
        public new virtual ConfigurationManager clone()
        {
            ConfigurationManager configurationManager = (ConfigurationManager)base.clone();

            configurationManager.changeListeners = new ArrayList();
            configurationManager.symbolTable     = new LinkedHashMap();
            Iterator iterator = this.symbolTable.entrySet().iterator();

            while (iterator.hasNext())
            {
                Map.Entry entry = (Map.Entry)iterator.next();
                configurationManager.symbolTable.put(entry.getKey(), ((PropertySheet)entry.getValue()).clone());
            }
            configurationManager.globalProperties = new HashMap(this.globalProperties);
            configurationManager.rawPropertyMap   = new HashMap(this.rawPropertyMap);
            return(configurationManager);
        }
コード例 #13
0
        private static PropertySheet getPropSheetInstanceFromClass(Class @class, Map map, string name, ConfigurationManager cm)
        {
            RawPropertyData rawPropertyData = new RawPropertyData(name, @class.getName());
            Iterator        iterator        = map.entrySet().iterator();

            while (iterator.hasNext())
            {
                Map.Entry entry = (Map.Entry)iterator.next();
                object    obj   = entry.getValue();
                if (obj is Class)
                {
                    obj = ((Class)obj).getName();
                }
                rawPropertyData.getProperties().put(entry.getKey(), obj);
            }
            return(new PropertySheet(@class, name, cm, rawPropertyData));
        }
コード例 #14
0
        public virtual RawPropertyData flatten(ConfigurationManager cm)
        {
            RawPropertyData rawPropertyData = new RawPropertyData(this.name, this.className);
            Iterator        iterator        = this.properties.entrySet().iterator();

            while (iterator.hasNext())
            {
                Map.Entry entry = (Map.Entry)iterator.next();
                object    obj   = entry.getValue();
                if (obj is string && String.instancehelper_startsWith((string)obj, "_{"))
                {
                    obj = cm.getGloPropReference(ConfigurationManagerUtils.stripGlobalSymbol((string)obj));
                }
                rawPropertyData.properties.put(entry.getKey(), obj);
            }
            return(rawPropertyData);
        }
コード例 #15
0
            public override bool contains(object o)
            {
                if (!(o is Map.Entry))
                {
                    return(false);
                }
                Map.Entry e   = (Map.Entry)o;
                object    key = e.getKey();

                if (key == null)
                {
                    return(false);      // we don't support null keys
                }
                object val = e.getValue();
                object v   = _map.get(key);

                return(v == null ? val == null : v.Equals(val));
            }
コード例 #16
0
                public override bool contains(Object o)
                {
                    if (!(o is Map.Entry))
                    {
                        return(false);
                    }

                    Map.Entry entry = (Map.Entry)o;
                    Object    key   = entry.getKey();
                    Object    value = entry.getValue();

                    if (key == null || value == null)
                    {
                        return(false);
                    }

                    return(value.Equals(_owner.get(key)));
                }
コード例 #17
0
                public override bool remove(Object o)
                {
                    if (!(o is Map.Entry))
                    {
                        return(false);
                    }

                    Map.Entry entry = (Map.Entry)o;
                    Object    key   = entry.getKey();
                    Object    value = entry.getValue();

                    if (key == null || value == null ||
                        !value.Equals(_owner.get(key)))
                    {
                        return(false);
                    }

                    return(_owner.remove(((Map.Entry)o).getKey()) != null);
                }
コード例 #18
0
        private void scheduleNextAlignment(List list, Map map, Queue queue, Queue queue2, Queue queue3, long num)
        {
            int      num2     = 0;
            long     num3     = 0L;
            Iterator iterator = map.entrySet().iterator();

            while (iterator.hasNext())
            {
                Map.Entry entry = (Map.Entry)iterator.next();
                if (((Integer)entry.getKey()).intValue() - num2 > 1)
                {
                    this.checkedOffer(list, queue2, queue3, queue, num2, ((Integer)entry.getKey()).intValue() + 1, num3, ((WordResult)entry.getValue()).getTimeFrame().getEnd());
                }
                num2 = ((Integer)entry.getKey()).intValue();
                num3 = ((WordResult)entry.getValue()).getTimeFrame().getStart();
            }
            if (list.size() - num2 > 1)
            {
                this.checkedOffer(list, queue2, queue3, queue, num2, list.size(), num3, num);
            }
        }
コード例 #19
0
        public Map <string, float> sortMapByValue(Map <string, float> oriMap, string userId, int score)
        {
            if (oriMap == null || oriMap.isEmpty())
            {
                return(null);
            }
            Map <string, float> sortedMap = new LinkedHashMap <string, float>();
            List <Map.Entry <string, float> > entryList = new ArrayList <Map.Entry <string, float> >(oriMap.entrySet());

            Collections.sort(entryList, new MapValueComparator());

            Iterator <Map.Entry <string, float> > iter = entryList.iterator();

            Map.Entry <string, float> tmpEntry = null;
            while (iter.hasNext())
            {
                tmpEntry = iter.next();
                sortedMap.put(tmpEntry.getKey(), tmpEntry.getValue());
            }
            return(sortedMap);
        }
コード例 #20
0
        public MultipartBody(Env env, Value body)
        {
            _boundary      = createBoundary();
            _boundaryBytes = _boundary.getBytes();

            Iterator <Map.Entry <Value, Value> > iter = body.getIterator(env);

            while (iter.hasNext())
            {
                Map.Entry <Value, Value> entry = iter.next();

                StringValue key   = entry.getKey().ToString(env);
                StringValue value = entry.getValue().ToString(env);

                if (value.length() > 0 && value[0] == '@')
                {
                    StringValue fileName = value.substring(1);

                    string path = env.lookup(fileName);

                    if (path == null || !path.canRead())
                    {
                        env.warning(L.l("cannot read file '{0}'", fileName));

                        setValid(false);

                        return;
                    }

                    _postItems.add(new PathEntry(env, key.ToString(), path));
                }
                else
                {
                    _postItems.add(new UrlEncodedEntry(env, key.ToString(), value));
                }
            }

            _length = getContentLength(_postItems, _boundary);
        }
コード例 #21
0
            private void addEmptyEntryPoints()
            {
                HashMap  hashMap  = new HashMap();
                Iterator iterator = this.entryPoints.entrySet().iterator();

                while (iterator.hasNext())
                {
                    Map.Entry   entry       = (Map.Entry)iterator.next();
                    ContextPair contextPair = (ContextPair)entry.getKey();
                    if (this.needsEmptyVersion(contextPair))
                    {
                        ContextPair contextPair2 = ContextPair.get(contextPair.getLeftContext(), UnitContext.EMPTY);
                        object      obj          = (List)hashMap.get(contextPair2);
                        if ((List)obj == null)
                        {
                            obj = new ArrayList();
                            hashMap.put(contextPair2, (ArrayList)obj);
                        }
                        object     obj2       = obj;
                        Collection collection = (Collection)entry.getValue();
                        List       list;
                        if (obj2 != null)
                        {
                            if ((list = (obj2 as List)) == null)
                            {
                                throw new IncompatibleClassChangeError();
                            }
                        }
                        else
                        {
                            list = null;
                        }
                        list.addAll(collection);
                    }
                }
                this.entryPoints.putAll(hashMap);
            }
コード例 #22
0
        public static string toXML(ConfigurationManager cm)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
            stringBuilder.append("\n<!--    Sphinx-4 Configuration file--> \n\n");
            stringBuilder.append("<config>");
            Pattern  pattern          = Pattern.compile("\\_\\{(\\w+)\\}");
            Map      globalProperties = cm.getGlobalProperties();
            Iterator iterator         = globalProperties.entrySet().iterator();

            while (iterator.hasNext())
            {
                Map.Entry    entry        = (Map.Entry)iterator.next();
                string       text         = (string)entry.getKey();
                Pattern      pattern2     = pattern;
                object       _ref         = text;
                CharSequence charSequence = CharSequence.Cast(_ref);
                Matcher      matcher      = pattern2.matcher(charSequence);
                text = ((!matcher.matches()) ? text : matcher.group(1));
                stringBuilder.append("\n\t<property name=\"").append(text).append("\" value=\"").append((string)entry.getValue()).append("\"/>");
            }
            iterator = cm.getComponentNames().iterator();
            while (iterator.hasNext())
            {
                string text2 = (string)iterator.next();
                stringBuilder.append("\n\n").append(ConfigurationManagerUtils.propSheet2XML(text2, cm.getPropertySheet(text2)));
            }
            stringBuilder.append("\n</config>");
            return(stringBuilder.toString());
        }
コード例 #23
0
        internal static void renameComponent(ConfigurationManager configurationManager, string text, string text2)
        {
            if (!ConfigurationManagerUtils.assertionsDisabled && configurationManager == null)
            {
                throw new AssertionError();
            }
            if (!ConfigurationManagerUtils.assertionsDisabled && (text == null || text2 == null))
            {
                throw new AssertionError();
            }
            if (configurationManager.getPropertySheet(text) == null)
            {
                string text3 = new StringBuilder().append("no configurable (to be renamed) named ").append(text).append(" is contained in the CM").toString();

                throw new RuntimeException(text3);
            }
            Iterator iterator = configurationManager.getComponentNames().iterator();

            while (iterator.hasNext())
            {
                string        instanceName  = (string)iterator.next();
                PropertySheet propertySheet = configurationManager.getPropertySheet(instanceName);
                Iterator      iterator2     = propertySheet.getRegisteredProperties().iterator();
                while (iterator2.hasNext())
                {
                    string text4 = (string)iterator2.next();
                    if (propertySheet.getRawNoReplacement(text4) != null)
                    {
                        int num = ConfigurationManagerUtils_1._SwitchMap_edu_cmu_sphinx_util_props_PropertyType[propertySheet.getType(text4).ordinal()];
                        if (num == 1)
                        {
                            List list = ConfigurationManagerUtils.toStringList(propertySheet.getRawNoReplacement(text4));
                            for (int i = 0; i < list.size(); i++)
                            {
                                string text5 = (string)list.get(i);
                                if (String.instancehelper_equals(text5, text))
                                {
                                    list.set(i, text2);
                                }
                            }
                        }
                        else if (num == 2)
                        {
                            if (Object.instancehelper_equals(propertySheet.getRawNoReplacement(text4), text))
                            {
                                propertySheet.setRaw(text4, text2);
                            }
                        }
                    }
                }
            }
            PropertySheet propertySheet2 = configurationManager.getPropertySheet(text);

            propertySheet2.setInstanceName(text2);
            Iterator iterator3 = configurationManager.getGlobalProperties().entrySet().iterator();

            while (iterator3.hasNext())
            {
                Map.Entry entry = (Map.Entry)iterator3.next();
                if (String.instancehelper_equals((string)entry.getValue(), text))
                {
                    configurationManager.setGlobalProperty((string)entry.getKey(), text2);
                }
            }
        }
コード例 #24
0
        public override void allocate()
        {
            this.vocabulary.clear();
            this.logProbs.clear();
            this.logBackoffs.clear();
            HashMap  hashMap  = new HashMap();
            HashMap  hashMap2 = new HashMap();
            HashMap  hashMap3 = new HashMap();
            int      num      = 0;
            Iterator iterator = this.sentences.iterator();

            while (iterator.hasNext())
            {
                string    text      = (string)iterator.next();
                string[]  array     = String.instancehelper_split(text, "\\s+");
                ArrayList arrayList = new ArrayList();
                arrayList.add(this.dictionary.getSentenceStartWord());
                string[] array2 = array;
                int      num2   = array2.Length;
                for (int i = 0; i < num2; i++)
                {
                    string text2 = array2[i];
                    if (String.instancehelper_length(text2) != 0)
                    {
                        this.vocabulary.add(text2);
                        Word word = this.dictionary.getWord(text2);
                        if (word == null)
                        {
                            arrayList.add(Word.__UNKNOWN);
                        }
                        else
                        {
                            arrayList.add(word);
                        }
                    }
                }
                arrayList.add(this.dictionary.getSentenceEndWord());
                if (arrayList.size() > 0)
                {
                    HashMap hashMap4 = hashMap;
                    this.addSequence(hashMap4, new WordSequence(new Word[]
                    {
                        (Word)arrayList.get(0)
                    }));
                    num++;
                }
                if (arrayList.size() > 1)
                {
                    num++;
                    HashMap hashMap5 = hashMap;
                    this.addSequence(hashMap5, new WordSequence(new Word[]
                    {
                        (Word)arrayList.get(1)
                    }));
                    HashMap hashMap6 = hashMap2;
                    this.addSequence(hashMap6, new WordSequence(new Word[]
                    {
                        (Word)arrayList.get(0),
                        (Word)arrayList.get(1)
                    }));
                }
                for (int j = 2; j < arrayList.size(); j++)
                {
                    num++;
                    HashMap hashMap7 = hashMap;
                    this.addSequence(hashMap7, new WordSequence(new Word[]
                    {
                        (Word)arrayList.get(j)
                    }));
                    HashMap hashMap8 = hashMap2;
                    this.addSequence(hashMap8, new WordSequence(new Word[]
                    {
                        (Word)arrayList.get(j - 1),
                        (Word)arrayList.get(j)
                    }));
                    HashMap hashMap9 = hashMap3;
                    this.addSequence(hashMap9, new WordSequence(new Word[]
                    {
                        (Word)arrayList.get(j - 2),
                        (Word)arrayList.get(j - 1),
                        (Word)arrayList.get(j)
                    }));
                }
            }
            float    num3      = 0.5f;
            float    num4      = 1f - num3;
            HashMap  hashMap10 = new HashMap();
            Iterator iterator2 = hashMap.entrySet().iterator();

            while (iterator2.hasNext())
            {
                Map.Entry entry = (Map.Entry)iterator2.next();
                hashMap10.put(entry.getKey(), Float.valueOf((float)((Integer)entry.getValue()).intValue() * num4 / (float)num));
            }
            LogMath      logMath      = LogMath.getLogMath();
            float        num5         = logMath.linearToLog((double)this.unigramWeight);
            float        num6         = logMath.linearToLog((double)(1f - this.unigramWeight));
            float        num7         = -logMath.linearToLog((double)hashMap10.size());
            TreeSet      treeSet      = new TreeSet(hashMap.keySet());
            Iterator     iterator3    = new TreeSet(hashMap2.keySet()).iterator();
            WordSequence wordSequence = (!iterator3.hasNext()) ? null : ((WordSequence)iterator3.next());
            Iterator     iterator4    = treeSet.iterator();

            while (iterator4.hasNext())
            {
                WordSequence wordSequence2 = (WordSequence)iterator4.next();
                float        num8          = logMath.linearToLog((double)((Float)hashMap10.get(wordSequence2)).floatValue());
                num8 += num5;
                num8  = logMath.addAsLinear(num8, num7 + num6);
                this.logProbs.put(wordSequence2, Float.valueOf(num8));
                float num9 = 0f;
                while (wordSequence != null)
                {
                    int num10 = wordSequence.getOldest().compareTo(wordSequence2);
                    if (num10 > 0)
                    {
                        break;
                    }
                    if (num10 == 0)
                    {
                        num9 += ((Float)hashMap10.get(wordSequence.getNewest())).floatValue();
                    }
                    wordSequence = ((!iterator3.hasNext()) ? null : ((WordSequence)iterator3.next()));
                }
                this.logBackoffs.put(wordSequence2, Float.valueOf(logMath.linearToLog((double)(num3 / (1f - num9)))));
            }
            HashMap  hashMap11 = new HashMap();
            Iterator iterator5 = hashMap2.entrySet().iterator();

            while (iterator5.hasNext())
            {
                Map.Entry entry2 = (Map.Entry)iterator5.next();
                int       num11  = ((Integer)hashMap.get(((WordSequence)entry2.getKey()).getOldest())).intValue();
                hashMap11.put(entry2.getKey(), Float.valueOf((float)((Integer)entry2.getValue()).intValue() * num4 / (float)num11));
            }
            TreeSet treeSet2 = new TreeSet(hashMap2.keySet());

            iterator3    = new TreeSet(hashMap3.keySet()).iterator();
            wordSequence = ((!iterator3.hasNext()) ? null : ((WordSequence)iterator3.next()));
            Iterator iterator6 = treeSet2.iterator();

            while (iterator6.hasNext())
            {
                WordSequence wordSequence3 = (WordSequence)iterator6.next();
                this.logProbs.put(wordSequence3, Float.valueOf(logMath.linearToLog((double)((Float)hashMap11.get(wordSequence3)).floatValue())));
                float num12 = 0f;
                while (wordSequence != null)
                {
                    int num13 = wordSequence.getOldest().compareTo(wordSequence3);
                    if (num13 > 0)
                    {
                        break;
                    }
                    if (num13 == 0)
                    {
                        num12 += ((Float)hashMap11.get(wordSequence.getNewest())).floatValue();
                    }
                    wordSequence = ((!iterator3.hasNext()) ? null : ((WordSequence)iterator3.next()));
                }
                this.logBackoffs.put(wordSequence3, Float.valueOf(logMath.linearToLog((double)(num3 / (1f - num12)))));
            }
            iterator6 = hashMap3.entrySet().iterator();
            while (iterator6.hasNext())
            {
                Map.Entry entry3 = (Map.Entry)iterator6.next();
                float     num12  = (float)((Integer)entry3.getValue()).intValue() * num4;
                num12 /= (float)((Integer)hashMap2.get(((WordSequence)entry3.getKey()).getOldest())).intValue();
                this.logProbs.put(entry3.getKey(), Float.valueOf(logMath.linearToLog((double)num12)));
            }
        }
コード例 #25
0
        public object GetPermission(Path path)
        {
            Acl acl = path.attributes().getAcl();

            if (!Acl.EMPTY.equals(acl))
            {
                StringBuilder s        = new StringBuilder();
                Iterator      iterator = acl.entrySet().iterator();
                while (iterator.hasNext())
                {
                    Map.Entry entry = (Map.Entry)iterator.next();
                    s.Append(String.Format("{0}{1}:{2}", s.Length == 0 ? "" : ", ",
                                           ((Acl.User)entry.getKey()).getDisplayName(), entry.getValue()));
                }
                return(s.ToString());
            }
            Permission permission = path.attributes().getPermission();

            return(permission.toString());
        }
コード例 #26
0
        public bool next(RecordIdentifier recordIdentifier,
                         OrcStruct prev)
        {
            bool keysSame = true;

            while (keysSame && primary != null)
            {
                // The primary's nextRecord is the next value to return
                OrcStruct current = primary.nextRecord;
                recordIdentifier.set(primary.key);

                // Advance the primary reader to the next record
                primary.next(extraValue);

                // Save the current record as the new extraValue for next time so that
                // we minimize allocations
                extraValue = current;

                // now that the primary reader has advanced, we need to see if we
                // continue to read it or move to the secondary.
                if (primary.nextRecord == null ||
                    primary.key.compareTo(secondaryKey) > 0)
                {
                    // if the primary isn't done, push it back into the readers
                    if (primary.nextRecord != null)
                    {
                        readers.put(primary.key, primary);
                    }

                    // update primary and secondaryKey
                    Map.Entry <ReaderKey, ReaderPair> entry = readers.pollFirstEntry();
                    if (entry != null)
                    {
                        primary = entry.getValue();
                        if (readers.isEmpty())
                        {
                            secondaryKey = null;
                        }
                        else
                        {
                            secondaryKey = readers.firstKey();
                        }
                    }
                    else
                    {
                        primary = null;
                    }
                }

                // if this transaction isn't ok, skip over it
                if (!validTxnList.isTxnValid(
                        ((ReaderKey)recordIdentifier).getCurrentTransactionId()))
                {
                    continue;
                }

                /*for multi-statement txns, you may have multiple events for the same
                 * row in the same (current) transaction.  We want to collapse these to just the last one
                 * regardless whether we are minor compacting.  Consider INSERT/UPDATE/UPDATE of the
                 * same row in the same txn.  There is no benefit passing along anything except the last
                 * event.  If we did want to pass it along, we'd have to include statementId in the row
                 * returned so that compaction could write it out or make minor minor compaction understand
                 * how to write out delta files in delta_xxx_yyy_stid format.  There doesn't seem to be any
                 * value in this.*/
                bool isSameRow = prevKey.isSameRow((ReaderKey)recordIdentifier);
                // if we are collapsing, figure out if this is a new row
                if (collapse || isSameRow)
                {
                    keysSame = (collapse && prevKey.compareRow(recordIdentifier) == 0) || (isSameRow);
                    if (!keysSame)
                    {
                        prevKey.set(recordIdentifier);
                    }
                }
                else
                {
                    keysSame = false;
                }

                // set the output record by fiddling with the pointers so that we can
                // avoid a copy.
                prev.linkFields(current);
            }
            return(!keysSame);
        }
コード例 #27
0
        /**
         * Create a reader that merge sorts the ACID events together.
         * @param conf the configuration
         * @param collapseEvents should the events on the same row be collapsed
         * @param isOriginal is the base file a pre-acid file
         * @param bucket the bucket we are reading
         * @param options the options to read with
         * @param deltaDirectory the list of delta directories to include
         * @
         */
        OrcRawRecordMerger(Configuration conf,
                           bool collapseEvents,
                           Reader reader,
                           bool isOriginal,
                           int bucket,
                           ValidTxnList validTxnList,
                           Reader.Options options,
                           Path[] deltaDirectory)
        {
            this.conf         = conf;
            this.collapse     = collapseEvents;
            this.offset       = options.getOffset();
            this.length       = options.getLength();
            this.validTxnList = validTxnList;
            TypeDescription typeDescr = OrcUtils.getDesiredRowTypeDescr(conf);

            if (typeDescr == null)
            {
                throw new IOException(ErrorMsg.SCHEMA_REQUIRED_TO_READ_ACID_TABLES.getErrorCodedMsg());
            }

            objectInspector = OrcRecordUpdater.createEventSchema
                                  (OrcStruct.createObjectInspector(0, OrcUtils.getOrcTypes(typeDescr)));

            // modify the options to reflect the event instead of the base row
            Reader.Options eventOptions = createEventOptions(options);
            if (reader == null)
            {
                baseReader = null;
            }
            else
            {
                // find the min/max based on the offset and length
                if (isOriginal)
                {
                    discoverOriginalKeyBounds(reader, bucket, options);
                }
                else
                {
                    discoverKeyBounds(reader, options);
                }
                LOG.info("min key = " + minKey + ", max key = " + maxKey);
                // use the min/max instead of the byte range
                ReaderPair pair;
                ReaderKey  key = new ReaderKey();
                if (isOriginal)
                {
                    options = options.clone();
                    options.range(options.getOffset(), Long.MAX_VALUE);
                    pair = new OriginalReaderPair(key, reader, bucket, minKey, maxKey,
                                                  options);
                }
                else
                {
                    pair = new ReaderPair(key, reader, bucket, minKey, maxKey,
                                          eventOptions, 0);
                }

                // if there is at least one record, put it in the map
                if (pair.nextRecord != null)
                {
                    readers.put(key, pair);
                }
                baseReader = pair.recordReader;
            }

            // we always want to read all of the deltas
            eventOptions.range(0, Long.MAX_VALUE);
            if (deltaDirectory != null)
            {
                foreach (Path delta in deltaDirectory)
                {
                    ReaderKey             key       = new ReaderKey();
                    Path                  deltaFile = AcidUtils.createBucketFile(delta, bucket);
                    AcidUtils.ParsedDelta deltaDir  = AcidUtils.parsedDelta(delta);
                    FileSystem            fs        = deltaFile.getFileSystem(conf);
                    long                  length    = getLastFlushLength(fs, deltaFile);
                    if (length != -1 && fs.exists(deltaFile))
                    {
                        Reader deltaReader = OrcFile.createReader(deltaFile,
                                                                  OrcFile.readerOptions(conf).maxLength(length));
                        Reader.Options deltaEventOptions = null;
                        if (eventOptions.getSearchArgument() != null)
                        {
                            // Turn off the sarg before pushing it to delta.  We never want to push a sarg to a delta as
                            // it can produce wrong results (if the latest valid version of the record is filtered out by
                            // the sarg) or ArrayOutOfBounds errors (when the sarg is applied to a delete record)
                            // unless the delta only has insert events
                            OrcRecordUpdater.AcidStats acidStats = OrcRecordUpdater.parseAcidStats(deltaReader);
                            if (acidStats.deletes > 0 || acidStats.updates > 0)
                            {
                                deltaEventOptions = eventOptions.clone().searchArgument(null, null);
                            }
                        }
                        ReaderPair deltaPair;
                        deltaPair = new ReaderPair(key, deltaReader, bucket, minKey,
                                                   maxKey, deltaEventOptions != null ? deltaEventOptions : eventOptions, deltaDir.getStatementId());
                        if (deltaPair.nextRecord != null)
                        {
                            readers.put(key, deltaPair);
                        }
                    }
                }
            }

            // get the first record
            Map.Entry <ReaderKey, ReaderPair> entry = readers.pollFirstEntry();
            if (entry == null)
            {
                columns = 0;
                primary = null;
            }
            else
            {
                primary = entry.getValue();
                if (readers.isEmpty())
                {
                    secondaryKey = null;
                }
                else
                {
                    secondaryKey = readers.firstKey();
                }
                // get the number of columns in the user's rows
                columns = primary.getColumns();
            }
        }
コード例 #28
0
        internal virtual void setConfigurableClass(Class @class)
        {
            this.ownerClass = @class;
            if (this.isInstanciated())
            {
                string text = "class is already instantiated";

                throw new RuntimeException(text);
            }
            HashSet  hashSet  = new HashSet();
            Map      map      = PropertySheet.parseClass(this.ownerClass);
            Iterator iterator = map.entrySet().iterator();

            while (iterator.hasNext())
            {
                Map.Entry entry = (Map.Entry)iterator.next();
                try
                {
                    string text2 = (string)((Field)entry.getKey()).get(null, PropertySheet.__GetCallerID());
                    if (!PropertySheet.assertionsDisabled && hashSet.contains(text2))
                    {
                        object obj = new StringBuilder().append("duplicate property-name for different properties: ").append(text2).append(" for the class ").append(@class).toString();

                        throw new AssertionError(obj);
                    }
                    this.registerProperty(text2, new S4PropWrapper((java.lang.annotation.Annotation)entry.getValue()));
                    hashSet.add(text2);
                }
                catch (IllegalAccessException ex)
                {
                    Throwable.instancehelper_printStackTrace(ex);
                }
                continue;
            }
        }
コード例 #29
0
        public virtual void dump()
        {
            Iterator iterator = this.map.entrySet().iterator();

            while (iterator.hasNext())
            {
                Map.Entry entry = (Map.Entry)iterator.next();
                [email protected](new StringBuilder().append(entry.getKey()).append(" ").append(entry.getValue()).toString());
            }
        }
コード例 #30
0
        public override string toString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.append("#JSGF V1.0;").append(JSGFRuleGrammar.LINE_SEPARATOR);
            stringBuilder.append(JSGFRuleGrammar.LINE_SEPARATOR);
            stringBuilder.append(this.formatComment(this.grammarDocComment));
            stringBuilder.append(JSGFRuleGrammar.LINE_SEPARATOR);
            stringBuilder.append("grammar ").append(this.name).append(';').append(JSGFRuleGrammar.LINE_SEPARATOR);
            stringBuilder.append(JSGFRuleGrammar.LINE_SEPARATOR);
            Set set = this.importDocComments.keySet();

            for (int i = 0; i < this.__imports.size(); i++)
            {
                string text = new StringBuilder().append('<').append(((JSGFRuleName)this.__imports.get(i)).getRuleName()).append('>').toString();
                if (set.contains(text))
                {
                    stringBuilder.append(this.formatComment((string)this.importDocComments.get(text)));
                    stringBuilder.append(JSGFRuleGrammar.LINE_SEPARATOR);
                    stringBuilder.append("import ").append(new StringBuilder().append(text).append(';').toString()).append(JSGFRuleGrammar.LINE_SEPARATOR);
                    stringBuilder.append(JSGFRuleGrammar.LINE_SEPARATOR);
                }
            }
            set = this.ruleDocComments.keySet();
            Iterator iterator = this.__rules.entrySet().iterator();

            while (iterator.hasNext())
            {
                Map.Entry entry = (Map.Entry)iterator.next();
                object    key   = entry.getKey();
                if (set.size() > 0 && set.contains(key))
                {
                    stringBuilder.append(this.formatComment((string)this.ruleDocComments.get(key))).append(JSGFRuleGrammar.LINE_SEPARATOR);
                }
                JSGFRuleGrammar.JSGFRuleState jsgfruleState = (JSGFRuleGrammar.JSGFRuleState)entry.getValue();
                if (jsgfruleState.isPublic)
                {
                    stringBuilder.append("public ");
                }
                stringBuilder.append('<').append(key).append("> = ").append(jsgfruleState.rule).append(';').append(JSGFRuleGrammar.LINE_SEPARATOR);
                stringBuilder.append(JSGFRuleGrammar.LINE_SEPARATOR);
            }
            return(stringBuilder.toString());
        }