Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ordering keys in ingestion and serving #4

Merged
merged 2 commits into from
May 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
#
REGISTRY := gcr.io/pm-registry/feast
VERSION := v0.4.3-cassandra-experiment-2.22-notrace
VERSION := v0.4-cassandra-ordered-notrace
PROJECT_ROOT := $(shell git rev-parse --show-toplevel)

test:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
import feast.types.FieldProto.Field;
import java.io.Serializable;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
import org.apache.beam.sdk.coders.AvroCoder;
import org.apache.beam.sdk.coders.DefaultCoder;
Expand Down Expand Up @@ -86,20 +84,25 @@ public int getTtl() {
}

static String keyFromFeatureRow(FeatureSetSpec featureSetSpec, FeatureRow featureRow) {
Set<String> entityNames =
List<String> entityNames =
featureSetSpec.getEntitiesList().stream()
.map(EntitySpec::getName)
.collect(Collectors.toSet());
List<Field> entities = new ArrayList<>();
.collect(Collectors.toList());
Collections.sort(entityNames);
HashMap<String, Field> entities = new HashMap<>();
for (Field field : featureRow.getFieldsList()) {
if (entityNames.contains(field.getName())) {
entities.add(field);
entities.put(entityNames.get(entityNames.indexOf(field.getName())), field);
}
}
return featureRow.getFeatureSet()
+ ":"
+ entities.stream()
.map(f -> f.getName() + "=" + ValueUtil.toString(f.getValue()))
+ entityNames.stream()
.map(
f ->
entities.get(f).getName()
+ "="
+ ValueUtil.toString(entities.get(f).getValue()))
.collect(Collectors.joining("|"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import java.nio.ByteBuffer;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -303,6 +304,7 @@ private static String createCassandraKey(
String featureSet, List<String> featureSetEntityNames, EntityRow entityRow) {
Map<String, Value> fieldsMap = entityRow.getFieldsMap();
List<String> res = new ArrayList<>();
Collections.sort(featureSetEntityNames);
for (String entityName : featureSetEntityNames) {
res.add(entityName + "=" + ValueUtil.toString(fieldsMap.get(entityName)));
}
Expand Down