本文整理汇总了Java中org.apache.metamodel.data.Row类的典型用法代码示例。如果您正苦于以下问题:Java Row类的具体用法?Java Row怎么用?Java Row使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Row类属于org.apache.metamodel.data包,在下文中一共展示了Row类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: insertScript
import org.apache.metamodel.data.Row; //导入依赖的package包/类
private UpdateScript insertScript() {
UpdateScript insertScrript = new UpdateScript() {
public void run(UpdateCallback callback) {
Object value = null;
RowInsertionBuilder insertData = callback.insertInto(table);
for(Row rows: row){
for (SelectItem column : rows.getSelectItems()) {
if (!column.getColumn().getType().isTimeBased()) {
value = rows.getValue(column);
} else {
value = ElementParser.getDate(rows.getValue(column));
}
insertData.value(column.getColumn(), value);
}
requests.mark();
insertData.execute();
}
}
};
return insertScrript;
}
开发者ID:Iranox,项目名称:mapbench-datadistributor,代码行数:27,代码来源:DataWriter.java
示例2: insertRowIntoBlockingQueue
import org.apache.metamodel.data.Row; //导入依赖的package包/类
private void insertRowIntoBlockingQueue(DataSet dataset) throws InterruptedException {
hashedColumn = table.getColumnByName(columnName);
requests = metrics.meter("read thread");
while (dataset.next()) {
Row row = dataset.getRow();
if (horizontal && isKey(row)) {
queue.put(row);
requests.mark();
} else {
if(!horizontal){
queue.put(row);
requests.mark();
}
}
}
}
开发者ID:Iranox,项目名称:mapbench-datadistributor,代码行数:21,代码来源:DataReader.java
示例3: readComplexData
import org.apache.metamodel.data.Row; //导入依赖的package包/类
public void readComplexData() throws Exception {
Column primaryColumn = dataContext.getTableByQualifiedLabel(joinTable).getColumnByName(secondFkey);
System.out.println(dataContext.query().from(joinTable).select(primaryColumn).groupBy(primaryColumn).toQuery().toString());
DataSet dataSet = dataContext.query().from(joinTable).select(primaryColumn).groupBy(primaryColumn).execute();
while (dataSet.next()) {
arrayData = new ArrayList<Row>();
Object dataValue = dataSet.getRow().getValue(primaryColumn);
DataSet dataSetArray = dataContext.query().from(joinTable).select(forgeinKey).where(primaryColumn)
.eq(dataValue).execute();
System.out.println( dataContext.query().from(joinTable).select(forgeinKey).where(primaryColumn)
.eq(dataValue).toQuery().toSql());
readDataSet(dataSetArray);
ComplexData complexDataObject = new ComplexData(dataSet.getRow(), arrayData);
queueComplexData.put(complexDataObject);
dataSetArray.close();
// dataContext.executeUpdate();
}
insertPosion();
dataSet.close();
}
开发者ID:Iranox,项目名称:mapbench-datadistributor,代码行数:24,代码来源:ComplexDataReader.java
示例4: loadIntoMemory
import org.apache.metamodel.data.Row; //导入依赖的package包/类
public SimpleSynonymCatalog loadIntoMemory(final DatastoreConnection datastoreConnection) {
final Map<String, String> synonymMap = new HashMap<>();
final Column masterTermColumn = getMasterTermColumn(datastoreConnection);
final Column[] columns = getSynonymColumns(datastoreConnection);
try (DataSet dataSet = datastoreConnection.getDataContext().query().from(masterTermColumn.getTable().getName())
.select(masterTermColumn).select(columns).execute()) {
while (dataSet.next()) {
final Row row = dataSet.getRow();
final String masterTerm = getMasterTerm(row, masterTermColumn);
final String[] synonyms = getSynonyms(row, columns);
for (final String synonym : synonyms) {
synonymMap.put(synonym, masterTerm);
}
}
}
return new SimpleSynonymCatalog(getName(), synonymMap);
}
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:21,代码来源:DatastoreSynonymCatalog.java
示例5: materializeMainSchemaTable
import org.apache.metamodel.data.Row; //导入依赖的package包/类
@Override
protected DataSet materializeMainSchemaTable(final Table table, final List<Column> columns, final int maxRows) {
final SelectItem[] tableSelectItems = MetaModelHelper.createSelectItems(table.getColumns().toArray(new Column[0]));
final SelectItem[] selectItems = MetaModelHelper.createSelectItems(columns.toArray(new Column[0]));
final SimpleDataSetHeader header = new SimpleDataSetHeader(tableSelectItems);
final List<Row> rows = new ArrayList<>();
final SimpleDataSetHeader subSelectionHeader = new SimpleDataSetHeader(selectItems);
rows.add(new DefaultRow(header, new Object[] { 1, "hello" }).getSubSelection(subSelectionHeader));
rows.add(new DefaultRow(header, new Object[] { 2, "there" }).getSubSelection(subSelectionHeader));
rows.add(new DefaultRow(header, new Object[] { 3, "big" }).getSubSelection(subSelectionHeader));
rows.add(new DefaultRow(header, new Object[] { 4, "wide" }).getSubSelection(subSelectionHeader));
rows.add(new DefaultRow(header, new Object[] { 5, "world" }).getSubSelection(subSelectionHeader));
return new InMemoryDataSet(rows);
}
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:19,代码来源:SampleDataContext.java
示例6: getValues
import org.apache.metamodel.data.Row; //导入依赖的package包/类
@Override
public Collection<String> getValues() {
try (final DatastoreConnection con = _datastore.openConnection()) {
final DataContext dataContext = con.getDataContext();
final Query q = dataContext.query().from(_column.getTable()).select(_column).toQuery();
q.selectDistinct();
try (final DataSet dataSet = dataContext.executeQuery(q)) {
final List<String> values = new ArrayList<String>();
while (dataSet.next()) {
final Row row = dataSet.getRow();
Object value = row.getValue(0);
if (value != null) {
value = value.toString();
}
values.add((String) value);
}
return values;
}
}
}
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:24,代码来源:DatastoreReferenceValues.java
示例7: testGetRendererByHierarchyDistance
import org.apache.metamodel.data.Row; //导入依赖的package包/类
public void testGetRendererByHierarchyDistance() throws Exception {
ClasspathScanDescriptorProvider descriptorProvider = new ClasspathScanDescriptorProvider().scanPackage(
"org.eobjects.analyzer.result.renderer", true);
RendererFactory rendererFactory = new RendererFactory(
new AnalyzerBeansConfigurationImpl().replace(descriptorProvider));
Renderer<?, ? extends CharSequence> r;
r = rendererFactory.getRenderer(new NumberResult(1), TextRenderingFormat.class);
assertEquals(ToStringTextRenderer.class, r.getClass());
r = rendererFactory.getRenderer(new CrosstabResult(null), TextRenderingFormat.class);
assertEquals(CrosstabTextRenderer.class, r.getClass());
r = rendererFactory.getRenderer(new DataSetResult(new LinkedList<Row>()), TextRenderingFormat.class);
assertEquals(MetricBasedResultTextRenderer.class, r.getClass());
}
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:17,代码来源:RendererFactoryTest.java
示例8: getRow
import org.apache.metamodel.data.Row; //导入依赖的package包/类
@Override
public Row getRow() {
final DataSetHeader header = getHeader();
final Object[] values = new Object[header.size()];
if (row != null) {
for (int i = 0; i < header.size(); i++) {
final Column column = header.getSelectItem(i).getColumn();
final int kettleIndex = rowMeta.indexOfValue(column.getName());
final Object rawValue = row[kettleIndex];
try {
final ValueMetaInterface valueMeta = rowMeta.getValueMeta(kettleIndex);
values[i] = valueMeta.convertData(valueMeta, rawValue);
} catch (KettleValueException e) {
throw new MetaModelException(e);
}
}
}
return new DefaultRow(header, values);
}
开发者ID:datacleaner,项目名称:pdi-datacleaner,代码行数:22,代码来源:KettleDataSet.java
示例9: execute
import org.apache.metamodel.data.Row; //导入依赖的package包/类
@Override
public void execute() throws MetaModelException {
Table table = getTable();
List<FilterItem> whereItems = getWhereItems();
CouchDbConnector connector = _updateCallback.getConnector(table.getName());
CouchDbDataContext dataContext = _updateCallback.getDataContext();
DataSet dataSet = dataContext.query().from(table)
.select(CouchDbDataContext.FIELD_ID, CouchDbDataContext.FIELD_REV).where(whereItems).execute();
try {
while (dataSet.next()) {
Row row = dataSet.getRow();
String id = (String) row.getValue(0);
String revision = (String) row.getValue(1);
connector.delete(id, revision);
}
} finally {
dataSet.close();
}
}
开发者ID:apache,项目名称:metamodel,代码行数:22,代码来源:CouchDbRowDeletionBuilder.java
示例10: deleteFrom
import org.apache.metamodel.data.Row; //导入依赖的package包/类
@Override
public RowDeletionBuilder deleteFrom(Table table) throws IllegalArgumentException, IllegalStateException,
UnsupportedOperationException {
return new AbstractRowDeletionBuilder(table) {
@Override
public void execute() throws MetaModelException {
final DataSet dataSet = _dataContext.query().from(getTable()).select(getTable().getColumns()).execute();
final PojoDataSet<?> pojoDataSet = (PojoDataSet<?>) dataSet;
final List<FilterItem> whereItems = getWhereItems();
while (pojoDataSet.next()) {
boolean delete = true;
final Row row = pojoDataSet.getRow();
for (FilterItem whereItem : whereItems) {
if (!whereItem.evaluate(row)) {
delete = false;
break;
}
}
if (delete) {
pojoDataSet.remove();
}
}
}
};
}
开发者ID:apache,项目名称:metamodel,代码行数:27,代码来源:PojoUpdateCallback.java
示例11: testJoin
import org.apache.metamodel.data.Row; //导入依赖的package包/类
@Test
public void testJoin() {
Stopwatch duration = Stopwatch.createStarted();
CompositeDataContext compDcon = new CompositeDataContext(this.emp_dcon, this.dep_dcon);
DataSet ds = compDcon.query().from("employee").innerJoin("department").on("dep_id", "id").selectAll().execute();
int rowCount = 0;
while (ds.next()) {
Row row = ds.getRow();
Assert.assertNotNull(row);
rowCount++;
}
duration.stop();
logger.info("Test duration was {} ms", duration.elapsed(TimeUnit.MILLISECONDS));
Assert.assertEquals(employeeSize, rowCount);
}
开发者ID:apache,项目名称:metamodel,代码行数:19,代码来源:MultiJDBCDataSetTest.java
示例12: testSelectiveJoin
import org.apache.metamodel.data.Row; //导入依赖的package包/类
@Test
public void testSelectiveJoin() {
Stopwatch duration = Stopwatch.createStarted();
CompositeDataContext compDcon = new CompositeDataContext(this.emp_dcon, this.dep_dcon);
DataSet ds = compDcon.query().from("employee").innerJoin("department").on("dep_id", "id").selectAll().where(
compDcon.getTableByQualifiedLabel("department").getColumnByName("id")).eq(1).execute();
int rowCount = 0;
while (ds.next()) {
Row row = ds.getRow();
Assert.assertNotNull(row);
rowCount++;
}
duration.stop();
logger.info("Test duration was {} ms", duration.elapsed(TimeUnit.MILLISECONDS));
Assert.assertEquals(employeesPerDepartment, rowCount);
}
开发者ID:apache,项目名称:metamodel,代码行数:19,代码来源:MultiJDBCDataSetTest.java
示例13: testMaxAndOffset
import org.apache.metamodel.data.Row; //导入依赖的package包/类
public void testMaxAndOffset() throws Exception {
if (!isConfigured()) {
return;
}
final JdbcDataContext context = getDataContext();
final List<Row> onlyMaxRows =
context.query().from("HR", "EMPLOYEES").select("EMPLOYEE_ID").maxRows(10).execute().toRows();
assertEquals("Should limit size even without offset", 10, onlyMaxRows.size());
final List<Row> onlyOffset =
context.query().from("HR", "EMPLOYEES").select("EMPLOYEE_ID").orderBy("EMPLOYEE_ID").firstRow(5)
.execute().toRows();
assertEquals("Should offset first row", new BigDecimal(104), onlyOffset.get(0).getValue(0));
assertEquals("Should not limit size beyond offset", 103, onlyOffset.size());
final List<Row> maxRowsAndOffset =
context.query().from("HR", "EMPLOYEES").select("EMPLOYEE_ID").maxRows(20).orderBy("EMPLOYEE_ID")
.firstRow(20).execute().toRows();
assertEquals("Should offset first row", new BigDecimal(119), maxRowsAndOffset.get(0).getValue(0));
assertEquals("Should not limit size", 20, maxRowsAndOffset.size());
}
开发者ID:apache,项目名称:metamodel,代码行数:25,代码来源:OracleTest.java
示例14: testMaxAndOffset
import org.apache.metamodel.data.Row; //导入依赖的package包/类
public void testMaxAndOffset() throws Exception {
if (!isConfigured()) {
return;
}
final JdbcDataContext context = getDataContext();
final List<Row> onlyMaxRows =
context.query().from("Person", "Person").select("BusinessEntityID").maxRows(10).execute().toRows();
assertEquals("Should limit size even without offset or order by", 10, onlyMaxRows.size());
final List<Row> onlyOffset =
context.query().from("Person", "Person").select("BusinessEntityID").orderBy("BusinessEntityID").firstRow(5)
.execute().toRows();
assertEquals("Should offset first row", 5, onlyOffset.get(0).getValue(0));
assertEquals("Should not limit size beyond offset", 19968, onlyOffset.size());
final List<Row> maxRowsAndOffset =
context.query().from("Person", "Person").select("BusinessEntityID").maxRows(20).orderBy("BusinessEntityID")
.firstRow(20).execute().toRows();
assertEquals("Should offset first row", 20, maxRowsAndOffset.get(0).getValue(0));
assertEquals("Should not limit size", 20, maxRowsAndOffset.size());
}
开发者ID:apache,项目名称:metamodel,代码行数:25,代码来源:SQLServerJtdsDriverTest.java
示例15: executePrimaryKeyLookupQuery
import org.apache.metamodel.data.Row; //导入依赖的package包/类
@Override
protected Row executePrimaryKeyLookupQuery(Table table, List<SelectItem> selectItems, Column primaryKeyColumn,
Object keyValue) {
final org.apache.hadoop.hbase.client.Table hTable = getHTable(table.getName());
final Get get = new Get(ByteUtils.toBytes(keyValue));
try {
final Result result = hTable.get(get);
final DataSetHeader header = new SimpleDataSetHeader(selectItems);
final Row row = new HBaseRow(header, result);
return row;
} catch (IOException e) {
throw new IllegalStateException("Failed to execute HBase get operation with " + primaryKeyColumn.getName()
+ " = " + keyValue, e);
} finally {
FileHelper.safeClose(hTable);
}
}
开发者ID:apache,项目名称:metamodel,代码行数:18,代码来源:HBaseDataContext.java
示例16: toRow
import org.apache.metamodel.data.Row; //导入依赖的package包/类
/**
* Converts a Cassandra Row data object {@link com.datastax.driver.core.Row}
* into MetaModel {@link org.apache.metamodel.data.Row}.
*
* @param dbObject
* a Cassandra object storing data.
* @param header
* a header describing the columns of the data stored.
* @return the MetaModel {@link org.apache.metamodel.data.Row} result
* object.
*/
public static Row toRow(com.datastax.driver.core.Row dbObject, DataSetHeader header) {
if (dbObject == null) {
return null;
}
final int size = header.size();
final Object[] values = new Object[size];
for (int i = 0; i < values.length; i++) {
final SelectItem selectItem = header.getSelectItem(i);
final String key = selectItem.getColumn().getName();
values[i] = getColumnValue(key, dbObject);
}
return new DefaultRow(header, values);
}
开发者ID:apache,项目名称:metamodel,代码行数:27,代码来源:CassandraUtils.java
示例17: executePrimaryKeyLookupQuery
import org.apache.metamodel.data.Row; //导入依赖的package包/类
@Override
protected Row executePrimaryKeyLookupQuery(Table table, List<SelectItem> selectItems, Column primaryKeyColumn,
Object keyValue) {
final List<String> attributeNames = new ArrayList<>();
for (SelectItem selectItem : selectItems) {
attributeNames.add(selectItem.getColumn().getName());
}
final GetItemRequest getItemRequest = new GetItemRequest(table.getName(), Collections.singletonMap(
primaryKeyColumn.getName(), DynamoDbUtils.toAttributeValue(keyValue))).withAttributesToGet(
attributeNames);
final GetItemResult item = _dynamoDb.getItem(getItemRequest);
final Object[] values = new Object[selectItems.size()];
for (int i = 0; i < values.length; i++) {
final AttributeValue attributeValue = item.getItem().get(attributeNames.get(i));
values[i] = DynamoDbUtils.toValue(attributeValue);
}
return new DefaultRow(new SimpleDataSetHeader(selectItems), values);
}
开发者ID:apache,项目名称:metamodel,代码行数:22,代码来源:DynamoDbDataContext.java
示例18: executePrimaryKeyLookupQuery
import org.apache.metamodel.data.Row; //导入依赖的package包/类
@Override
protected Row executePrimaryKeyLookupQuery(Table table, List<SelectItem> selectItems, Column primaryKeyColumn,
Object keyValue) {
if (keyValue == null) {
return null;
}
final String documentType = table.getName();
final String id = keyValue.toString();
final DataSetHeader header = new SimpleDataSetHeader(selectItems);
try {
return ElasticSearchUtils.createRow(getElasticSearchClient()
.get(new GetRequest(getIndexName(), documentType, id))
.getSource(), id, header);
} catch (IOException e) {
logger.warn("Could not execute ElasticSearch query", e);
throw new MetaModelException("Could not execute ElasticSearch query", e);
}
}
开发者ID:apache,项目名称:metamodel,代码行数:22,代码来源:ElasticSearchRestDataContext.java
示例19: testDeleteAll
import org.apache.metamodel.data.Row; //导入依赖的package包/类
@Test
public void testDeleteAll() throws Exception {
final Schema schema = dataContext.getDefaultSchema();
final CreateTable createTable = new CreateTable(schema, "testCreateTable");
createTable.withColumn("foo").ofType(ColumnType.STRING);
createTable.withColumn("bar").ofType(ColumnType.NUMBER);
dataContext.executeUpdate(createTable);
final Table table = schema.getTableByName("testCreateTable");
dataContext.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback callback) {
callback.insertInto(table).value("foo", "hello").value("bar", 42).execute();
callback.insertInto(table).value("foo", "world").value("bar", 43).execute();
}
});
dataContext.executeUpdate(new DeleteFrom(table));
Row row = MetaModelHelper.executeSingleRowQuery(dataContext, dataContext.query().from(table).selectCount()
.toQuery());
assertEquals("Count is wrong", 0, ((Number) row.getValue(0)).intValue());
}
开发者ID:apache,项目名称:metamodel,代码行数:25,代码来源:ElasticSearchRestDataContextIT.java
示例20: testDeleteByQuery
import org.apache.metamodel.data.Row; //导入依赖的package包/类
@Test
public void testDeleteByQuery() throws Exception {
final Schema schema = dataContext.getDefaultSchema();
final CreateTable createTable = new CreateTable(schema, "testCreateTable");
createTable.withColumn("foo").ofType(ColumnType.STRING);
createTable.withColumn("bar").ofType(ColumnType.NUMBER);
dataContext.executeUpdate(createTable);
final Table table = schema.getTableByName("testCreateTable");
dataContext.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback callback) {
callback.insertInto(table).value("foo", "hello").value("bar", 42).execute();
callback.insertInto(table).value("foo", "world").value("bar", 43).execute();
}
});
dataContext.executeUpdate(new DeleteFrom(table).where("foo").eq("hello").where("bar").eq(42));
Row row = MetaModelHelper.executeSingleRowQuery(dataContext,
dataContext.query().from(table).select("foo", "bar").toQuery());
assertEquals("Row[values=[world, 43]]", row.toString());
}
开发者ID:apache,项目名称:metamodel,代码行数:25,代码来源:ElasticSearchRestDataContextIT.java
注:本文中的org.apache.metamodel.data.Row类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论