use of org.teiid.metadata.Table in project teiid by teiid.
the class AccumuloUpdateExecution method performInsert.
private void performInsert(Insert insert) throws TranslatorException, TableNotFoundException, MutationsRejectedException {
Table table = insert.getTable().getMetadataObject();
this.updateCount = 0;
Connector connector = this.connection.getInstance();
BatchWriter writer = createBatchWriter(table, connector);
List<ColumnReference> columns = insert.getColumns();
if (insert.getParameterValues() == null) {
List<Expression> values = ((ExpressionValueSource) insert.getValueSource()).getValues();
writeMutation(writer, columns, values);
this.updateCount++;
} else {
int batchSize = this.executionContext.getBatchSize();
// bulk insert; should help
Iterator<? extends List<Expression>> args = (Iterator<? extends List<Expression>>) insert.getParameterValues();
while (args.hasNext()) {
List<Expression> values = args.next();
writeMutation(writer, columns, values);
this.updateCount++;
if ((this.updateCount % batchSize) == 0) {
writer.close();
writer = createBatchWriter(table, connector);
}
}
}
// write the mutation
writer.close();
}
use of org.teiid.metadata.Table in project teiid by teiid.
the class AccumuloUpdateExecution method performDelete.
private void performDelete(Delete delete) throws TableNotFoundException, MutationsRejectedException, TranslatorException {
if (delete.getParameterValues() != null) {
throw new TranslatorException(AccumuloPlugin.Event.TEIID19005, AccumuloPlugin.Util.gs(AccumuloPlugin.Event.TEIID19005));
}
Table table = delete.getTable().getMetadataObject();
AccumuloQueryVisitor visitor = new AccumuloQueryVisitor(this.aef);
visitor.visitNode(delete.getWhere());
if (!visitor.exceptions.isEmpty()) {
throw visitor.exceptions.get(0);
}
/*
// To get the update count I am taking longer route..
Connector connector = this.connection.getInstance();
BatchDeleter deleter = connector.createBatchDeleter(SQLStringVisitor.getRecordName(table), auths, this.aef.getQueryThreadsCount(), new BatchWriterConfig());
deleter.setRanges(visitor.getRanges());
deleter.delete();
deleter.close();
*/
Text prevRow = null;
Connector connector = this.connection.getInstance();
BatchWriter writer = createBatchWriter(table, connector);
Iterator<Entry<Key, Value>> results = AccumuloQueryExecution.runQuery(this.aef, this.connection.getInstance(), this.connection.getAuthorizations(), visitor.getRanges(), table, null);
while (results.hasNext()) {
Key key = results.next().getKey();
Text rowId = key.getRow();
if (prevRow == null || !prevRow.equals(rowId)) {
this.updateCount++;
}
prevRow = rowId;
Mutation mutation = new Mutation(rowId);
mutation.putDelete(key.getColumnFamily(), key.getColumnQualifier());
writer.addMutation(mutation);
}
writer.close();
}
use of org.teiid.metadata.Table in project teiid by teiid.
the class TestCouchbaseMetadataProcessor method testComplexJson.
@Test
public void testComplexJson() throws ResourceException {
CouchbaseMetadataProcessor mp = new CouchbaseMetadataProcessor();
MetadataFactory mf = new MetadataFactory("vdb", 1, "couchbase", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
Table table = createTable(mf, KEYSPACE, KEYSPACE);
mp.scanRow(KEYSPACE, KEYSPACE_SOURCE, complexJson(), mf, table, KEYSPACE, false, new Dimension());
helpTest("complexJson.expected", mf);
}
use of org.teiid.metadata.Table in project teiid by teiid.
the class TestCouchbaseMetadataProcessor method testCustomerOrderWithTypedName.
@Test
public void testCustomerOrderWithTypedName() throws ResourceException {
CouchbaseMetadataProcessor mp = new CouchbaseMetadataProcessor();
mp.setTypeNameList("`test`:`type`,`beer-sample`:`type`,` travel-sample`:`type`");
MetadataFactory mf = new MetadataFactory("vdb", 1, "couchbase", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
Table customer = createTable(mf, KEYSPACE, "Customer");
mp.scanRow(KEYSPACE, KEYSPACE_SOURCE, formCustomer(), mf, customer, customer.getName(), false, new Dimension());
Table order = createTable(mf, KEYSPACE, "Oder");
mp.scanRow(KEYSPACE, KEYSPACE_SOURCE, formOder(), mf, order, order.getName(), false, new Dimension());
helpTest("customerOrderTypedName.expected", mf);
}
use of org.teiid.metadata.Table in project teiid by teiid.
the class TestCouchbaseMetadataProcessor method testJsonNestedArray.
@Test
public void testJsonNestedArray() throws ResourceException {
CouchbaseMetadataProcessor mp = new CouchbaseMetadataProcessor();
MetadataFactory mf = new MetadataFactory("vdb", 1, "couchbase", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
Table table = createTable(mf, KEYSPACE, KEYSPACE);
mp.scanRow(KEYSPACE, KEYSPACE_SOURCE, complexJsonNestedArray(), mf, table, KEYSPACE, false, new Dimension());
helpTest("complexJsonNestedArray.expected", mf);
}
Aggregations