public static Schema convertSchema(CatalogProtos.SchemaProto proto) { return SchemaFactory.newV1(proto); }
/** * This method transforms the unqualified names of a schema to the qualified names. * * @param tableName a table name to be prefixed * @param schema a schema to be transformed * * @return */ public static SchemaProto getQualfiedSchema(String tableName, SchemaProto schema) { Schema restored = SchemaFactory.newV1(schema); restored.setQualifier(tableName); return restored.getProto(); }
builder.mergeFrom(schemaBytes); SchemaProto proto = builder.build(); this.keySchema = SchemaFactory.newV1(proto); this.rowStoreDecoder = RowStoreUtil.createDecoder(keySchema);
int databaseId = getDatabaseId(databaseName); int tableId = getTableId(databaseId, databaseName, tableName); Schema relationSchema = SchemaFactory.newV1(getTable(databaseName, tableName).getSchema());
public PartitionMethodDesc(CatalogProtos.PartitionMethodProto proto) { this(proto.getTableIdentifier().getDatabaseName(), proto.getTableIdentifier().getTableName(), proto.getPartitionType(), proto.getExpression(), SchemaFactory.newV1(proto.getExpressionSchema())); }
String unifiedName = CatalogUtil.getUnifiedSimpleColumnName(SchemaFactory.newV1(tableDescProto.getSchema()), columnNames); pstmt.setInt(1, databaseId); pstmt.setInt(2, tableId);
public IndexDesc(IndexDescProto proto) { this(); SortSpec[] keySortSpecs = new SortSpec[proto.getKeySortSpecsCount()]; for (int i = 0; i < keySortSpecs.length; i++) { keySortSpecs[i] = new SortSpec(proto.getKeySortSpecs(i)); } try { this.set(proto.getTableIdentifier().getDatabaseName(), proto.getTableIdentifier().getTableName(), proto.getIndexName(), new URI(proto.getIndexPath()), keySortSpecs, proto.getIndexMethod(), proto.getIsUnique(), proto.getIsClustered(), SchemaFactory.newV1(proto.getTargetRelationSchema())); } catch (URISyntaxException e) { e.printStackTrace(); } }
public TableDesc(TableDescProto proto) { this(proto.getTableName(), proto.hasSchema() ? SchemaFactory.newV1(proto.getSchema()) : null, new TableMeta(proto.getMeta()), proto.hasPath() ? URI.create(proto.getPath()) : null, proto.getIsExternal()); if(proto.hasStats()) { this.stats = new TableStats(proto.getStats()); } if (proto.hasPartition()) { this.partitionMethodDesc = new PartitionMethodDesc(proto.getPartition()); } }
private static IndexScanNode convertIndexScan(OverridableConf context, EvalContext evalContext, PlanProto.LogicalNode protoNode) { IndexScanNode indexScan = new IndexScanNode(protoNode.getNodeId()); fillScanNode(context, evalContext, protoNode, indexScan); PlanProto.IndexScanSpec indexScanSpec = protoNode.getIndexScan(); SimplePredicate[] predicates = new SimplePredicate[indexScanSpec.getPredicatesCount()]; for (int i = 0; i < predicates.length; i++) { predicates[i] = new SimplePredicate(indexScanSpec.getPredicates(i)); } indexScan.set(SchemaFactory.newV1(indexScanSpec.getKeySchema()), predicates, TUtil.stringToURI(indexScanSpec.getIndexPath())); return indexScan; }
public BaseTupleComparator(TupleComparatorProto proto) { this.schema = SchemaFactory.newV1(proto.getSchema()); this.sortSpecs = new SortSpec[proto.getSortSpecsCount()]; for (int i = 0; i < proto.getSortSpecsCount(); i++) { sortSpecs[i] = new SortSpec(proto.getSortSpecs(i)); } this.sortKeyIds = new int[proto.getCompSpecsCount()]; this.asc = new boolean[proto.getCompSpecsCount()]; this.nullFirsts = new boolean[proto.getCompSpecsCount()]; for (int i = 0; i < proto.getCompSpecsCount(); i++) { TupleComparatorSpecProto sortSepcProto = proto.getCompSpecs(i); sortKeyIds[i] = sortSepcProto.getColumnId(); asc[i] = sortSepcProto.getAscending(); nullFirsts[i] = sortSepcProto.getNullFirst(); } }
schema = SchemaFactory.newV1(request.getSchema());
public static ResultSet createResultSet(QueryClient client, ClientProtos.SubmitQueryResponse response, int fetchRows) { if (response.hasTableDesc()) { // non-forward query // select * from table1 [limit 10] int fetchRowNum = fetchRows; if (response.hasSessionVars()) { for (PrimitiveProtos.KeyValueProto eachKeyValue: response.getSessionVars().getKeyvalList()) { if (eachKeyValue.getKey().equals(SessionVars.FETCH_ROWNUM.keyname())) { fetchRowNum = Integer.parseInt(eachKeyValue.getValue()); } } } TableDesc tableDesc = new TableDesc(response.getTableDesc()); return new FetchResultSet(client, tableDesc.getLogicalSchema(), new QueryId(response.getQueryId()), fetchRowNum); } else { // simple eval query // select substr('abc', 1, 2) ClientProtos.SerializedResultSet serializedResultSet = response.getResultSet(); return new TajoMemoryResultSet(new QueryId(response.getQueryId()), SchemaFactory.newV1(serializedResultSet.getSchema()), serializedResultSet, client.getClientSideSessionVars()); } }
protected TajoMemoryResultSet fetchNextQueryResult(final QueryId queryId, final int fetchRowNum) throws TajoException { final boolean compress = conn.getProperties().getBool(ClientParameters.USE_COMPRESSION); final BlockingInterface stub = conn.getTMStub(); final GetQueryResultDataRequest.Builder request = GetQueryResultDataRequest.newBuilder(); request.setSessionId(conn.sessionId) .setQueryId(queryId.getProto()) .setFetchRowNum(fetchRowNum); if (compress) { request.setCompressCodec(DEFAULT_CODEC); } GetQueryResultDataResponse response; try { response = stub.getQueryResultData(null, request.build()); } catch (ServiceException e) { throw new RuntimeException(e); } throwIfError(response.getState()); if(response.hasResultSet()) { SerializedResultSet resultSet = response.getResultSet(); return new TajoMemoryResultSet(queryId, SchemaFactory.newV1(resultSet.getSchema()), resultSet, getClientSideSessionVars()); } else { return TajoClientUtil.createNullResultSet(queryId); } }
private static CreateIndexNode convertCreateIndex(Map<Integer, LogicalNode> nodeMap, PlanProto.LogicalNode protoNode) { CreateIndexNode createIndex = new CreateIndexNode(protoNode.getNodeId()); PlanProto.CreateIndexNode createIndexProto = protoNode.getCreateIndex(); createIndex.setIndexName(createIndexProto.getIndexName()); createIndex.setIndexMethod(createIndexProto.getIndexMethod()); try { createIndex.setIndexPath(new URI(createIndexProto.getIndexPath())); } catch (URISyntaxException e) { e.printStackTrace(); } SortSpec[] keySortSpecs = new SortSpec[createIndexProto.getKeySortSpecsCount()]; for (int i = 0; i < keySortSpecs.length; i++) { keySortSpecs[i] = new SortSpec(createIndexProto.getKeySortSpecs(i)); } createIndex.setKeySortSpecs(SchemaFactory.newV1(createIndexProto.getTargetRelationSchema()), keySortSpecs); createIndex.setUnique(createIndexProto.getIsUnique()); createIndex.setClustered(createIndexProto.getIsClustered()); if (createIndexProto.hasIndexProperties()) { createIndex.setOptions(new KeyValueSet(createIndexProto.getIndexProperties())); } createIndex.setChild(nodeMap.get(createIndexProto.getChildSeq())); createIndex.setInSchema(convertSchema(protoNode.getInSchema())); createIndex.setOutSchema(convertSchema(protoNode.getOutSchema())); createIndex.setExternal(createIndexProto.getIsExternal()); return createIndex; }
public DataChannel(DataChannelProto proto) { this.srcId = new ExecutionBlockId(proto.getSrcId()); this.targetId = new ExecutionBlockId(proto.getTargetId()); this.transmitType = proto.getTransmitType(); this.shuffleType = proto.getShuffleType(); if (proto.hasSchema()) { this.setSchema(SchemaFactory.newV1(proto.getSchema())); } if (proto.getShuffleKeysCount() > 0) { shuffleKeys = new Column[proto.getShuffleKeysCount()]; for (int i = 0; i < proto.getShuffleKeysCount(); i++) { shuffleKeys[i] = new Column(proto.getShuffleKeys(i)); } } else { shuffleKeys = new Column[] {}; } if (proto.hasNumOutputs()) { this.numOutputs = proto.getNumOutputs(); } if (proto.hasDataFormat()) { this.dataFormat = proto.getDataFormat(); } }