Skip to content

Commit

Permalink
[ENH] Remove seq_id from protos, record and result types. Refactor ru…
Browse files Browse the repository at this point in the history
…st to use LogRecord / OperationRecord (#1935)

## Description of changes

*Summarize the changes made by this PR.*
 - Improvements & Bug fixes
- Remove the seq_id concept from our record and result types. This is
unused and not needed. The python segments still internally use this
though.
	 - Refactor rust to use LogRecord/OperationRecord
- Remove Segment Manager and Ingestor from rust, as well as other pulsar
based paraphenelia such as message_id. This resulted in the /ingest
module being removed altogether.
 - New functionality
	 - None

## Test plan
*How are these changes tested?*

- [ ] Tests pass locally with `pytest` for python, `yarn test` for js,
`cargo test` for rust

## Documentation Changes
*Are all docstrings for user-facing APIs updated if required? Do we need
to make documentation changes in the [docs
repository](https://github.com/chroma-core/docs)?*
  • Loading branch information
HammadB authored Mar 28, 2024
1 parent 1d77f99 commit 4da1a6c
Show file tree
Hide file tree
Showing 40 changed files with 398 additions and 984 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions chromadb/logservice/logservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ def push_logs(self, collection_id: UUID, records: Sequence[OperationRecord]) ->
return response.record_count # type: ignore

def pull_logs(
self, collection_id: UUID, start_id: int, batch_size: int
self, collection_id: UUID, start_offset: int, batch_size: int
) -> Sequence[LogRecord]:
request = PullLogsRequest(
collection_id=str(collection_id),
start_from_id=start_id,
start_from_offset=start_offset,
batch_size=batch_size,
end_timestamp=-1,
)
Expand Down
44 changes: 22 additions & 22 deletions chromadb/proto/chroma_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions chromadb/proto/chroma_pb2.pyi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 1 addition & 13 deletions chromadb/proto/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from typing import Dict, Optional, Tuple, Union, cast
from chromadb.api.types import Embedding
import chromadb.proto.chroma_pb2 as proto
from chromadb.utils.messageid import bytes_to_int, int_to_bytes
from chromadb.types import (
Collection,
LogRecord,
Expand Down Expand Up @@ -117,7 +116,7 @@ def from_proto_submit(
embedding, encoding = from_proto_vector(operation_record.vector)
record = LogRecord(
log_offset=seq_id,
operation_record=OperationRecord(
record=OperationRecord(
id=operation_record.id,
embedding=embedding,
encoding=encoding,
Expand Down Expand Up @@ -258,7 +257,6 @@ def from_proto_vector_embedding_record(
) -> VectorEmbeddingRecord:
return VectorEmbeddingRecord(
id=embedding_record.id,
seq_id=from_proto_seq_id(embedding_record.seq_id),
embedding=from_proto_vector(embedding_record.vector)[0],
)

Expand All @@ -269,7 +267,6 @@ def to_proto_vector_embedding_record(
) -> proto.VectorEmbeddingRecord:
return proto.VectorEmbeddingRecord(
id=embedding_record["id"],
seq_id=to_proto_seq_id(embedding_record["seq_id"]),
vector=to_proto_vector(embedding_record["embedding"], encoding),
)

Expand All @@ -279,15 +276,6 @@ def from_proto_vector_query_result(
) -> VectorQueryResult:
return VectorQueryResult(
id=vector_query_result.id,
seq_id=from_proto_seq_id(vector_query_result.seq_id),
distance=vector_query_result.distance,
embedding=from_proto_vector(vector_query_result.vector)[0],
)


def to_proto_seq_id(seq_id: SeqId) -> bytes:
return int_to_bytes(seq_id)


def from_proto_seq_id(seq_id: bytes) -> SeqId:
return bytes_to_int(seq_id)
28 changes: 14 additions & 14 deletions chromadb/proto/logservice_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4da1a6c

Please sign in to comment.