public long modifyStruct(int structId, byte[] fieldName, int fieldPos, int fieldLen, StructType fieldType, int fieldDim) { assert((IS_STRUCT_BIT&structId)!=0) : "must be valid struct"; int idx = STRUCT_MASK & structId; long fieldIdx = fieldIdLookup(this.fields[idx], fieldName, fieldPos, fieldLen, Integer.MAX_VALUE); if (-1 == fieldIdx) { //only creating copy here because we know it will be held for the run. fieldIdx = growStruct(structId, fieldType, fieldDim, Arrays.copyOfRange(fieldName,fieldPos,fieldLen)); } else { ////////// //modify an existing field, we have new data to apply ////////// //use the newest defined type this.fieldTypes[idx][ FIELD_MASK&(int)fieldIdx] = fieldType; //keep largest dim value this.fieldDims[idx][ FIELD_MASK&(int)fieldIdx] = Math.max(this.fieldDims[idx][FIELD_MASK&(int)fieldIdx], fieldDim); } return fieldIdx; }
public long modifyStruct(int structId, byte[] fieldName, int fieldPos, int fieldLen, StructType fieldType, int fieldDim) { assert((IS_STRUCT_BIT&structId)!=0) : "must be valid struct"; int idx = STRUCT_MASK & structId; long fieldIdx = fieldIdLookup(this.fields[idx], fieldName, fieldPos, fieldLen, Integer.MAX_VALUE); if (-1 == fieldIdx) { //only creating copy here because we know it will be held for the run. fieldIdx = growStruct(structId, fieldType, fieldDim, Arrays.copyOfRange(fieldName,fieldPos,fieldLen)); } else { ////////// //modify an existing field, we have new data to apply ////////// //use the newest defined type this.fieldTypes[idx][ FIELD_MASK&(int)fieldIdx] = fieldType; //keep largest dim value this.fieldDims[idx][ FIELD_MASK&(int)fieldIdx] = Math.max(this.fieldDims[idx][FIELD_MASK&(int)fieldIdx], fieldDim); } //System.out.println("modify struct "+fieldIdx+" "+Appendables.appendUTF8(new StringBuilder(), fieldName, fieldPos, fieldLen, Integer.MAX_VALUE)); return fieldIdx; }
public long modifyStruct(int structId, byte[] fieldName, int fieldPos, int fieldLen, StructType fieldType, int fieldDim) { assert((IS_STRUCT_BIT&structId)!=0) : "must be valid struct"; int idx = STRUCT_MASK & structId; long fieldIdx = fieldIdLookup(this.fields[idx], fieldName, fieldPos, fieldLen, Integer.MAX_VALUE); if (-1 == fieldIdx) { //only creating copy here because we know it will be held for the run. fieldIdx = growStruct(structId, fieldType, fieldDim, Arrays.copyOfRange(fieldName,fieldPos,fieldLen)); } else { ////////// //modify an existing field, we have new data to apply ////////// //use the newest defined type this.fieldTypes[idx][ FIELD_MASK&(int)fieldIdx] = fieldType; //keep largest dim value this.fieldDims[idx][ FIELD_MASK&(int)fieldIdx] = Math.max(this.fieldDims[idx][FIELD_MASK&(int)fieldIdx], fieldDim); } //System.out.println("modify struct "+fieldIdx+" "+Appendables.appendUTF8(new StringBuilder(), fieldName, fieldPos, fieldLen, Integer.MAX_VALUE)); return fieldIdx; }
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]); } }
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; }
unmappedPathField = conStruct.registry.growStruct(structId,StructType.Text,0,"path".getBytes()); conStruct.registry.setAssociatedObject(unmappedPathField, "path");