/** * @return the id of the {@link RevObject} this Node points to */ public ObjectId getObjectId() { return ObjectId.create(objectId_h1, objectId_h2, objectId_h3); }
/** * Get the name of this object. * * @return unique hash of this object. */ public final ObjectId getId() { return ObjectId.create(h1, h2, h3); }
public @Override ObjectId getObjectId() { return ObjectId.create(bucketTreeH1, bucketTreeH2, bucketTreeH3); }
public ObjectId id() { return ObjectId.create(h1, h2, h3); }
public ObjectId getObjectId(final int offset) { // duplicate() instead of mark()/reset() to preserve thread safety ByteBuffer raw = this.raw.duplicate(); raw.position(offset); int h1 = raw.getInt(); long h2 = raw.getLong(); long h3 = raw.getLong(); return ObjectId.create(h1, h2, h3); }
private static ObjectId hash(Consumer<PrimitiveSink> funnel) { final Hasher hasher = ObjectId.HASH_FUNCTION.newHasher(); funnel.accept(hasher); final byte[] rawKey = hasher.hash().asBytes(); final ObjectId id = ObjectId.create(rawKey); return id; } }
public static ObjectId readFrom(DataInput in) throws IOException { int h1 = in.readInt(); long h2 = in.readLong(); long h3 = in.readLong(); return create(h1, h2, h3); }
public static ObjectId hashValue(@Nullable Object value) { final Hasher hasher = ObjectId.HASH_FUNCTION.newHasher(); PropertyValueFunnel.funnel(value, hasher); final byte[] rawKey = hasher.hash().asBytes(); final ObjectId id = ObjectId.create(rawKey); return id; }
public static ObjectId hashTag(@NonNull String name, @NonNull ObjectId commitId, @NonNull String message, @NonNull RevPerson tagger) { final Hasher hasher = ObjectId.HASH_FUNCTION.newHasher(); HashObjectFunnels.tag(hasher, name, commitId, message, tagger); return ObjectId.create(hasher.hash().asBytes()); }
public static ObjectId hashFeature(@NonNull List<Object> values) { final Hasher hasher = ObjectId.HASH_FUNCTION.newHasher(); HashObjectFunnels.feature(hasher, values); return ObjectId.create(hasher.hash().asBytes()); }
public static ObjectId hashTree(@Nullable List<Node> trees, @Nullable List<Node> features, @Nullable Iterable<Bucket> buckets) { final Hasher hasher = ObjectId.HASH_FUNCTION.newHasher(); trees = trees == null ? ImmutableList.of() : trees; features = features == null ? ImmutableList.of() : features; buckets = buckets == null ? Collections.emptySet() : buckets; HashObjectFunnels.tree(hasher, trees, features, buckets); final byte[] rawKey = hasher.hash().asBytes(); final ObjectId id = ObjectId.create(rawKey); return id; }
@Deprecated public static ObjectId hashTree(@Nullable List<Node> trees, @Nullable List<Node> features, @Nullable SortedMap<Integer, Bucket> buckets) { final Hasher hasher = ObjectId.HASH_FUNCTION.newHasher(); trees = trees == null ? ImmutableList.of() : trees; features = features == null ? ImmutableList.of() : features; buckets = buckets == null ? ImmutableSortedMap.of() : buckets; HashObjectFunnels.tree(hasher, trees, features, buckets.values()); final byte[] rawKey = hasher.hash().asBytes(); final ObjectId id = ObjectId.create(rawKey); return id; }
public static ObjectId hashCommit(@NonNull ObjectId treeId, @NonNull List<ObjectId> parentIds, @NonNull RevPerson author, @NonNull RevPerson committer, @NonNull String commitMessage) { final Hasher hasher = ObjectId.HASH_FUNCTION.newHasher(); HashObjectFunnels.commit(hasher, treeId, parentIds, author, committer, commitMessage); return ObjectId.create(hasher.hash().asBytes()); }
public static ObjectId hashFeatureType(@NonNull FeatureType featureType) { final Hasher hasher = ObjectId.HASH_FUNCTION.newHasher(); HashObjectFunnels.featureType(hasher, featureType); return ObjectId.create(hasher.hash().asBytes()); }
public static ObjectId getIndexId(String treeName, String attributeName) { final Hasher hasher = ObjectId.HASH_FUNCTION.newHasher(); hasher.putBytes(treeName.getBytes(Charsets.UTF_8)); hasher.putBytes(attributeName.getBytes(Charsets.UTF_8)); return ObjectId.create(hasher.hash().asBytes()); }
private static ObjectId hashString(final String strToHash) { Preconditions.checkNotNull(strToHash); HashCode hashCode = ObjectId.HASH_FUNCTION.hashString(strToHash, Charset.forName("UTF-8")); return ObjectId.create(hashCode.asBytes()); } }
public static ObjectId toId(@NonNull SHA id) { return ObjectId.create(id.h1(), id.h2(), id.h3()); }
@Override public Optional<ObjectId> resolveIndexedTree(IndexInfo index, ObjectId treeId) { byte[] indexTreeLookupId = computeIndexTreeLookupId(index.getId(), treeId); byte[] indexTreeBytes; try (RocksDBReference dbRef = dbhandle.getReference()) { indexTreeBytes = dbRef.db().get(indexMappingsColumn, indexTreeLookupId); } catch (RocksDBException e) { throw new RuntimeException(e); } if (indexTreeBytes != null) { return Optional.of(ObjectId.create(indexTreeBytes)); } return Optional.absent(); }
private RevTree createLeafTree(int i) { final int numNodes = 512; List<Node> nodes = IntStream.range(0, numNodes).mapToObj(this::createNode) .collect(Collectors.toList()); ObjectId id = ObjectId.create(i, i * i, i * i * i); RevTree tree = objectFactory.createTree(id, numNodes, Collections.emptyList(), ImmutableList.copyOf(nodes)); return tree; }