Package org.teiid.query.parser

Examples of org.teiid.query.parser.ParseInfo


  @Test
  public void testSessionSpecfic() {
   
    SessionAwareCache<Cachable> cache = new SessionAwareCache<Cachable>();
   
    CacheID id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO");
   
    Cachable result = Mockito.mock(Cachable.class);
   
    id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO");
    cache.put(id, Determinism.SESSION_DETERMINISTIC, result, null);
   
    // make sure that in the case of session specific; we do not call prepare
    // as session is local only call for distributed
    Mockito.verify(result, times(0)).prepare((Cache)anyObject(), (BufferManager)anyObject());
View Full Code Here


  @Test
  public void testUserSpecfic() {
   
    SessionAwareCache<Cachable> cache = new SessionAwareCache<Cachable>();
   
    CacheID id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO");
   
    Cachable result = Mockito.mock(Cachable.class);
    Mockito.stub(result.prepare((Cache)anyObject(), (BufferManager)anyObject())).toReturn(true);
    Mockito.stub(result.restore((Cache)anyObject(), (BufferManager)anyObject())).toReturn(true);
       
    cache.put(id, Determinism.USER_DETERMINISTIC, result, null);
   
    // make sure that in the case of session specific; we do not call prepare
    // as session is local only call for distributed
    Mockito.verify(result, times(1)).prepare((Cache)anyObject(), (BufferManager)anyObject());
   
    id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO");
   
    Object c = cache.get(id);
   
    Mockito.verify(result, times(1)).restore((Cache)anyObject(), (BufferManager)anyObject());   
   
View Full Code Here

  @Test
  public void testNoScope() {
   
    SessionAwareCache<Cachable> cache = new SessionAwareCache<Cachable>();
   
    CacheID id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO");
   
    Cachable result = Mockito.mock(Cachable.class);
    Mockito.stub(result.prepare((Cache)anyObject(), (BufferManager)anyObject())).toReturn(true);
    Mockito.stub(result.restore((Cache)anyObject(), (BufferManager)anyObject())).toReturn(true);   
   
    cache.put(id, Determinism.VDB_DETERMINISTIC, result, null);
   
    // make sure that in the case of session specific; we do not call prepare
    // as session is local only call for distributed
    Mockito.verify(result, times(1)).prepare((Cache)anyObject(), (BufferManager)anyObject());
   
    id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO");
   
    Object c = cache.get(id);
   
    Mockito.verify(result, times(1)).restore((Cache)anyObject(), (BufferManager)anyObject());   
   
View Full Code Here

  @Test
  public void testVDBRemoval() {
   
    SessionAwareCache<Cachable> cache = new SessionAwareCache<Cachable>();
   
    CacheID id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO");
   
    Cachable result = Mockito.mock(Cachable.class);
    Mockito.stub(result.prepare((Cache)anyObject(), (BufferManager)anyObject())).toReturn(true);
    Mockito.stub(result.restore((Cache)anyObject(), (BufferManager)anyObject())).toReturn(true);   
   
    id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO");
    cache.put(id, Determinism.VDB_DETERMINISTIC, result, null);
   
    Object c = cache.get(id);
   
    assertTrue(result==c);
View Full Code Here

    //collapse the hash to single byte for the key to restrict the possible results to 256
    int hash = vals.hashCode();
    hash |= (hash >>> 16);
    hash |= (hash >>> 8);
    hash &= 0x000000ff;
    CacheID cid = new CacheID(new ParseInfo(), fullName + hash, context.getVdbName(),
        context.getVdbVersion(), context.getConnectionID(), context.getUserName());
    cid.setParameters(vals);
    CachedResults results = cache.get(cid);
    if (results != null) {
      TupleBuffer buffer = results.getResults();
View Full Code Here

    try {
      String fullName = metadata.getFullName(group.getMetadataID());
      TupleSource ts = null;
      CacheID cid = null;
      if (distributedCache != null) {
        cid = new CacheID(new ParseInfo(), fullName, context.getVdbName(),
            context.getVdbVersion(), context.getConnectionID(), context.getUserName());
        CachedResults cr = this.distributedCache.get(cid);
        if (cr != null) {
          ts = cr.getResults().createIndexedTupleSource();
        }
View Full Code Here

   
    if (rsCache != null) {
      if (!canUseCached) {
        LogManager.logDetail(LogConstants.CTX_DQP, requestID, "No cache directive"); //$NON-NLS-1$
      } else {
        ParseInfo pi = Request.createParseInfo(requestMsg);
        cacheId = new CacheID(this.dqpWorkContext, pi, requestMsg.getCommandString());
          cachable = cacheId.setParameters(requestMsg.getParameterValues());
        if (cachable) {
          CachedResults cr = rsCache.get(cacheId);
          if (cr != null) {
View Full Code Here

    }

    private MetadataResult obtainMetadataForPreparedSql(String sql, DQPWorkContext workContext, boolean isDoubleQuotedVariablesAllowed) throws QueryParserException, QueryResolverException, TeiidComponentException {
        Command command = null;
       
        ParseInfo info = new ParseInfo();
        // Defect 19747 - the parser needs the following connection property to decide whether to treat double-quoted strings as variable names
        info.ansiQuotedIdentifiers = isDoubleQuotedVariablesAllowed;
        CacheID id = new CacheID(workContext, info, sql);
        PreparedPlan plan = planCache.get(id);
        if(plan != null) {
View Full Code Here

        validateWithVisitor(visitor, metadata, command);
    }
   
    private Command parseCommand() throws QueryParserException {
        String[] commands = requestMsg.getCommands();
        ParseInfo parseInfo = createParseInfo(this.requestMsg);
        if (requestMsg.isPreparedStatement() || requestMsg.isCallableStatement() || !requestMsg.isBatchedUpdate()) {
          String commandStr = commands[0];
            return QueryParser.getQueryParser().parseCommand(commandStr, parseInfo);
        }
        List<Command> parsedCommands = new ArrayList<Command>(commands.length);
View Full Code Here

        }
        return new BatchedUpdateCommand(parsedCommands);
    }

  public static ParseInfo createParseInfo(RequestMessage requestMsg) {
    ParseInfo parseInfo = new ParseInfo();
      parseInfo.ansiQuotedIdentifiers = requestMsg.isAnsiQuotedIdentifiers();
    return parseInfo;
  }
View Full Code Here

TOP

Related Classes of org.teiid.query.parser.ParseInfo

Copyright © 2018 www.massapicom. 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.