blob: 711c31ed66751f0c0810f65c90e66b5a2c74387f [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.asterix.om.lazy;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.AbstractCollectionType;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.utils.NonTaggedFormatUtil;
import org.apache.hyracks.api.exceptions.HyracksDataException;
/**
* This implementation is only for closed {@link ATypeTag#ARRAY} and {@link ATypeTag#MULTISET} with fixed-length
* items.
*/
public class FixedListLazyVisitablePointable extends AbstractListLazyVisitablePointable {
private final int itemSize;
public FixedListLazyVisitablePointable(boolean tagged, AbstractCollectionType listType) {
super(tagged, listType);
ATypeTag itemTag = listType.getItemType().getTypeTag();
currentChildTypeTag = itemTag.serialize();
try {
itemSize = NonTaggedFormatUtil.getFieldValueLength(null, -1, itemTag, false);
} catch (HyracksDataException e) {
throw new IllegalStateException(e);
}
}
@Override
public void nextChild() {
byte[] data = getByteArray();
int itemOffset = itemsOffset + currentIndex * itemSize;
currentValue.set(data, itemOffset, itemSize);
currentIndex++;
}
@Override
public boolean isTaggedChild() {
return false;
}
@Override
AbstractLazyVisitablePointable createVisitablePointable(IAType itemType) {
return createVisitable(itemType);
}
}