IntsReader(Directory dir, String id, int maxDoc, IOContext context, Type type) throws IOException { super(dir, id, CODEC_NAME, VERSION_CURRENT, maxDoc, context, type); arrayTemplate = DocValuesArraySource.forType(type); assert arrayTemplate != null; assert type == sizeToType(size); }
@Override public Source load() throws IOException { final IndexInput indexInput = cloneData(); try { return arrayTemplate.newFromInput(indexInput, maxDoc); } finally { IOUtils.close(indexInput); } }
protected IntsWriter( Directory dir, String id, String codecName, int version, Counter bytesUsed, IOContext context, Type valueType) { super(dir, id, codecName, version, bytesUsed, context); size = typeToSize(valueType); this.bytesRef = new BytesRef(size); bytesRef.length = size; template = DocValuesArraySource.forType(valueType); }
@Override protected boolean tryBulkMerge(DocValues docValues) { // only bulk merge if value type is the same otherwise size differs return super.tryBulkMerge(docValues) && docValues.getType() == template.getType(); }
@Override public void add(int docID, IndexableField value) throws IOException { template.toBytes(value.numericValue().longValue(), bytesRef); bytesSpareField.setBytesValue(bytesRef); super.add(docID, bytesSpareField); }
@Override protected void setMergeBytes(Source source, int sourceDoc) { final long value = source.getInt(sourceDoc); template.toBytes(value, bytesRef); }