Examples of Insert


Examples of org.tarantool.core.cmd.Insert

      }
    };
    TupleSupport ts = new TupleSupport();
    for (int i = 0; i < 10; i++) {
      Tuple tuple = ts.create(i, Long.parseLong("98765432" + i), "Hello world " + i + "!");
      xlog.writeXLog(new Insert(0, tuple).flags(2));
    }

    xlog.close();
    Assert.assertTrue(closed.get());
    DataInputStream is = new DataInputStream(ClassLoader.getSystemResourceAsStream("test.xlog"));
View Full Code Here

Examples of org.teiid.language.Insert

            if (l.isBindValue() || isBindEligible(l)) {
                return true;
            }
        }
      if (command instanceof Insert) {
          Insert insert = (Insert)command;
          return insert.getValueSource() instanceof IteratorValueSource<?>;
      }
        return false;
    }
View Full Code Here

Examples of org.teiid.language.Insert

                addStatementWarnings();
            } else {
              PreparedStatement pstatement = getPreparedStatement(sql);
             
              if (command instanceof Insert) {
                  Insert insert = (Insert)command;
                  if (insert.getValueSource() instanceof IteratorValueSource) {
                        commitType = getAutoCommit(translatedComm);
                        if (commitType) {
                            connection.setAutoCommit(false);
                        }
                   
                    IteratorValueSource<List<Object>> ivs = (IteratorValueSource)insert.getValueSource();
                    List<Object>[] values = new List[ivs.getColumnCount()];
                    for (int i = 0; i < ivs.getColumnCount(); i++) {
                      values[i] = new ArrayList<Object>();
                      Literal literal = new Literal(values[i], insert.getColumns().get(i).getType());
                      literal.setMultiValued(true);
                      translatedComm.getPreparedValues().add(literal);
                    }
                    Iterator<List<Object>> i = ivs.getIterator();
                    int maxBatchSize = this.executionFactory.getMaxPreparedInsertBatchSize();
View Full Code Here

Examples of org.teiid.language.Insert

    }
   
    @Test public void testInsertWithQuery() throws Exception {
      String sql = "insert into pm1.g1 values (null, null, null, null)"; //$NON-NLS-1$

      Insert insert = (Insert)FakeTranslationFactory.getInstance().getExampleTranslationUtility().parseCommand(sql);
     
      Select command = (Select)FakeTranslationFactory.getInstance().getExampleTranslationUtility().parseCommand("select * from pm1.g2"); //$NON-NLS-1$
      insert.setValueSource(command);
      assertEquals("INSERT INTO g1 (e1, e2, e3, e4) SELECT g2.e1, g2.e2, g2.e3, g2.e4 FROM g2", insert.toString()); //$NON-NLS-1$
    }
View Full Code Here

Examples of org.teiid.language.Insert

    updateExecution.execute();
    Mockito.verify(p, Mockito.times(2)).addBatch();
  }
 
  @Test public void testInsertIteratorUpdate() throws Exception {
    Insert command = (Insert)TranslationHelper.helpTranslate(TranslationHelper.BQT_VDB, "insert into BQT1.SmallA (IntKey, IntNum) values (1, 2)"); //$NON-NLS-1$
    List<List<Integer>> values = new ArrayList<List<Integer>>();
    values.add(Arrays.asList(1, 2));
    values.add(Arrays.asList(2, 3));
    command.setValueSource(new IteratorValueSource(values.iterator(), 2));
   
    Connection connection = Mockito.mock(Connection.class);
    PreparedStatement p = Mockito.mock(PreparedStatement.class);
    Mockito.stub(p.executeBatch()).toReturn(new int [] {1, 1});
    Mockito.stub(connection.prepareStatement("INSERT INTO SmallA (IntKey, IntNum) VALUES (?, ?)")).toReturn(p); //$NON-NLS-1$
View Full Code Here

Examples of org.teiid.language.Insert

            assertTrue(i.next() instanceof Expression);
        }
    }
   
    public void testExpressionsInInsert() throws Exception {
        Insert insert = example2("a.b"); //$NON-NLS-1$
        assertNotNull(insert.getColumns());
        assertEquals(1, insert.getColumns().size());
        for (Iterator i = insert.getColumns().iterator(); i.hasNext();) {
            assertTrue(i.next() instanceof ColumnReference);
        }
        assertNotNull(insert.getValueSource());
        assertEquals(1, ((ExpressionValueSource)insert.getValueSource()).getValues().size());
        for (Iterator i = ((ExpressionValueSource)insert.getValueSource()).getValues().iterator(); i.hasNext();) {
            assertTrue(i.next() instanceof Expression);
        }
    }
View Full Code Here

Examples of org.teiid.language.Insert

    public void testGetGroup() throws Exception {
        assertNotNull(example("a.b").getTable()); //$NON-NLS-1$
    }

    public void testGetElements() throws Exception {
        Insert insert = example("a.b"); //$NON-NLS-1$
        assertNotNull(insert.getColumns());
        assertEquals(4, insert.getColumns().size());
        for (Iterator i = insert.getColumns().iterator(); i.hasNext();) {
            assertTrue(i.next() instanceof ColumnReference);
        }

        // verify that elements are not qualified by group
        String sInsertSQL = insert.toString();
        assertTrue(sInsertSQL.substring(sInsertSQL.indexOf('(')).indexOf( '.') == -1 );                       
    }
View Full Code Here

Examples of org.teiid.language.Insert

        String sInsertSQL = insert.toString();
        assertTrue(sInsertSQL.substring(sInsertSQL.indexOf('(')).indexOf( '.') == -1 );                       
    }

    public void testGetValues() throws Exception {
        Insert insert = example("a.b"); //$NON-NLS-1$
        assertNotNull(insert.getValueSource());
        assertEquals(4, ((ExpressionValueSource)insert.getValueSource()).getValues().size());
        for (Iterator i = ((ExpressionValueSource)insert.getValueSource()).getValues().iterator(); i.hasNext();) {
            assertTrue(i.next() instanceof Expression);
        }
    }
View Full Code Here

Examples of org.teiid.query.sql.lang.Insert

    public TestRuleValidateWhereAll(String name) {
        super(name);
    }

    public void testHasNoCriteria1() {
        assertEquals("Got incorrect answer checking for no criteria", false, RuleValidateWhereAll.hasNoCriteria(new Insert())); //$NON-NLS-1$
    }
View Full Code Here

Examples of org.teiid.query.sql.lang.Insert

                plan = removeUnnecessaryInlineView(plan, commandRoot);
                QueryCommand queryCommand = createQuery(metadata, capFinder, accessNode, commandRoot);
              addDistinct(metadata, capFinder, accessNode, queryCommand);
                command = queryCommand;
                if (intoGroup != null) {
                  Insert insertCommand = new Insert(intoGroup, ResolverUtil.resolveElementsInGroup(intoGroup, metadata), null);
                  insertCommand.setQueryExpression(queryCommand);
                  command = insertCommand;
                }
            }
            if (command != null) {
              accessNode.setProperty(NodeConstants.Info.ATOMIC_REQUEST, command);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.