You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by Leif Hedstrom <zw...@apache.org> on 2014/08/09 03:39:16 UTC
Re: [1/6] git commit: TS-1800: Add new hash function base class
On Aug 8, 2014, at 4:08 PM, sorber@apache.org wrote:
> Repository: trafficserver
> Updated Branches:
> refs/heads/master 5c0bc7c94 -> 7fa5c5c7a
>
>
> TS-1800: Add new hash function base class
>
>
> Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
> Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/9e7ceddb
> Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/9e7ceddb
> Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/9e7ceddb
>
> Branch: refs/heads/master
This ode doesn’t look indented as per our coding standard :-/
— Leif
> Commit: 9e7ceddbad56370643ab514d9ad918d7740f3db8
> Parents: 5c0bc7c
> Author: Phil Sorber <so...@apache.org>
> Authored: Fri Aug 8 12:30:54 2014 -0600
> Committer: Phil Sorber <so...@apache.org>
> Committed: Fri Aug 8 15:26:02 2014 -0600
>
> ----------------------------------------------------------------------
> CHANGES | 2 ++
> lib/ts/Hash.cc | 48 ++++++++++++++++++++++++++++++++++++++++++++++
> lib/ts/Hash.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
> lib/ts/Makefile.am | 2 ++
> lib/ts/libts.h | 1 +
> 5 files changed, 104 insertions(+)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e7ceddb/CHANGES
> ----------------------------------------------------------------------
> diff --git a/CHANGES b/CHANGES
> index d8dd8bf..0050a2d 100644
> --- a/CHANGES
> +++ b/CHANGES
> @@ -1,6 +1,8 @@
> -*- coding: utf-8 -*-
> Changes with Apache Traffic Server 5.1.0
>
> + *) [TS-1800] Create one hashing infrastructure.
> +
> *) [TS-2860] Add AArch64 support.
>
> *) [TS-2916] set response header properly for combo_handler plugin.
>
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e7ceddb/lib/ts/Hash.cc
> ----------------------------------------------------------------------
> diff --git a/lib/ts/Hash.cc b/lib/ts/Hash.cc
> new file mode 100644
> index 0000000..a0931ef
> --- /dev/null
> +++ b/lib/ts/Hash.cc
> @@ -0,0 +1,48 @@
> +/** @file
> +
> + @section license License
> +
> + Licensed to the Apache Software Foundation (ASF) under one
> + or more contributor license agreements. See the NOTICE file
> + distributed with this work for additional information
> + regarding copyright ownership. The ASF licenses this file
> + to you under the Apache License, Version 2.0 (the
> + "License"); you may not use this file except in compliance
> + with the License. You may obtain a copy of the License at
> +
> + http://www.apache.org/licenses/LICENSE-2.0
> +
> + Unless required by applicable law or agreed to in writing, software
> + distributed under the License is distributed on an "AS IS" BASIS,
> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + See the License for the specific language governing permissions and
> + limitations under the License.
> + */
> +
> +#include "Hash.h"
> +#include <cstring>
> +
> +ATSHashBase::~ATSHashBase() {
> +}
> +
> +bool
> +ATSHash::operator==(const ATSHash & other) const {
> + if (this->size() != other.size()) {
> + return false;
> + }
> + if (memcmp(this->get(), other.get(), this->size()) == 0) {
> + return true;
> + } else {
> + return false;
> + }
> +}
> +
> +bool
> +ATSHash32::operator==(const ATSHash32 & other) const {
> + return this->get() == other.get();
> +}
> +
> +bool
> +ATSHash64::operator==(const ATSHash64 & other) const {
> + return this->get() == other.get();
> +}
>
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e7ceddb/lib/ts/Hash.h
> ----------------------------------------------------------------------
> diff --git a/lib/ts/Hash.h b/lib/ts/Hash.h
> new file mode 100644
> index 0000000..c0e621c
> --- /dev/null
> +++ b/lib/ts/Hash.h
> @@ -0,0 +1,51 @@
> +/** @file
> +
> + @section license License
> +
> + Licensed to the Apache Software Foundation (ASF) under one
> + or more contributor license agreements. See the NOTICE file
> + distributed with this work for additional information
> + regarding copyright ownership. The ASF licenses this file
> + to you under the Apache License, Version 2.0 (the
> + "License"); you may not use this file except in compliance
> + with the License. You may obtain a copy of the License at
> +
> + http://www.apache.org/licenses/LICENSE-2.0
> +
> + Unless required by applicable law or agreed to in writing, software
> + distributed under the License is distributed on an "AS IS" BASIS,
> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + See the License for the specific language governing permissions and
> + limitations under the License.
> + */
> +
> +#ifndef __HASH_H__
> +#define __HASH_H__
> +
> +#include <cstddef>
> +#include <stdint.h>
> +
> +struct ATSHashBase {
> + virtual void update(const void *, size_t) = 0;
> + virtual void final(void) = 0;
> + virtual void clear(void) = 0;
> + virtual ~ATSHashBase();
> +};
> +
> +struct ATSHash : ATSHashBase {
> + virtual const void *get(void) const = 0;
> + virtual size_t size(void) const = 0;
> + virtual bool operator==(const ATSHash &) const;
> +};
> +
> +struct ATSHash32 : ATSHashBase {
> + virtual uint32_t get(void) const = 0;
> + virtual bool operator==(const ATSHash32 &) const;
> +};
> +
> +struct ATSHash64 : ATSHashBase {
> + virtual uint64_t get(void) const = 0;
> + virtual bool operator==(const ATSHash64 &) const;
> +};
> +
> +#endif
>
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e7ceddb/lib/ts/Makefile.am
> ----------------------------------------------------------------------
> diff --git a/lib/ts/Makefile.am b/lib/ts/Makefile.am
> index 437d654..d745dba 100644
> --- a/lib/ts/Makefile.am
> +++ b/lib/ts/Makefile.am
> @@ -52,6 +52,8 @@ libtsutil_la_SOURCES = \
> DynArray.h \
> EventNotify.cc \
> EventNotify.h \
> + Hash.cc \
> + Hash.h \
> HostLookup.cc \
> HostLookup.h \
> INK_MD5.h \
>
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e7ceddb/lib/ts/libts.h
> ----------------------------------------------------------------------
> diff --git a/lib/ts/libts.h b/lib/ts/libts.h
> index 97ce163..7a6097c 100644
> --- a/lib/ts/libts.h
> +++ b/lib/ts/libts.h
> @@ -81,6 +81,7 @@
> #include "Compatability.h"
> #include "DynArray.h"
> #include "EventNotify.h"
> +#include "Hash.h"
> #include "I_Version.h"
> #include "InkPool.h"
> #include "List.h"
>
Re: [1/6] git commit: TS-1800: Add new hash function base class
Posted by Phil Sorber <so...@apache.org>.
On Fri, Aug 8, 2014 at 7:39 PM, Leif Hedstrom <zw...@apache.org> wrote:
>
> On Aug 8, 2014, at 4:08 PM, sorber@apache.org wrote:
>
> > Repository: trafficserver
> > Updated Branches:
> > refs/heads/master 5c0bc7c94 -> 7fa5c5c7a
> >
> >
> > TS-1800: Add new hash function base class
> >
> >
> > Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
> > Commit:
> http://git-wip-us.apache.org/repos/asf/trafficserver/commit/9e7ceddb
> > Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/9e7ceddb
> > Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/9e7ceddb
> >
> > Branch: refs/heads/master
>
>
> This ode doesn’t look indented as per our coding standard :-/
>
>
When I wrote it I thought our standard was four spaces and { on the same
line as function declarations. I'm already cringing when I use cuddled
elses. It would be totally awesome to have a formatting script to run
through before I commit. We could even have Jenkins run it in test mode...
I wanted to get this commit in there for amc, but I can go back and fix the
formatting on the files where it is wrong.
> — Leif
>
> > Commit: 9e7ceddbad56370643ab514d9ad918d7740f3db8
> > Parents: 5c0bc7c
> > Author: Phil Sorber <so...@apache.org>
> > Authored: Fri Aug 8 12:30:54 2014 -0600
> > Committer: Phil Sorber <so...@apache.org>
> > Committed: Fri Aug 8 15:26:02 2014 -0600
> >
> > ----------------------------------------------------------------------
> > CHANGES | 2 ++
> > lib/ts/Hash.cc | 48 ++++++++++++++++++++++++++++++++++++++++++++++
> > lib/ts/Hash.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
> > lib/ts/Makefile.am | 2 ++
> > lib/ts/libts.h | 1 +
> > 5 files changed, 104 insertions(+)
> > ----------------------------------------------------------------------
> >
> >
> >
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e7ceddb/CHANGES
> > ----------------------------------------------------------------------
> > diff --git a/CHANGES b/CHANGES
> > index d8dd8bf..0050a2d 100644
> > --- a/CHANGES
> > +++ b/CHANGES
> > @@ -1,6 +1,8 @@
> > -*- coding:
> utf-8 -*-
> > Changes with Apache Traffic Server 5.1.0
> >
> > + *) [TS-1800] Create one hashing infrastructure.
> > +
> > *) [TS-2860] Add AArch64 support.
> >
> > *) [TS-2916] set response header properly for combo_handler plugin.
> >
> >
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e7ceddb/lib/ts/Hash.cc
> > ----------------------------------------------------------------------
> > diff --git a/lib/ts/Hash.cc b/lib/ts/Hash.cc
> > new file mode 100644
> > index 0000000..a0931ef
> > --- /dev/null
> > +++ b/lib/ts/Hash.cc
> > @@ -0,0 +1,48 @@
> > +/** @file
> > +
> > + @section license License
> > +
> > + Licensed to the Apache Software Foundation (ASF) under one
> > + or more contributor license agreements. See the NOTICE file
> > + distributed with this work for additional information
> > + regarding copyright ownership. The ASF licenses this file
> > + to you under the Apache License, Version 2.0 (the
> > + "License"); you may not use this file except in compliance
> > + with the License. You may obtain a copy of the License at
> > +
> > + http://www.apache.org/licenses/LICENSE-2.0
> > +
> > + Unless required by applicable law or agreed to in writing, software
> > + distributed under the License is distributed on an "AS IS" BASIS,
> > + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> > + See the License for the specific language governing permissions and
> > + limitations under the License.
> > + */
> > +
> > +#include "Hash.h"
> > +#include <cstring>
> > +
> > +ATSHashBase::~ATSHashBase() {
> > +}
> > +
> > +bool
> > +ATSHash::operator==(const ATSHash & other) const {
> > + if (this->size() != other.size()) {
> > + return false;
> > + }
> > + if (memcmp(this->get(), other.get(), this->size()) == 0) {
> > + return true;
> > + } else {
> > + return false;
> > + }
> > +}
> > +
> > +bool
> > +ATSHash32::operator==(const ATSHash32 & other) const {
> > + return this->get() == other.get();
> > +}
> > +
> > +bool
> > +ATSHash64::operator==(const ATSHash64 & other) const {
> > + return this->get() == other.get();
> > +}
> >
> >
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e7ceddb/lib/ts/Hash.h
> > ----------------------------------------------------------------------
> > diff --git a/lib/ts/Hash.h b/lib/ts/Hash.h
> > new file mode 100644
> > index 0000000..c0e621c
> > --- /dev/null
> > +++ b/lib/ts/Hash.h
> > @@ -0,0 +1,51 @@
> > +/** @file
> > +
> > + @section license License
> > +
> > + Licensed to the Apache Software Foundation (ASF) under one
> > + or more contributor license agreements. See the NOTICE file
> > + distributed with this work for additional information
> > + regarding copyright ownership. The ASF licenses this file
> > + to you under the Apache License, Version 2.0 (the
> > + "License"); you may not use this file except in compliance
> > + with the License. You may obtain a copy of the License at
> > +
> > + http://www.apache.org/licenses/LICENSE-2.0
> > +
> > + Unless required by applicable law or agreed to in writing, software
> > + distributed under the License is distributed on an "AS IS" BASIS,
> > + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> > + See the License for the specific language governing permissions and
> > + limitations under the License.
> > + */
> > +
> > +#ifndef __HASH_H__
> > +#define __HASH_H__
> > +
> > +#include <cstddef>
> > +#include <stdint.h>
> > +
> > +struct ATSHashBase {
> > + virtual void update(const void *, size_t) = 0;
> > + virtual void final(void) = 0;
> > + virtual void clear(void) = 0;
> > + virtual ~ATSHashBase();
> > +};
> > +
> > +struct ATSHash : ATSHashBase {
> > + virtual const void *get(void) const = 0;
> > + virtual size_t size(void) const = 0;
> > + virtual bool operator==(const ATSHash &) const;
> > +};
> > +
> > +struct ATSHash32 : ATSHashBase {
> > + virtual uint32_t get(void) const = 0;
> > + virtual bool operator==(const ATSHash32 &) const;
> > +};
> > +
> > +struct ATSHash64 : ATSHashBase {
> > + virtual uint64_t get(void) const = 0;
> > + virtual bool operator==(const ATSHash64 &) const;
> > +};
> > +
> > +#endif
> >
> >
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e7ceddb/lib/ts/Makefile.am
> > ----------------------------------------------------------------------
> > diff --git a/lib/ts/Makefile.am b/lib/ts/Makefile.am
> > index 437d654..d745dba 100644
> > --- a/lib/ts/Makefile.am
> > +++ b/lib/ts/Makefile.am
> > @@ -52,6 +52,8 @@ libtsutil_la_SOURCES = \
> > DynArray.h \
> > EventNotify.cc \
> > EventNotify.h \
> > + Hash.cc \
> > + Hash.h \
> > HostLookup.cc \
> > HostLookup.h \
> > INK_MD5.h \
> >
> >
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e7ceddb/lib/ts/libts.h
> > ----------------------------------------------------------------------
> > diff --git a/lib/ts/libts.h b/lib/ts/libts.h
> > index 97ce163..7a6097c 100644
> > --- a/lib/ts/libts.h
> > +++ b/lib/ts/libts.h
> > @@ -81,6 +81,7 @@
> > #include "Compatability.h"
> > #include "DynArray.h"
> > #include "EventNotify.h"
> > +#include "Hash.h"
> > #include "I_Version.h"
> > #include "InkPool.h"
> > #include "List.h"
> >
>
>