Browse Source
The standard Google distribution of Protocol Buffers in Java is better maintained than TinyProtobuf, and should be faster for most uses. It does use slightly more memory due to many of our key types being stored as strings in protobuf messages, but this is probably worth the small hit to memory in exchange for better maintained code that is easier to reuse in other applications. Exposing all of our data members to the underlying implementation makes it easier to develop reporting and data mining tools, or to expand out a nested structure like RefData into a flat format in a SQL database table. Since the C++ `protoc` tool is necessary to convert the protobuf script into Java code, the generated files are committed as part of the source repository to make it easier for developers who do not have this tool installed to still build the overall JGit package and make use of it. Reviewers will need to be careful to ensure that any edits made to a *.proto file come in a commit that also updates the generated code to match. CQ: 5135 Change-Id: I53e11e82c186b9cf0d7b368e0276519e6a0b2893 Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>stable-1.0
Shawn O. Pearce
14 years ago
committed by
Chris Aniszczyk
58 changed files with 12217 additions and 2406 deletions
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<classpath> |
||||
<classpathentry kind="src" path="src"/> |
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> |
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> |
||||
<classpathentry kind="output" path="bin"/> |
||||
</classpath> |
@ -0,0 +1,2 @@
|
||||
/bin |
||||
/target |
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<projectDescription> |
||||
<name>org.eclipse.jgit.generated.storage.dht.proto</name> |
||||
<comment></comment> |
||||
<projects> |
||||
</projects> |
||||
<buildSpec> |
||||
<buildCommand> |
||||
<name>org.eclipse.jdt.core.javabuilder</name> |
||||
<arguments> |
||||
</arguments> |
||||
</buildCommand> |
||||
<buildCommand> |
||||
<name>org.eclipse.pde.ManifestBuilder</name> |
||||
<arguments> |
||||
</arguments> |
||||
</buildCommand> |
||||
<buildCommand> |
||||
<name>org.eclipse.pde.SchemaBuilder</name> |
||||
<arguments> |
||||
</arguments> |
||||
</buildCommand> |
||||
</buildSpec> |
||||
<natures> |
||||
<nature>org.eclipse.jdt.core.javanature</nature> |
||||
<nature>org.eclipse.pde.PluginNature</nature> |
||||
</natures> |
||||
</projectDescription> |
@ -0,0 +1,3 @@
|
||||
#Mon Aug 11 16:46:12 PDT 2008 |
||||
eclipse.preferences.version=1 |
||||
encoding/<project>=UTF-8 |
@ -0,0 +1,3 @@
|
||||
#Mon Mar 24 18:55:50 EDT 2008 |
||||
eclipse.preferences.version=1 |
||||
line.separator=\n |
@ -0,0 +1,349 @@
|
||||
#Thu May 05 16:40:25 PDT 2011 |
||||
eclipse.preferences.version=1 |
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled |
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 |
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=optimize out |
||||
org.eclipse.jdt.core.compiler.compliance=1.5 |
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=do not generate |
||||
org.eclipse.jdt.core.compiler.debug.localVariable=do not generate |
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=do not generate |
||||
org.eclipse.jdt.core.compiler.doc.comment.support=disabled |
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=ignore |
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error |
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore |
||||
org.eclipse.jdt.core.compiler.problem.comparingIdentical=ignore |
||||
org.eclipse.jdt.core.compiler.problem.deadCode=ignore |
||||
org.eclipse.jdt.core.compiler.problem.deprecation=ignore |
||||
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled |
||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled |
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore |
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore |
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error |
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore |
||||
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled |
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore |
||||
org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore |
||||
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=ignore |
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore |
||||
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=ignore |
||||
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=ignore |
||||
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore |
||||
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore |
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadoc=error |
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled |
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled |
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled |
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private |
||||
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore |
||||
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=ignore |
||||
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore |
||||
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore |
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=error |
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled |
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected |
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag |
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTags=error |
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled |
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private |
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore |
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled |
||||
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore |
||||
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore |
||||
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=ignore |
||||
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=ignore |
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore |
||||
org.eclipse.jdt.core.compiler.problem.nullReference=ignore |
||||
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=ignore |
||||
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore |
||||
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore |
||||
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore |
||||
org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore |
||||
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore |
||||
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore |
||||
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled |
||||
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=ignore |
||||
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled |
||||
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled |
||||
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore |
||||
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=ignore |
||||
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore |
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore |
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore |
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore |
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore |
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore |
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore |
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled |
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled |
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled |
||||
org.eclipse.jdt.core.compiler.problem.unusedImport=ignore |
||||
org.eclipse.jdt.core.compiler.problem.unusedLabel=ignore |
||||
org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore |
||||
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore |
||||
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore |
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled |
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled |
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled |
||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore |
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=ignore |
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=ignore |
||||
org.eclipse.jdt.core.compiler.source=1.5 |
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false |
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 |
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 |
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 |
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 |
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 |
||||
org.eclipse.jdt.core.formatter.alignment_for_assignment=0 |
||||
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 |
||||
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 |
||||
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 |
||||
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 |
||||
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 |
||||
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 |
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 |
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 |
||||
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 |
||||
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 |
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 |
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 |
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 |
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 |
||||
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 |
||||
org.eclipse.jdt.core.formatter.blank_lines_after_package=1 |
||||
org.eclipse.jdt.core.formatter.blank_lines_before_field=1 |
||||
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 |
||||
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 |
||||
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 |
||||
org.eclipse.jdt.core.formatter.blank_lines_before_method=1 |
||||
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 |
||||
org.eclipse.jdt.core.formatter.blank_lines_before_package=0 |
||||
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 |
||||
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 |
||||
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line |
||||
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line |
||||
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line |
||||
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line |
||||
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line |
||||
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line |
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line |
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line |
||||
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line |
||||
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line |
||||
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line |
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines=false |
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false |
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false |
||||
org.eclipse.jdt.core.formatter.comment.format_block_comments=true |
||||
org.eclipse.jdt.core.formatter.comment.format_comments=true |
||||
org.eclipse.jdt.core.formatter.comment.format_header=false |
||||
org.eclipse.jdt.core.formatter.comment.format_html=true |
||||
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true |
||||
org.eclipse.jdt.core.formatter.comment.format_line_comments=true |
||||
org.eclipse.jdt.core.formatter.comment.format_source_code=true |
||||
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true |
||||
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true |
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert |
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert |
||||
org.eclipse.jdt.core.formatter.comment.line_length=80 |
||||
org.eclipse.jdt.core.formatter.compact_else_if=true |
||||
org.eclipse.jdt.core.formatter.continuation_indentation=2 |
||||
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 |
||||
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false |
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true |
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true |
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true |
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true |
||||
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true |
||||
org.eclipse.jdt.core.formatter.indent_empty_lines=false |
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true |
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true |
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true |
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false |
||||
org.eclipse.jdt.core.formatter.indentation.size=4 |
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert |
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert |
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert |
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert |
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert |
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert |
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert |
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert |
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert |
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert |
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert |
||||
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false |
||||
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false |
||||
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false |
||||
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false |
||||
org.eclipse.jdt.core.formatter.lineSplit=80 |
||||
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false |
||||
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false |
||||
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 |
||||
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 |
||||
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true |
||||
org.eclipse.jdt.core.formatter.tabulation.char=tab |
||||
org.eclipse.jdt.core.formatter.tabulation.size=4 |
||||
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false |
||||
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true |
@ -0,0 +1,62 @@
|
||||
#Thu Aug 26 12:30:58 CDT 2010 |
||||
eclipse.preferences.version=1 |
||||
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true |
||||
formatter_profile=_JGit Format |
||||
formatter_settings_version=11 |
||||
org.eclipse.jdt.ui.ignorelowercasenames=true |
||||
org.eclipse.jdt.ui.importorder=java;javax;org;com; |
||||
org.eclipse.jdt.ui.ondemandthreshold=99 |
||||
org.eclipse.jdt.ui.staticondemandthreshold=99 |
||||
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates/> |
||||
sp_cleanup.add_default_serial_version_id=true |
||||
sp_cleanup.add_generated_serial_version_id=false |
||||
sp_cleanup.add_missing_annotations=false |
||||
sp_cleanup.add_missing_deprecated_annotations=true |
||||
sp_cleanup.add_missing_methods=false |
||||
sp_cleanup.add_missing_nls_tags=false |
||||
sp_cleanup.add_missing_override_annotations=true |
||||
sp_cleanup.add_missing_override_annotations_interface_methods=false |
||||
sp_cleanup.add_serial_version_id=false |
||||
sp_cleanup.always_use_blocks=true |
||||
sp_cleanup.always_use_parentheses_in_expressions=false |
||||
sp_cleanup.always_use_this_for_non_static_field_access=false |
||||
sp_cleanup.always_use_this_for_non_static_method_access=false |
||||
sp_cleanup.convert_to_enhanced_for_loop=false |
||||
sp_cleanup.correct_indentation=false |
||||
sp_cleanup.format_source_code=true |
||||
sp_cleanup.format_source_code_changes_only=true |
||||
sp_cleanup.make_local_variable_final=false |
||||
sp_cleanup.make_parameters_final=false |
||||
sp_cleanup.make_private_fields_final=true |
||||
sp_cleanup.make_type_abstract_if_missing_method=false |
||||
sp_cleanup.make_variable_declarations_final=false |
||||
sp_cleanup.never_use_blocks=false |
||||
sp_cleanup.never_use_parentheses_in_expressions=true |
||||
sp_cleanup.on_save_use_additional_actions=true |
||||
sp_cleanup.organize_imports=false |
||||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false |
||||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true |
||||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true |
||||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=false |
||||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false |
||||
sp_cleanup.remove_private_constructors=true |
||||
sp_cleanup.remove_trailing_whitespaces=true |
||||
sp_cleanup.remove_trailing_whitespaces_all=true |
||||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false |
||||
sp_cleanup.remove_unnecessary_casts=false |
||||
sp_cleanup.remove_unnecessary_nls_tags=false |
||||
sp_cleanup.remove_unused_imports=false |
||||
sp_cleanup.remove_unused_local_variables=false |
||||
sp_cleanup.remove_unused_private_fields=true |
||||
sp_cleanup.remove_unused_private_members=false |
||||
sp_cleanup.remove_unused_private_methods=true |
||||
sp_cleanup.remove_unused_private_types=true |
||||
sp_cleanup.sort_members=false |
||||
sp_cleanup.sort_members_all=false |
||||
sp_cleanup.use_blocks=false |
||||
sp_cleanup.use_blocks_only_for_return_and_throw=false |
||||
sp_cleanup.use_parentheses_in_expressions=false |
||||
sp_cleanup.use_this_for_non_static_field_access=false |
||||
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true |
||||
sp_cleanup.use_this_for_non_static_method_access=false |
||||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true |
@ -0,0 +1,11 @@
|
||||
Manifest-Version: 1.0 |
||||
Bundle-ManifestVersion: 2 |
||||
Bundle-Name: %plugin_name |
||||
Bundle-SymbolicName: org.eclipse.jgit.generated.storage.dht.proto |
||||
Bundle-Version: 1.0.0.qualifier |
||||
Bundle-Localization: plugin |
||||
Bundle-Vendor: %provider_name |
||||
Bundle-ActivationPolicy: lazy |
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5 |
||||
Export-Package: org.eclipse.jgit.generated.storage.dht.proto;version="1.0.0" |
||||
Import-Package: com.google.protobuf;version="[2.4.0,2.5.0)" |
@ -0,0 +1,5 @@
|
||||
source.. = src/ |
||||
output.. = bin/ |
||||
bin.includes = META-INF/,\ |
||||
.,\ |
||||
plugin.properties |
@ -0,0 +1,11 @@
|
||||
#!/bin/sh |
||||
# |
||||
# Update generated Java code from protocol buffer descriptions. |
||||
|
||||
set -e |
||||
|
||||
for proto in resources/org/eclipse/jgit/storage/dht/*.proto |
||||
do |
||||
echo >&2 Generating from $proto |
||||
protoc -Iresources --java_out=src $proto |
||||
done |
@ -0,0 +1,2 @@
|
||||
plugin_name=JGit DHT Storage Protocol Buffer Messages (Incubation) |
||||
provider_name=Eclipse.org |
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- |
||||
Copyright (C) 2011, Google Inc. |
||||
and other copyright owners as documented in the project's IP log. |
||||
|
||||
This program and the accompanying materials are made available |
||||
under the terms of the Eclipse Distribution License v1.0 which |
||||
accompanies this distribution, is reproduced below, and is |
||||
available at http://www.eclipse.org/org/documents/edl-v10.php |
||||
|
||||
All rights reserved. |
||||
|
||||
Redistribution and use in source and binary forms, with or |
||||
without modification, are permitted provided that the following |
||||
conditions are met: |
||||
|
||||
- Redistributions of source code must retain the above copyright |
||||
notice, this list of conditions and the following disclaimer. |
||||
|
||||
- Redistributions in binary form must reproduce the above |
||||
copyright notice, this list of conditions and the following |
||||
disclaimer in the documentation and/or other materials provided |
||||
with the distribution. |
||||
|
||||
- Neither the name of the Eclipse Foundation, Inc. nor the |
||||
names of its contributors may be used to endorse or promote |
||||
products derived from this software without specific prior |
||||
written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
--> |
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<parent> |
||||
<groupId>org.eclipse.jgit</groupId> |
||||
<artifactId>org.eclipse.jgit-parent</artifactId> |
||||
<version>1.0.0-SNAPSHOT</version> |
||||
</parent> |
||||
|
||||
<artifactId>org.eclipse.jgit.generated.storage.dht.proto</artifactId> |
||||
<name>JGit - DHT Storage Protocol Buffer Messages</name> |
||||
|
||||
<description> |
||||
Compiled protocol buffer messages for DHT storage |
||||
</description> |
||||
|
||||
<properties> |
||||
<translate-qualifier/> |
||||
</properties> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>com.google.protobuf</groupId> |
||||
<artifactId>protobuf-java</artifactId> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
<build> |
||||
<sourceDirectory>src/</sourceDirectory> |
||||
|
||||
<resources> |
||||
<resource> |
||||
<directory>.</directory> |
||||
<includes> |
||||
<include>plugin.properties</include> |
||||
</includes> |
||||
</resource> |
||||
<resource> |
||||
<directory>resources/</directory> |
||||
</resource> |
||||
</resources> |
||||
|
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.apache.maven.plugins</groupId> |
||||
<artifactId>maven-source-plugin</artifactId> |
||||
<inherited>true</inherited> |
||||
<executions> |
||||
<execution> |
||||
<id>attach-sources</id> |
||||
<phase>process-classes</phase> |
||||
<goals> |
||||
<goal>jar</goal> |
||||
</goals> |
||||
<configuration> |
||||
<archive> |
||||
<manifestFile>${source-bundle-manifest}</manifestFile> |
||||
</archive> |
||||
</configuration> |
||||
</execution> |
||||
</executions> |
||||
</plugin> |
||||
|
||||
<plugin> |
||||
<artifactId>maven-jar-plugin</artifactId> |
||||
<configuration> |
||||
<archive> |
||||
<manifestFile>${bundle-manifest}</manifestFile> |
||||
</archive> |
||||
</configuration> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
</project> |
@ -0,0 +1,86 @@
|
||||
// Copyright (C) 2011, Google Inc. |
||||
// and other copyright owners as documented in the project's IP log. |
||||
// |
||||
// This program and the accompanying materials are made available |
||||
// under the terms of the Eclipse Distribution License v1.0 which |
||||
// accompanies this distribution, is reproduced below, and is |
||||
// available at http://www.eclipse.org/org/documents/edl-v10.php |
||||
// |
||||
// All rights reserved. |
||||
// |
||||
// Redistribution and use in source and binary forms, with or |
||||
// without modification, are permitted provided that the following |
||||
// conditions are met: |
||||
// |
||||
// - Redistributions of source code must retain the above copyright |
||||
// notice, this list of conditions and the following disclaimer. |
||||
// |
||||
// - Redistributions in binary form must reproduce the above |
||||
// copyright notice, this list of conditions and the following |
||||
// disclaimer in the documentation and/or other materials provided |
||||
// with the distribution. |
||||
// |
||||
// - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
// names of its contributors may be used to endorse or promote |
||||
// products derived from this software without specific prior |
||||
// written permission. |
||||
// |
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
// CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||||
// |
||||
// WARNING: If you edit this file, run generate.sh |
||||
// |
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||||
|
||||
syntax = "proto2"; |
||||
|
||||
package org.eclipse.jgit.storage.dht; |
||||
option java_generate_equals_and_hash = true; |
||||
option java_package = "org.eclipse.jgit.generated.storage.dht.proto"; |
||||
|
||||
import "org/eclipse/jgit/storage/dht/git_store.proto"; |
||||
|
||||
|
||||
// Caches ObjectIndexTable in a single message. |
||||
// |
||||
message CachedObjectIndex { |
||||
message Item { |
||||
required string chunk_key = 1; |
||||
required ObjectInfo object_info = 2; |
||||
optional fixed64 time = 3; |
||||
} |
||||
repeated Item item = 1; |
||||
} |
||||
|
||||
|
||||
// Caches CachedPackInfo in a single message. |
||||
// |
||||
message CachedPackInfoList { |
||||
repeated CachedPackInfo pack = 1; |
||||
} |
||||
|
||||
|
||||
// Caches ChunkTable in a single message. |
||||
// |
||||
// WARNING: Formatters for this message are also hand-coded |
||||
// inside of the CacheChunkTable class. If you make changes |
||||
// to this message, ensure that class is also updated. |
||||
// |
||||
message CachedChunk { |
||||
required bytes data = 1; |
||||
optional bytes index = 2; |
||||
optional ChunkMeta meta = 3; |
||||
} |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,212 +0,0 @@
|
||||
/* |
||||
* Copyright (C) 2011, Google Inc. |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
|
||||
package org.eclipse.jgit.storage.dht; |
||||
|
||||
import static org.eclipse.jgit.lib.Constants.OBJECT_ID_STRING_LENGTH; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
import java.util.SortedSet; |
||||
import java.util.TreeSet; |
||||
|
||||
import org.eclipse.jgit.lib.ObjectId; |
||||
|
||||
/** |
||||
* Summary information about a cached pack owned by a repository. |
||||
*/ |
||||
public class CachedPackInfo { |
||||
/** |
||||
* Parse info from the storage system. |
||||
* |
||||
* @param raw |
||||
* the raw encoding of the info. |
||||
* @return the info object. |
||||
*/ |
||||
public static CachedPackInfo fromBytes(byte[] raw) { |
||||
return fromBytes(TinyProtobuf.decode(raw)); |
||||
} |
||||
|
||||
/** |
||||
* Parse info from the storage system. |
||||
* |
||||
* @param d |
||||
* decoder for the message buffer. |
||||
* @return the info object. |
||||
*/ |
||||
public static CachedPackInfo fromBytes(TinyProtobuf.Decoder d) { |
||||
CachedPackInfo info = new CachedPackInfo(); |
||||
PARSE: for (;;) { |
||||
switch (d.next()) { |
||||
case 0: |
||||
break PARSE; |
||||
case 1: |
||||
info.name = d.stringObjectId(); |
||||
continue; |
||||
case 2: |
||||
info.version = d.stringObjectId(); |
||||
continue; |
||||
case 3: |
||||
info.objectsTotal = d.int64(); |
||||
continue; |
||||
case 4: |
||||
info.objectsDelta = d.int64(); |
||||
continue; |
||||
case 5: |
||||
info.bytesTotal = d.int64(); |
||||
continue; |
||||
case 6: { |
||||
TinyProtobuf.Decoder m = d.message(); |
||||
for (;;) { |
||||
switch (m.next()) { |
||||
case 0: |
||||
continue PARSE; |
||||
case 1: |
||||
info.tips.add(m.stringObjectId()); |
||||
continue; |
||||
default: |
||||
m.skip(); |
||||
continue; |
||||
} |
||||
} |
||||
} |
||||
case 7: { |
||||
TinyProtobuf.Decoder m = d.message(); |
||||
for (;;) { |
||||
switch (m.next()) { |
||||
case 0: |
||||
continue PARSE; |
||||
case 1: |
||||
info.chunks.add(ChunkKey.fromBytes(m)); |
||||
continue; |
||||
default: |
||||
m.skip(); |
||||
continue; |
||||
} |
||||
} |
||||
} |
||||
default: |
||||
d.skip(); |
||||
continue; |
||||
} |
||||
} |
||||
return info; |
||||
} |
||||
|
||||
private static byte[] asBytes(CachedPackInfo info) { |
||||
int tipSize = (2 + OBJECT_ID_STRING_LENGTH) * info.tips.size(); |
||||
TinyProtobuf.Encoder tipList = TinyProtobuf.encode(tipSize); |
||||
for (ObjectId tip : info.tips) |
||||
tipList.string(1, tip); |
||||
|
||||
int chunkSize = (2 + ChunkKey.KEYLEN) * info.chunks.size(); |
||||
TinyProtobuf.Encoder chunkList = TinyProtobuf.encode(chunkSize); |
||||
for (ChunkKey key : info.chunks) |
||||
chunkList.bytes(1, key.asBytes()); |
||||
|
||||
TinyProtobuf.Encoder e = TinyProtobuf.encode(1024); |
||||
e.string(1, info.name); |
||||
e.string(2, info.version); |
||||
e.int64(3, info.objectsTotal); |
||||
e.int64IfNotZero(4, info.objectsDelta); |
||||
e.int64IfNotZero(5, info.bytesTotal); |
||||
e.message(6, tipList); |
||||
e.message(7, chunkList); |
||||
return e.asByteArray(); |
||||
} |
||||
|
||||
ObjectId name; |
||||
|
||||
ObjectId version; |
||||
|
||||
SortedSet<ObjectId> tips = new TreeSet<ObjectId>(); |
||||
|
||||
long objectsTotal; |
||||
|
||||
long objectsDelta; |
||||
|
||||
long bytesTotal; |
||||
|
||||
List<ChunkKey> chunks = new ArrayList<ChunkKey>(); |
||||
|
||||
/** @return name of the information object. */ |
||||
public CachedPackKey getRowKey() { |
||||
return new CachedPackKey(name, version); |
||||
} |
||||
|
||||
/** @return number of objects stored in the cached pack. */ |
||||
public long getObjectsTotal() { |
||||
return objectsTotal; |
||||
} |
||||
|
||||
/** @return number of objects stored in delta format. */ |
||||
public long getObjectsDelta() { |
||||
return objectsDelta; |
||||
} |
||||
|
||||
/** @return number of bytes in the cached pack. */ |
||||
public long getTotalBytes() { |
||||
return bytesTotal; |
||||
} |
||||
|
||||
/** @return list of all chunks that make up this pack, in order. */ |
||||
public List<ChunkKey> getChunkKeys() { |
||||
return Collections.unmodifiableList(chunks); |
||||
} |
||||
|
||||
/** |
||||
* Convert this information into a byte array for storage. |
||||
* |
||||
* @return the data, encoded as a byte array. This does not include the key, |
||||
* callers must store that separately. |
||||
*/ |
||||
public byte[] asBytes() { |
||||
return asBytes(this); |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return getRowKey().toString(); |
||||
} |
||||
} |
@ -1,391 +0,0 @@
|
||||
/* |
||||
* Copyright (C) 2011, Google Inc. |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
|
||||
package org.eclipse.jgit.storage.dht; |
||||
|
||||
import java.text.MessageFormat; |
||||
import java.util.ArrayList; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
/** Metadata stored inline with each PackChunk. */ |
||||
public class ChunkMeta { |
||||
/** |
||||
* Convert from byte array. |
||||
* |
||||
* @param key |
||||
* the chunk key this meta object sits in. |
||||
* @param raw |
||||
* the raw byte array. |
||||
* @return the chunk meta. |
||||
*/ |
||||
public static ChunkMeta fromBytes(ChunkKey key, byte[] raw) { |
||||
return fromBytes(key, TinyProtobuf.decode(raw)); |
||||
} |
||||
|
||||
/** |
||||
* Convert from byte array. |
||||
* |
||||
* @param key |
||||
* the chunk key this meta object sits in. |
||||
* @param d |
||||
* the message decoder. |
||||
* @return the chunk meta. |
||||
*/ |
||||
public static ChunkMeta fromBytes(ChunkKey key, TinyProtobuf.Decoder d) { |
||||
List<BaseChunk> baseChunk = null; |
||||
List<ChunkKey> fragment = null; |
||||
PrefetchHint commit = null; |
||||
PrefetchHint tree = null; |
||||
|
||||
PARSE: for (;;) { |
||||
switch (d.next()) { |
||||
case 0: |
||||
break PARSE; |
||||
case 1: |
||||
if (baseChunk == null) |
||||
baseChunk = new ArrayList<BaseChunk>(4); |
||||
baseChunk.add(BaseChunk.fromBytes(d.message())); |
||||
continue; |
||||
case 2: |
||||
if (fragment == null) |
||||
fragment = new ArrayList<ChunkKey>(4); |
||||
fragment.add(ChunkKey.fromBytes(d)); |
||||
continue; |
||||
case 51: |
||||
commit = PrefetchHint.fromBytes(d.message()); |
||||
continue; |
||||
case 52: |
||||
tree = PrefetchHint.fromBytes(d.message()); |
||||
continue; |
||||
default: |
||||
d.skip(); |
||||
continue; |
||||
} |
||||
} |
||||
|
||||
return new ChunkMeta(key, baseChunk, fragment, commit, tree); |
||||
} |
||||
|
||||
private final ChunkKey chunkKey; |
||||
|
||||
List<BaseChunk> baseChunks; |
||||
|
||||
List<ChunkKey> fragments; |
||||
|
||||
PrefetchHint commitPrefetch; |
||||
|
||||
PrefetchHint treePrefetch; |
||||
|
||||
ChunkMeta(ChunkKey key) { |
||||
this(key, null, null, null, null); |
||||
} |
||||
|
||||
ChunkMeta(ChunkKey chunkKey, List<BaseChunk> baseChunk, |
||||
List<ChunkKey> fragment, PrefetchHint commit, PrefetchHint tree) { |
||||
this.chunkKey = chunkKey; |
||||
this.baseChunks = baseChunk; |
||||
this.fragments = fragment; |
||||
this.commitPrefetch = commit; |
||||
this.treePrefetch = tree; |
||||
} |
||||
|
||||
/** @return key of the chunk this meta information is for. */ |
||||
public ChunkKey getChunkKey() { |
||||
return chunkKey; |
||||
} |
||||
|
||||
BaseChunk getBaseChunk(long position) throws DhtException { |
||||
// Chunks are sorted by ascending relative_start order.
|
||||
// Thus for a pack sequence of: A B C, we have:
|
||||
//
|
||||
// -- C relative_start = 10,000
|
||||
// -- B relative_start = 20,000
|
||||
// -- A relative_start = 30,000
|
||||
//
|
||||
// Indicating that chunk C starts 10,000 bytes before us,
|
||||
// chunk B starts 20,000 bytes before us (and 10,000 before C),
|
||||
// chunk A starts 30,000 bytes before us (and 10,000 before B),
|
||||
//
|
||||
// If position falls within:
|
||||
//
|
||||
// -- C (10k), then position is between 0..10,000
|
||||
// -- B (20k), then position is between 10,000 .. 20,000
|
||||
// -- A (30k), then position is between 20,000 .. 30,000
|
||||
|
||||
int high = baseChunks.size(); |
||||
int low = 0; |
||||
while (low < high) { |
||||
final int mid = (low + high) >>> 1; |
||||
final BaseChunk base = baseChunks.get(mid); |
||||
|
||||
if (position > base.relativeStart) { |
||||
low = mid + 1; |
||||
|
||||
} else if (mid == 0 || position == base.relativeStart) { |
||||
return base; |
||||
|
||||
} else if (baseChunks.get(mid - 1).relativeStart < position) { |
||||
return base; |
||||
|
||||
} else { |
||||
high = mid; |
||||
} |
||||
} |
||||
|
||||
throw new DhtException(MessageFormat.format( |
||||
DhtText.get().missingLongOffsetBase, chunkKey, |
||||
Long.valueOf(position))); |
||||
} |
||||
|
||||
/** @return number of fragment chunks that make up the object. */ |
||||
public int getFragmentCount() { |
||||
return fragments != null ? fragments.size() : 0; |
||||
} |
||||
|
||||
/** |
||||
* Get the nth fragment key. |
||||
* |
||||
* @param nth |
||||
* @return the key. |
||||
*/ |
||||
public ChunkKey getFragmentKey(int nth) { |
||||
return fragments.get(nth); |
||||
} |
||||
|
||||
/** |
||||
* Find the key of the fragment that occurs after this chunk. |
||||
* |
||||
* @param currentKey |
||||
* the current chunk key. |
||||
* @return next chunk after this; null if there isn't one. |
||||
*/ |
||||
public ChunkKey getNextFragment(ChunkKey currentKey) { |
||||
for (int i = 0; i < fragments.size() - 1; i++) { |
||||
if (fragments.get(i).equals(currentKey)) |
||||
return fragments.get(i + 1); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** @return chunks to visit. */ |
||||
public PrefetchHint getCommitPrefetch() { |
||||
return commitPrefetch; |
||||
} |
||||
|
||||
/** @return chunks to visit. */ |
||||
public PrefetchHint getTreePrefetch() { |
||||
return treePrefetch; |
||||
} |
||||
|
||||
/** @return true if there is no data in this object worth storing. */ |
||||
boolean isEmpty() { |
||||
if (baseChunks != null && !baseChunks.isEmpty()) |
||||
return false; |
||||
if (fragments != null && !fragments.isEmpty()) |
||||
return false; |
||||
if (commitPrefetch != null && !commitPrefetch.isEmpty()) |
||||
return false; |
||||
if (treePrefetch != null && !treePrefetch.isEmpty()) |
||||
return false; |
||||
return true; |
||||
} |
||||
|
||||
/** @return format as byte array for storage. */ |
||||
public byte[] asBytes() { |
||||
TinyProtobuf.Encoder e = TinyProtobuf.encode(256); |
||||
|
||||
if (baseChunks != null) { |
||||
for (BaseChunk base : baseChunks) |
||||
e.message(1, base.asBytes()); |
||||
} |
||||
|
||||
if (fragments != null) { |
||||
for (ChunkKey key : fragments) |
||||
e.bytes(2, key.asBytes()); |
||||
} |
||||
|
||||
if (commitPrefetch != null) |
||||
e.message(51, commitPrefetch.asBytes()); |
||||
if (treePrefetch != null) |
||||
e.message(52, treePrefetch.asBytes()); |
||||
|
||||
return e.asByteArray(); |
||||
} |
||||
|
||||
/** Describes other chunks that contain the bases for this chunk's deltas. */ |
||||
public static class BaseChunk { |
||||
final long relativeStart; |
||||
|
||||
private final ChunkKey chunk; |
||||
|
||||
BaseChunk(long relativeStart, ChunkKey chunk) { |
||||
this.relativeStart = relativeStart; |
||||
this.chunk = chunk; |
||||
} |
||||
|
||||
/** @return bytes backward from current chunk to start of base chunk. */ |
||||
public long getRelativeStart() { |
||||
return relativeStart; |
||||
} |
||||
|
||||
/** @return unique key of this chunk. */ |
||||
public ChunkKey getChunkKey() { |
||||
return chunk; |
||||
} |
||||
|
||||
TinyProtobuf.Encoder asBytes() { |
||||
int max = 11 + 2 + ChunkKey.KEYLEN; |
||||
TinyProtobuf.Encoder e = TinyProtobuf.encode(max); |
||||
e.int64(1, relativeStart); |
||||
e.bytes(2, chunk.asBytes()); |
||||
return e; |
||||
} |
||||
|
||||
static BaseChunk fromBytes(TinyProtobuf.Decoder d) { |
||||
long relativeStart = -1; |
||||
ChunkKey chunk = null; |
||||
|
||||
PARSE: for (;;) { |
||||
switch (d.next()) { |
||||
case 0: |
||||
break PARSE; |
||||
case 1: |
||||
relativeStart = d.int64(); |
||||
continue; |
||||
case 2: |
||||
chunk = ChunkKey.fromBytes(d); |
||||
continue; |
||||
default: |
||||
d.skip(); |
||||
continue; |
||||
} |
||||
} |
||||
|
||||
return new BaseChunk(relativeStart, chunk); |
||||
} |
||||
} |
||||
|
||||
/** Describes the prefetching for a particular object type. */ |
||||
public static class PrefetchHint { |
||||
private final List<ChunkKey> edge; |
||||
|
||||
private final List<ChunkKey> sequential; |
||||
|
||||
PrefetchHint(List<ChunkKey> edge, List<ChunkKey> sequential) { |
||||
if (edge == null) |
||||
edge = Collections.emptyList(); |
||||
else |
||||
edge = Collections.unmodifiableList(edge); |
||||
|
||||
if (sequential == null) |
||||
sequential = Collections.emptyList(); |
||||
else |
||||
sequential = Collections.unmodifiableList(sequential); |
||||
|
||||
this.edge = edge; |
||||
this.sequential = sequential; |
||||
} |
||||
|
||||
/** @return chunks on the edge of this chunk. */ |
||||
public List<ChunkKey> getEdge() { |
||||
return edge; |
||||
} |
||||
|
||||
/** @return chunks according to sequential ordering. */ |
||||
public List<ChunkKey> getSequential() { |
||||
return sequential; |
||||
} |
||||
|
||||
boolean isEmpty() { |
||||
return edge.isEmpty() && sequential.isEmpty(); |
||||
} |
||||
|
||||
TinyProtobuf.Encoder asBytes() { |
||||
int max = 0; |
||||
|
||||
max += (2 + ChunkKey.KEYLEN) * edge.size(); |
||||
max += (2 + ChunkKey.KEYLEN) * sequential.size(); |
||||
|
||||
TinyProtobuf.Encoder e = TinyProtobuf.encode(max); |
||||
for (ChunkKey key : edge) |
||||
e.bytes(1, key.asBytes()); |
||||
for (ChunkKey key : sequential) |
||||
e.bytes(2, key.asBytes()); |
||||
return e; |
||||
} |
||||
|
||||
static PrefetchHint fromBytes(TinyProtobuf.Decoder d) { |
||||
ArrayList<ChunkKey> edge = null; |
||||
ArrayList<ChunkKey> sequential = null; |
||||
|
||||
PARSE: for (;;) { |
||||
switch (d.next()) { |
||||
case 0: |
||||
break PARSE; |
||||
case 1: |
||||
if (edge == null) |
||||
edge = new ArrayList<ChunkKey>(16); |
||||
edge.add(ChunkKey.fromBytes(d)); |
||||
continue; |
||||
case 2: |
||||
if (sequential == null) |
||||
sequential = new ArrayList<ChunkKey>(16); |
||||
sequential.add(ChunkKey.fromBytes(d)); |
||||
continue; |
||||
default: |
||||
d.skip(); |
||||
continue; |
||||
} |
||||
} |
||||
|
||||
if (edge != null) |
||||
edge.trimToSize(); |
||||
|
||||
if (sequential != null) |
||||
sequential.trimToSize(); |
||||
|
||||
return new PrefetchHint(edge, sequential); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,111 @@
|
||||
/* |
||||
* Copyright (C) 2011, Google Inc. |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
|
||||
package org.eclipse.jgit.storage.dht; |
||||
|
||||
import java.text.MessageFormat; |
||||
import java.util.List; |
||||
|
||||
import org.eclipse.jgit.generated.storage.dht.proto.GitStore.ChunkMeta; |
||||
import org.eclipse.jgit.generated.storage.dht.proto.GitStore.ChunkMeta.BaseChunk; |
||||
|
||||
class ChunkMetaUtil { |
||||
static BaseChunk getBaseChunk(ChunkKey chunkKey, ChunkMeta meta, |
||||
long position) throws DhtException { |
||||
// Chunks are sorted by ascending relative_start order.
|
||||
// Thus for a pack sequence of: A B C, we have:
|
||||
//
|
||||
// -- C relative_start = 10,000
|
||||
// -- B relative_start = 20,000
|
||||
// -- A relative_start = 30,000
|
||||
//
|
||||
// Indicating that chunk C starts 10,000 bytes before us,
|
||||
// chunk B starts 20,000 bytes before us (and 10,000 before C),
|
||||
// chunk A starts 30,000 bytes before us (and 10,000 before B),
|
||||
//
|
||||
// If position falls within:
|
||||
//
|
||||
// -- C (10k), then position is between 0..10,000
|
||||
// -- B (20k), then position is between 10,000 .. 20,000
|
||||
// -- A (30k), then position is between 20,000 .. 30,000
|
||||
|
||||
List<BaseChunk> baseChunks = meta.getBaseChunkList(); |
||||
int high = baseChunks.size(); |
||||
int low = 0; |
||||
while (low < high) { |
||||
final int mid = (low + high) >>> 1; |
||||
final BaseChunk base = baseChunks.get(mid); |
||||
|
||||
if (position > base.getRelativeStart()) { |
||||
low = mid + 1; |
||||
|
||||
} else if (mid == 0 || position == base.getRelativeStart()) { |
||||
return base; |
||||
|
||||
} else if (baseChunks.get(mid - 1).getRelativeStart() < position) { |
||||
return base; |
||||
|
||||
} else { |
||||
high = mid; |
||||
} |
||||
} |
||||
|
||||
throw new DhtException(MessageFormat.format( |
||||
DhtText.get().missingLongOffsetBase, chunkKey, |
||||
Long.valueOf(position))); |
||||
} |
||||
|
||||
static ChunkKey getNextFragment(ChunkMeta meta, ChunkKey chunkKey) { |
||||
int cnt = meta.getFragmentCount(); |
||||
for (int i = 0; i < cnt - 1; i++) { |
||||
ChunkKey key = ChunkKey.fromString(meta.getFragment(i)); |
||||
if (chunkKey.equals(key)) |
||||
return ChunkKey.fromString(meta.getFragment(i + 1)); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
private ChunkMetaUtil() { |
||||
// Static utilities only, do not create instances.
|
||||
} |
||||
} |
@ -1,235 +0,0 @@
|
||||
/* |
||||
* Copyright (C) 2011, Google Inc. |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
|
||||
package org.eclipse.jgit.storage.dht; |
||||
|
||||
import static org.eclipse.jgit.lib.Constants.OBJECT_ID_STRING_LENGTH; |
||||
import static org.eclipse.jgit.storage.dht.TinyProtobuf.encode; |
||||
|
||||
import java.util.Arrays; |
||||
|
||||
import org.eclipse.jgit.lib.AnyObjectId; |
||||
import org.eclipse.jgit.lib.ObjectId; |
||||
import org.eclipse.jgit.lib.Ref; |
||||
import org.eclipse.jgit.storage.dht.TinyProtobuf.Encoder; |
||||
|
||||
/** |
||||
* Describes the current state of a Git reference. |
||||
* <p> |
||||
* The reference state contains not just the SHA-1 object name that a reference |
||||
* points to, but the state also caches its peeled value if its a tag, and the |
||||
* {@link ChunkKey} the object was observed in when the reference was last |
||||
* updated. This cached data reduces latency when initially starting to work |
||||
* with a repository. |
||||
*/ |
||||
public class RefData { |
||||
/** Magic constant meaning does not exist. */ |
||||
public static final RefData NONE = new RefData(new byte[0]); |
||||
|
||||
static final int TAG_SYMREF = 1; |
||||
|
||||
static final int TAG_TARGET = 2; |
||||
|
||||
static final int TAG_IS_PEELED = 3; |
||||
|
||||
static final int TAG_PEELED = 4; |
||||
|
||||
/** |
||||
* @param data |
||||
* @return the content |
||||
*/ |
||||
public static RefData fromBytes(byte[] data) { |
||||
return new RefData(data); |
||||
} |
||||
|
||||
static RefData symbolic(String target) { |
||||
Encoder e = encode(2 + target.length()); |
||||
e.string(TAG_SYMREF, target); |
||||
return new RefData(e.asByteArray()); |
||||
} |
||||
|
||||
static RefData id(AnyObjectId id) { |
||||
Encoder e = encode(4 + OBJECT_ID_STRING_LENGTH + ChunkKey.KEYLEN); |
||||
e.message(TAG_TARGET, IdWithChunk.encode(id)); |
||||
return new RefData(e.asByteArray()); |
||||
} |
||||
|
||||
static RefData fromRef(Ref ref) { |
||||
if (ref.isSymbolic()) |
||||
return symbolic(ref.getTarget().getName()); |
||||
|
||||
if (ref.getObjectId() == null) |
||||
return RefData.NONE; |
||||
|
||||
int max = 8 + 2 * OBJECT_ID_STRING_LENGTH + 2 * ChunkKey.KEYLEN; |
||||
Encoder e = encode(max); |
||||
e.message(TAG_TARGET, IdWithChunk.encode(ref.getObjectId())); |
||||
if (ref.isPeeled()) { |
||||
e.bool(TAG_IS_PEELED, true); |
||||
if (ref.getPeeledObjectId() != null) |
||||
e.message(TAG_PEELED, |
||||
IdWithChunk.encode(ref.getPeeledObjectId())); |
||||
} |
||||
return new RefData(e.asByteArray()); |
||||
} |
||||
|
||||
static RefData peeled(ObjectId targetId, ObjectId peeledId) { |
||||
int max = 8 + 2 * OBJECT_ID_STRING_LENGTH + 2 * ChunkKey.KEYLEN; |
||||
Encoder e = encode(max); |
||||
e.message(TAG_TARGET, IdWithChunk.encode(targetId)); |
||||
e.bool(TAG_IS_PEELED, true); |
||||
if (peeledId != null) |
||||
e.message(TAG_PEELED, IdWithChunk.encode(peeledId)); |
||||
return new RefData(e.asByteArray()); |
||||
} |
||||
|
||||
private final byte[] data; |
||||
|
||||
RefData(byte[] data) { |
||||
this.data = data; |
||||
} |
||||
|
||||
TinyProtobuf.Decoder decode() { |
||||
return TinyProtobuf.decode(data); |
||||
} |
||||
|
||||
/** @return the contents, encoded as a byte array for storage. */ |
||||
public byte[] asBytes() { |
||||
return data; |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
int hash = 5381; |
||||
for (int ptr = 0; ptr < data.length; ptr++) |
||||
hash = ((hash << 5) + hash) + (data[ptr] & 0xff); |
||||
return hash; |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object other) { |
||||
if (other instanceof RefData) |
||||
return Arrays.equals(data, ((RefData) other).data); |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
StringBuilder b = new StringBuilder(); |
||||
TinyProtobuf.Decoder d = decode(); |
||||
for (;;) { |
||||
switch (d.next()) { |
||||
case 0: |
||||
return b.toString().substring(1); |
||||
case TAG_SYMREF: |
||||
b.append("\nsymref: ").append(d.string()); |
||||
continue; |
||||
case TAG_TARGET: |
||||
b.append("\ntarget: ").append(IdWithChunk.decode(d.message())); |
||||
continue; |
||||
case TAG_IS_PEELED: |
||||
b.append("\nis_peeled: ").append(d.bool()); |
||||
continue; |
||||
case TAG_PEELED: |
||||
b.append("\npeeled: ").append(IdWithChunk.decode(d.message())); |
||||
continue; |
||||
default: |
||||
d.skip(); |
||||
continue; |
||||
} |
||||
} |
||||
} |
||||
|
||||
static class IdWithChunk extends ObjectId { |
||||
static ObjectId decode(TinyProtobuf.Decoder d) { |
||||
ObjectId id = null; |
||||
ChunkKey key = null; |
||||
DECODE: for (;;) { |
||||
switch (d.next()) { |
||||
case 0: |
||||
break DECODE; |
||||
case 1: |
||||
id = d.stringObjectId(); |
||||
continue; |
||||
case 2: |
||||
key = ChunkKey.fromBytes(d); |
||||
continue; |
||||
default: |
||||
d.skip(); |
||||
} |
||||
} |
||||
return key != null ? new IdWithChunk(id, key) : id; |
||||
} |
||||
|
||||
static TinyProtobuf.Encoder encode(AnyObjectId id) { |
||||
if (id instanceof IdWithChunk) { |
||||
int max = 4 + OBJECT_ID_STRING_LENGTH + ChunkKey.KEYLEN; |
||||
TinyProtobuf.Encoder e = TinyProtobuf.encode(max); |
||||
e.string(1, id); |
||||
e.string(2, ((IdWithChunk) id).chunkKey); |
||||
return e; |
||||
} else { |
||||
int max = 2 + OBJECT_ID_STRING_LENGTH; |
||||
TinyProtobuf.Encoder e = TinyProtobuf.encode(max); |
||||
e.string(1, id); |
||||
return e; |
||||
} |
||||
} |
||||
|
||||
private final ChunkKey chunkKey; |
||||
|
||||
IdWithChunk(AnyObjectId id, ChunkKey key) { |
||||
super(id); |
||||
this.chunkKey = key; |
||||
} |
||||
|
||||
ChunkKey getChunkKey() { |
||||
return chunkKey; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return name() + "->" + chunkKey; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,132 @@
|
||||
/* |
||||
* Copyright (C) 2011, Google Inc. |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
|
||||
package org.eclipse.jgit.storage.dht; |
||||
|
||||
import org.eclipse.jgit.generated.storage.dht.proto.GitStore.RefData; |
||||
import org.eclipse.jgit.lib.AnyObjectId; |
||||
import org.eclipse.jgit.lib.ObjectId; |
||||
import org.eclipse.jgit.lib.Ref; |
||||
|
||||
/** Tools to work with {@link RefData}. */ |
||||
public class RefDataUtil { |
||||
/** Magic constant meaning does not exist. */ |
||||
public static final RefData NONE = RefData.newBuilder().build(); |
||||
|
||||
static RefData symbolic(String target) { |
||||
RefData.Builder b = RefData.newBuilder(); |
||||
b.setSymref(target); |
||||
return b.build(); |
||||
} |
||||
|
||||
static RefData id(AnyObjectId id) { |
||||
RefData.Builder b = RefData.newBuilder(); |
||||
b.setTarget(toRefData(id)); |
||||
return b.build(); |
||||
} |
||||
|
||||
static RefData fromRef(Ref ref) { |
||||
if (ref.isSymbolic()) |
||||
return symbolic(ref.getTarget().getName()); |
||||
|
||||
if (ref.getObjectId() == null) |
||||
return NONE; |
||||
|
||||
RefData.Builder b = RefData.newBuilder(); |
||||
b.setTarget(toRefData(ref.getObjectId())); |
||||
if (ref.isPeeled()) { |
||||
b.setIsPeeled(true); |
||||
if (ref.getPeeledObjectId() != null) |
||||
b.setPeeled(toRefData(ref.getPeeledObjectId())); |
||||
} |
||||
return b.build(); |
||||
} |
||||
|
||||
static RefData peeled(ObjectId targetId, ObjectId peeledId) { |
||||
RefData.Builder b = RefData.newBuilder(); |
||||
b.setTarget(toRefData(targetId)); |
||||
b.setIsPeeled(true); |
||||
if (peeledId != null) |
||||
b.setPeeled(toRefData(peeledId)); |
||||
return b.build(); |
||||
} |
||||
|
||||
private static RefData.Id toRefData(AnyObjectId id) { |
||||
RefData.Id.Builder r = RefData.Id.newBuilder(); |
||||
r.setObjectName(id.name()); |
||||
if (id instanceof IdWithChunk) |
||||
r.setChunkKey(((IdWithChunk) id).getChunkKey().asString()); |
||||
return r.build(); |
||||
} |
||||
|
||||
static class IdWithChunk extends ObjectId { |
||||
static ObjectId create(RefData.Id src) { |
||||
if (src.hasChunkKey()) { |
||||
return new IdWithChunk( |
||||
ObjectId.fromString(src.getObjectName()), |
||||
ChunkKey.fromString(src.getChunkKey())); |
||||
} |
||||
return ObjectId.fromString(src.getObjectName()); |
||||
} |
||||
|
||||
private final ChunkKey chunkKey; |
||||
|
||||
IdWithChunk(AnyObjectId id, ChunkKey key) { |
||||
super(id); |
||||
this.chunkKey = key; |
||||
} |
||||
|
||||
ChunkKey getChunkKey() { |
||||
return chunkKey; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return name() + "->" + chunkKey; |
||||
} |
||||
} |
||||
|
||||
private RefDataUtil() { |
||||
// Utility class, do not create instances.
|
||||
} |
||||
} |
@ -1,755 +0,0 @@
|
||||
/* |
||||
* Copyright (C) 2011, Google Inc. |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
|
||||
package org.eclipse.jgit.storage.dht; |
||||
|
||||
import static org.eclipse.jgit.lib.Constants.OBJECT_ID_LENGTH; |
||||
import static org.eclipse.jgit.lib.Constants.OBJECT_ID_STRING_LENGTH; |
||||
|
||||
import java.nio.ByteBuffer; |
||||
import java.text.MessageFormat; |
||||
|
||||
import org.eclipse.jgit.lib.AnyObjectId; |
||||
import org.eclipse.jgit.lib.Constants; |
||||
import org.eclipse.jgit.lib.ObjectId; |
||||
import org.eclipse.jgit.util.RawParseUtils; |
||||
|
||||
/** |
||||
* A tiny implementation of a subset of the Google Protocol Buffers format. |
||||
* <p> |
||||
* For more information on the network format, see the canonical documentation |
||||
* at <a href="http://code.google.com/p/protobuf/">Google Protocol Buffers</a>. |
||||
*/ |
||||
public class TinyProtobuf { |
||||
private static final int WIRE_VARINT = 0; |
||||
|
||||
private static final int WIRE_FIXED_64 = 1; |
||||
|
||||
private static final int WIRE_LEN_DELIM = 2; |
||||
|
||||
private static final int WIRE_FIXED_32 = 5; |
||||
|
||||
/** |
||||
* Create a new encoder. |
||||
* |
||||
* @param estimatedSize |
||||
* estimated size of the message. If the size is accurate, |
||||
* copying of the result can be avoided during |
||||
* {@link Encoder#asByteArray()}. If the size is too small, the |
||||
* buffer will grow dynamically. |
||||
* @return a new encoder. |
||||
*/ |
||||
public static Encoder encode(int estimatedSize) { |
||||
return new Encoder(new byte[estimatedSize]); |
||||
} |
||||
|
||||
/** |
||||
* Create an encoder that estimates size. |
||||
* |
||||
* @return a new encoder. |
||||
*/ |
||||
public static Encoder size() { |
||||
return new Encoder(null); |
||||
} |
||||
|
||||
/** |
||||
* Decode a buffer. |
||||
* |
||||
* @param buf |
||||
* the buffer to read. |
||||
* @return a new decoder. |
||||
*/ |
||||
public static Decoder decode(byte[] buf) { |
||||
return decode(buf, 0, buf.length); |
||||
} |
||||
|
||||
/** |
||||
* Decode a buffer. |
||||
* |
||||
* @param buf |
||||
* the buffer to read. |
||||
* @param off |
||||
* offset to begin reading from {@code buf}. |
||||
* @param len |
||||
* total number of bytes to read from {@code buf}. |
||||
* @return a new decoder. |
||||
*/ |
||||
public static Decoder decode(byte[] buf, int off, int len) { |
||||
return new Decoder(buf, off, len); |
||||
} |
||||
|
||||
/** An enumerated value that encodes/decodes as int32. */ |
||||
public static interface Enum { |
||||
/** @return the wire value. */ |
||||
public int value(); |
||||
} |
||||
|
||||
/** Decode fields from a binary protocol buffer. */ |
||||
public static class Decoder { |
||||
private final byte[] buf; |
||||
|
||||
private final int end; |
||||
|
||||
private int ptr; |
||||
|
||||
private int field; |
||||
|
||||
private int type; |
||||
|
||||
private int length; |
||||
|
||||
private Decoder(byte[] buf, int off, int len) { |
||||
this.buf = buf; |
||||
this.ptr = off; |
||||
this.end = off + len; |
||||
} |
||||
|
||||
/** @return get the field tag number, 0 on end of buffer. */ |
||||
public int next() { |
||||
if (ptr == end) |
||||
return 0; |
||||
|
||||
int fieldAndType = varint32(); |
||||
field = fieldAndType >>> 3; |
||||
type = fieldAndType & 7; |
||||
return field; |
||||
} |
||||
|
||||
/** Skip the current field's value. */ |
||||
public void skip() { |
||||
switch (type) { |
||||
case WIRE_VARINT: |
||||
varint64(); |
||||
break; |
||||
case WIRE_FIXED_64: |
||||
ptr += 8; |
||||
break; |
||||
case WIRE_LEN_DELIM: |
||||
ptr += varint32(); |
||||
break; |
||||
case WIRE_FIXED_32: |
||||
ptr += 4; |
||||
break; |
||||
default: |
||||
throw new IllegalStateException(MessageFormat.format(DhtText |
||||
.get().protobufUnsupportedFieldType, Integer |
||||
.valueOf(type))); |
||||
} |
||||
} |
||||
|
||||
/** @return decode the current field as an int32. */ |
||||
public int int32() { |
||||
checkFieldType(WIRE_VARINT); |
||||
return varint32(); |
||||
} |
||||
|
||||
/** @return decode the current field as an int64. */ |
||||
public long int64() { |
||||
checkFieldType(WIRE_VARINT); |
||||
return varint64(); |
||||
} |
||||
|
||||
/** |
||||
* @param <T> |
||||
* the type of enumeration. |
||||
* @param all |
||||
* all of the supported values. |
||||
* @return decode the current field as an enumerated value. |
||||
*/ |
||||
public <T extends Enum> T intEnum(T[] all) { |
||||
checkFieldType(WIRE_VARINT); |
||||
int value = varint32(); |
||||
for (T t : all) { |
||||
if (t.value() == value) |
||||
return t; |
||||
} |
||||
throw new IllegalStateException(MessageFormat.format( |
||||
DhtText.get().protobufWrongFieldType, Integer |
||||
.valueOf(field), Integer.valueOf(type), all[0] |
||||
.getClass().getSimpleName())); |
||||
} |
||||
|
||||
/** @return decode the current field as a bool. */ |
||||
public boolean bool() { |
||||
checkFieldType(WIRE_VARINT); |
||||
int val = varint32(); |
||||
switch (val) { |
||||
case 0: |
||||
return false; |
||||
case 1: |
||||
return true; |
||||
default: |
||||
throw new IllegalStateException(MessageFormat.format(DhtText |
||||
.get().protobufNotBooleanValue, Integer.valueOf(field), |
||||
Integer.valueOf(val))); |
||||
} |
||||
} |
||||
|
||||
/** @return decode a fixed 64 bit value. */ |
||||
public long fixed64() { |
||||
checkFieldType(WIRE_FIXED_64); |
||||
long val = buf[ptr + 0] & 0xff; |
||||
val |= ((long) (buf[ptr + 1] & 0xff)) << (1 * 8); |
||||
val |= ((long) (buf[ptr + 2] & 0xff)) << (2 * 8); |
||||
val |= ((long) (buf[ptr + 3] & 0xff)) << (3 * 8); |
||||
val |= ((long) (buf[ptr + 4] & 0xff)) << (4 * 8); |
||||
val |= ((long) (buf[ptr + 5] & 0xff)) << (5 * 8); |
||||
val |= ((long) (buf[ptr + 6] & 0xff)) << (6 * 8); |
||||
val |= ((long) (buf[ptr + 7] & 0xff)) << (7 * 8); |
||||
ptr += 8; |
||||
return val; |
||||
} |
||||
|
||||
/** @return decode the current field as a string. */ |
||||
public String string() { |
||||
checkFieldType(WIRE_LEN_DELIM); |
||||
int len = varint32(); |
||||
String s = RawParseUtils.decode(buf, ptr, ptr + len); |
||||
ptr += len; |
||||
return s; |
||||
} |
||||
|
||||
/** @return decode the current hex string to an ObjectId. */ |
||||
public ObjectId stringObjectId() { |
||||
checkFieldType(WIRE_LEN_DELIM); |
||||
int len = varint32(); |
||||
if (len != OBJECT_ID_STRING_LENGTH) |
||||
throw new IllegalStateException(MessageFormat.format(DhtText |
||||
.get().protobufWrongFieldLength, |
||||
Integer.valueOf(field), Integer |
||||
.valueOf(OBJECT_ID_STRING_LENGTH), Integer |
||||
.valueOf(len))); |
||||
|
||||
ObjectId id = ObjectId.fromString(buf, ptr); |
||||
ptr += OBJECT_ID_STRING_LENGTH; |
||||
return id; |
||||
} |
||||
|
||||
/** @return decode a string from 8 hex digits. */ |
||||
public int stringHex32() { |
||||
checkFieldType(WIRE_LEN_DELIM); |
||||
int len = varint32(); |
||||
if (len != 8) |
||||
throw new IllegalStateException(MessageFormat.format(DhtText |
||||
.get().protobufWrongFieldLength, |
||||
Integer.valueOf(field), Integer.valueOf(8), Integer |
||||
.valueOf(len))); |
||||
int val = KeyUtils.parse32(buf, ptr); |
||||
ptr += 8; |
||||
return val; |
||||
} |
||||
|
||||
/** @return decode the current field as an array of bytes. */ |
||||
public byte[] bytes() { |
||||
checkFieldType(WIRE_LEN_DELIM); |
||||
byte[] r = new byte[varint32()]; |
||||
System.arraycopy(buf, ptr, r, 0, r.length); |
||||
ptr += r.length; |
||||
return r; |
||||
} |
||||
|
||||
/** @return backing array of the current field. */ |
||||
public byte[] bytesArray() { |
||||
return buf; |
||||
} |
||||
|
||||
/** @return length of field, call before {@link #bytesOffset}. */ |
||||
public int bytesLength() { |
||||
checkFieldType(WIRE_LEN_DELIM); |
||||
length = varint32(); |
||||
return length; |
||||
} |
||||
|
||||
/** @return starting offset of the field, after {@link #bytesLength()}. */ |
||||
public int bytesOffset() { |
||||
int start = ptr; |
||||
ptr += length; |
||||
return start; |
||||
} |
||||
|
||||
/** @return decode the current raw bytes to an ObjectId. */ |
||||
public ObjectId bytesObjectId() { |
||||
checkFieldType(WIRE_LEN_DELIM); |
||||
int len = varint32(); |
||||
if (len != OBJECT_ID_LENGTH) |
||||
throw new IllegalStateException(MessageFormat.format(DhtText |
||||
.get().protobufWrongFieldLength, |
||||
Integer.valueOf(field), Integer |
||||
.valueOf(OBJECT_ID_LENGTH), Integer |
||||
.valueOf(len))); |
||||
|
||||
ObjectId id = ObjectId.fromRaw(buf, ptr); |
||||
ptr += OBJECT_ID_LENGTH; |
||||
return id; |
||||
} |
||||
|
||||
/** @return decode the current field as a nested message. */ |
||||
public Decoder message() { |
||||
checkFieldType(WIRE_LEN_DELIM); |
||||
int len = varint32(); |
||||
Decoder msg = decode(buf, ptr, len); |
||||
ptr += len; |
||||
return msg; |
||||
} |
||||
|
||||
private int varint32() { |
||||
long v = varint64(); |
||||
if (Integer.MAX_VALUE < v) |
||||
throw new IllegalStateException(MessageFormat.format(DhtText |
||||
.get().protobufWrongFieldType, Integer.valueOf(field), |
||||
"int64", "int32")); |
||||
return (int) v; |
||||
} |
||||
|
||||
private long varint64() { |
||||
int c = buf[ptr++]; |
||||
long r = c & 0x7f; |
||||
int shift = 7; |
||||
while ((c & 0x80) != 0) { |
||||
c = buf[ptr++]; |
||||
r |= ((long) (c & 0x7f)) << shift; |
||||
shift += 7; |
||||
} |
||||
return r; |
||||
} |
||||
|
||||
private void checkFieldType(int expected) { |
||||
if (type != expected) |
||||
throw new IllegalStateException(MessageFormat.format(DhtText |
||||
.get().protobufWrongFieldType, Integer.valueOf(field), |
||||
Integer.valueOf(type), Integer.valueOf(expected))); |
||||
} |
||||
} |
||||
|
||||
/** Encode values into a binary protocol buffer. */ |
||||
public static class Encoder { |
||||
private byte[] buf; |
||||
|
||||
private int ptr; |
||||
|
||||
private Encoder(byte[] buf) { |
||||
this.buf = buf; |
||||
} |
||||
|
||||
/** |
||||
* Encode a variable length positive integer. |
||||
* |
||||
* @param field |
||||
* field tag number. |
||||
* @param value |
||||
* the value to store. Must be >= 0. |
||||
*/ |
||||
public void int32(int field, int value) { |
||||
int64(field, value); |
||||
} |
||||
|
||||
/** |
||||
* Encode a variable length positive integer. |
||||
* |
||||
* @param field |
||||
* field tag number. |
||||
* @param value |
||||
* the value to store; omitted if 0. |
||||
*/ |
||||
public void int32IfNotZero(int field, int value) { |
||||
int64IfNotZero(field, value); |
||||
} |
||||
|
||||
/** |
||||
* Encode a variable length positive integer. |
||||
* |
||||
* @param field |
||||
* field tag number. |
||||
* @param value |
||||
* the value to store; omitted if negative. |
||||
*/ |
||||
public void int32IfNotNegative(int field, int value) { |
||||
int64IfNotNegative(field, value); |
||||
} |
||||
|
||||
/** |
||||
* Encode a variable length positive integer. |
||||
* |
||||
* @param field |
||||
* field tag number. |
||||
* @param value |
||||
* the value to store. Must be >= 0. |
||||
*/ |
||||
public void int64(int field, long value) { |
||||
if (value < 0) |
||||
throw new IllegalArgumentException( |
||||
DhtText.get().protobufNegativeValuesNotSupported); |
||||
|
||||
field(field, WIRE_VARINT); |
||||
varint(value); |
||||
} |
||||
|
||||
/** |
||||
* Encode a variable length positive integer. |
||||
* |
||||
* @param field |
||||
* field tag number. |
||||
* @param value |
||||
* the value to store; omitted if 0. |
||||
*/ |
||||
public void int64IfNotZero(int field, long value) { |
||||
if (0 != value) |
||||
int64(field, value); |
||||
} |
||||
|
||||
/** |
||||
* Encode a variable length positive integer. |
||||
* |
||||
* @param field |
||||
* field tag number. |
||||
* @param value |
||||
* the value to store; omitted if negative. |
||||
*/ |
||||
public void int64IfNotNegative(int field, long value) { |
||||
if (0 <= value) |
||||
int64(field, value); |
||||
} |
||||
|
||||
/** |
||||
* Encode an enumerated value. |
||||
* |
||||
* @param <T> |
||||
* type of the enumerated values. |
||||
* @param field |
||||
* field tag number. |
||||
* @param value |
||||
* value to store; if null the field is omitted. |
||||
*/ |
||||
public <T extends Enum> void intEnum(int field, T value) { |
||||
if (value != null) { |
||||
field(field, WIRE_VARINT); |
||||
varint(value.value()); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Encode a boolean value. |
||||
* |
||||
* @param field |
||||
* field tag number. |
||||
* @param value |
||||
* the value to store. |
||||
*/ |
||||
public void bool(int field, boolean value) { |
||||
field(field, WIRE_VARINT); |
||||
varint(value ? 1 : 0); |
||||
} |
||||
|
||||
/** |
||||
* Encode a boolean value, only if true. |
||||
* |
||||
* @param field |
||||
* field tag number. |
||||
* @param value |
||||
* the value to store. |
||||
*/ |
||||
public void boolIfTrue(int field, boolean value) { |
||||
if (value) |
||||
bool(field, value); |
||||
} |
||||
|
||||
/** |
||||
* Encode a fixed 64 value. |
||||
* |
||||
* @param field |
||||
* field tag number. |
||||
* @param value |
||||
* the value to store. |
||||
*/ |
||||
public void fixed64(int field, long value) { |
||||
field(field, WIRE_FIXED_64); |
||||
if (buf != null) { |
||||
ensureSpace(8); |
||||
|
||||
buf[ptr + 0] = (byte) value; |
||||
value >>>= 8; |
||||
|
||||
buf[ptr + 1] = (byte) value; |
||||
value >>>= 8; |
||||
|
||||
buf[ptr + 3] = (byte) value; |
||||
value >>>= 8; |
||||
|
||||
buf[ptr + 3] = (byte) value; |
||||
value >>>= 8; |
||||
|
||||
buf[ptr + 4] = (byte) value; |
||||
value >>>= 8; |
||||
|
||||
buf[ptr + 5] = (byte) value; |
||||
value >>>= 8; |
||||
|
||||
buf[ptr + 6] = (byte) value; |
||||
value >>>= 8; |
||||
|
||||
buf[ptr + 7] = (byte) value; |
||||
} |
||||
ptr += 8; |
||||
} |
||||
|
||||
/** |
||||
* Encode a length delimited bytes field. |
||||
* |
||||
* @param field |
||||
* field tag number. |
||||
* @param value |
||||
* the value to store; if null the field is omitted. |
||||
*/ |
||||
public void bytes(int field, byte[] value) { |
||||
if (value != null) |
||||
bytes(field, value, 0, value.length); |
||||
} |
||||
|
||||
/** |
||||
* Encode a length delimited bytes field. |
||||
* |
||||
* @param field |
||||
* field tag number. |
||||
* @param value |
||||
* the value to store; if null the field is omitted. |
||||
*/ |
||||
public void bytes(int field, ByteBuffer value) { |
||||
if (value != null) { |
||||
if (!value.hasArray()) |
||||
throw new IllegalArgumentException(DhtText.get().protobufNoArray); |
||||
byte[] valBuf = value.array(); |
||||
int valPtr = value.arrayOffset() + value.position(); |
||||
int valLen = value.limit() - value.position(); |
||||
bytes(field, valBuf, valPtr, valLen); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Encode a length delimited bytes field. |
||||
* |
||||
* @param field |
||||
* field tag number. |
||||
* @param value |
||||
* the value to store; if null the field is omitted. |
||||
* @param off |
||||
* position to copy from. |
||||
* @param len |
||||
* number of bytes to copy. |
||||
*/ |
||||
public void bytes(int field, byte[] value, int off, int len) { |
||||
if (value != null) { |
||||
field(field, WIRE_LEN_DELIM); |
||||
varint(len); |
||||
copy(value, off, len); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Encode an ObjectId as a bytes (in raw binary format). |
||||
* |
||||
* @param field |
||||
* field tag number. |
||||
* @param value |
||||
* the value to store, as a raw binary; if null the field is |
||||
* omitted. |
||||
*/ |
||||
public void bytes(int field, AnyObjectId value) { |
||||
if (value != null) { |
||||
field(field, WIRE_LEN_DELIM); |
||||
varint(OBJECT_ID_LENGTH); |
||||
if (buf != null) { |
||||
ensureSpace(OBJECT_ID_LENGTH); |
||||
value.copyRawTo(buf, ptr); |
||||
} |
||||
ptr += OBJECT_ID_LENGTH; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Encode an ObjectId as a string (in hex format). |
||||
* |
||||
* @param field |
||||
* field tag number. |
||||
* @param value |
||||
* the value to store, as a hex string; if null the field is |
||||
* omitted. |
||||
*/ |
||||
public void string(int field, AnyObjectId value) { |
||||
if (value != null) { |
||||
field(field, WIRE_LEN_DELIM); |
||||
varint(OBJECT_ID_STRING_LENGTH); |
||||
if (buf != null) { |
||||
ensureSpace(OBJECT_ID_STRING_LENGTH); |
||||
value.copyTo(buf, ptr); |
||||
} |
||||
ptr += OBJECT_ID_STRING_LENGTH; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Encode a plain Java string. |
||||
* |
||||
* @param field |
||||
* field tag number. |
||||
* @param value |
||||
* the value to store; if null the field is omitted. |
||||
*/ |
||||
public void string(int field, String value) { |
||||
if (value != null) |
||||
bytes(field, Constants.encode(value)); |
||||
} |
||||
|
||||
/** |
||||
* Encode a row key as a string. |
||||
* |
||||
* @param field |
||||
* field tag number. |
||||
* @param key |
||||
* the row key to store as a string; if null the field is |
||||
* omitted. |
||||
*/ |
||||
public void string(int field, RowKey key) { |
||||
if (key != null) |
||||
bytes(field, key.asBytes()); |
||||
} |
||||
|
||||
/** |
||||
* Encode an integer as an 8 byte hex string. |
||||
* |
||||
* @param field |
||||
* field tag number. |
||||
* @param value |
||||
* value to encode. |
||||
*/ |
||||
public void stringHex32(int field, int value) { |
||||
field(field, WIRE_LEN_DELIM); |
||||
varint(8); |
||||
if (buf != null) { |
||||
ensureSpace(8); |
||||
KeyUtils.format32(buf, ptr, value); |
||||
} |
||||
ptr += 8; |
||||
} |
||||
|
||||
/** |
||||
* Encode a nested message. |
||||
* |
||||
* @param field |
||||
* field tag number. |
||||
* @param msg |
||||
* message to store; if null or empty the field is omitted. |
||||
*/ |
||||
public void message(int field, Encoder msg) { |
||||
if (msg != null && msg.ptr > 0) |
||||
bytes(field, msg.buf, 0, msg.ptr); |
||||
} |
||||
|
||||
private void field(int field, int type) { |
||||
varint((field << 3) | type); |
||||
} |
||||
|
||||
private void varint(long value) { |
||||
if (buf != null) { |
||||
if (buf.length - ptr < 10) |
||||
ensureSpace(varintSize(value)); |
||||
|
||||
do { |
||||
byte b = (byte) (value & 0x7f); |
||||
value >>>= 7; |
||||
if (value != 0) |
||||
b |= 0x80; |
||||
buf[ptr++] = b; |
||||
} while (value != 0); |
||||
} else { |
||||
ptr += varintSize(value); |
||||
} |
||||
} |
||||
|
||||
private static int varintSize(long value) { |
||||
value >>>= 7; |
||||
int need = 1; |
||||
for (; value != 0; value >>>= 7) |
||||
need++; |
||||
return need; |
||||
} |
||||
|
||||
private void copy(byte[] src, int off, int cnt) { |
||||
if (buf != null) { |
||||
ensureSpace(cnt); |
||||
System.arraycopy(src, off, buf, ptr, cnt); |
||||
} |
||||
ptr += cnt; |
||||
} |
||||
|
||||
private void ensureSpace(int need) { |
||||
if (buf.length - ptr < need) { |
||||
byte[] n = new byte[Math.max(ptr + need, buf.length * 2)]; |
||||
System.arraycopy(buf, 0, n, 0, ptr); |
||||
buf = n; |
||||
} |
||||
} |
||||
|
||||
/** @return size of the protocol buffer message, in bytes. */ |
||||
public int size() { |
||||
return ptr; |
||||
} |
||||
|
||||
/** @return the current buffer, as a byte array. */ |
||||
public byte[] asByteArray() { |
||||
if (ptr == buf.length) |
||||
return buf; |
||||
byte[] r = new byte[ptr]; |
||||
System.arraycopy(buf, 0, r, 0, ptr); |
||||
return r; |
||||
} |
||||
|
||||
/** @return the current buffer. */ |
||||
public ByteBuffer asByteBuffer() { |
||||
return ByteBuffer.wrap(buf, 0, ptr); |
||||
} |
||||
} |
||||
|
||||
private TinyProtobuf() { |
||||
// Don't make instances.
|
||||
} |
||||
} |
Loading…
Reference in new issue