repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
project-lakechain | github_2023 | awslabs | typescript | LanceDbStorageConnectorBuilder.withStorageProvider | public withStorageProvider(storageProvider: LanceDbStorageConnectorProps['storageProvider']) {
this.providerProps.storageProvider = storageProvider;
return (this);
} | /**
* Sets the storage provider to use.
* @param storageProvider the storage provider to use.
* @returns the builder instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/index.ts#L78-L81 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | LanceDbStorageConnectorBuilder.withTableName | public withTableName(tableName: string) {
this.providerProps.tableName = tableName;
return (this);
} | /**
* Sets the name of the table in LanceDB.
* @param tableName the name of the table in LanceDB.
* @returns the builder instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/index.ts#L88-L91 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | LanceDbStorageConnectorBuilder.withVectorSize | public withVectorSize(vectorSize: number) {
this.providerProps.vectorSize = vectorSize;
return (this);
} | /**
* Sets the size of the vector embeddings.
* @param vectorSize the size of the vector embeddings.
* @returns the builder instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/index.ts#L98-L101 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | LanceDbStorageConnectorBuilder.withIncludeText | public withIncludeText(includeText: boolean) {
this.providerProps.includeText = includeText;
return (this);
} | /**
* Sets whether to include the text associated
* with the embeddings in LanceDB.
* @param includeText whether to include the text
* associated with the embeddings in LanceDB.
* @default false
* @returns the builder instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/index.ts#L111-L114 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | LanceDbStorageConnectorBuilder.build | public build(): LanceDbStorageConnector {
return (new LanceDbStorageConnector(
this.scope,
this.identifier, {
...this.providerProps as LanceDbStorageConnectorProps,
...this.props
}
));
} | /**
* @returns a new instance of the `LanceDbStorageConnector`
* service constructed with the given parameters.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/index.ts#L120-L128 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | LanceDbStorageConnector.constructor | constructor(scope: Construct, id: string, props: LanceDbStorageConnectorProps) {
super(scope, id, description, {
...props,
queueVisibilityTimeout: cdk.Duration.seconds(
2 * PROCESSING_TIMEOUT.toSeconds()
)
});
// Validate the properties.
props = this.parse(LanceDbStorageConnectorPropsSchema, props);
///////////////////////////////////////////
////// Storage Infrastructure //////
///////////////////////////////////////////
// Set the storage provider.
this.storageProvider = props.storageProvider;
// EFS access point.
let accessPoint: efs.IAccessPoint | undefined;
let vpc: ec2.IVpc | undefined;
if (props.storageProvider.id() === 'EFS_STORAGE') {
const provider = props.storageProvider as EfsStorageProvider;
accessPoint = provider.accessPoint;
vpc = provider.vpc();
}
// Ensure the provided VPC matches the storage provider VPC.
if (vpc && props.vpc && vpc !== props.vpc) {
throw new Error('The EFS storage provider VPC must match the provided VPC.');
}
///////////////////////////////////////////
/////// Processing Function ///////
///////////////////////////////////////////
this.processor = new node.NodejsFunction(this, 'Processor', {
description: 'A function writing vector embeddings in a LanceDB table.',
entry: path.resolve(__dirname, 'lambdas', 'processor', 'index.js'),
vpc: props.vpc ?? vpc,
memorySize: props.maxMemorySize ?? DEFAULT_MEMORY_SIZE,
timeout: PROCESSING_TIMEOUT,
runtime: EXECUTION_RUNTIME,
architecture: lambda.Architecture.ARM_64,
tracing: lambda.Tracing.ACTIVE,
environmentEncryption: props.kmsKey,
logGroup: this.logGroup,
filesystem: accessPoint ?
lambda.FileSystem.fromEfsAccessPoint(accessPoint, '/mnt/efs') :
undefined,
insightsVersion: props.cloudWatchInsights ?
LAMBDA_INSIGHTS_VERSION :
undefined,
environment: {
POWERTOOLS_SERVICE_NAME: description.name,
POWERTOOLS_METRICS_NAMESPACE: NAMESPACE,
LAKECHAIN_CACHE_STORAGE: props.cacheStorage.id(),
LANCEDB_STORAGE: JSON.stringify(props.storageProvider),
LANCEDB_TABLE_NAME: props.tableName,
LANCEDB_VECTOR_SIZE: `${props.vectorSize}`,
INCLUDE_TEXT: props.includeText ? 'true' : 'false'
},
layers: [
LanceDbLayer.arm64(this, 'LanceDbLayer')
],
bundling: {
minify: true,
externalModules: [
'@aws-sdk/client-s3',
'vectordb'
]
}
});
// Allows this construct to act as a `IGrantable`
// for other middlewares to grant the processing
// lambda permissions to access their resources.
this.grantPrincipal = this.processor.grantPrincipal;
// Storage provider permissions.
props.storageProvider.grant(this.processor);
// Plug the SQS queue into the lambda function.
this.processor.addEventSource(new sources.SqsEventSource(this.eventQueue, {
batchSize: props.batchSize ?? 10,
maxBatchingWindow: props.batchingWindow ?? cdk.Duration.seconds(10),
maxConcurrency: props.maxConcurrency ?? 5
}));
super.bind();
} | /**
* LanceDb data store constructor.
* @param scope the construct scope.
* @param id the construct identifier.
* @param props the construct properties.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/index.ts#L158-L248 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | LanceDbStorageConnector.grantReadProcessedDocuments | grantReadProcessedDocuments(_: iam.IGrantable): iam.Grant {
return ({} as iam.Grant);
} | /**
* Allows a grantee to read from the processed documents
* generated by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/index.ts#L254-L256 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | LanceDbStorageConnector.supportedInputTypes | supportedInputTypes(): string[] {
return ([
'*/*'
]);
} | /**
* @returns an array of mime-types supported as input
* type by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/index.ts#L262-L266 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | LanceDbStorageConnector.supportedOutputTypes | supportedOutputTypes(): string[] {
return ([]);
} | /**
* @returns an array of mime-types supported as output
* type by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/index.ts#L272-L274 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | LanceDbStorageConnector.supportedComputeTypes | supportedComputeTypes(): ComputeType[] {
return ([
ComputeType.CPU
]);
} | /**
* @returns the supported compute types by a given
* middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/index.ts#L280-L284 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | LanceDbStorageConnector.conditional | conditional() {
return (super
.conditional()
.and(when('type').equals('document-created'))
.and(when('data.metadata.properties.attrs.embeddings.vectors').exists())
);
} | /**
* @returns the middleware conditional statement defining
* in which conditions this middleware should be executed.
* In this case, we want the middleware to only be invoked
* when the document mime-type is supported, the event
* type is `document-created`, and embeddings are available
* in the document metadata.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/index.ts#L294-L300 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | EfsStorageProviderBuilder.withScope | public withScope(scope: Construct): EfsStorageProviderBuilder {
this.scope = scope;
return (this);
} | /**
* Sets the construct scope.
* @param scope the construct scope.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/efs/index.ts#L98-L101 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | EfsStorageProviderBuilder.withIdentifier | public withIdentifier(id: string): EfsStorageProviderBuilder {
this.id = id;
return (this);
} | /**
* Sets the construct identifier.
* @param id the construct identifier.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/efs/index.ts#L107-L110 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | EfsStorageProviderBuilder.withFileSystem | public withFileSystem(fileSystem: efs.IFileSystem): EfsStorageProviderBuilder {
this.props.efs = fileSystem;
return (this);
} | /**
* Sets the EFS file system.
* @param fileSystem the EFS file system.
* @returns a reference to the builder.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/efs/index.ts#L117-L120 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | EfsStorageProviderBuilder.withVpc | public withVpc(vpc: ec2.IVpc): EfsStorageProviderBuilder {
this.props.vpc = vpc;
return (this);
} | /**
* Sets the VPC in which the EFS storage should be deployed.
* @param vpc the VPC in which the EFS storage should be deployed.
* @returns a reference to the builder.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/efs/index.ts#L127-L130 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | EfsStorageProviderBuilder.withPath | public withPath(path: string): EfsStorageProviderBuilder {
this.props.path = path;
return (this);
} | /**
* Sets the path to the LanceDB dataset in the bucket.
* @param path the path to the LanceDB dataset in the bucket.
* @returns a reference to the builder.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/efs/index.ts#L137-L140 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | EfsStorageProviderBuilder.build | public build(): EfsStorageProvider {
return (EfsStorageProvider.from(
this.scope,
this.id,
this.props
));
} | /**
* Builds the EFS storage properties.
* @returns a new instance of the `EfsStorageProvider` class.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/efs/index.ts#L146-L152 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | EfsStorageProvider.constructor | constructor(scope: Construct, resourceId: string, public props: EfsStorageProviderProps) {
super(scope, resourceId);
// Set the file system.
this.fileSystem = props.efs;
// Create the access point.
this.accessPoint = new efs.AccessPoint(this, 'AccessPoint', {
fileSystem: this.fileSystem,
path: '/lancedb',
createAcl: {
ownerGid: '1000',
ownerUid: '1000',
permissions: '750'
},
posixUser: {
uid: '1000',
gid: '1000'
}
});
} | /**
* Creates a new instance of the `EfsStorageProvider` class.
* @param scope the construct scope.
* @param resourceId the construct identifier.
* @param props the task properties.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/efs/index.ts#L181-L201 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | EfsStorageProvider.id | public id(): string {
return (this.props.id);
} | /**
* @returns the storage identifier.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/efs/index.ts#L206-L208 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | EfsStorageProvider.efs | public efs(): efs.IFileSystem {
return (this.fileSystem);
} | /**
* @returns the file system.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/efs/index.ts#L213-L215 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | EfsStorageProvider.vpc | public vpc(): ec2.IVpc {
return (this.props.vpc);
} | /**
* @returns the VPC.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/efs/index.ts#L220-L222 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | EfsStorageProvider.path | public path(): string {
return (this.props.path);
} | /**
* @returns the storage path.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/efs/index.ts#L227-L229 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | EfsStorageProvider.uri | public uri(): string {
return (path.join('/', 'mnt', 'efs', this.path()));
} | /**
* @returns the storage URI.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/efs/index.ts#L234-L236 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | EfsStorageProvider.grant | grant(grantee: iam.IGrantable) {
this.fileSystem.grantReadWrite(grantee);
} | /**
* Grants permissions to an `IGrantable`.
* @param grantee the grantee to whom permissions should be granted.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/efs/index.ts#L242-L244 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | EfsStorageProvider.from | public static from(scope: Construct, id: string, props: any) {
return (new EfsStorageProvider(scope, id, EfsStorageProviderPropsSchema.parse(props)));
} | /**
* Creates a new instance of the `EfsStorageProvider` class.
* @param scope the construct scope.
* @param id the construct identifier.
* @param props the storage properties.
* @returns a new instance of the `EfsStorageProvider` class.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/efs/index.ts#L253-L255 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | EfsStorageProvider.toJSON | public toJSON() {
return ({
id: this.id(),
path: this.path(),
uri: this.uri()
});
} | /**
* @returns the JSON representation of the storage.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/efs/index.ts#L260-L266 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | S3StorageProviderBuilder.withScope | public withScope(scope: Construct): S3StorageProviderBuilder {
this.scope = scope;
return (this);
} | /**
* Sets the construct scope.
* @param scope the construct scope.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/s3/index.ts#L86-L89 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | S3StorageProviderBuilder.withIdentifier | public withIdentifier(id: string): S3StorageProviderBuilder {
this.id = id;
return (this);
} | /**
* Sets the construct identifier.
* @param id the construct identifier.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/s3/index.ts#L95-L98 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | S3StorageProviderBuilder.withPath | public withPath(path: string): S3StorageProviderBuilder {
this.props.path = path;
return (this);
} | /**
* Sets the path to the LanceDB dataset in the bucket.
* @param path the path to the LanceDB dataset in the bucket.
* @returns a reference to the builder.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/s3/index.ts#L105-L108 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | S3StorageProviderBuilder.withBucket | public withBucket(bucket: s3.IBucket): S3StorageProviderBuilder {
this.props.bucket = bucket;
return (this);
} | /**
* Sets the bucket to use as a storage.
* @param bucket the bucket to use as a storage.
* @returns a reference to the builder.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/s3/index.ts#L115-L118 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | S3StorageProviderBuilder.build | public build(): S3StorageProvider {
return (S3StorageProvider.from(
this.scope,
this.id,
this.props
));
} | /**
* Builds the S3 storage properties.
* @returns a new instance of the `S3StorageProvider` class.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/s3/index.ts#L124-L130 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | S3StorageProvider.constructor | constructor(scope: Construct, resourceId: string, public props: S3StorageProviderProps) {
super(scope, resourceId);
// Set the bucket.
this.bucketStorage = props.bucket;
// Create the DynamoDB table.
this.table = new dynamodb.Table(this, 'Table', {
partitionKey: {
name: 'base_uri',
type: dynamodb.AttributeType.STRING
},
sortKey: {
name: 'version',
type: dynamodb.AttributeType.NUMBER
},
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
removalPolicy: cdk.RemovalPolicy.DESTROY
});
} | /**
* Creates a new instance of the `S3StorageProvider` class.
* @param scope the construct scope.
* @param resourceId the construct identifier.
* @param props the task properties.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/s3/index.ts#L159-L178 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | S3StorageProvider.id | public id(): string {
return (this.props.id);
} | /**
* @returns the storage identifier.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/s3/index.ts#L183-L185 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | S3StorageProvider.bucket | public bucket(): s3.IBucket {
return (this.bucketStorage);
} | /**
* @returns the storage bucket.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/s3/index.ts#L190-L192 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | S3StorageProvider.path | public path(): string {
return (this.props.path);
} | /**
* @returns the storage path.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/s3/index.ts#L197-L199 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | S3StorageProvider.uri | public uri(): string {
return (`s3+ddb://${this.bucketStorage.bucketName}/${this.path()}?ddbTableName=${this.table.tableName}`);
} | /**
* @returns the storage URI.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/s3/index.ts#L204-L206 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | S3StorageProvider.grant | grant(grantee: iam.IGrantable) {
// Allow the processor to read and write to the DynamoDB table.
this.table.grantReadWriteData(grantee);
// Allow the processor to read and write to the S3 bucket.
this.bucketStorage.grantReadWrite(grantee);
} | /**
* Grants permissions to an `IGrantable`.
* @param grantee the grantee to whom permissions should be granted.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/s3/index.ts#L212-L217 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | S3StorageProvider.from | public static from(scope: Construct, id: string, props: any) {
return (new S3StorageProvider(scope, id, S3StorageProviderPropsSchema.parse(props)));
} | /**
* Creates a new instance of the `S3StorageProvider` class.
* @param scope the construct scope.
* @param id the construct identifier.
* @param props the storage properties.
* @returns a new instance of the `S3StorageProvider` class.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/s3/index.ts#L226-L228 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | S3StorageProvider.toJSON | public toJSON() {
return ({
id: this.id(),
path: this.path(),
uri: this.uri()
});
} | /**
* @returns the JSON representation of the storage.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/definitions/storage/s3/index.ts#L233-L239 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Lambda.getId | private getId(event: CloudEvent) {
const metadata = event.data().metadata();
// If there is a chunk identifier that specifically
// identifies a chunk associated with the given document,
// we use that.
if (metadata.properties?.kind === 'text'
&& metadata.properties.attrs?.chunk) {
return (metadata.properties.attrs?.chunk.id);
}
return (event.data().document().id());
} | /**
* @param event the event associated with the
* received document.
* @returns a unique identifier for the given
* document that is fit to identify the vectors
* associated with the document.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/lambdas/processor/index.ts#L45-L57 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Lambda.getEmbeddings | private getEmbeddings(event: CloudEvent): Promise<number[]> {
const metadata = event.data().metadata();
if (metadata.properties?.kind !== 'text'
|| !metadata.properties.attrs.embeddings) {
throw new Error('The event does not contain embeddings.');
}
return (metadata.properties.attrs.embeddings.vectors.resolve());
} | /**
* @param event the event associated with the
* received document.
* @returns a vector embedding object associated
* with the document.
* @throws if the vector embedding object could not
* be resolved.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/lambdas/processor/index.ts#L67-L76 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Lambda.getTable | private async getTable(): Promise<lancedb.Table> {
const db = await lancedb.connect(LANCEDB_STORAGE.uri);
let table: lancedb.Table;
try {
// Attempt to open the table.
table = await db.openTable(LANCEDB_TABLE_NAME);
} catch (e) {
// If the table does not exist, we create it.
table = await db.createTable({
name: LANCEDB_TABLE_NAME,
schema: makeSchema(LANCEDB_VECTOR_SIZE)
});
}
return (table);
} | /**
* Retrieves the table to use to store events and embeddings.
* @returns a promise resolved with the table object.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/lambdas/processor/index.ts#L82-L98 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Lambda.getText | private async getText(event: CloudEvent): Promise<string | null> {
const metadata = event.data().metadata();
const document = event.data().document();
if (metadata.properties?.kind === 'text') {
return ((await document.data().asBuffer()).toString('utf-8'));
}
return (null);
} | /**
* A helper returning a textual representation of the document
* to include within the index.
* @param event the event associated with the
* received document.
* @returns a string representation of the
* document, null if the document is not text.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/lambdas/processor/index.ts#L108-L116 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Lambda.handler | async handler(event: SQSEvent, _: Context) {
const table = await this.getTable();
const data = [];
// Combine all received events into a single batch.
for (const record of event.Records) {
const event = CloudEvent.from(JSON.parse(record.body));
data.push({
...normalizeEvent(event),
vector: await this.getEmbeddings(event),
id: this.getId(event),
text: INCLUDE_TEXT ? await this.getText(event) : undefined
});
}
// Insert the event into the table.
await table.add(data);
} | // eslint-disable-next-line @typescript-eslint/no-unused-vars | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/lancedb-storage-connector/src/lambdas/processor/index.ts#L126-L143 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Neo4jStorageConnectorBuilder.withUri | public withUri(uri: string): Neo4jStorageConnectorBuilder {
this.providerProps.uri = uri;
return (this);
} | /**
* Sets the URI for the Neo4j API.
* @param uri the URI for the Neo4j API.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/neo4j-storage-connector/src/index.ts#L74-L77 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Neo4jStorageConnectorBuilder.withCredentials | public withCredentials(credentials: secrets.ISecret): Neo4jStorageConnectorBuilder {
this.providerProps.credentials = credentials;
return (this);
} | /**
* Sets the credentials to use for the Neo4j API.
* @param credentials the credentials to use for the Neo4j API.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/neo4j-storage-connector/src/index.ts#L83-L86 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Neo4jStorageConnectorBuilder.build | public build(): Neo4jStorageConnector {
return (new Neo4jStorageConnector(
this.scope,
this.identifier, {
...this.providerProps as Neo4jStorageConnectorProps,
...this.props
}
));
} | /**
* @returns a new instance of the `Neo4jStorageConnector`
* service constructed with the given parameters.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/neo4j-storage-connector/src/index.ts#L92-L100 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Neo4jStorageConnector.constructor | constructor(scope: Construct, id: string, props: Neo4jStorageConnectorProps) {
super(scope, id, description, {
...props,
queueVisibilityTimeout: cdk.Duration.seconds(
6 * PROCESSING_TIMEOUT.toSeconds()
)
});
// Validate the properties.
props = this.parse(Neo4jStorageConnectorPropsSchema, props);
///////////////////////////////////////////
/////// Processing Function ///////
///////////////////////////////////////////
this.processor = new node.NodejsFunction(this, 'Processor', {
description: 'A function writing vector embeddings in a Neo4j database.',
entry: path.resolve(__dirname, 'lambdas', 'processor', 'index.js'),
vpc: props.vpc,
memorySize: props.maxMemorySize ?? DEFAULT_MEMORY_SIZE,
timeout: PROCESSING_TIMEOUT,
runtime: EXECUTION_RUNTIME,
architecture: lambda.Architecture.ARM_64,
tracing: lambda.Tracing.ACTIVE,
environmentEncryption: props.kmsKey,
logGroup: this.logGroup,
insightsVersion: props.cloudWatchInsights ?
LAMBDA_INSIGHTS_VERSION :
undefined,
environment: {
POWERTOOLS_SERVICE_NAME: description.name,
POWERTOOLS_METRICS_NAMESPACE: NAMESPACE,
LAKECHAIN_CACHE_STORAGE: props.cacheStorage.id(),
NEO4J_URI: props.uri,
NEO4J_CREDENTIALS_SECRET_NAME: props.credentials.secretName
},
bundling: {
minify: true,
externalModules: [
'@aws-sdk/client-s3',
'@aws-sdk/client-secrets-manager'
]
}
});
// Allows this construct to act as a `IGrantable`
// for other middlewares to grant the processing
// lambda permissions to access their resources.
this.grantPrincipal = this.processor.grantPrincipal;
// Plug the SQS queue into the lambda function.
this.processor.addEventSource(new sources.SqsEventSource(this.eventQueue, {
batchSize: props.batchSize ?? 2,
maxBatchingWindow: props.batchingWindow ?? cdk.Duration.seconds(10),
maxConcurrency: 5,
reportBatchItemFailures: true
}));
// Grant the lambda function permissions to
// read from the API credentials secret.
props.credentials.grantRead(this.processor);
super.bind();
} | /**
* Neo4j data store constructor.
* @param scope the construct scope.
* @param id the construct identifier.
* @param props the construct properties.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/neo4j-storage-connector/src/index.ts#L125-L188 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Neo4jStorageConnector.grantReadProcessedDocuments | grantReadProcessedDocuments(_: iam.IGrantable): iam.Grant {
return ({} as iam.Grant);
} | /**
* Allows a grantee to read from the processed documents
* generated by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/neo4j-storage-connector/src/index.ts#L194-L196 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Neo4jStorageConnector.supportedInputTypes | supportedInputTypes(): string[] {
return ([
'*/*'
]);
} | /**
* @returns an array of mime-types supported as input
* type by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/neo4j-storage-connector/src/index.ts#L202-L206 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Neo4jStorageConnector.supportedOutputTypes | supportedOutputTypes(): string[] {
return ([]);
} | /**
* @returns an array of mime-types supported as output
* type by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/neo4j-storage-connector/src/index.ts#L212-L214 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Neo4jStorageConnector.supportedComputeTypes | supportedComputeTypes(): ComputeType[] {
return ([
ComputeType.CPU
]);
} | /**
* @returns the supported compute types by a given
* middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/neo4j-storage-connector/src/index.ts#L220-L224 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Neo4jStorageConnector.conditional | conditional() {
return (super
.conditional()
.and(when('type').equals('document-created'))
);
} | /**
* @returns the middleware conditional statement defining
* in which conditions this middleware should be executed.
* In this case, we want the middleware to only be invoked
* when the document mime-type is supported, and the event
* type is `document-created`.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/neo4j-storage-connector/src/index.ts#L233-L238 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Lambda.sanitize | private sanitize(str: string, maxLength = 128): string {
if (str.length > maxLength || !/^[a-zA-Z0-9_]+$/.test(str)) {
throw new Error(
`Invalid value: ${str}. Only alphanumeric characters and underscores are allowed, and values must not exceed ${maxLength} characters.`
);
}
return (str);
} | /**
* Sanitizes a string.
* @param str the string to sanitize.
* @param maxLength the maximum length of the string.
* @throws an error if the string is invalid.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/neo4j-storage-connector/src/lambdas/processor/index.ts#L46-L53 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Lambda.recordHandler | async recordHandler(record: SQSRecord): Promise<void> {
const event = CloudEvent.from(JSON.parse(record.body));
const graph = await event.asGraph();
const client = await createClient();
const session = client.session();
try {
await session.executeWrite(async (tx) => {
// Write the nodes.
for (const node of graph.nodes()) {
const props = graph.getNodeAttributes(node);
const type = this.sanitize(props.type);
await tx.run(
`MERGE (n:${type} { id: $id }) SET n += $props`,
{ id: node, props: props.attrs ?? {} }
);
}
// Write the edges.
for (const edge of graph.edges()) {
const source = graph.source(edge);
const target = graph.target(edge);
const props = graph.getEdgeAttributes(edge);
const type = this.sanitize(props.type);
await tx.run(
`MATCH (a { id: $source }), (b { id: $target })
MERGE (a)-[r:${type}]->(b)
SET r += $props`,
{ source, target, props: props.attrs ?? {} }
);
}
}, { timeout: 10000 });
} finally {
await session.close();
await client.close();
}
} | /**
* Writes the document graph in the Neo4j database.
* @param record the SQS record associated with
* the received document.
* @returns a promise resolved when the document graph
* has been written in the database.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/neo4j-storage-connector/src/lambdas/processor/index.ts#L62-L101 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Lambda.handler | async handler(event: SQSEvent, _: Context) {
return (await processPartialResponse(
event, this.recordHandler.bind(this), processor
));
} | // eslint-disable-next-line @typescript-eslint/no-unused-vars | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/neo4j-storage-connector/src/lambdas/processor/index.ts#L111-L115 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchStorageConnectorBuilder.withDomain | public withDomain(domain: opensearch.Domain) {
this.providerProps.domain = domain;
return (this);
} | /**
* Specifies the OpenSearch domain to use.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-storage-connector/src/index.ts#L56-L59 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchStorageConnectorBuilder.withIndexName | public withIndexName(index: string) {
this.providerProps.index = index;
return (this);
} | /**
* Specifies the name of the index to use.
* @param index the name of the index.
* @returns the current builder instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-storage-connector/src/index.ts#L66-L69 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchStorageConnectorBuilder.withBufferingHints | public withBufferingHints(hints: firehose.CfnDeliveryStream.BufferingHintsProperty) {
this.providerProps.bufferingHints = hints;
return (this);
} | /**
* Specifies buffering hints to apply on the Firehose
* delivery stream.
* @param hints the buffering hints.
* @returns the current builder instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-storage-connector/src/index.ts#L77-L80 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchStorageConnectorBuilder.withIndexRotationPeriod | public withIndexRotationPeriod(period: IndexRotationPeriod) {
this.providerProps.indexRotationPeriod = period;
return (this);
} | /**
* Specifies the index rotation period to apply
* when inserting data in OpenSearch.
* @param period the index rotation period.
* @returns the current builder instance.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-storage-connector/src/index.ts#L88-L91 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchStorageConnectorBuilder.build | public build(): OpenSearchStorageConnector {
return (new OpenSearchStorageConnector(
this.scope,
this.identifier, {
...this.providerProps as OpenSearchStorageConnectorProps,
...this.props
}
));
} | /**
* @returns a new instance of the `OpenSearchStorageConnector`
* service constructed with the given parameters.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-storage-connector/src/index.ts#L97-L105 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchStorageConnector.constructor | constructor(scope: Construct, id: string, private props: OpenSearchStorageConnectorProps) {
super(scope, id, description, props);
// Validate the properties.
this.props = this.parse(OpenSearchStorageConnectorPropsSchema, props);
///////////////////////////////////////////
///// Firehose Bucket Storage /////
///////////////////////////////////////////
this.firehoseBucket = new s3.Bucket(this, 'Bucket', {
encryption: s3.BucketEncryption.S3_MANAGED,
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
removalPolicy: cdk.RemovalPolicy.RETAIN,
enforceSSL: true
});
///////////////////////////////////////////
///// Firehose Delivery Stream /////
///////////////////////////////////////////
// The Firehose log group.
this.firehoseLogGroup = new logs.LogGroup(this, 'FirehoseLogGroup');
// The IAM role to be used by the delivery stream.
const deliveryRole = this.getFirehoseRole(id);
// OpenSearch delivery configuration.
const openSearchProps: any = {
bufferingHints: this.props.bufferingHints,
domainArn: this.props.domain.domainArn,
documentIdOptions: {
defaultDocumentIdFormat: 'FIREHOSE_DEFAULT'
},
indexName: this.props.index,
indexRotationPeriod: this.props.indexRotationPeriod,
roleArn: deliveryRole.roleArn,
s3Configuration: {
bucketArn: this.firehoseBucket.bucketArn,
roleArn: deliveryRole.roleArn,
cloudWatchLoggingOptions: {
enabled: true,
logGroupName: this.firehoseLogGroup.logGroupName,
logStreamName: 's3'
}
},
cloudWatchLoggingOptions: {
enabled: true,
logGroupName: this.firehoseLogGroup.logGroupName,
logStreamName: 'delivery'
}
};
// If a VPC configuration is specified, add it to the
// delivery stream configuration.
if (this.props.vpc) {
openSearchProps.vpcConfiguration = {
roleArn: deliveryRole.roleArn,
securityGroupIds: this.props.domain.connections.securityGroups.map(
sg => sg.securityGroupId
),
subnetIds: this.props.vpc.selectSubnets({
subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS
}).subnetIds
};
}
// The delivery stream which will store buffered
// document data in OpenSearch.
this.deliveryStream = new firehose.CfnDeliveryStream(this, 'Stream', {
deliveryStreamType: 'DirectPut',
amazonopensearchserviceDestinationConfiguration: openSearchProps
});
super.bind();
} | /**
* Construct constructor.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-storage-connector/src/index.ts#L141-L216 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchStorageConnector.getInput | public getInput() {
return (this.deliveryStream);
} | /**
* We override the `getInput` method to allow the previous middlewares
* to write their data directly to the Firehose delivery stream.
* @returns the Firehose delivery stream that should be used by
* the previous middlewares to write their data.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-storage-connector/src/index.ts#L224-L226 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchStorageConnector.getFirehoseRole | private getFirehoseRole(id: string): iam.IRole {
const policy = new iam.PolicyDocument({
statements:[
// VPC Policy
new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: [
'ec2:DescribeVpcs',
'ec2:DescribeVpcAttribute',
'ec2:DescribeSubnets',
'ec2:DescribeSecurityGroups',
'ec2:DescribeNetworkInterfaces',
'ec2:CreateNetworkInterface',
'ec2:CreateNetworkInterfacePermission',
'ec2:DeleteNetworkInterface'
],
resources: ['*']
}),
// S3 Delivery Policy
new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: [
's3:AbortMultipartUpload',
's3:GetBucketLocation',
's3:GetObject',
's3:ListBucket',
's3:ListBucketMultipartUploads',
's3:PutObject'
],
resources: [
this.firehoseBucket.bucketArn,
`${this.firehoseBucket.bucketArn}/*`
]
}),
// OpenSearch Write Policy
new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: [
'es:DescribeElasticsearchDomain',
'es:DescribeElasticsearchDomains',
'es:DescribeElasticsearchDomainConfig',
'es:ESHttpPost',
'es:ESHttpPut'
],
resources: [
`arn:aws:es:${cdk.Aws.REGION}:${cdk.Aws.ACCOUNT_ID}:domain/${this.props.domain.domainName}`,
`arn:aws:es:${cdk.Aws.REGION}:${cdk.Aws.ACCOUNT_ID}:domain/${this.props.domain.domainName}/*`
]
}),
// OpenSearch Read Policy
new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: [
'es:ESHttpGet'
],
resources: [
`arn:aws:es:${cdk.Aws.REGION}:${cdk.Aws.ACCOUNT_ID}:domain/${this.props.domain.domainName}/_all/_settings`,
`arn:aws:es:${cdk.Aws.REGION}:${cdk.Aws.ACCOUNT_ID}:domain/${this.props.domain.domainName}/_cluster/stats`,
`arn:aws:es:${cdk.Aws.REGION}:${cdk.Aws.ACCOUNT_ID}:domain/${this.props.domain.domainName}/cloudwatch-event*/_mapping/`,
`arn:aws:es:${cdk.Aws.REGION}:${cdk.Aws.ACCOUNT_ID}:domain/${this.props.domain.domainName}/_nodes`,
`arn:aws:es:${cdk.Aws.REGION}:${cdk.Aws.ACCOUNT_ID}:domain/${this.props.domain.domainName}/_nodes/stats`,
`arn:aws:es:${cdk.Aws.REGION}:${cdk.Aws.ACCOUNT_ID}:domain/${this.props.domain.domainName}/_nodes/*/stats`,
`arn:aws:es:${cdk.Aws.REGION}:${cdk.Aws.ACCOUNT_ID}:domain/${this.props.domain.domainName}/_stats`,
`arn:aws:es:${cdk.Aws.REGION}:${cdk.Aws.ACCOUNT_ID}:domain/${this.props.domain.domainName}/cloudwatch-event*/_stats`
]
}),
// CloudWatch Logs Policy
new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: [
'logs:PutLogEvents'
],
resources: [
`arn:aws:logs:${cdk.Aws.REGION}:${cdk.Aws.ACCOUNT_ID}:log-group:${this.firehoseLogGroup.logGroupName}:log-stream:*`
]
})
]
});
return (new iam.Role(this, `FirehoseRole-${id}`, {
assumedBy: new iam.ServicePrincipal('firehose.amazonaws.com'),
description: 'Firehose delivery stream role.',
inlinePolicies: {
'StreamPolicy': policy
}
}));
} | /**
* Creates the IAM role to be used by the Firehose
* delivery stream.
* @param id the identifier of the role.
* @returns the created role.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-storage-connector/src/index.ts#L234-L324 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchStorageConnector.grantReadProcessedDocuments | grantReadProcessedDocuments(_: iam.IGrantable): iam.Grant {
return ({} as iam.Grant);
} | /**
* Allows a grantee to read from the processed documents
* generated by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-storage-connector/src/index.ts#L330-L332 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchStorageConnector.supportedInputTypes | supportedInputTypes(): string[] {
return ([
'*/*'
]);
} | /**
* @returns an array of mime-types supported as input
* type by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-storage-connector/src/index.ts#L338-L342 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchStorageConnector.supportedOutputTypes | supportedOutputTypes(): string[] {
return ([]);
} | /**
* @returns an array of mime-types supported as output
* type by the data producer.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-storage-connector/src/index.ts#L348-L350 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchStorageConnector.supportedComputeTypes | supportedComputeTypes(): ComputeType[] {
return ([
ComputeType.CPU
]);
} | /**
* @returns the supported compute types by a given
* middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-storage-connector/src/index.ts#L356-L360 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchVectorStorageConnectorBuilder.withEndpoint | public withEndpoint(endpoint: opensearch.IDomain | oss.ICollection | opensearchserverless.CfnCollection) {
const e = endpoint as any;
if (e.collectionName && e.collectionArn && e.collectionId && e.collectionEndpoint) {
endpoint = oss.Collection.fromCollectionAttributes(this.scope, 'Collection', {
collectionName: e.name,
collectionArn: e.attrArn,
collectionId: e.attrId,
collectionEndpoint: e.attrCollectionEndpoint,
dashboardEndpoint: e.attrDashboardEndpoint
});
}
this.providerProps.endpoint = e;
return (this);
} | /**
* Specifies the OpenSearch endpoint to use.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/index.ts#L82-L96 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchVectorStorageConnectorBuilder.withIndex | public withIndex(index: OpenSearchVectorIndexDefinition) {
this.providerProps.index = index;
return (this);
} | /**
* Specifies the definition of the index to use.
* @param index the index definition.
* @returns the current builder instance.
* @see https://opensearch.org/docs/latest/search-plugins/knn/knn-index#method-definitions
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/index.ts#L104-L107 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchVectorStorageConnectorBuilder.withIncludeDocument | public withIncludeDocument(includeDocument: boolean) {
this.providerProps.includeDocument = includeDocument;
return (this);
} | /**
* Specifies whether to include the document associated
* with the embeddings in the OpenSearch index.
* @param includeDocument whether to include the document.
* @returns the current builder instance.
* @default true
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/index.ts#L116-L119 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchVectorStorageConnectorBuilder.build | public build(): OpenSearchVectorStorageConnector {
return (new OpenSearchVectorStorageConnector(
this.scope,
this.identifier, {
...this.providerProps as OpenSearchVectorStorageConnectorProps,
...this.props
}
));
} | /**
* @returns a new instance of the `OpenSearchVectorStorageConnector`
* service constructed with the given parameters.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/index.ts#L125-L133 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchVectorStorageConnector.constructor | constructor(scope: Construct, id: string, private props: OpenSearchVectorStorageConnectorProps) {
super(scope, id, description, props);
// Validate the properties.
this.props = this.parse(OpenSearchVectorStorageConnectorPropsSchema, props);
///////////////////////////////////////////////
/////// OpenSearch Vector Index ///////
///////////////////////////////////////////////
// Create the vector index.
new OpenSearchIndex(this, 'Index', {
indexName: this.props.index.indexName(),
endpoint: this.props.endpoint,
vpc: this.props.vpc,
body: {
settings: {
index: {
knn: true,
'knn.algo_param.ef_search': this.props.index.efSearch()
}
},
mappings: {
properties: {
embeddings: {
type: 'knn_vector',
dimension: this.props.index.dimensions(),
method: {
name: this.props.index.knnMethod(),
space_type: this.props.index.spaceType(),
engine: this.props.index.knnEngine(),
parameters: this.props.index.parameters()
}
}
}
}
}
});
///////////////////////////////////////////
/////// Processing Function ///////
///////////////////////////////////////////
this.processor = new node.NodejsFunction(this, 'Compute', {
description: 'A function writing vector embeddings in an OpenSearch index.',
entry: path.resolve(__dirname, 'lambdas', 'processor', 'index.js'),
vpc: this.props.vpc,
memorySize: props.maxMemorySize ?? DEFAULT_MEMORY_SIZE,
timeout: PROCESSING_TIMEOUT,
runtime: EXECUTION_RUNTIME,
architecture: lambda.Architecture.ARM_64,
tracing: lambda.Tracing.ACTIVE,
environmentEncryption: props.kmsKey,
logGroup: this.logGroup,
insightsVersion: props.cloudWatchInsights ?
LAMBDA_INSIGHTS_VERSION :
undefined,
environment: {
POWERTOOLS_SERVICE_NAME: description.name,
POWERTOOLS_METRICS_NAMESPACE: NAMESPACE,
LAKECHAIN_CACHE_STORAGE: this.props.cacheStorage.id(),
INDEX_NAME: this.props.index.indexName(),
OPENSEARCH_ENDPOINT: this.getEndpoint(this.props.endpoint),
INCLUDE_DOCUMENT: props.includeDocument ? 'true' : 'false',
SERVICE_IDENTIFIER: this.getServiceIdentifier(this.props.endpoint)
},
bundling: {
minify: true,
externalModules: [
'@aws-sdk/client-s3',
'@aws-sdk/credential-provider-node'
]
}
});
// Allows this construct to act as a `IGrantable`
// for other middlewares to grant the processing
// lambda permissions to access their resources.
this.grantPrincipal = this.processor.grantPrincipal;
// Plug the SQS queue into the lambda function.
this.processor.addEventSource(new sources.SqsEventSource(this.eventQueue, {
batchSize: props.batchSize ?? 10,
maxBatchingWindow: props.batchingWindow ?? cdk.Duration.seconds(20),
maxConcurrency: 10,
reportBatchItemFailures: true
}));
///////////////////////////////////////////
/////////// Permissions ///////////
///////////////////////////////////////////
// Get the service identifier of the endpoint.
const serviceIdentifier = this.getServiceIdentifier(this.props.endpoint);
if (serviceIdentifier === 'es') {
// Grant the lambda function permissions to write
// to the OpenSearch domain.
(this.props.endpoint as opensearch.Domain).grantWrite(this.processor);
} else if (serviceIdentifier === 'aoss') {
const endpoint = this.props.endpoint as oss.Collection;
// If the endpoint is a collection, we need to create an
// access policy on the collection to allow the lambda function
// to manage the index.
endpoint.addAccessPolicy(
this.node.id,
[this.processor.role!.roleArn],
[
'aoss:ReadDocument',
'aoss:WriteDocument',
'aoss:CreateIndex',
'aoss:DescribeIndex',
'aoss:DeleteIndex',
'aoss:UpdateIndex'
]
);
// We also need to grant the lambda function permissions
// to write to the OpenSearch index.
this.processor.addToRolePolicy(new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: ['aoss:APIAccessAll'],
resources: [endpoint.collectionArn]
}));
}
super.bind();
} | /**
* Construct constructor.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/index.ts#L155-L283 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchVectorStorageConnector.getEndpoint | private getEndpoint(endpoint: opensearch.IDomain | oss.ICollection): string {
const serviceIdentifier = this.getServiceIdentifier(endpoint);
if (serviceIdentifier === 'es') {
return (`https://${(endpoint as opensearch.Domain).domainEndpoint}`);
} else if (serviceIdentifier === 'aoss') {
return ((endpoint as oss.Collection).collectionEndpoint);
} else {
throw new Error('Invalid endpoint.');
}
} | /**
* Get the URL of the OpenSearch endpoint.
* @param endpoint the OpenSearch endpoint.
* @returns the endpoint URL.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/index.ts#L290-L300 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchVectorStorageConnector.getServiceIdentifier | private getServiceIdentifier(endpoint: opensearch.IDomain | oss.ICollection): ServiceIdentifier {
const e = endpoint as any;
if (e.domainArn
&& e.domainName
&& e.domainId
&& e.domainEndpoint) {
return ('es');
} else if (e.collectionName
&& e.collectionArn
&& e.collectionId
&& e.collectionEndpoint) {
return ('aoss');
} else {
throw new Error('Invalid endpoint.');
}
} | /**
* Get the service identifier of the OpenSearch endpoint.
* @param endpoint the OpenSearch endpoint.
* @returns a string identifying the service.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/index.ts#L307-L323 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchVectorStorageConnector.grantReadProcessedDocuments | grantReadProcessedDocuments(_: iam.IGrantable): iam.Grant {
return ({} as iam.Grant);
} | /**
* Allows a grantee to read from the processed documents
* generated by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/index.ts#L329-L331 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchVectorStorageConnector.supportedInputTypes | supportedInputTypes(): string[] {
return ([
'*/*'
]);
} | /**
* @returns an array of mime-types supported as input
* type by this middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/index.ts#L337-L341 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchVectorStorageConnector.supportedOutputTypes | supportedOutputTypes(): string[] {
return ([]);
} | /**
* @returns an array of mime-types supported as output
* type by the data producer.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/index.ts#L347-L349 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchVectorStorageConnector.supportedComputeTypes | supportedComputeTypes(): ComputeType[] {
return ([
ComputeType.CPU
]);
} | /**
* @returns the supported compute types by a given
* middleware.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/index.ts#L355-L359 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchVectorStorageConnector.conditional | conditional() {
return (super
.conditional()
.and(when('type').equals('document-created'))
.and(when('data.metadata.properties.attrs.embeddings.vectors').exists())
);
} | /**
* @returns the middleware conditional statement defining
* in which conditions this middleware should be executed.
* In this case, we want the middleware to only be invoked
* when the document mime-type is supported, the event
* type is `document-created`, and embeddings are available
* in the document metadata.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/index.ts#L369-L375 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchIndexDefinitionBuilder.withIndexName | public withIndexName(indexName: string) {
this.props.indexName = indexName;
return (this);
} | /**
* @param indexName the name of the index.
* @returns the OpenSearch index definition builder.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/definitions/index.ts#L117-L120 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchIndexDefinitionBuilder.withKnnMethod | public withKnnMethod(knnMethod: KnnMethod) {
this.props.knnMethod = knnMethod;
return (this);
} | /**
* @param knnMethod the k-NN method.
* @returns the OpenSearch index definition builder.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/definitions/index.ts#L126-L129 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchIndexDefinitionBuilder.withKnnEngine | public withKnnEngine(knnEngine: KnnEngine) {
this.props.knnEngine = knnEngine;
return (this);
} | /**
* @param knnEngine the k-NN engine.
* @returns the OpenSearch index definition builder.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/definitions/index.ts#L135-L138 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchIndexDefinitionBuilder.withSpaceType | public withSpaceType(spaceType: SpaceType) {
this.props.spaceType = spaceType;
return (this);
} | /**
* @param spaceType the space type.
* @returns the OpenSearch index definition builder.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/definitions/index.ts#L144-L147 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchIndexDefinitionBuilder.withDimensions | public withDimensions(dimensions: number) {
this.props.dimensions = dimensions;
return (this);
} | /**
* @param dimensions the vector dimensions.
* @returns the OpenSearch index definition builder.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/definitions/index.ts#L153-L156 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchIndexDefinitionBuilder.withEfSearch | public withEfSearch(efSearch: number) {
this.props.efSearch = efSearch;
return (this);
} | /**
* @param efSearch the size of the dynamic list used during k-NN searches.
* @returns the OpenSearch index definition builder.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/definitions/index.ts#L162-L165 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchIndexDefinitionBuilder.withParameters | public withParameters(parameters: any) {
this.props.parameters = parameters;
return (this);
} | /**
* @param parameters the parameters.
* @returns the OpenSearch index definition builder.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/definitions/index.ts#L171-L174 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchIndexDefinitionBuilder.build | public build() {
return (OpenSearchVectorIndexDefinition.from(this.props));
} | /**
* @returns a new OpenSearch index definition.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/definitions/index.ts#L179-L181 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchVectorIndexDefinition.constructor | constructor(public props: OpenSearchVectorIndexDefinitionProps) {} | /**
* OpenSearch index definition constructor.
* @param props the properties of the OpenSearch index definition.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/definitions/index.ts#L198-L198 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchVectorIndexDefinition.indexName | indexName() {
return (this.props.indexName);
} | /**
* @returns the name of the index.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/definitions/index.ts#L203-L205 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchVectorIndexDefinition.knnMethod | knnMethod() {
return (this.props.knnMethod);
} | /**
* @returns the k-NN method.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/definitions/index.ts#L210-L212 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchVectorIndexDefinition.knnEngine | knnEngine() {
return (this.props.knnEngine);
} | /**
* @returns the k-NN engine.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/definitions/index.ts#L217-L219 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchVectorIndexDefinition.spaceType | spaceType() {
return (this.props.spaceType);
} | /**
* @returns the space type.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/definitions/index.ts#L224-L226 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchVectorIndexDefinition.dimensions | dimensions() {
return (this.props.dimensions);
} | /**
* @returns the vector dimensions.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/definitions/index.ts#L231-L233 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchVectorIndexDefinition.efSearch | efSearch() {
return (this.props.efSearch);
} | /**
* @returns the size of the dynamic list used during k-NN searches.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/definitions/index.ts#L238-L240 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchVectorIndexDefinition.parameters | parameters() {
return (this.props.parameters);
} | /**
* @returns the parameters.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/definitions/index.ts#L245-L247 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | OpenSearchVectorIndexDefinition.from | public static from(data: any) {
return (new OpenSearchVectorIndexDefinition(OpenSearchVectorIndexDefinitionPropsSchema.parse(data)));
} | /**
* @returns a new OpenSearch index definition.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/definitions/index.ts#L252-L254 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Lambda.getId | private getId(event: CloudEvent) {
const metadata = event.data().metadata();
const docId = event.data().document().id();
// If there is a chunk identifier that specifically
// identifies a chunk associated with the given document,
// we use a combination between the identifier of the
// document and the chunk identifier.
if (metadata.properties?.kind === 'text'
&& metadata.properties.attrs?.chunk) {
return (`${docId}-${metadata.properties.attrs.chunk.id}`);
}
return (docId);
} | /**
* @param event the event associated with the
* received document.
* @returns a unique identifier for the given
* document that is fit to identify the vectors
* associated with the document.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/lambdas/processor/index.ts#L80-L94 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Lambda.getEmbeddings | private getEmbeddings(event: CloudEvent): Promise<number[]> {
const metadata = event.data().metadata();
if (!metadata.properties?.attrs.embeddings) {
throw new Error('The event does not contain embeddings.');
}
return (metadata.properties.attrs.embeddings.vectors.resolve());
} | /**
* @param event the event associated with the
* received document.
* @returns a vector embedding object associated
* with the document.
* @throws if the vector embedding object could not
* be resolved.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/lambdas/processor/index.ts#L104-L111 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
project-lakechain | github_2023 | awslabs | typescript | Lambda.getDocument | private async getDocument(event: CloudEvent): Promise<string | Buffer> {
const metadata = event.data().metadata();
const buffer = await event.data()
.document()
.data()
.asBuffer();
if (metadata.properties?.kind === 'text') {
return (buffer.toString('utf-8'));
} else {
return (buffer);
}
} | /**
* A helper returning a representation of the document
* to include within the index.
* @param event the event associated with the
* received document.
* @returns a string or buffer representation of the
* document.
*/ | https://github.com/awslabs/project-lakechain/blob/4285173e80584eedfc1a8424d3d1b6c1a7038088/packages/middlewares/storage-connectors/opensearch-vector-storage-connector/src/lambdas/processor/index.ts#L121-L133 | 4285173e80584eedfc1a8424d3d1b6c1a7038088 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.