Refine search
protected final OperatorFactory createTableScanOperator(int operatorId, PlanNodeId planNodeId, String tableName, String... columnNames) checkArgument(session.getCatalog().isPresent(), "catalog not set"); checkArgument(session.getSchema().isPresent(), "schema not set"); QualifiedObjectName qualifiedTableName = new QualifiedObjectName(session.getCatalog().get(), session.getSchema().get(), tableName); TableHandle tableHandle = metadata.getTableHandle(session, qualifiedTableName).orElse(null); checkArgument(tableHandle != null, "Table %s does not exist", qualifiedTableName); Map<String, ColumnHandle> allColumnHandles = metadata.getColumnHandles(session, tableHandle); ImmutableList.Builder<ColumnHandle> columnHandlesBuilder = ImmutableList.builder(); for (String columnName : columnNames) { ColumnHandle columnHandle = allColumnHandles.get(columnName); List<TableLayoutResult> layouts = metadata.getLayouts(session, tableHandle, Constraint.alwaysTrue(), Optional.empty()); Split split = getLocalQuerySplit(session, layouts.get(0).getLayout().getHandle());
TableLayout table = new TableLayout(this); TableRow tr = new TableRow(this); tr.setBackgroundColor(Color.BLACK); tr.setPadding(0, 0, 0, 2); //Border between rows TableRow.LayoutParams llp = new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); llp.setMargins(0, 0, 2, 0);//2px right-margin //New Cell LinearLayout cell = new LinearLayout(this); cell.setBackgroundColor(Color.WHITE); cell.setLayoutParams(llp);//2px border on the right for the cell TextView tv = new TextView(this); tv.setText("Some Text"); tv.setPadding(0, 0, 4, 3); cell.addView(tv); tr.addView(cell); //add as many cells you want to a row, using the same approach table.addView(tr);
@Override public List<TableLayoutResult> getLayouts(Session session, TableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) { if (constraint.getSummary().isNone()) { return ImmutableList.of(); } ConnectorId connectorId = table.getConnectorId(); ConnectorTableHandle connectorTable = table.getConnectorHandle(); CatalogMetadata catalogMetadata = getCatalogMetadata(session, connectorId); ConnectorMetadata metadata = catalogMetadata.getMetadataFor(connectorId); ConnectorTransactionHandle transaction = catalogMetadata.getTransactionHandleFor(connectorId); ConnectorSession connectorSession = session.toConnectorSession(connectorId); List<ConnectorTableLayoutResult> layouts = metadata.getTableLayouts(connectorSession, connectorTable, constraint, desiredColumns); return layouts.stream() .map(layout -> new TableLayoutResult(fromConnectorLayout(connectorId, transaction, layout.getTableLayout()), layout.getUnenforcedConstraint())) .collect(toImmutableList()); }
TableLayout table = new TableLayout(this); // Java. You succeed! FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); table.setLayoutParams(lp); table.setStretchAllColumns(true); TableLayout.LayoutParams rowLp = new TableLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, 1.0f); TableRow.LayoutParams cellLp = new TableRow.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, 1.0f); for (int r = 0; r < 2; ++r) { TableRow row = new TableRow(this); for (int c = 0; c < 2; ++c) { Button btn = new Button(this); btn.setText("A"); row.addView(btn, cellLp); } table.addView(row, rowLp); } setContentView(table);
public class MainActivity extends Activity implements View.OnClickListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TableLayout layout = new TableLayout (this); layout.setLayoutParams( new TableLayout.LayoutParams(4,5) ); layout.setPadding(1,1,1,1); for (int f=0; f<=13; f++) { TableRow tr = new TableRow(this); for (int c=0; c<=9; c++) { Button b = new Button (this); b.setText(""+f+c); b.setTextSize(10.0f); b.setTextColor(Color.rgb( 100, 200, 200)); b.setOnClickListener(this); tr.addView(b, 30,30); } // for layout.addView(tr); } // for super.setContentView(layout); } // () public void onClick(View view) { ((Button) view).setText("*"); ((Button) view).setEnabled(false); } } // class
@Override public ActualProperties visitTableScan(TableScanNode node, List<ActualProperties> inputProperties) { checkArgument(node.getLayout().isPresent(), "table layout has not yet been chosen"); TableLayout layout = metadata.getLayout(session, node.getLayout().get()); Map<ColumnHandle, Symbol> assignments = ImmutableBiMap.copyOf(node.getAssignments()).inverse(); ActualProperties.Builder properties = ActualProperties.builder(); // Globally constant assignments Map<ColumnHandle, NullableValue> globalConstants = new HashMap<>(); extractFixedValues(node.getCurrentConstraint()).orElse(ImmutableMap.of()) .entrySet().stream() .filter(entry -> !entry.getValue().isNull()) .forEach(entry -> globalConstants.put(entry.getKey(), entry.getValue())); Map<Symbol, NullableValue> symbolConstants = globalConstants.entrySet().stream() .filter(entry -> assignments.containsKey(entry.getKey())) .collect(toMap(entry -> assignments.get(entry.getKey()), Map.Entry::getValue)); properties.constants(symbolConstants); // Partitioning properties properties.global(deriveGlobalProperties(layout, assignments, globalConstants)); // Append the global constants onto the local properties to maximize their translation potential List<LocalProperty<ColumnHandle>> constantAppendedLocalProperties = ImmutableList.<LocalProperty<ColumnHandle>>builder() .addAll(globalConstants.keySet().stream().map(ConstantProperty::new).iterator()) .addAll(layout.getLocalProperties()) .build(); properties.local(LocalProperties.translate(constantAppendedLocalProperties, column -> Optional.ofNullable(assignments.get(column)))); return properties.build(); }
private static KdbTree loadKdbTree(String tableName, Session session, Metadata metadata, SplitManager splitManager, PageSourceManager pageSourceManager) QualifiedObjectName name = toQualifiedObjectName(tableName, session.getCatalog().get(), session.getSchema().get()); TableHandle tableHandle = metadata.getTableHandle(session, name) .orElseThrow(() -> new PrestoException(INVALID_SPATIAL_PARTITIONING, format("Table not found: %s", name))); Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle); List<ColumnHandle> visibleColumnHandles = columnHandles.values().stream() .filter(handle -> !metadata.getColumnMetadata(session, tableHandle, handle).isHidden()) .collect(toImmutableList()); checkSpatialPartitioningTable(visibleColumnHandles.size() == 1, "Expected single column for table %s, but found %s columns", name, columnHandles.size()); Optional<KdbTree> kdbTree = Optional.empty(); try (SplitSource splitSource = splitManager.getSplits(session, layouts.get(0).getLayout().getHandle(), UNGROUPED_SCHEDULING)) { while (!Thread.currentThread().isInterrupted()) { SplitBatch splitBatch = getFutureValue(splitSource.getNextBatch(NOT_PARTITIONED, Lifespan.taskWide(), 1000)); try (ConnectorPageSource pageSource = pageSourceManager.createPageSource(session, split, ImmutableList.of(kdbTreeColumn))) { do { getFutureValue(pageSource.isBlocked());
private Object getHiveTableProperty(String tableName, Function<HiveTableLayoutHandle, Object> propertyGetter) { Session session = getSession(); Metadata metadata = ((DistributedQueryRunner) getQueryRunner()).getCoordinator().getMetadata(); return transaction(getQueryRunner().getTransactionManager(), getQueryRunner().getAccessControl()) .readOnly() .execute(session, transactionSession -> { Optional<TableHandle> tableHandle = metadata.getTableHandle(transactionSession, new QualifiedObjectName(catalog, TPCH_SCHEMA, tableName)); assertTrue(tableHandle.isPresent()); List<TableLayoutResult> layouts = metadata.getLayouts(transactionSession, tableHandle.get(), Constraint.alwaysTrue(), Optional.empty()); TableLayout layout = getOnlyElement(layouts).getLayout(); return propertyGetter.apply((HiveTableLayoutHandle) layout.getHandle().getConnectorHandle()); }); }
.intersect(node.getCurrentConstraint()); List<TableLayoutResult> layouts = metadata.getLayouts( session, node.getTable(), new Constraint<>(simplifiedConstraint, bindings -> true), Optional.of(ImmutableSet.copyOf(node.getAssignments().values()))); return new ValuesNode(idAllocator.getNextId(), node.getOutputSymbols(), ImmutableList.of()); node.getOutputSymbols(), node.getAssignments(), Optional.of(layout.getLayout().getHandle()), simplifiedConstraint.intersect(layout.getLayout().getPredicate()), Optional.ofNullable(node.getOriginalConstraint()).orElse(predicate));
Optional<TableHandle> tableHandle = metadata.getTableHandle(session, table); if (!tableHandle.isPresent()) { throw new SemanticException(MISSING_TABLE, showPartitions, "Table '%s' does not exist", table); List<TableLayoutResult> layouts = metadata.getLayouts(session, tableHandle.get(), Constraint.alwaysTrue(), Optional.empty()); if (layouts.size() != 1) { throw new SemanticException(NOT_SUPPORTED, showPartitions, "Table does not have exactly one layout: %s", table); if (!layout.getDiscretePredicates().isPresent()) { throw new SemanticException(NOT_SUPPORTED, showPartitions, "Table does not have partition columns: %s", table); List<ColumnHandle> partitionColumns = layout.getDiscretePredicates().get().getColumns(); ImmutableList.Builder<SelectItem> selectList = ImmutableList.builder(); ImmutableList.Builder<SelectItem> wrappedList = ImmutableList.builder(); selectList.add(unaliasedName("partition_number")); for (ColumnHandle columnHandle : partitionColumns) { ColumnMetadata column = metadata.getColumnMetadata(session, tableHandle.get(), columnHandle); Expression key = equal(nameReference("partition_key"), new StringLiteral(column.getName())); Expression value = caseWhen(key, nameReference("partition_value")); equal(nameReference("table_schema"), new StringLiteral(table.getSchemaName())), equal(nameReference("table_name"), new StringLiteral(table.getObjectName())))), Optional.of(new GroupBy(false, ImmutableList.of(new SimpleGroupBy(ImmutableList.of(nameReference("partition_number")))))), Optional.empty(), ImmutableList.of(),
if (!result.isPresent()) { return context.defaultRewrite(node); TableScanNode tableScan = result.get(); for (Symbol symbol : inputs) { ColumnHandle column = tableScan.getAssignments().get(symbol); ColumnMetadata columnMetadata = metadata.getColumnMetadata(session, tableScan.getTable(), column); if (!tableScan.getLayout().isPresent()) { List<TableLayoutResult> layouts = metadata.getLayouts(session, tableScan.getTable(), Constraint.alwaysTrue(), Optional.empty()); if (layouts.size() == 1) { layout = Iterables.getOnlyElement(layouts).getLayout(); layout = metadata.getLayout(session, tableScan.getLayout().get()); if (layout == null || !layout.getDiscretePredicates().isPresent()) { return context.defaultRewrite(node); DiscretePredicates predicates = layout.getDiscretePredicates().get(); ImmutableList.Builder<List<Expression>> rowsBuilder = ImmutableList.builder(); for (TupleDomain<ColumnHandle> domain : predicates.getPredicates()) { if (!domain.isNone()) { Map<ColumnHandle, NullableValue> entries = TupleDomain.extractFixedValues(domain).get(); ImmutableList.Builder<Expression> rowBuilder = ImmutableList.builder();
String... columnNames) checkArgument(session.getCatalog().isPresent(), "catalog not set"); checkArgument(session.getSchema().isPresent(), "schema not set"); QualifiedObjectName qualifiedTableName = new QualifiedObjectName(session.getCatalog().get(), session.getSchema().get(), tableName); TableHandle tableHandle = metadata.getTableHandle(session, qualifiedTableName).orElse(null); checkArgument(tableHandle != null, "Table %s does not exist", qualifiedTableName); ImmutableList.Builder<ColumnHandle> columnHandlesBuilder = ImmutableList.builder(); ImmutableList.Builder<Type> columnTypesBuilder = ImmutableList.builder(); for (String columnName : columnNames) { ColumnHandle columnHandle = allColumnHandles.get(columnName); List<TableLayoutResult> layouts = metadata.getLayouts(session, tableHandle, Constraint.alwaysTrue(), Optional.empty()); Split split = getLocalQuerySplit(session, layouts.get(0).getLayout().getHandle());
Optional<TableHandle> tableHandle = metadata.getTableHandle(session, tableName); if (!tableHandle.isPresent()) { throw new TableNotFoundException(tableName.asSchemaTableName()); List<TableLayoutResult> layouts = metadata.getLayouts(session, tableHandle.get(), Constraint.<ColumnHandle>alwaysTrue(), Optional.empty()); Map<ColumnHandle, String> columnHandles = ImmutableBiMap.copyOf(metadata.getColumnHandles(session, tableHandle.get())).inverse(); Map<ColumnHandle, MethodHandle> methodHandles = new HashMap<>(); for (ColumnHandle columnHandle : columnHandles.keySet()) { layout.getDiscretePredicates().ifPresent(predicates -> { int partitionNumber = 1; for (TupleDomain<ColumnHandle> domain : predicates.getPredicates()) {
public boolean hasAllOutputs(TableScanNode node) { if (!layout.getColumns().isPresent()) { return true; } Set<ColumnHandle> columns = ImmutableSet.copyOf(layout.getColumns().get()); List<ColumnHandle> nodeColumnHandles = node.getOutputSymbols().stream() .map(node.getAssignments()::get) .collect(toImmutableList()); return columns.containsAll(nodeColumnHandles); }
TupleDomain<ColumnHandle> originalEnforcedConstraint = scan.getEnforcedConstraint(); List<TableLayoutResult> layouts = metadata.getLayouts( session, handle, new Constraint<>(originalEnforcedConstraint), Optional.of(ImmutableSet.copyOf(scan.getAssignments().values()))); verify(layouts.size() == 1, "Expected exactly one layout for delete"); TableLayoutResult layoutResult = Iterables.getOnlyElement(layouts); scan.getOutputSymbols(), scan.getAssignments(), Optional.of(layoutResult.getLayout().getHandle()), layoutResult.getLayout().getPredicate(), computeEnforced(originalEnforcedConstraint, layoutResult.getUnenforcedConstraint())); return replaceChildren(node, ImmutableList.of(source)); return replaceChildren(node, ImmutableList.of(source)); return replaceChildren(node, ImmutableList.of(source, ((SemiJoinNode) node).getFilteringSource()));
LinearLayout linearLayout = (LinearLayout)findViewById(R.id.linearLayout2); for(int i = 0; i < listItems.length; i++) { TableRow.LayoutParams lp = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT); TableLayout.LayoutParams lp2 = new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT); TableLayout tableLayout = new TableLayout(this); tableLayout.setLayoutParams(lp2); tableLayout.setColumnStretchable(0, true);//NOTE: you may not want this if you do not want your textview to always fill the available space TableRow tableRow = new TableRow(this); tableRow.setLayoutParams(lp); TextView textView = new TextView(this); textView.setText(listItems[i]); textView.setLayoutParams(lp); tableRow.addView(textView); tableLayout.addView(tableRow); linearLayout.addView(tableLayout); }
private Predicate<TableLayoutResult> layoutHasAllNeededOutputs(TableScanNode node) { return layout -> !layout.getLayout().getColumns().isPresent() || layout.getLayout().getColumns().get().containsAll(Lists.transform(node.getOutputSymbols(), node.getAssignments()::get)); }
TextView introduction = new TextView(this); introduction.setText("Set Text Here"); introduction.setGravity(Gravity.LEFT); introduction.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); l.addView(introduction); TableLayout tl1 = new TableLayout(this); View v1 = new View(this); v1.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, 1)); v1.setBackgroundColor(Color.rgb(51, 51, 51)); tl1.addView(v1); l.addView(tl1); TableLayout tl2 = new TableLayout(this); View v2 = new View(this); v2.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, 1)); v2.setBackgroundColor(Color.rgb(51, 51, 51)); tl2.addView(v2); l.addView(tl2); TableLayout tl3 = new TableLayout(this); View v3 = new View(this); v3.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, 1)); TableLayout tl3 = new TableLayout(this); View v3 = new View(this); v3.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, 1));
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TableLayout table = new TableLayout(this); table.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT)); TableRow tableRow = new TableRow(this); tableRow.setOrientation(TableLayout.HORIZONTAL); for(int j=0;j<3;j++){ TextView textView = new TextView(this); textView.setGravity(Gravity.CENTER); textView.setId(id++); textView.setText(String.valueOf(textView.getId())); textView.setTag(textView.getId()); TableRow.LayoutParams textviewParams = new TableRow.LayoutParams(0, TableRow.LayoutParams.MATCH_PARENT,1f); textviewParams.setMargins(5, 5, 5, 5); tableRow.addView(textView,textviewParams); table.addView(tableRow,new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,0,1f));