Search in sources :

Example 46 with LinkedHashMap

use of java.util.LinkedHashMap in project SQLWindowing by hbutani.

the class WindowingTypeCheckProcFactory method genExprNode.

public static HashMap<Node, Object> genExprNode(ASTNode expr, TypeCheckCtx tcCtx) throws SemanticException {
    // Create the walker, the rules dispatcher and the context.
    // create a walker which walks the tree in a DFS manner while
    // maintaining
    // the operator stack. The dispatcher
    // generates the plan from the operator tree
    Map<Rule, NodeProcessor> opRules = new LinkedHashMap<Rule, NodeProcessor>();
    opRules.put(new RuleRegExp("R1", Windowing2Parser.NULL + "%"), getNullExprProcessor());
    opRules.put(new RuleRegExp("R2", Windowing2Parser.Number + "%|" + Windowing2Parser.TinyintLiteral + "%|" + Windowing2Parser.SmallintLiteral + "%|" + Windowing2Parser.BigintLiteral + "%"), getNumExprProcessor());
    opRules.put(new RuleRegExp("R3", Windowing2Parser.Identifier + "%|" + Windowing2Parser.StringLiteral + "%|" + Windowing2Parser.CHARSETLITERAL + "%|" + Windowing2Parser.STRINGLITERALSEQUENCE + "%|" + "%|" + Windowing2Parser.IF + "%|" + Windowing2Parser.CASE + "%|" + Windowing2Parser.WHEN + "%|" + Windowing2Parser.IN + "%|" + Windowing2Parser.ARRAY + "%|" + Windowing2Parser.MAP + "%|" + Windowing2Parser.BETWEEN + "%|" + Windowing2Parser.STRUCT + "%"), getStrExprProcessor());
    opRules.put(new RuleRegExp("R4", Windowing2Parser.TRUE + "%|" + Windowing2Parser.FALSE + "%"), getBoolExprProcessor());
    opRules.put(new RuleRegExp("R5", Windowing2Parser.TABLEORCOL + "%"), getColumnExprProcessor());
    // The dispatcher fires the processor corresponding to the closest
    // matching
    // rule and passes the context along
    Dispatcher disp = new DefaultRuleDispatcher(getDefaultExprProcessor(), opRules, tcCtx);
    GraphWalker ogw = new DefaultGraphWalker(disp);
    // Create a list of topop nodes
    ArrayList<Node> topNodes = new ArrayList<Node>();
    topNodes.add(expr);
    HashMap<Node, Object> nodeOutputs = new HashMap<Node, Object>();
    ogw.startWalking(topNodes, nodeOutputs);
    return nodeOutputs;
}
Also used : NodeProcessor(org.apache.hadoop.hive.ql.lib.NodeProcessor) DefaultRuleDispatcher(org.apache.hadoop.hive.ql.lib.DefaultRuleDispatcher) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) DefaultGraphWalker(org.apache.hadoop.hive.ql.lib.DefaultGraphWalker) ASTNode(org.apache.hadoop.hive.ql.parse.ASTNode) Node(org.apache.hadoop.hive.ql.lib.Node) RuleRegExp(org.apache.hadoop.hive.ql.lib.RuleRegExp) ArrayList(java.util.ArrayList) Dispatcher(org.apache.hadoop.hive.ql.lib.Dispatcher) DefaultRuleDispatcher(org.apache.hadoop.hive.ql.lib.DefaultRuleDispatcher) LinkedHashMap(java.util.LinkedHashMap) Rule(org.apache.hadoop.hive.ql.lib.Rule) GraphWalker(org.apache.hadoop.hive.ql.lib.GraphWalker) DefaultGraphWalker(org.apache.hadoop.hive.ql.lib.DefaultGraphWalker)

Example 47 with LinkedHashMap

use of java.util.LinkedHashMap in project j2objc by google.

the class LinkedHashMapTest method test_values.

/**
     * java.util.LinkedHashMap#values()
     */
public void test_values() {
    // Test for method java.util.Collection java.util.LinkedHashMap.values()
    Collection c = hm.values();
    assertTrue("Returned collection of incorrect size()", c.size() == hm.size());
    for (int i = 0; i < objArray.length; i++) assertTrue("Returned collection does not contain all keys", c.contains(objArray[i]));
    LinkedHashMap myLinkedHashMap = new LinkedHashMap();
    for (int i = 0; i < 100; i++) myLinkedHashMap.put(objArray2[i], objArray[i]);
    Collection values = myLinkedHashMap.values();
    new Support_UnmodifiableCollectionTest("Test Returned Collection From LinkedHashMap.values()", values).runTest();
    values.remove(new Integer(0));
    assertTrue("Removing from the values collection should remove from the original map", !myLinkedHashMap.containsValue(new Integer(0)));
}
Also used : Support_UnmodifiableCollectionTest(tests.support.Support_UnmodifiableCollectionTest) Collection(java.util.Collection) LinkedHashMap(java.util.LinkedHashMap)

Example 48 with LinkedHashMap

use of java.util.LinkedHashMap in project j2objc by google.

the class LinkedHashMapTest method test_clone.

/**
     * java.util.LinkedHashMap#clone()
     */
public void test_clone() {
    // Test for method java.lang.Object java.util.LinkedHashMap.clone()
    LinkedHashMap hm2 = (LinkedHashMap) hm.clone();
    assertTrue("Clone answered equivalent LinkedHashMap", hm2 != hm);
    for (int counter = 0; counter < hmSize; counter++) assertTrue("Clone answered unequal LinkedHashMap", hm.get(objArray2[counter]) == hm2.get(objArray2[counter]));
    LinkedHashMap map = new LinkedHashMap();
    map.put("key", "value");
    // get the keySet() and values() on the original Map
    Set keys = map.keySet();
    Collection values = map.values();
    assertEquals("values() does not work", "value", values.iterator().next());
    assertEquals("keySet() does not work", "key", keys.iterator().next());
    AbstractMap map2 = (AbstractMap) map.clone();
    map2.put("key", "value2");
    Collection values2 = map2.values();
    assertTrue("values() is identical", values2 != values);
    // values() and keySet() on the cloned() map should be different
    assertEquals("values() was not cloned", "value2", values2.iterator().next());
    map2.clear();
    map2.put("key2", "value3");
    Set key2 = map2.keySet();
    assertTrue("keySet() is identical", key2 != keys);
    assertEquals("keySet() was not cloned", "key2", key2.iterator().next());
}
Also used : AbstractMap(java.util.AbstractMap) Set(java.util.Set) Collection(java.util.Collection) LinkedHashMap(java.util.LinkedHashMap)

Example 49 with LinkedHashMap

use of java.util.LinkedHashMap in project j2objc by google.

the class LinkedHashMapTest method test_clone_Mock.

// regresion test for HARMONY-4603
public void test_clone_Mock() {
    LinkedHashMap hashMap = new MockMap();
    String value = "value a";
    hashMap.put("key", value);
    MockMap cloneMap = (MockMap) hashMap.clone();
    assertEquals(value, cloneMap.get("key"));
    assertEquals(hashMap, cloneMap);
    assertEquals(1, cloneMap.num);
    hashMap.put("key", "value b");
    assertFalse(hashMap.equals(cloneMap));
}
Also used : LinkedHashMap(java.util.LinkedHashMap)

Example 50 with LinkedHashMap

use of java.util.LinkedHashMap in project j2objc by google.

the class LinkedHashMapTest method test_getLjava_lang_Object.

/**
     * java.util.LinkedHashMap#get(java.lang.Object)
     */
public void test_getLjava_lang_Object() {
    // Test for method java.lang.Object
    // java.util.LinkedHashMap.get(java.lang.Object)
    assertNull("Get returned non-null for non existent key", hm.get("T"));
    hm.put("T", "HELLO");
    assertEquals("Get returned incorecct value for existing key", "HELLO", hm.get("T"));
    LinkedHashMap m = new LinkedHashMap();
    m.put(null, "test");
    assertEquals("Failed with null key", "test", m.get(null));
    assertNull("Failed with missing key matching null hash", m.get(new Integer(0)));
}
Also used : LinkedHashMap(java.util.LinkedHashMap)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)2398 Map (java.util.Map)691 ArrayList (java.util.ArrayList)675 HashMap (java.util.HashMap)439 Test (org.junit.Test)317 List (java.util.List)298 IOException (java.io.IOException)152 HashSet (java.util.HashSet)128 Set (java.util.Set)110 LinkedHashSet (java.util.LinkedHashSet)100 File (java.io.File)93 LinkedList (java.util.LinkedList)75 TreeMap (java.util.TreeMap)72 Node (org.apache.hadoop.hive.ql.lib.Node)70 NodeProcessor (org.apache.hadoop.hive.ql.lib.NodeProcessor)68 Rule (org.apache.hadoop.hive.ql.lib.Rule)68 GraphWalker (org.apache.hadoop.hive.ql.lib.GraphWalker)66 Dispatcher (org.apache.hadoop.hive.ql.lib.Dispatcher)65 Iterator (java.util.Iterator)64 DefaultRuleDispatcher (org.apache.hadoop.hive.ql.lib.DefaultRuleDispatcher)64