public static FieldReferenceOffsetManager loadFrom(String source) throws ParserConfigurationException, SAXException, IOException { return loadFrom(source,(short)0); }
public static FieldReferenceOffsetManager loadFrom(InputStream sourceInputStream) throws ParserConfigurationException, SAXException, IOException { TemplateHandler handler = new TemplateHandler(); SAXParserFactory spfac = SAXParserFactory.newInstance(); SAXParser sp = spfac.newSAXParser(); sp.parse(sourceInputStream, handler); return TemplateHandler.from(handler,(short)0); }
public static void postProcessDictionary(TemplateHandler handler, int byteGap, int maxByteLength) { handler.buildDictionaryMemberLists(); // the catalog file need not be "Small" but it probably will be. // the catalog file must be "Fast" to load without any "Processing" // needed by the consumer. // this enables fast startup/recovery times that do not produce garbage. handler.defaultConstValues.setTypeCounts( handler.tokenBuilderIntCount.intValue(), handler.tokenBuilderLongCount.intValue(), handler.tokenBuilderByteCount.intValue(), byteGap, maxByteLength); }
public static FieldReferenceOffsetManager loadFrom(String source, short preamble) throws ParserConfigurationException, SAXException, IOException { InputStream sourceInputStream = TemplateHandler.class.getResourceAsStream(source); File folder = null; if (null == sourceInputStream) { folder = new File(source); if (folder.exists() && !folder.isDirectory()) { sourceInputStream = new FileInputStream(source); } } TemplateHandler handler = new TemplateHandler(); SAXParserFactory spfac = SAXParserFactory.newInstance(); SAXParser sp = spfac.newSAXParser(); if (null != sourceInputStream) { sp.parse(sourceInputStream, handler); } else { if (null == folder || null == folder.listFiles()) { throw new FileNotFoundException(source); } for (File f : folder.listFiles()) { if (f.isFile()) { sp.parse(f, handler); } } } return TemplateHandler.from(handler, preamble, simpleName(source)); }
String dictionaryName = setActiveDictionary(attributes); catalogScriptDictionaryNames[catalogTemplateScriptIdx] = dictionaryName; setActiveDictionary(attributes); templatesXMLns = attributes.getValue("xmlns"); commonIdAttributes(attributes); } else if (qName.equalsIgnoreCase("int32")) { fieldType = "optional".equals(attributes.getValue("presence")) ? TypeMask.IntegerSignedOptional : TypeMask.IntegerSigned; commonIdAttributes(attributes); } else if (qName.equalsIgnoreCase("uint64")) { fieldType = "optional".equals(attributes.getValue("presence")) ? TypeMask.LongUnsignedOptional : TypeMask.LongUnsigned; commonIdAttributes(attributes); } else if (qName.equalsIgnoreCase("int64")) { fieldType = "optional".equals(attributes.getValue("presence")) ? TypeMask.LongSignedOptional : TypeMask.LongSigned; commonIdAttributes(attributes); } else if (qName.equalsIgnoreCase("length")) { commonIdAttributes(attributes); } else if (qName.equalsIgnoreCase("string")) { if ("unicode".equals(attributes.getValue("charset"))) { commonIdAttributes(attributes); } else if (qName.equalsIgnoreCase("decimal")) { fieldPMapInc = 2; // any operators must count as two PMap fields. fieldType = "optional".equals(attributes.getValue("presence")) ? TypeMask.DecimalOptional : TypeMask.Decimal; commonIdAttributes(attributes); fieldOperator = OperatorMask.Field_None;
int token = buildToken(tokenBuilderIntCount); int token = buildToken(tokenBuilderLongCount); int token = buildToken(tokenBuilderByteCount); int idx = token & TokenBuilder.MAX_INSTANCE; int tokenExponent = buildToken(tokenBuilderIntCount); int tokenMantisssa = buildToken(tokenBuilderLongCount); } else if (qName.equalsIgnoreCase("bytevector")) { int token = buildToken(tokenBuilderByteCount); int token = buildToken(tokenBuilderIntCount); basicGroupClose(opMask); basicGroupClose(opMask);
public void play(TemplateHandler handler) throws SAXException { handler.endElement(uri,localName, qName); } }
public static FieldReferenceOffsetManager from(TemplateHandler handler, short preambleBytes) { return from(handler, preambleBytes,"Catalog"); }
private void buildDictionaryMemberLists() { // walk the lists of dictionary members and join them into a master list // for each dictionary. // each section must start with stop bit and type for the following // identifiers. All cache friendly forward motion. int dictionaryCount = dictionaryNames.size(); tokenIdxMembers = new int[dictionaryCount][]; tokenIdxMemberHeads = new int[dictionaryCount]; int j = resetList.size(); while (--j >= 0) { if (!resetList.get(j).isEmpty()) { final int d = j >>> TokenBuilder.BITS_TYPE; //only allocate exactly what is needed, when it is needed for the type needed if (null == tokenIdxMembers[d]) { tokenIdxMembers[d] = new int[lengthOfArrayForThisType(d)]; } int t = j & TokenBuilder.MASK_TYPE; int stopInt = 0xFFFF0000 | t; tokenIdxMembers[d][tokenIdxMemberHeads[d]++] = stopInt; // System.err.println("stopInt:"+stopInt+" "+Integer.toBinaryString(stopInt)+" "+TypeMask.toString(t)); for (Integer i : resetList.get(j)) { tokenIdxMembers[d][tokenIdxMemberHeads[d]++] = i.intValue(); } } } // tokenIdxMembers are ready to be saved but must be trimmed by heads }
public static FieldReferenceOffsetManager loadFrom(String source, short preamble) throws ParserConfigurationException, SAXException, IOException { InputStream sourceInputStream = TemplateHandler.class.getResourceAsStream(source); File folder = null; if (null == sourceInputStream) { folder = new File(source); if (folder.exists() && !folder.isDirectory()) { sourceInputStream = new FileInputStream(source); } } TemplateHandler handler = new TemplateHandler(); SAXParserFactory spfac = SAXParserFactory.newInstance(); SAXParser sp = spfac.newSAXParser(); if (null != sourceInputStream) { sp.parse(sourceInputStream, handler); } else { if (null == folder || null == folder.listFiles()) { throw new FileNotFoundException(source); } for (File f : folder.listFiles()) { if (f.isFile()) { sp.parse(f, handler); } } } return TemplateHandler.from(handler, preamble, simpleName(source)); }
String dictionaryName = setActiveDictionary(attributes); catalogScriptDictionaryNames[catalogTemplateScriptIdx] = dictionaryName; setActiveDictionary(attributes); templatesXMLns = attributes.getValue("xmlns"); commonIdAttributes(attributes); } else if (qName.equalsIgnoreCase("int32")) { fieldType = "optional".equals(attributes.getValue("presence")) ? TypeMask.IntegerSignedOptional : TypeMask.IntegerSigned; commonIdAttributes(attributes); } else if (qName.equalsIgnoreCase("uint64")) { fieldType = "optional".equals(attributes.getValue("presence")) ? TypeMask.LongUnsignedOptional : TypeMask.LongUnsigned; commonIdAttributes(attributes); } else if (qName.equalsIgnoreCase("int64")) { fieldType = "optional".equals(attributes.getValue("presence")) ? TypeMask.LongSignedOptional : TypeMask.LongSigned; commonIdAttributes(attributes); } else if (qName.equalsIgnoreCase("length")) { commonIdAttributes(attributes); } else if (qName.equalsIgnoreCase("string")) { if ("unicode".equals(attributes.getValue("charset"))) { commonIdAttributes(attributes); } else if (qName.equalsIgnoreCase("decimal")) { fieldPMapInc = 2; // any operators must count as two PMap fields. fieldType = "optional".equals(attributes.getValue("presence")) ? TypeMask.DecimalOptional : TypeMask.Decimal; commonIdAttributes(attributes); fieldOperator = OperatorMask.Field_None;
int token = buildToken(tokenBuilderIntCount); int token = buildToken(tokenBuilderLongCount); int token = buildToken(tokenBuilderByteCount); int idx = token & TokenBuilder.MAX_INSTANCE; int tokenExponent = buildToken(tokenBuilderIntCount); int tokenMantisssa = buildToken(tokenBuilderLongCount); } else if (qName.equalsIgnoreCase("bytevector")) { int token = buildToken(tokenBuilderByteCount); int token = buildToken(tokenBuilderIntCount); basicGroupClose(opMask); basicGroupClose(opMask);
public void play(TemplateHandler handler) throws SAXException { handler.endElement(uri,localName, qName); } }
public static FieldReferenceOffsetManager from(TemplateHandler handler, short preambleBytes) { return from(handler, preambleBytes,"Catalog"); }
private void buildDictionaryMemberLists() { // walk the lists of dictionary members and join them into a master list // for each dictionary. // each section must start with stop bit and type for the following // identifiers. All cache friendly forward motion. int dictionaryCount = dictionaryNames.size(); tokenIdxMembers = new int[dictionaryCount][]; tokenIdxMemberHeads = new int[dictionaryCount]; int j = resetList.size(); while (--j >= 0) { if (!resetList.get(j).isEmpty()) { final int d = j >>> TokenBuilder.BITS_TYPE; //only allocate exactly what is needed, when it is needed for the type needed if (null == tokenIdxMembers[d]) { tokenIdxMembers[d] = new int[lengthOfArrayForThisType(d)]; } int t = j & TokenBuilder.MASK_TYPE; int stopInt = 0xFFFF0000 | t; tokenIdxMembers[d][tokenIdxMemberHeads[d]++] = stopInt; // System.err.println("stopInt:"+stopInt+" "+Integer.toBinaryString(stopInt)+" "+TypeMask.toString(t)); for (Integer i : resetList.get(j)) { tokenIdxMembers[d][tokenIdxMemberHeads[d]++] = i.intValue(); } } } // tokenIdxMembers are ready to be saved but must be trimmed by heads }
public static FieldReferenceOffsetManager loadFrom(String source) throws ParserConfigurationException, SAXException, IOException { return loadFrom(source,(short)0); }
public static FieldReferenceOffsetManager loadFrom(String source, short preamble) throws ParserConfigurationException, SAXException, IOException { InputStream sourceInputStream = TemplateHandler.class.getResourceAsStream(source); File folder = null; if (null == sourceInputStream) { folder = new File(source); if (folder.exists() && !folder.isDirectory()) { sourceInputStream = new FileInputStream(source); } } TemplateHandler handler = new TemplateHandler(); SAXParserFactory spfac = SAXParserFactory.newInstance(); SAXParser sp = spfac.newSAXParser(); if (null != sourceInputStream) { sp.parse(sourceInputStream, handler); } else { if (null == folder || null == folder.listFiles()) { throw new FileNotFoundException(source); } for (File f : folder.listFiles()) { if (f.isFile()) { sp.parse(f, handler); } } } return TemplateHandler.from(handler, preamble, simpleName(source)); }
String dictionaryName = setActiveDictionary(attributes); catalogScriptDictionaryNames[catalogTemplateScriptIdx] = dictionaryName; setActiveDictionary(attributes); templatesXMLns = attributes.getValue("xmlns"); commonIdAttributes(attributes); } else if (qName.equalsIgnoreCase("int32")) { fieldType = "optional".equals(attributes.getValue("presence")) ? TypeMask.IntegerSignedOptional : TypeMask.IntegerSigned; commonIdAttributes(attributes); } else if (qName.equalsIgnoreCase("uint64")) { fieldType = "optional".equals(attributes.getValue("presence")) ? TypeMask.LongUnsignedOptional : TypeMask.LongUnsigned; commonIdAttributes(attributes); } else if (qName.equalsIgnoreCase("int64")) { fieldType = "optional".equals(attributes.getValue("presence")) ? TypeMask.LongSignedOptional : TypeMask.LongSigned; commonIdAttributes(attributes); } else if (qName.equalsIgnoreCase("length")) { commonIdAttributes(attributes); } else if (qName.equalsIgnoreCase("string")) { if ("unicode".equals(attributes.getValue("charset"))) { commonIdAttributes(attributes); } else if (qName.equalsIgnoreCase("decimal")) { fieldPMapInc = 2; // any operators must count as two PMap fields. fieldType = "optional".equals(attributes.getValue("presence")) ? TypeMask.DecimalOptional : TypeMask.Decimal; commonIdAttributes(attributes); fieldOperator = OperatorMask.Field_None;
public static FieldReferenceOffsetManager loadFrom(InputStream sourceInputStream) throws ParserConfigurationException, SAXException, IOException { TemplateHandler handler = new TemplateHandler(); SAXParserFactory spfac = SAXParserFactory.newInstance(); SAXParser sp = spfac.newSAXParser(); sp.parse(sourceInputStream, handler); return TemplateHandler.from(handler,(short)0); }
int token = buildToken(tokenBuilderIntCount); int token = buildToken(tokenBuilderLongCount); int token = buildToken(tokenBuilderByteCount); int idx = token & TokenBuilder.MAX_INSTANCE; int tokenExponent = buildToken(tokenBuilderIntCount); int tokenMantisssa = buildToken(tokenBuilderLongCount); } else if (qName.equalsIgnoreCase("bytevector")) { int token = buildToken(tokenBuilderByteCount); int token = buildToken(tokenBuilderIntCount); basicGroupClose(opMask); basicGroupClose(opMask);