[ https://issues.apache.org/jira/browse/PIRK-78?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15603061#comment-15603061 ]
ASF GitHub Bot commented on PIRK-78: ------------------------------------ Github user tellison commented on a diff in the pull request: https://github.com/apache/incubator-pirk/pull/112#discussion_r84772832 --- Diff: src/main/java/org/apache/pirk/schema/query/QuerySchemaLoader.java --- @@ -226,50 +215,28 @@ public QuerySchema loadSchema(InputStream stream) throws IOException, PIRExcepti Element elements = (Element) elementsList.item(0); LinkedHashSet<String> elementNames = new LinkedHashSet<>(); - int dataElementSize = 0; NodeList nList = elements.getElementsByTagName("name"); for (int i = 0; i < nList.getLength(); i++) { Node nNode = nList.item(i); if (nNode.getNodeType() == Node.ELEMENT_NODE) { - // Pull the name - String queryElementName = nNode.getFirstChild().getNodeValue().trim(); - if (!dataSchema.containsElement(queryElementName)) - { - throw new PIRException("dataSchema = " + dataSchemaName + " does not contain requested element name = " + queryElementName); - } - elementNames.add(queryElementName); - logger.info("name = " + queryElementName + " partitionerName = " + dataSchema.getPartitionerTypeName(queryElementName)); - - // Compute the number of bits for this element. - DataPartitioner partitioner = dataSchema.getPartitionerForElement(queryElementName); - int bits = partitioner.getBits(dataSchema.getElementType(queryElementName)); - - // Multiply by the number of array elements allowed, if applicable. - if (dataSchema.isArrayElement(queryElementName)) - { - bits *= Integer.parseInt(SystemConfiguration.getProperty("pir.numReturnArrayElements")); - } - dataElementSize += bits; - - logger.info("name = " + queryElementName + " bits = " + bits + " dataElementSize = " + dataElementSize); + elementNames.add(nNode.getFirstChild().getNodeValue().trim()); } } + schemaBuilder.setQueryElementNames(elementNames); // Extract the filter, if it exists - String filterTypeName = NO_FILTER; if (doc.getElementsByTagName("filter").item(0) != null) { - filterTypeName = doc.getElementsByTagName("filter").item(0).getTextContent().trim(); + schemaBuilder.setFilterTypeName(doc.getElementsByTagName("filter").item(0).getTextContent().trim()); } // Create a filter over the query elements. - Set<String> filteredNamesSet = extractFilteredElementNames(doc); - DataFilter filter = instantiateFilter(filterTypeName, filteredNamesSet); + schemaBuilder.setFilteredElementNames(extractFilteredElementNames(doc)); // Extract the additional fields, if they exists - HashMap<String,String> additionalFields = new HashMap<String,String>(); + Map<String,String> additionalFields = new HashMap<String,String>(); --- End diff -- Yep, I didn't spot that one - fixed. > Create a new QuerySchema builder to separate from representation > ---------------------------------------------------------------- > > Key: PIRK-78 > URL: https://issues.apache.org/jira/browse/PIRK-78 > Project: PIRK > Issue Type: Improvement > Reporter: Tim Ellison > > Presently, Pirk has a QuerySchemaLoader that reads an XML formatted stream > and builds a new QuerySchema. > In order to separate the representation of the schema in XML from the logic > of assembling a new schema such as validating the values, a new > QuerySchemaBuilder is to be introduced. The QuerySchemaLoader will then > delegate the creation to the new builder, and other representations can also > use the builder to create a new QuerySchema without having to go via XML. -- This message was sent by Atlassian JIRA (v6.3.4#6332)