public HollowObjectTypeDataElements(HollowObjectSchema schema, ArraySegmentRecycler memoryRecycler) { varLengthData = new SegmentedByteArray[schema.numFields()]; bitsPerField = new int[schema.numFields()]; bitOffsetPerField = new int[schema.numFields()]; nullValueForField = new long[schema.numFields()]; this.schema = schema; this.memoryRecycler = memoryRecycler; }
public HollowObjectWriteRecord(HollowObjectSchema schema) { this.schema = schema; this.fieldData = new ByteDataBuffer[schema.numFields()]; this.isNonNull = new boolean[schema.numFields()]; for (int i = 0; i < fieldData.length; i++) { fieldData[i] = new ByteDataBuffer(WastefulRecycler.SMALL_ARRAY_RECYCLER); } }
public HollowObjectSampler(HollowObjectSchema schema, HollowSamplingDirector director) { this.typeName = schema.getName(); this.sampleCounts = new long[schema.numFields()]; HollowSamplingDirector[] samplingDirectors = new HollowSamplingDirector[schema.numFields()]; Arrays.fill(samplingDirectors, director); String fieldNames[] = new String[schema.numFields()]; for(int i=0;i<fieldNames.length;i++) { fieldNames[i] = schema.getFieldName(i); } this.fieldNames = fieldNames; this.samplingDirectors = samplingDirectors; }
private int getIndexFromFieldName(String fieldName) { for (int i = 0; i < schema.numFields(); i++) { if (getFieldName(i).equals(fieldName)) { return i; } } return -1; } }
private static boolean referencesGenericStringSchema(HollowSchema schema) { if(schema instanceof HollowObjectSchema) { HollowObjectSchema objSchema = (HollowObjectSchema)schema; for(int i=0;i<objSchema.numFields();i++) { if("String".equals(objSchema.getReferencedType(i))) { return true; } } } return false; }
private int[] createFieldMapping(HollowObjectSchema unionSchema, HollowObjectSchema individualSchema) { int mapping[] = new int[unionSchema.numFields()]; for(int i=0;i<unionSchema.numFields();i++) { String fieldName = unionSchema.getFieldName(i); mapping[i] = individualSchema.getPosition(fieldName); } return mapping; }
private void generateChainableSetters(StringBuilder classBodyBuilder) { for (int i = 0; i < schema.numFields(); i++) { classBodyBuilder.append(" public ").append(getClassName()).append(" set") .append(uppercase(getFieldName(i))).append("(") .append(fieldType(i)).append(" ").append(getFieldName(i)).append(") {\n"); classBodyBuilder.append(" this.").append(getFieldName(i)).append(" = ") .append(getFieldName(i)).append(";\n"); classBodyBuilder.append(" return this;\n"); classBodyBuilder.append(" }\n"); } }
private int[] buildCommonSchemaFieldMapping(HollowObjectTypeReadState state) { int[] commonFieldMapping = new int[commonSchema.numFields()]; for(int i=0;i<commonFieldMapping.length;i++) { String fieldName = commonSchema.getFieldName(i); commonFieldMapping[i] = state.getSchema().getPosition(fieldName); } return commonFieldMapping; }
private long writeBitsPerField(HollowObjectSchema unfilteredSchema, int bitsPerField[], HollowObjectSchema filteredSchema, DataOutputStream os) throws IOException { long bitsPerRecord = 0; for(int i=0;i<unfilteredSchema.numFields();i++) { if(filteredSchema.getPosition(unfilteredSchema.getFieldName(i)) != -1) { VarInt.writeVInt(os, bitsPerField[i]); bitsPerRecord += bitsPerField[i]; } } return bitsPerRecord; }
private void addRecord(int ordinal, long recordBitOffset, FixedLengthElementArray fixedLengthLongArray, ByteDataBuffer varLengthByteArrays[]) { long pointer = ordinalMap.getPointerForData(ordinal); for(int fieldIndex=0; fieldIndex < getSchema().numFields(); fieldIndex++) { pointer = addRecordField(pointer, recordBitOffset, fieldIndex, fixedLengthLongArray, varLengthByteArrays); } }
private void discoverObjectFieldStatisticsForRecord(FieldStatistics fieldStats, int ordinal) { if(currentCyclePopulated.get(ordinal) || previousCyclePopulated.get(ordinal)) { long pointer = ordinalMap.getPointerForData(ordinal); for(int fieldIndex=0; fieldIndex<((HollowObjectSchema)schema).numFields(); fieldIndex++) { pointer = discoverObjectFieldStatisticsForField(fieldStats, pointer, fieldIndex); } } }
public HollowObjectDeltaHistoricalStateCreator(HollowObjectTypeReadState typeState) { this.typeState = typeState; this.stateEngineDataElements = typeState.currentDataElements(); this.historicalDataElements = new HollowObjectTypeDataElements(typeState.getSchema(), WastefulRecycler.DEFAULT_INSTANCE); this.iter = new RemovedOrdinalIterator(typeState.getListener(PopulatedOrdinalListener.class)); this.currentWriteVarLengthDataPointers = new long[typeState.getSchema().numFields()]; this.shardNumberMask = stateEngineDataElements.length - 1; this.shardOrdinalShift = 31 - Integer.numberOfLeadingZeros(stateEngineDataElements.length); }
public void writeDataTo(ByteDataBuffer buf, HollowObjectSchema translate) { for(int i=0; i < translate.numFields(); i++) { int fieldIndex = schema.getPosition(translate.getFieldName(i)); if(fieldIndex != -1) { writeField(buf, fieldIndex); } else { writeNull(buf, translate.getFieldType(i)); } } }
private void traverseObject(HollowObjectTypeReadState typeState, int ordinal) { HollowObjectSchema schema = typeState.getSchema(); for(int i=0;i<schema.numFields();i++) { if(schema.getFieldType(i) == FieldType.REFERENCE) { HollowTypeReadState refTypeState = schema.getReferencedTypeState(i); int refOrdinal = typeState.readOrdinal(ordinal, i); extractHollowRecord(refTypeState, refOrdinal); } } }
public HollowObjectCopier(HollowObjectTypeReadState readTypeState, HollowObjectSchema destinationSchema, OrdinalRemapper ordinalRemapper) { super(readTypeState, new HollowObjectWriteRecord(destinationSchema), ordinalRemapper, false); fieldIndexMapping = new int[destinationSchema.numFields()]; for(int i=0;i<fieldIndexMapping.length;i++) { String fieldName = destinationSchema.getFieldName(i); fieldIndexMapping[i] = readState().getSchema().getPosition(fieldName); } }
private void mapAllPaths(HollowObjectSchema schema) { for(int i=0;i<schema.numFields();i++) { if(!mappedFieldPaths.containsKey(schema.getFieldName(i))) { HollowObjectWriteRecord rec = getWriteRecord(schema); mappedFieldPaths.put(schema.getFieldName(i), new ObjectMappedFieldPath(rec, schema.getFieldName(i), schema.getName(), schema.getFieldName(i), i, populator.getFieldProcessor(schema.getName(), schema.getFieldName(i)))); } } }
private boolean isSearchable(HollowObjectSchema schema, int fieldNumber) { if(schema.getFieldType(fieldNumber) == FieldType.REFERENCE) { if(schema.getReferencedTypeState(fieldNumber).getSchema().getSchemaType() != SchemaType.OBJECT) return false; HollowObjectSchema refObjSchema = (HollowObjectSchema)schema.getReferencedTypeState(fieldNumber).getSchema(); if(refObjSchema.numFields() != 1) return false; return isSearchable(refObjSchema, 0); } return true; }
private void addNullRecord(int ordinal, long recordBitOffset, FixedLengthElementArray fixedLengthLongArray, ByteDataBuffer varLengthByteArrays[]) { for(int fieldIndex=0; fieldIndex < getSchema().numFields(); fieldIndex++) { if(getSchema().getFieldType(fieldIndex) == FieldType.STRING || getSchema().getFieldType(fieldIndex) == FieldType.BYTES) { long fieldBitOffset = recordBitOffset + fieldStats.getFieldBitOffset(fieldIndex); int bitsPerElement = fieldStats.getMaxBitsForField(fieldIndex); long currentPointer = varLengthByteArrays[fieldIndex] == null ? 0 : varLengthByteArrays[fieldIndex].length(); fixedLengthLongArray.setElementValue(fieldBitOffset, bitsPerElement, currentPointer); } } }
@Test public void filterSchema() { HollowObjectSchema s1 = new HollowObjectSchema("Test", 2, "F2"); s1.addField("F1", FieldType.INT); s1.addField("F2", FieldType.LONG); Assert.assertEquals(2, s1.numFields()); HollowFilterConfig filter = new HollowFilterConfig(); filter.addField("Test", "F2"); HollowObjectSchema s2 = s1.filterSchema(filter); Assert.assertEquals(1, s2.numFields()); Assert.assertEquals("F2", s2.getFieldName(0)); Assert.assertEquals(s1.getPrimaryKey(), s2.getPrimaryKey()); }