use of org.teiid.query.sql.symbol.ElementSymbol in project teiid by teiid.
the class TestAuthorizationValidationVisitor method helpTest.
private void helpTest(String sql, QueryMetadataInterface metadata, String[] expectedInaccesible, VDBMetaData vdb, DataPolicyMetadata... roles) throws QueryParserException, QueryResolverException, TeiidComponentException {
QueryParser parser = QueryParser.getQueryParser();
Command command = parser.parseCommand(sql);
QueryResolver.resolveCommand(command, metadata);
DataRolePolicyDecider dataRolePolicyDecider = createPolicyDecider(metadata, vdb, roles);
// $NON-NLS-1$
AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(dataRolePolicyDecider, context);
ValidatorReport report = Validator.validate(command, metadata, visitor);
if (report.hasItems()) {
ValidatorFailure firstFailure = report.getItems().iterator().next();
// strings
Set<String> expected = new HashSet<String>(Arrays.asList(expectedInaccesible));
// elements
Set<String> actual = new HashSet<String>();
for (LanguageObject obj : firstFailure.getInvalidObjects()) {
if (obj instanceof ElementSymbol) {
actual.add(((ElementSymbol) obj).getName());
} else {
actual.add(obj.toString());
}
}
assertEquals(expected, actual);
} else if (expectedInaccesible.length > 0) {
// $NON-NLS-1$
fail("Expected inaccessible objects, but got none.");
}
}
use of org.teiid.query.sql.symbol.ElementSymbol in project teiid by teiid.
the class TestSTree method testOrderedInsert.
@Test
public void testOrderedInsert() throws TeiidComponentException {
BufferManagerImpl bm = BufferManagerFactory.createBufferManager();
bm.setProcessorBatchSize(4);
ElementSymbol e1 = new ElementSymbol("x");
e1.setType(Integer.class);
List<ElementSymbol> elements = Arrays.asList(e1);
STree map = bm.createSTree(elements, "1", 1);
int size = (1 << 16) + (1 << 4) + 1;
for (int i = 0; i < size; i++) {
assertNull(map.insert(Arrays.asList(i), InsertMode.ORDERED, size));
assertEquals(i + 1, map.getRowCount());
}
assertEquals(4, map.getHeight());
for (int i = 0; i < size; i++) {
assertNotNull(map.remove(Arrays.asList(i)));
}
}
use of org.teiid.query.sql.symbol.ElementSymbol in project teiid by teiid.
the class TestSTree method testUnOrderedInsert.
@Test
public void testUnOrderedInsert() throws TeiidComponentException {
BufferManagerImpl bm = BufferManagerFactory.createBufferManager();
bm.setProcessorBatchSize(16);
ElementSymbol e1 = new ElementSymbol("x");
e1.setType(Integer.class);
List elements = Arrays.asList(e1);
STree map = bm.createSTree(elements, "1", 1);
int size = (1 << 16) + (1 << 4) + 1;
int logSize = map.getExpectedHeight(size);
for (int i = 0; i < size; i++) {
assertNull(map.insert(Arrays.asList(i), InsertMode.NEW, logSize));
assertEquals(i + 1, map.getRowCount());
}
assertTrue(5 >= map.getHeight());
}
use of org.teiid.query.sql.symbol.ElementSymbol in project teiid by teiid.
the class TestSTree method testSearch.
@Test
public void testSearch() throws TeiidComponentException, TeiidProcessingException {
// due to buffering changes we need to hold this in memory directly rather than serialize it out as that will lead to GC overhead errors
BufferManagerImpl bm = BufferManagerFactory.getTestBufferManager(Integer.MAX_VALUE, 1);
ElementSymbol e1 = new ElementSymbol("x");
e1.setType(Integer.class);
ElementSymbol e2 = new ElementSymbol("x");
e2.setType(Integer.class);
List elements = Arrays.asList(e1, e2);
STree map = bm.createSTree(elements, "1", 2);
int size = 1 << 16;
for (int i = 0; i < size; i++) {
assertNull(map.insert(Arrays.asList(i, i), InsertMode.NEW, -1));
assertEquals(i + 1, map.getRowCount());
}
map.compact();
for (int i = 0; i < size; i++) {
TupleBrowser tb = new TupleBrowser(map, new CollectionTupleSource(Collections.singletonList(Arrays.asList(i)).iterator()), true);
assertNotNull(tb.nextTuple());
assertNull(tb.nextTuple());
}
}
use of org.teiid.query.sql.symbol.ElementSymbol in project teiid by teiid.
the class TestSTree method testSearchWithRepeated.
@Test
public void testSearchWithRepeated() throws TeiidComponentException, TeiidProcessingException {
// due to buffering changes we need to hold this in memory directly rather than serialize it out as that will lead to GC overhead errors
BufferManagerImpl bm = BufferManagerFactory.getTestBufferManager(Integer.MAX_VALUE, 1);
ElementSymbol e1 = new ElementSymbol("x");
e1.setType(Integer.class);
ElementSymbol e2 = new ElementSymbol("x");
e2.setType(Integer.class);
List<ElementSymbol> elements = Arrays.asList(e1, e2);
STree map = bm.createSTree(elements, "1", 2);
int size = 1 << 16;
for (int i = 0; i < size; i++) {
assertNull(map.insert(Arrays.asList(i, i * 2), InsertMode.NEW, -1));
assertNull(map.insert(Arrays.asList(i, i * 2 + 1), InsertMode.NEW, -1));
assertEquals((i + 1) * 2, map.getRowCount());
}
map.compact();
for (int i = 0; i < size; i++) {
TupleBrowser tb = new TupleBrowser(map, new CollectionTupleSource(Collections.singletonList(Arrays.asList(i)).iterator()), true);
for (int j = 0; j < 2; j++) {
assertNotNull(tb.nextTuple());
}
assertNull(tb.nextTuple());
}
}
Aggregations