/** * Reads the schema and initializes the vectors. */ private void initialize() throws IOException { Schema originalSchema = readSchema(); List<Field> fields = new ArrayList<>(); List<FieldVector> vectors = new ArrayList<>(); Map<Long, Dictionary> dictionaries = new HashMap<>(); // Convert fields with dictionaries to have the index type for (Field field : originalSchema.getFields()) { Field updated = DictionaryUtility.toMemoryFormat(field, allocator, dictionaries); fields.add(updated); vectors.add(updated.createVector(allocator)); } Schema schema = new Schema(fields, originalSchema.getCustomMetadata()); this.root = new VectorSchemaRoot(schema, vectors, 0); this.loader = new VectorLoader(root); this.dictionaries = Collections.unmodifiableMap(dictionaries); // Read and load all dictionaries from schema for (int i = 0; i < dictionaries.size(); i++) { ArrowDictionaryBatch dictionaryBatch = readDictionary(); loadDictionary(dictionaryBatch); } }
public Schema start() throws JsonParseException, IOException { readToken(START_OBJECT); { Schema originalSchema = readNextField("schema", Schema.class); List<Field> fields = new ArrayList<>(); dictionaries = new HashMap<>(); // Convert fields with dictionaries to have the index type for (Field field : originalSchema.getFields()) { fields.add(DictionaryUtility.toMemoryFormat(field, allocator, dictionaries)); } this.schema = new Schema(fields, originalSchema.getCustomMetadata()); if (!dictionaries.isEmpty()) { nextFieldIs("dictionaries"); readDictionaryBatches(); } nextFieldIs("batches"); readToken(START_ARRAY); started = true; return this.schema; } }
updatedChildren.add(toMemoryFormat(child, allocator, dictionaries));