public void setRawMetadata(final int index, final char[] src, final int offset, final int length) throws IOException { if (length == 0) { if (!NonTaggedFormatUtil.isOptional(metaTypes[index])) { throw new RuntimeDataException(ErrorCode.INPUT_RECORD_RECORD_WITH_METADATA_AND_PK_NULL_IN_NON_OPTIONAL, index); } fieldValueBufferOutputs[index].writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG); } else { fieldValueBufferOutputs[index].writeByte(fieldTypeTags[index]); valueParsers[index].parse(src, offset, length, fieldValueBufferOutputs[index]); } }
public int getItemLength(int itemOffset) throws HyracksDataException { ATypeTag itemType = getItemType(itemOffset); return NonTaggedFormatUtil.getFieldValueLength(listBytes, itemOffset, itemType, itemsAreSelfDescribing()); }
throw new AsterixException("Could not find field " + secondaryKeyFields.get(0) + " in the schema."); IAType nestedKeyType = NonTaggedFormatUtil.getNestedSpatialType(spatialType.getTypeTag()); int numDimensions = NonTaggedFormatUtil.getNumDimensions(spatialType.getTypeTag()); int numNestedSecondaryKeyFields = numDimensions * 2; IBinaryComparatorFactory[] secondaryComparatorFactories =
public static int getItemOffset(byte[] serOrderedList, int offset, int itemIndex) throws HyracksDataException { if (serOrderedList[offset] == ATypeTag.ARRAY.serialize()) { ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serOrderedList[offset + 1]); if (NonTaggedFormatUtil.isFixedSizedCollection(typeTag)) { int length = NonTaggedFormatUtil.getFieldValueLength(serOrderedList, offset + 1, typeTag, true); return offset + 10 + (length * itemIndex); } else { return offset + AInt32SerializerDeserializer.getInt(serOrderedList, offset + 10 + (4 * itemIndex)); } // 10 = tag (1) + itemTag (1) + list size (4) + number of items (4) } else { return -1; } }
varTypes.add(NonTaggedFormatUtil.getTokenType(secondaryKeyType)); boolean isPointMBR = spatialType.getTypeTag() == ATypeTag.POINT || spatialType.getTypeTag() == ATypeTag.POINT3D; int dimension = NonTaggedFormatUtil.getNumDimensions(spatialType.getTypeTag()); int numKeys = (isPointMBR && isBulkload) ? dimension : dimension * 2;
tokenComparatorFactories = new IBinaryComparatorFactory[numTokenFields]; tokenTypeTraits = new ITypeTraits[numTokenFields]; tokenComparatorFactories[0] = NonTaggedFormatUtil.getTokenBinaryComparatorFactory(secondaryKeyType); tokenTypeTraits[0] = NonTaggedFormatUtil.getTokenTypeTrait(secondaryKeyType); if (isPartitioned) { tokenizerFactory = NonTaggedFormatUtil.getBinaryTokenizerFactory(secondaryKeyType.getTypeTag(), indexType, index.getGramLength()); tokenKeyPairFields[0] = serdeProvider.getSerializerDeserializer(secondaryKeyType); tokenKeyPairTypeTraits[0] = tokenTypeTraits[0]; tokenKeyPairComparatorFactories[0] = NonTaggedFormatUtil.getTokenBinaryComparatorFactory(secondaryKeyType); int pkOff = 1; if (isPartitioned) {
chooseSource(keySourceIndicators, 0, recordType, metaRecordType)); IAType keyType = keyPairType.first; return NonTaggedFormatUtil.getNumDimensions(keyType.getTypeTag()) * 2; default: throw new CompilationException(ErrorCode.COMPILATION_UNKNOWN_INDEX_TYPE, index.getIndexType());
boolean hasOptionalFields = NonTaggedFormatUtil.hasOptionalField(inputRecType); if (hasOptionalFields) { nullBitMapOffset = s; fieldType = ((AUnionType) fieldTypes[fieldNumber]).getActualType(); typeTag = fieldType.getTypeTag(); fieldValueLength = NonTaggedFormatUtil.getFieldValueLength(b, fieldOffsets[fieldNumber], typeTag, false); typeTag = fieldTypes[fieldNumber].getTypeTag(); fieldValueLength = NonTaggedFormatUtil.getFieldValueLength(b, fieldOffsets[fieldNumber], typeTag, false); NonTaggedFormatUtil.getFieldValueLength(b, fieldOffset, ATypeTag.STRING, false); int fnstart = dataBos.size(); dataDos.writeByte(ATypeTag.SERIALIZED_STRING_TYPE_TAG); fieldValueLength = NonTaggedFormatUtil.getFieldValueLength(b, fieldOffset, typeTag, true) + 1;
public static IBinaryComparatorFactory getTokenBinaryComparatorFactory(IAType keyType) throws AlgebricksException { IAType type = getTokenType(keyType); // Ignore case for string types. return BinaryComparatorFactoryProvider.INSTANCE.getBinaryComparatorFactory(type, true, true); }
tokenTypeTraits[0] = NonTaggedFormatUtil.getTokenTypeTrait(secondaryKeyType); if (isPartitioned) { IBinaryTokenizerFactory tokenizerFactory = NonTaggedFormatUtil.getBinaryTokenizerFactory( secondaryKeyType.getTypeTag(), indexType, secondaryIndex.getGramLength());
/** * Get the types of RTree index key fields * * @param index, * the index to consider. * @param recordType, * the main record type. * @param metaRecordType * the auxiliary meta record type. * @return a list of IATypes, one for each corresponding index key field. * @throws AlgebricksException */ public static List<IAType> getRTreeIndexKeyTypes(Index index, ARecordType recordType, ARecordType metaRecordType) throws AlgebricksException { List<Integer> keySourceIndicators = index.getKeyFieldSourceIndicators(); List<IAType> indexKeyTypes = new ArrayList<>(); ARecordType targetRecType = chooseSource(keySourceIndicators, 0, recordType, metaRecordType); Pair<IAType, Boolean> keyPairType = Index.getNonNullableOpenFieldType(index.getKeyFieldTypes().get(0), index.getKeyFieldNames().get(0), targetRecType); IAType keyType = keyPairType.first; IAType nestedKeyType = NonTaggedFormatUtil.getNestedSpatialType(keyType.getTypeTag()); int numKeys = KeyFieldTypeUtil.getNumSecondaryKeys(index, targetRecType, metaRecordType); for (int i = 0; i < numKeys; i++) { indexKeyTypes.add(nestedKeyType); } return indexKeyTypes; }
return NonTaggedFormatUtil.getBinaryTokenizerFactory(secondaryKeyType.getTypeTag(), indexType, index.getGramLength());
public static int getItemOffset(byte[] serOrderedList, int offset, int itemIndex) throws HyracksDataException { if (serOrderedList[offset] == ATypeTag.MULTISET.serialize()) { ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serOrderedList[offset + 1]); if (NonTaggedFormatUtil.isFixedSizedCollection(typeTag)) { int length = NonTaggedFormatUtil.getFieldValueLength(serOrderedList, offset + 1, typeTag, true); return offset + 10 + (length * itemIndex); } else { return offset + AInt32SerializerDeserializer.getInt(serOrderedList, offset + 10 + (4 * itemIndex)); } // 10 = tag (1) + itemTag (1) + list size (4) + number of items (4) } else { return -1; } } }
tokenComparatorFactories = new IBinaryComparatorFactory[numTokenFields]; tokenTypeTraits = new ITypeTraits[numTokenFields]; tokenComparatorFactories[0] = NonTaggedFormatUtil.getTokenBinaryComparatorFactory(secondaryKeyType); tokenTypeTraits[0] = NonTaggedFormatUtil.getTokenTypeTrait(secondaryKeyType); if (isPartitioned) { tokenizerFactory = NonTaggedFormatUtil.getBinaryTokenizerFactory(secondaryKeyType.getTypeTag(), indexType, index.getGramLength()); tokenKeyPairFields[0] = serdeProvider.getSerializerDeserializer(secondaryKeyType); tokenKeyPairTypeTraits[0] = tokenTypeTraits[0]; tokenKeyPairComparatorFactories[0] = NonTaggedFormatUtil.getTokenBinaryComparatorFactory(secondaryKeyType); int pkOff = 1; if (isPartitioned) {
Index.getNonNullableOpenFieldType(secondaryKeyTypes.get(0), secondaryKeyExprs.get(0), recType); IAType spatialType = keyPairType.first; int dimension = NonTaggedFormatUtil.getNumDimensions(spatialType.getTypeTag()); int numSecondaryKeys = dimension * 2; int numPrimaryKeys = primaryKeys.size();
public static ITypeTraits getTokenTypeTrait(IAType keyType) throws AlgebricksException { IAType type = getTokenType(keyType); return TypeTraitProvider.INSTANCE.getTypeTrait(type); } }
public static Pair<IAType, Boolean> getNonNullableType(IAType keyType) { boolean nullable = false; IAType actualKeyType = keyType; if (NonTaggedFormatUtil.isOptional(keyType)) { actualKeyType = ((AUnionType) keyType).getActualType(); nullable = true; } return new Pair<>(actualKeyType, nullable); }
public int getFixedLength(AbstractCollectionType inputType) throws HyracksDataException { return NonTaggedFormatUtil.getFieldValueLength(bytes, 0, inputType.getItemType().getTypeTag(), false); }
throw new AsterixException("Could not find field " + secondaryKeyFields.get(0) + " in the schema."); int numDimensions = NonTaggedFormatUtil.getNumDimensions(spatialType.getTypeTag()); int numNestedSecondaryKeyFields = numDimensions * 2; ITypeTraits[] secondaryTypeTraits = new ITypeTraits[numNestedSecondaryKeyFields + numPrimaryKeys]; IAType nestedKeyType = NonTaggedFormatUtil.getNestedSpatialType(spatialType.getTypeTag()); for (int i = 0; i < numNestedSecondaryKeyFields; i++) { secondaryTypeTraits[i] = ttProvider.getTypeTrait(nestedKeyType);
int itemOffset; if (typedItemList && NonTaggedFormatUtil.isFixedSizedCollection(itemTag)) { itemOffset = s + 10; } else { if (typedItemList) { for (int i = 0; i < numberOfitems; i++) { itemLength = NonTaggedFormatUtil.getFieldValueLength(b, itemOffset, itemTag, false); IVisitablePointable tag = allocator.allocateEmpty(); IVisitablePointable item = allocator.allocateFieldValue(itemType); for (int i = 0; i < numberOfitems; i++) { itemTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(b[itemOffset]); itemLength = NonTaggedFormatUtil.getFieldValueLength(b, itemOffset, itemTag, true) + 1; IVisitablePointable tag = allocator.allocateEmpty(); IVisitablePointable item = allocator.allocateFieldValue(itemTag, b, itemOffset + 1);