All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yahoo.text.Utf8PartialArray Maven / Gradle / Ivy

Go to download

Library for use in Java components of Vespa. Shared code which do not fit anywhere else.

There is a newer version: 8.441.21
Show newest version
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.text;

/**
 * This wraps a window in a backing byte array. Without doing any copying.
 *
 * @author baldersheim
 */
public class Utf8PartialArray extends Utf8Array {

    final int offset;
    final int length;

    /**
     * Takes ownership of the given byte array. And keeps note of where
     * the interesting utf8 sequence start and its length.
     * @param utf8data The backing byte array.
     * @param offset   The start of the utf8 sequence.
     * @param bytes    The length of the utf8 sequence.
     */
    public Utf8PartialArray(byte[] utf8data, int offset, int bytes) {
        super(utf8data);
        this.offset = offset;
        this.length = bytes;
    }
    @Override
    public int getByteLength() {
        return length;
    }

    @Override
    protected int getByteOffset() {
        return offset;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy