public void headersToEcho(int maxSingleHeaderSize, HTTPHeader ... headers) { if (0==minInternalInFlightPayloadSize) { minInternalInFlightPayloadSize += 4;//room to open and add index } minInternalInFlightPayloadSize += (headers.length*maxSingleHeaderSize); headersToEcho = headers; for(int h = 0; h<headers.length; h++) { long id = registry.growStruct(connectionStructId, StructType.Blob, 0, headers[h].rootBytes()); registry.setAssociatedObject(id, headers[h]); } }
@Override public CompositeRouteFinish associatedObject(String key, Object object) { long fieldLookup = scs.registry.fieldLookup(key, structId); assert(-1 != fieldLookup) : "Unable to find associated key "+key; scs.registry.setAssociatedObject(fieldLookup, object); assert(fieldLookup == scs.registry.fieldLookupByIdentity(object, structId)); return this; }
@Override public CompositeRouteFinish refineInteger(String key, Object associatedObject, LongValidator validator) { long fieldLookup = scs.registry.fieldLookup(key, structId); if (-1 == fieldLookup) { throw new UnsupportedOperationException("The field "+key+" was not found defined above"); } scs.registry.setAssociatedObject(fieldLookup, associatedObject); assert(fieldLookup == scs.registry.fieldLookupByIdentity(associatedObject, structId)); scs.registry.setValidator(fieldLookup, JSONRequired.REQUIRED, validator); return this; }
@Override public CompositeRouteFinish refineText(String key, Object associatedObject, ByteSequenceValidator validator) { long fieldLookup = scs.registry.fieldLookup(key, structId); if (-1 == fieldLookup) { throw new UnsupportedOperationException("The field "+key+" was not found defined above"); } scs.registry.setAssociatedObject(fieldLookup, associatedObject); assert(fieldLookup == scs.registry.fieldLookupByIdentity(associatedObject, structId)); scs.registry.setValidator(fieldLookup, JSONRequired.REQUIRED, validator); return this; }
@Override public CompositeRouteFinish refineDecimal(String key, Object associatedObject, DecimalValidator validator) { long fieldLookup = scs.registry.fieldLookup(key, structId); if (-1 == fieldLookup) { throw new UnsupportedOperationException("The field "+key+" was not found defined above"); } scs.registry.setAssociatedObject(fieldLookup, associatedObject); assert(fieldLookup == scs.registry.fieldLookupByIdentity(associatedObject, structId)); scs.registry.setValidator(fieldLookup, JSONRequired.REQUIRED, validator); return this; }
@Override public CompositeRouteFinish refineInteger(String key, Object associatedObject, long defaultValue, LongValidator validator) { long fieldLookup = scs.registry.fieldLookup(key, structId); if (-1 == fieldLookup) { throw new UnsupportedOperationException("The field "+key+" was not found defined above"); } scs.registry.setAssociatedObject(fieldLookup, associatedObject); assert(fieldLookup == scs.registry.fieldLookupByIdentity(associatedObject, structId)); scs.registry.setValidator(fieldLookup, JSONRequired.REQUIRED, validator); defaultInteger(key, defaultValue); return this; }
@Override public CompositeRouteFinish refineText(String key, Object associatedObject, String defaultValue, ByteSequenceValidator validator) { long fieldLookup = scs.registry.fieldLookup(key, structId); if (-1 == fieldLookup) { throw new UnsupportedOperationException("The field "+key+" was not found defined above"); } scs.registry.setAssociatedObject(fieldLookup, associatedObject); assert(fieldLookup == scs.registry.fieldLookupByIdentity(associatedObject, structId)); scs.registry.setValidator(fieldLookup, JSONRequired.REQUIRED, validator); defaultText(key, defaultValue); return this; }
@Override public CompositeRouteFinish refineDecimal(String key, Object associatedObject, long defaultMantissa, byte defaultExponent, DecimalValidator validator) { long fieldLookup = scs.registry.fieldLookup(key, structId); if (-1 == fieldLookup) { throw new UnsupportedOperationException("The field "+key+" was not found defined above"); } scs.registry.setAssociatedObject(fieldLookup, associatedObject); assert(fieldLookup == scs.registry.fieldLookupByIdentity(associatedObject, structId)); scs.registry.setValidator(fieldLookup, JSONRequired.REQUIRED, validator); defaultDecimal(key, defaultMantissa, defaultExponent);//NOTE: we must always set the default AFTER the validator return this; }
public int[] addToStruct(StructRegistry struct, int structId) { int length = mappings.length; int[] jsonIndexLookup = new int[length]; int i = length; while (--i>=0) { JSONFieldMapping mapping = mappings[i]; long fieldId = struct.growStruct(structId, mapTypes(mapping), mapping.dimensions(), mapping.getName().getBytes()); jsonIndexLookup[i] = StructRegistry.FIELD_MASK&(int)fieldId; Object assoc = mapping.getAssociatedObject(); if (null!=assoc) { if (!struct.setAssociatedObject(fieldId, assoc)) { throw new UnsupportedOperationException("An object with the same identity hash is already held, can not add "+assoc); } } } return jsonIndexLookup; }
public static void addHeader(StructRegistry schema, int structId, TrieParser headerParser, HTTPHeader header) { long fieldId = schema.growStruct(structId, StructType.Blob, //TODO: need a way to define dimensions on headers 0, //NOTE: associated object will be used to interpret header.rootBytes()); if (!schema.setAssociatedObject(fieldId, header)) { throw new UnsupportedOperationException("A header with the same identity hash is already held, can not add "+header); } assert(schema.getAssociatedObject(fieldId) == header) : "unable to get associated object"; assert(fieldId == schema.fieldLookupByIdentity(header, structId)); CharSequence template = header.readingTemplate(); addHeader(headerParser, fieldId, template); }
public int[] addToStruct(StructRegistry struct, int structId) { int length = mappings.length; int[] jsonIndexLookup = new int[length]; int i = length; assert(i>0) : "Must not add an empty extraction"; while (--i>=0) { JSONFieldMapping mapping = mappings[i]; long fieldId = struct.growStruct(structId, mapTypes(mapping), mapping.dimensions(), mapping.getName().getBytes()); jsonIndexLookup[i] = StructRegistry.FIELD_MASK&(int)fieldId; Object assoc = mapping.getAssociatedObject(); if (null!=assoc) { if (!struct.setAssociatedObject(fieldId, assoc)) { throw new UnsupportedOperationException("An object with the same identity hash is already held, can not add "+assoc); } } struct.setValidator(fieldId, mapping.isRequired(), mapping.getValidator()); } return jsonIndexLookup; }
public int[] addToStruct(StructRegistry struct, int structId) { int length = mappings.length; int[] jsonIndexLookup = new int[length]; int i = length; assert(i>0) : "Must not add an empty extraction"; while (--i>=0) { JSONFieldMapping mapping = mappings[i]; long fieldId = struct.growStruct(structId, mapTypes(mapping), mapping.dimensions(), mapping.getName().getBytes()); jsonIndexLookup[i] = StructRegistry.FIELD_MASK&(int)fieldId; Object assoc = mapping.getAssociatedObject(); if (null!=assoc) { if (!struct.setAssociatedObject(fieldId, assoc)) { throw new UnsupportedOperationException("An object with the same identity hash is already held, can not add "+assoc); } } struct.setValidator(fieldId, mapping.isRequired(), mapping.getValidator()); } return jsonIndexLookup; }
conStruct.registry.setAssociatedObject(unmappedPathField, "path");