public void Validate(FixedSizeSchemaIndexDef actual) { if (actual == null) { throw new ArgumentNullException(nameof(actual), "Expected an index but received null"); } if (!SliceComparer.Equals(Name, actual.Name)) { throw new ArgumentException( $"Expected index to have Name='{Name}', got Name='{actual.Name}' instead", nameof(actual)); } if (StartIndex != actual.StartIndex) { throw new ArgumentException( $"Expected index {Name} to have StartIndex='{StartIndex}', got StartIndex='{actual.StartIndex}' instead", nameof(actual)); } if (IsGlobal != actual.IsGlobal) { throw new ArgumentException( $"Expected index {Name} to have IsGlobal='{IsGlobal}', got IsGlobal='{actual.IsGlobal}' instead", nameof(actual)); } }
public TableSchema DefineFixedSizeIndex(string name, FixedSizeSchemaIndexDef index) { index.NameAsSlice = Slice.From(StorageEnvironment.LabelsContext, name, ByteStringType.Immutable);; _fixedSizeIndexes[name] = index; return(this); }
public TableSchema DefineFixedSizeIndex(FixedSizeSchemaIndexDef index) { if (!index.Name.HasValue || SliceComparer.Equals(Slices.Empty, index.Name)) { throw new ArgumentException("Fixed size index name must be non-empty", nameof(index)); } _fixedSizeIndexes[index.Name] = index; return(this); }
public static TableSchema ReadFrom(ByteStringContext context, byte *location, int size) { var input = new TableValueReader(location, size); var schema = new TableSchema(); // Since there might not be a primary key, we have a moving index to deserialize the schema int currentIndex = 0; int currentSize; byte *currentPtr = input.Read(currentIndex++, out currentSize); bool hasPrimaryKey = Convert.ToBoolean(*currentPtr); if (hasPrimaryKey) { currentPtr = input.Read(currentIndex++, out currentSize); var pk = SchemaIndexDef.ReadFrom(context, currentPtr, currentSize); schema.DefineKey(pk); } // Read common schema indexes currentPtr = input.Read(currentIndex++, out currentSize); int indexCount = *(int *)currentPtr; while (indexCount > 0) { currentPtr = input.Read(currentIndex++, out currentSize); var indexSchemaDef = SchemaIndexDef.ReadFrom(context, currentPtr, currentSize); schema.DefineIndex(indexSchemaDef); indexCount--; } // Read fixed size schema indexes currentPtr = input.Read(currentIndex++, out currentSize); indexCount = *(int *)currentPtr; while (indexCount > 0) { currentPtr = input.Read(currentIndex++, out currentSize); var fixedIndexSchemaDef = FixedSizeSchemaIndexDef.ReadFrom(context, currentPtr, currentSize); schema.DefineFixedSizeIndex(fixedIndexSchemaDef); indexCount--; } return(schema); }
public static FixedSizeSchemaIndexDef ReadFrom(ByteStringContext context, byte *location, int size) { var input = new TableValueReader(location, size); var output = new FixedSizeSchemaIndexDef(); int currentSize; byte *currentPtr = input.Read(0, out currentSize); output.StartIndex = *(int *)currentPtr; currentPtr = input.Read(1, out currentSize); output.IsGlobal = Convert.ToBoolean(*currentPtr); currentPtr = input.Read(2, out currentSize); Slice.From(context, currentPtr, currentSize, ByteStringType.Immutable, out output.Name); return(output); }
public TableSchema CompressValues(FixedSizeSchemaIndexDef etagSource, bool compress) { _compressed = compress; CompressedEtagSourceIndex = etagSource ?? throw new ArgumentNullException(nameof(etagSource)); return(this); }